Re: [PATCH v5 1/4] gpio: shared-proxy: Fix race between concurrent first users
From: Bartosz Golaszewski
Date: Fri Oct 30 2026 - 07:22:58 EST
On Fri, Oct 30, 2026 at 10:58:05AM +0100, Marek Szyprowski wrote:
> On 28.10.2026 13:34, Shawn Guo wrote:
> > The proxy lets a consumer set the line direction and reset the
> > default value and vote tally only when usecnt == 1, i.e. when it is
> > the sole requester. But request() and direction_output() take the
> > descriptor mutex separately. When two consumers probe concurrently,
> > both request the line before either configures it, both see
> > usecnt == 2, both fall into the shared path, read back the still
> > unconfigured direction (input) and fail with -EPERM.
> >
> > On Nord RRD the two DAC supplies are reg-fixed-voltage regulators
> > sharing tlmm GPIO 41. They probe asynchronously and intermittently
> > both fail, leaving the codecs without supplies:
> >
> > reg-fixed-voltage regulator-3p3-dac: setup of GPIO (default) failed: -1
> > reg-fixed-voltage regulator-5p0-dac: setup of GPIO (default) failed: -1
> >
> > Requesting the line is not evidence that a consumer has claimed it.
> > Instead, count proxies that have actually configured the line (set its
> > direction or voted for a value) in a new cfgcnt, with a per-proxy
> > configured flag, and allow (re)initialization only while no other
> > proxy has done so. A consumer obtained with GPIOD_ASIS that votes via
> > gpiod_set_value() without ever setting the direction counts as
> > configured, so a later user can never reset def_val/votecnt behind its
> > vote. The count is dropped when the proxy frees the line.
> >
> > Fixes: e992d54c6f97 ("gpio: shared-proxy: implement the shared GPIO proxy driver")
> > Signed-off-by: Shawn Guo <shengchao.guo@xxxxxxxxxxxxxxxx>
>
> I've hit the same issue on RUBIK Pi3 board, see:
>
> https://lore.kernel.org/all/20261028222803.2682808-1-m.szyprowski@xxxxxxxxxxx/
>
> This patch fixes it, so feel free to add:
>
> Tested-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
>
>
Thanks, I'll queue this instead of your patch as it's more
comprehensive.
Bart