From nobody Sat Jan 7 19:16:57 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Nq91k432Xz2sMMr; Sat, 7 Jan 2023 19:16:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Nq91k0l0zz3jr7; Sat, 7 Jan 2023 19:16:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673119018; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fnmv5V8LL1GkjUE4DVb00TsYSIWsLT/UvHOMkjRRNNI=; b=CEZVIMi0KpNk53eiPSzSjDi2goPuzHie79uF7OWxPV/iGdW9jFBLMDxg1SUT4NZjKMGcdP 6p2nyZHImL8cDSIm4xnSJq2uRJwHSDUlgdQSQ/6dBjlQ26nmvkrUH9Mako2a2EB//0dCY2 tiUNKZqzivAXv8lKIEd4DxyXByR2SnUd8U//2zNJzOfSV6JNWm2sR3g1vXaHQRWyQu0/kS M3lNKmQz8169UGmkEZFAJFcuar1YPMrwOwzn6Lcqe1pzZriWscaa1vO8InqyLrxh/qjLub XDkbiRcFsV6RXQLVFm0P3wtwwxqWQl4mum7/FxeDcCAHJewIwASBrkbKMG9NsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673119018; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fnmv5V8LL1GkjUE4DVb00TsYSIWsLT/UvHOMkjRRNNI=; b=QvtWColgidPGJYYwV/Zc2FKnD2J3Dl+JwnZZFMJAFqkU5CRtvebt6LH06NO8rw/sfvsPOU jLVvV5NaofSzaQTzK/SeewI7Cg6lRnH7Dluix1yoGGPsnEsMrQmFrOwm1iP00i5Yg38qRi lIRIesv6RKYHfW+xVuq5h9MQo5EFduUsbC+RP0f1f6F82S5j2KxRrruWf9w6dNWowgIYS0 uQtHUqD3lD29w71gCqGRWEY4IHc28XwBi4nZCDbKt3Oiv/YgHBa77/6K97sczpZcAdwUdZ 9rlViN7kTsRb/Uo69qGuRsFV7qktjVyXPBMncf0A281GqVNlGcCM5nRao+jEyQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673119018; a=rsa-sha256; cv=none; b=NTi7X0Cr0hdNVe29nSKyW+1df5XsQMC7SQBKkPwvX4JrnRT/CmNj5YC9NspGCrxhuLYkZ6 Dh+ovPo0RSrlrMu6483BGP2zT9+2yloG2kPFOTOAY0AqHHv2ReH5vy9LWOF0MB69KP30ai AHLqmMrkT2P27rxBKPcOq5d2CaZzomdyoN+1qrsQhGkfr5dc5n/LgU7/Ms3RTnau3A1OHh 7XsUIqe7vVbr56Z+91ByUhYNLJ7d0Cjkq4LJHxercIFSs2a4qij3HzoZXOxqxtc5pAmdV9 eaHDSZLCMmV4DtkaeaEqeTTzgjRnQeup3lY8V2TkZ2Sdb3ndiA2amSEbjwNW+w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Nq91j6yPpzLYD; Sat, 7 Jan 2023 19:16:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 307JGvQb070205; Sat, 7 Jan 2023 19:16:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 307JGvwb070204; Sat, 7 Jan 2023 19:16:57 GMT (envelope-from git) Date: Sat, 7 Jan 2023 19:16:57 GMT Message-Id: <202301071916.307JGvwb070204@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 1e010401b801 - stable/13 - LinuxKPI: linux/seqlock.h: Fix write_seqcount_(begin|end) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1e010401b80196ac5904ad4e8b8b9589e61394b4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=1e010401b80196ac5904ad4e8b8b9589e61394b4 commit 1e010401b80196ac5904ad4e8b8b9589e61394b4 Author: Vladimir Kondratyev AuthorDate: 2022-12-24 09:01:20 +0000 Commit: Vladimir Kondratyev 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 #include -#include - 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)