Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Jan 2023 19:16:57 GMT
From:      Vladimir Kondratyev <wulf@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 1e010401b801 - stable/13 - LinuxKPI: linux/seqlock.h: Fix write_seqcount_(begin|end)
Message-ID:  <202301071916.307JGvwb070204@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=1e010401b80196ac5904ad4e8b8b9589e61394b4

commit 1e010401b80196ac5904ad4e8b8b9589e61394b4
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2022-12-24 09:01:20 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2023-01-07 12:37:09 +0000

    LinuxKPI: linux/seqlock.h: Fix write_seqcount_(begin|end)
    
    in seqcount_mutex_t case with removal of extraneous mutex lock/unlock
    calls and addition of missing critical section.
    While here strip one inline wrap layer to reduce code size.
    
    Fixes startup lockup of i915kms after update to drm-kmod v5.12
    
    (cherry picked from commit 68f08e26e2797707c76f8c6423baa41b25dd9df4)
---
 sys/compat/linuxkpi/common/include/linux/seqlock.h | 94 +++-------------------
 1 file changed, 13 insertions(+), 81 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/seqlock.h b/sys/compat/linuxkpi/common/include/linux/seqlock.h
index c520de90eca8..d82889528796 100644
--- a/sys/compat/linuxkpi/common/include/linux/seqlock.h
+++ b/sys/compat/linuxkpi/common/include/linux/seqlock.h
@@ -36,8 +36,6 @@
 #include <sys/rwlock.h>
 #include <sys/seqc.h>
 
-#include <linux/mutex.h>
-
 struct lock_class_key;
 
 struct seqcount {
@@ -52,8 +50,7 @@ struct seqlock {
 typedef struct seqlock seqlock_t;
 
 struct seqcount_mutex {
-	struct mutex	*seqm_lock;
-	struct seqcount	 seqm_count;
+	seqc_t		seqc;
 };
 typedef struct seqcount_mutex seqcount_mutex_t;
 
@@ -66,98 +63,33 @@ __seqcount_init(struct seqcount *seqcount, const char *name __unused,
 #define	seqcount_init(seqcount)	__seqcount_init(seqcount, NULL, NULL)
 
 static inline void
-seqcount_mutex_init(struct seqcount_mutex *seqcount, struct mutex *mutex)
+seqcount_mutex_init(struct seqcount_mutex *seqcount, void *mutex __unused)
 {
-	seqcount->seqm_lock = mutex;
-	seqcount_init(&seqcount->seqm_count);
+	seqcount->seqc = 0;
 }
 
 #define	write_seqcount_begin(s)						\
     _Generic(*(s),							\
-	struct seqcount:	lkpi_write_seqcount_begin,		\
-	struct seqcount_mutex:	lkpi_write_seqcount_mutex_begin		\
-    )(s)
-
-static inline void
-lkpi_write_seqcount_begin(struct seqcount *seqcount)
-{
-	seqc_sleepable_write_begin(&seqcount->seqc);
-}
-
-static inline void
-lkpi_write_seqcount_mutex_begin(struct seqcount_mutex *seqcount)
-{
-	mutex_lock(seqcount->seqm_lock);
-	lkpi_write_seqcount_begin(&seqcount->seqm_count);
-}
+	struct seqcount:	seqc_sleepable_write_begin,		\
+	struct seqcount_mutex:	seqc_write_begin			\
+    )(&(s)->seqc)
 
 #define	write_seqcount_end(s)						\
     _Generic(*(s),							\
-	struct seqcount:	lkpi_write_seqcount_end,		\
-	struct seqcount_mutex:	lkpi_write_seqcount_mutex_end		\
-    )(s)
-
-static inline void
-lkpi_write_seqcount_end(struct seqcount *seqcount)
-{
-	seqc_sleepable_write_end(&seqcount->seqc);
-}
+	struct seqcount:	seqc_sleepable_write_end,		\
+	struct seqcount_mutex:	seqc_write_end				\
+    )(&(s)->seqc)
 
-static inline void
-lkpi_write_seqcount_mutex_end(struct seqcount_mutex *seqcount)
-{
-	lkpi_write_seqcount_end(&seqcount->seqm_count);
-	mutex_unlock(seqcount->seqm_lock);
-}
-
-#define	read_seqcount_begin(s)						\
-    _Generic(*(s),							\
-	struct seqcount:	lkpi_read_seqcount_begin,		\
-	struct seqcount_mutex:	lkpi_read_seqcount_mutex_begin		\
-    )(s)
-
-static inline unsigned
-lkpi_read_seqcount_begin(const struct seqcount *seqcount)
-{
-	return (seqc_read(&seqcount->seqc));
-}
-
-static inline unsigned
-lkpi_read_seqcount_mutex_begin(const struct seqcount_mutex *seqcount)
-{
-	return (lkpi_read_seqcount_begin(&seqcount->seqm_count));
-}
-
-static inline unsigned
-raw_read_seqcount(const struct seqcount *seqcount)
-{
-	return (seqc_read_any(&seqcount->seqc));
-}
+#define	read_seqcount_begin(s)	seqc_read(&(s)->seqc)
+#define	raw_read_seqcount(s)	seqc_read_any(&(s)->seqc)
 
 /*
  * XXX: Are predicts from inline functions still not honored by clang?
  */
 #define	__read_seqcount_retry(seqcount, gen)	\
 	(!seqc_consistent_nomb(&(seqcount)->seqc, gen))
-#define	read_seqcount_retry(s, old)					\
-    _Generic(*(s),							\
-	struct seqcount:	lkpi_read_seqcount_retry,		\
-	struct seqcount_mutex:	lkpi_read_seqcount_mutex_retry		\
-    )(s, old)
-
-static inline int
-lkpi_read_seqcount_retry(
-    const struct seqcount *seqcount, unsigned int old)
-{
-	return (!seqc_consistent(&seqcount->seqc, old));
-}
-
-static inline int
-lkpi_read_seqcount_mutex_retry(
-    const struct seqcount_mutex *seqcount, unsigned int old)
-{
-	return (!seqc_consistent(&seqcount->seqm_count.seqc, old));
-}
+#define	read_seqcount_retry(seqcount, gen)	\
+	(!seqc_consistent(&(seqcount)->seqc, gen))
 
 static inline void
 seqlock_init(struct seqlock *seqlock)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202301071916.307JGvwb070204>