From nobody Sat Dec 24 09:02:18 2022 X-Original-To: dev-commits-src-all@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 4NfJ2z1Nyfz1HXKX; Sat, 24 Dec 2022 09:02:19 +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 4NfJ2z0m7zz3mNh; Sat, 24 Dec 2022 09:02:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671872539; 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=gDA7TJwXmIWhCes05KEBW1/bR480Bhlr/0PyITp06to=; b=cwOoSoZKjnf5GfOYwBPtX1jraA336nBoBRqDpAR1488ni8HMinD+x9BJZ+alOh6rqLvtm8 AOzn0RvzZY1OS9lGBjEtDso/aTW+rkQJ9y9B5LY1hOmMIk46DH1zK9WwE6SVho+PSRSCMU iDJ9eO8q/kKsZ4dvdeTj8se4Q7+FJGfox376nAC9x7mwDVwT1edbrNVBvcS91lU+bJpoNV pS+YO37m/W2hvOnRFdVH9Jm6VI5c+bL8rB/yIvG3R6s1pcy+RvH+kmzdwgtyxccr9+1RCR PYlrwcxuzX7vrsTsYHLeU9n1fWmnGbPc90KbuW7SDGMbl5vn2Nc3E76c6K8Pyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671872539; 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=gDA7TJwXmIWhCes05KEBW1/bR480Bhlr/0PyITp06to=; b=HFNMMniNAQbRhcfvwlGnYPG3kQZVFk+iAUkx97gfbYy6as8QvI8Xtit4h+LlO0ZjqXtwNg /iSWD/6E3fUDkGUdGA5JGZtdMvUN9Fdbm7R7uWxAZT3DvgL8B6VwEKc8SJxy77EDnyechn 3BD+A/Z4XOTq48LWPR1tpKZzKE4RdDtIEMfeoKPtrPAXdg/akQHBkjSIlJNtmaHRhe6Y08 dyOk9GPgIPMi9dh8cA/B0c5/1oD+qfgDJU0mgv3gywHyP7OslrZEy5zwULpz/e9rixeyOg Po3EvUWN12O0o46MgxTM9TAZZKUU41d1lSq/2RUiLt60QaNX/2gjdAOXDIdCjQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1671872539; a=rsa-sha256; cv=none; b=PMG6zUcHx7mEiHvV9ICQWZL5S+Nu32rKN/YSsr0ZZiBqRKkQpiqSiNWtL4tPGXI+S+4uQc ToFDnbsnLvO2PY8KHD1PyJ3ag5cDBR6uBVg44JNudqRNsCiqPCspU4NfX+fuM4Fx8m1kjc 8wEyl9YfMvUNhY/vYjEDkS10QlQfW3vZv9141igr8fqDyfgIrJW8OVPD9j7zzx9RQfLUoD NErS12MYAnTAx/nbrZ8BoL9xzk5HC8N/vQzhQebBAYdJuFYIOH5zbT7AcuXsS55QX0q3Ed jhewhbEYl0mPcLtJEL36vJrV88TrIBIbb8o5Ar8srn+xZkVqPe31UFfSW+1QyA== 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 4NfJ2y6xLhz17LL; Sat, 24 Dec 2022 09:02:18 +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 2BO92I1h026039; Sat, 24 Dec 2022 09:02:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BO92IwY026038; Sat, 24 Dec 2022 09:02:18 GMT (envelope-from git) Date: Sat, 24 Dec 2022 09:02:18 GMT Message-Id: <202212240902.2BO92IwY026038@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 68f08e26e279 - main - LinuxKPI: linux/seqlock.h: Fix write_seqcount_(begin|end) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 68f08e26e2797707c76f8c6423baa41b25dd9df4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=68f08e26e2797707c76f8c6423baa41b25dd9df4 commit 68f08e26e2797707c76f8c6423baa41b25dd9df4 Author: Vladimir Kondratyev AuthorDate: 2022-12-24 09:01:20 +0000 Commit: Vladimir Kondratyev CommitDate: 2022-12-24 09:01:20 +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 Reviewed by: hselasky, bz MFC after: 1week Differential Revision: https://reviews.freebsd.org/D37699 --- 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 4a5385f5e095..87a5136c1210 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_no_fence(&(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)