From: Jon Hunter <jonathanh@nvidia.com>
To: Tzung-Bi Shih <tzungbi@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>
Cc: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
Linus Walleij <linusw@kernel.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH] gpio: shared: call gpio_chip::of_xlate() if set
Date: Fri, 20 Mar 2026 11:46:25 +0000 [thread overview]
Message-ID: <ad20b7da-6c21-43a8-a450-0b6678fe395c@nvidia.com> (raw)
In-Reply-To: <abzRxyoW4svizpRY@google.com>
On 20/03/2026 04:49, Tzung-Bi Shih wrote:
...
> The context '}' here suggests that commit 16fdabe143fc ("gpio: Fix resource
> leaks on errors in gpiochip_add_data_with_key()") might not be applied in
> your code base. After applying that commit, this code should look like:
>
> err_put_device:
> gpio_device_put(gdev);
> goto err_print_message;
>
> err_cleanup_desc_srcu:
> cleanup_srcu_struct(&gdev->desc_srcu);
>
> I'll use v6.19 (i.e., without the commit) for the following examples.
Yes that's correct that commit is not present.
>>> err_cleanup_desc_srcu:
>>> + synchronize_srcu(&gdev->desc_srcu);
>>> cleanup_srcu_struct(&gdev->desc_srcu);
>>> err_cleanup_gdev_srcu:
>>> cleanup_srcu_struct(&gdev->srcu);
>>>
>>
>> Hi Tzung-Bi, allow me to Cc you. It looks like someone takes the SRCU lock
>> during the call to gpiochip_add_data_with_key() and this is why the cleanup
>> path complains. Does it make sense to add this synchronize_srcu() call here?
>
> No, I think this is very unusual: `gdev` is still initializing in
> gpiochip_add_data_with_key(), but someone else already starts to access
> members of `gdev`.
>
>>
>>>
>>>>> gpiochip_add_data_with_key: GPIOs 512..675 (tegra234-gpio) failed to register, -16
>>>>> tegra186-gpio 2200000.gpio: probe with driver tegra186-gpio failed with error -16
>
> Along with the above patch, the -16 (-EBUSY) should be from
> gpiodev_add_to_list_unlocked()[1].
>
> scoped_guard(mutex, &gpio_devices_lock) {
> ...
>
> ret = gpiodev_add_to_list_unlocked(gdev);
> if (ret) {
> gpiochip_err(gc, "GPIO integer space overlap, cannot add chip\n");
> goto err_cleanup_desc_srcu;
> }
> }
>
> [1] https://elixir.bootlin.com/linux/v6.19/source/drivers/gpio/gpiolib.c#L1151
>
> My understanding is that within this function, there appear to be no other
> users of `gdev->desc_srcu` between the calls to init_srcu_struct() and
> gpiodev_add_to_list_unlocked().
>
> At the point gpiodev_add_to_list_unlocked() is called, `gc->gpiodev` and
> `gdev->descs` have also been set.
>
> Jon: My main concern is about potential races from other threads. Is it
> possible that another thread could start accessing struct gpio_desc elements
> (e.g., via gpiochip_request_own_desc() and desc_set_label()) before
> gpiochip_add_data_with_key() has fully completed the initialization of `gdev`?
So today I tried to reproduce this WARNING with next-20260319 by making
the erroneous change in device-tree (combining gpio-hogs with shared
gpios) but after doing so I don't see this. So for now I don't think
that we should worry about this.
Jon
--
nvpublic
next prev parent reply other threads:[~2026-03-20 11:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 13:52 Bartosz Golaszewski
2026-03-17 8:47 ` Linus Walleij
2026-03-17 10:12 ` Jon Hunter
2026-03-17 11:44 ` Bartosz Golaszewski
2026-03-17 12:53 ` Jon Hunter
2026-03-17 13:43 ` Bartosz Golaszewski
2026-03-17 13:46 ` Jon Hunter
2026-03-17 14:05 ` Bartosz Golaszewski
2026-03-17 15:19 ` Bartosz Golaszewski
2026-03-17 22:46 ` Jon Hunter
2026-03-18 8:09 ` Bartosz Golaszewski
2026-03-18 19:09 ` Jon Hunter
2026-03-19 9:41 ` Bartosz Golaszewski
2026-03-20 4:49 ` Tzung-Bi Shih
2026-03-20 11:46 ` Jon Hunter [this message]
2026-03-27 13:05 ` Konrad Dybcio
2026-03-17 12:53 ` Jon Hunter
2026-03-17 13:44 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad20b7da-6c21-43a8-a450-0b6678fe395c@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=tzungbi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®