From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB2483570A0; Fri, 6 Feb 2026 09:13:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770369220; cv=none; b=DhXZ+jklxsHzOlbRQ3nNIKlHeGr++Dyf3f8yL9SYa+50Tfm3xbAPtpCRA2w+i5Eh6B5a9MuVDcci5EqNveZebJGS4HL3enVSIXS+tqjZQos/UIfLoCuyVTenYDMi8iOL+LGj5tnq20uYja3KsHSVsCd9+bIjv3Zs/rg1Tv0fjAw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770369220; c=relaxed/simple; bh=Ad+gFIapLDGeK2QdxKtz+WJu1GmvHE2AyaoW+Qo7jNA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EZXwQBlJlp+jPN7zvlIOs1CKgSTJMijaynSyBtxmPkMBD179qYq8+WK6Eu+D8fduBXgr7tRCjfIqRZ0VHqH0cBHOKckBWmh9WAmgy6yiiOB20Q8oG7pjqMP2PVfJ/uLNugzrrQBMhatTweHUeCW2tjADD7eg8MewFYc8qC+DbQE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BktlHtDv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BktlHtDv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 022A5C116C6; Fri, 6 Feb 2026 09:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770369220; bh=Ad+gFIapLDGeK2QdxKtz+WJu1GmvHE2AyaoW+Qo7jNA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BktlHtDvn1B+0UQ3KDROvzT0wYm01I6ZTOs3ug11EsugNIok9sxjKpyofrR07qBMe YmPmIt5f/YGhrFvmpub9Vr3m3vaIfnb2MTFYydRbJcLfmQmobWSrcuzrCVyYR3VbLX CehCcrIRsNJX1EgA3lDhaTKbxBQuiQxRoqg1PXFHbIzf6eYk14Effovqfskcf0n7QZ 8cNM5xDnZaigtaqV1xtDY+7Nlyy/Mtt3QGICPb819/vZUFWDtsQS9KUN8IagNSf3kg 9mvbmMLL+7O50RP/T5aemAajii8T3mTESNNFdo7FWORv0bpl6eYLLLAEpstgU7jP4z sUGb7pzKqqoNw== Date: Fri, 6 Feb 2026 09:13:35 +0000 From: Tzung-Bi Shih To: Bartosz Golaszewski Cc: Jonathan Corbet , Shuah Khan , Laurent Pinchart , Wolfram Sang , Jason Gunthorpe , Johan Hovold , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chrome-platform@lists.linux.dev, Dan Williams , linux-gpio@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Linus Walleij Subject: Re: [PATCH v2 07/11] gpio: Add revocable provider handle for struct gpio_chip Message-ID: References: <20260203061059.975605-1-tzungbi@kernel.org> <20260203061059.975605-8-tzungbi@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, Feb 05, 2026 at 05:57:15PM +0100, Bartosz Golaszewski wrote: > On Thu, Feb 5, 2026 at 9:52 AM Tzung-Bi Shih wrote: > > > > On Wed, Feb 04, 2026 at 07:58:44AM -0500, Bartosz Golaszewski wrote: > > > On Tue, 3 Feb 2026 07:10:54 +0100, Tzung-Bi Shih said: > > > > diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h > > > > index 3abb90385829..cd136d5b52e9 100644 > > > > --- a/drivers/gpio/gpiolib.h > > > > +++ b/drivers/gpio/gpiolib.h > > > > @@ -52,6 +52,7 @@ > > > > * @device_notifier: used to notify character device wait queues about the GPIO > > > > * device being unregistered > > > > * @srcu: protects the pointer to the underlying GPIO chip > > > > + * @chip_rp: revocable provider handle for the corresponding struct gpio_chip. > > > > * @pin_ranges: range of pins served by the GPIO driver > > > > * > > > > * This state container holds most of the runtime variable data > > > > @@ -79,6 +80,7 @@ struct gpio_device { > > > > struct workqueue_struct *line_state_wq; > > > > struct blocking_notifier_head device_notifier; > > > > struct srcu_struct srcu; > > > > + struct revocable_provider __rcu *chip_rp; > > > > > > > > > > Why __rcu? This doesn't live in a different address space, only the internal > > > resource it protects does. If anything - this could be __attribute__((noderef)) > > > but even that is questionable as this is an opaque structure. > > > > For fixing a race on the pointer itself. See also [1]. > > > > [1] https://lore.kernel.org/all/20260129143733.45618-2-tzungbi@kernel.org > > So we're just using a double RCU here? One to protect the resource and > another to protect the protector of the resource? I can't say I'm a > fan of this. I really want to like this interface but is there really > no way to hide the implementation details from the caller? Isn't this > the whole point? As it is: the user still has to care about an > RCU-protected pointer. Will think about it but I have no better idea for now. Ideally, I think the user doesn't need to interact with the RCU (even if it's annotated with __rcu) but revocable APIs should handle it correctly.