From nobody Fri Jan 31 16:03:21 2025 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 4Yl0zs47bFz5mQw2; Fri, 31 Jan 2025 16:03:21 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Yl0zs1VCpz3hFT; Fri, 31 Jan 2025 16:03:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738339401; 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=u+9jjmSAliKieY4nKd31MMx7QpWuc48bKtttykRArHo=; b=En6l/DIQ8gzL4uo2+0iTXVrpKziZt4Qu+xNwBuwilpf6mkAniAGzUdBA34xmDDm1wtsWDO IqZzHDYrxRwNdJ0VY8r2IHXBy5mcVnpX08BzzETnsGzx3vGtYCAv90rKdGh3SXbTFfuWOx DE+57HrGlxMRVpRU8CgwMVF5I4URB6HewhUilZEIXv4J2XqJifG7an4alvTmzNYvdtxMlq Cs977g/6F5Xh5vKSqRrVZgw6G6Rm5BeTlVhsBncMCDHW3upTvLTNK9lfFMg9m0OafrCQ/h sBsHyYSbDVNBmv4rCfIIRRAYk8N31zlzu4IXdEP9IPnEoC6YeR9icZy0QGfm6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738339401; 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=u+9jjmSAliKieY4nKd31MMx7QpWuc48bKtttykRArHo=; b=i8BknsWuPqQTGrgxZ7UDwOHqR9LlmjvWzf41BmkyPfBFKxUPxpkeMgTbhOZNjXLyMkzeIv J4CcY95SGx2AGdDKG2hi1hi4zOX7fDCGewK+orS2l7FHJFhhc+nPbVpHaQsePsEV8H8Y1h Nc9HedGkqZsFwjaNWu/0Agtg6nhEP1ZWW7u0p543cr7sRhG4qiNRZWpt67Ak+KoU6+G0fg Gjcen388pBWnRxF03x2mBbarSsCL4VmSOCnl2FhK0DaZM2r+ElYEQtgyRS447ZVe2Mf7hA 5SVJXbyxl/Zv8aI8vX68ObRU6JveWw/+rPtcR+RAlfP+PsXcnxtEuL1WwOdhSA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1738339401; a=rsa-sha256; cv=none; b=vH2WEYrUrSE4Ql9snOsox2Bneagm1s5B9Ve7GZklG+yK1okb1aCc80Iw52JPHpVmcrRG5E aIHJ8b2s/PyhdaMQQ1EQ45hz+1HEeUU2Edw1GrqhcS4l8qTOmH2xkzYTgesIWikABkKwnJ lk6/vJtKsirELa7tKpfrBJRwA81P4JfLGPS/TftNkjdMLXxSsS1n1206FnP7Emee593rX0 QdeOyE6Z7d4BasJVX5Q4NPlFvKWaaZnvOtiOviYcJORe9Yu4FYgrZFBDXbRqYt6RqUCtka IVAyIZYRHqmH8J9gg2+t4ch4SCs1nag9MsOCqOVLfkcDSsOI4xkqJb+BQO2Tsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4Yl0zs13LXz97v; Fri, 31 Jan 2025 16:03:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50VG3Lbv038820; Fri, 31 Jan 2025 16:03:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50VG3LPI038815; Fri, 31 Jan 2025 16:03:21 GMT (envelope-from git) Date: Fri, 31 Jan 2025 16:03:21 GMT Message-Id: <202501311603.50VG3LPI038815@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien?= =?utf-8?Q?P=C3=A9dron?= Subject: git: 1de8fcf419fc - main - linuxkpi: Add Linux 6.7 `get_file_rcu()` variant 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1de8fcf419fce890474271215dce3b6e4876b60a Auto-Submitted: auto-generated The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=1de8fcf419fce890474271215dce3b6e4876b60a commit 1de8fcf419fce890474271215dce3b6e4876b60a Author: Jean-Sébastien Pédron AuthorDate: 2025-01-01 13:11:14 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2025-01-31 16:00:49 +0000 linuxkpi: Add Linux 6.7 `get_file_rcu()` variant [Why] In Linux 6.7, the signature of `get_file_rcu()` changed significantly, going from: bool get_file_rcu(struct linux_file *f); ... to: struct linux_file * get_file_rcu(struct linux_file **f); I.e., both the argument and the return value changed in an incompatible way. This is used by the i915 DRM driver. [How] This patch introduces the variant and hide the new prototype behind `LINUXKPI_VERSION >= 60700`. Reviewed by: manu Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48756 --- sys/compat/linuxkpi/common/include/linux/fs.h | 5 ++++ sys/compat/linuxkpi/common/src/linux_compat.c | 39 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/fs.h b/sys/compat/linuxkpi/common/include/linux/fs.h index d277b717423f..86b922ac9a1d 100644 --- a/sys/compat/linuxkpi/common/include/linux/fs.h +++ b/sys/compat/linuxkpi/common/include/linux/fs.h @@ -264,12 +264,17 @@ get_file(struct linux_file *f) return (f); } +struct linux_file * linux67_get_file_rcu(struct linux_file **f); +#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 60700 +#define get_file_rcu(f) linux67_get_file_rcu(f) +#else static inline bool get_file_rcu(struct linux_file *f) { return (refcount_acquire_if_not_zero( f->_file == NULL ? &f->f_count : &f->_file->f_count)); } +#endif static inline struct inode * igrab(struct inode *inode) diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index ec3ccb16b47d..e5049a4b8f43 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -75,6 +75,7 @@ #include #include #include +#include #include #include #include @@ -1082,6 +1083,44 @@ linux_poll_wakeup(struct linux_file *filp) spin_unlock(&filp->f_kqlock); } +static struct linux_file * +__get_file_rcu(struct linux_file **f) +{ + struct linux_file *file1, *file2; + + file1 = READ_ONCE(*f); + if (file1 == NULL) + return (NULL); + + if (!refcount_acquire_if_not_zero( + file1->_file == NULL ? &file1->f_count : &file1->_file->f_count)) + return (ERR_PTR(-EAGAIN)); + + file2 = READ_ONCE(*f); + if (file2 == file1) + return (file2); + + fput(file1); + return (ERR_PTR(-EAGAIN)); +} + +struct linux_file * +linux67_get_file_rcu(struct linux_file **f) +{ + struct linux_file *file1; + + for (;;) { + file1 = __get_file_rcu(f); + if (file1 == NULL) + return (NULL); + + if (IS_ERR(file1)) + continue; + + return (file1); + } +} + static void linux_file_kqfilter_detach(struct knote *kn) {