[PATCH v2 0/2] gpio: shared-proxy: Fix line accounting

From: Shawn Guo

Date: Fri Oct 16 2026 - 11:45:12 EST


Two fixes for the shared GPIO proxy's accounting of users and votes.

Patch 1 fixes a race between consumers that request a shared line
concurrently. Each of them sees usecnt > 1, assumes another user has
already configured the line, and fails with -EPERM. On Nord RRD this
intermittently leaves both DAC supply regulators without their enable
GPIO.

Patch 2 fixes a stale vote left behind when a proxy releases the line
and restoring the default value fails. The line stays at the
non-default value for the remaining users, and votecnt can underflow
when the line is requested again.

Changes in v2:
- Patch 1: Also use gpio_shared_proxy_may_init() instead of
usecnt > 1 in set_config, so concurrent first users no longer skip
the hardware config or log a spurious conflict (Sashiko)
- Patch 2: New. Fix the votecnt underflow on a failed write in free.
It predates patch 1 (Sashiko)
- Link to v1: https://lore.kernel.org/all/20261015122740.971792-1-shengchao.guo@xxxxxxxxxxxxxxxx

Shawn Guo (2):
gpio: shared-proxy: Fix race between concurrent first users
gpio: shared-proxy: Drop the vote of a released proxy on write failure

drivers/gpio/gpio-shared-proxy.c | 80 ++++++++++++++++++++++++++++----
drivers/gpio/gpiolib-shared.h | 1 +
2 files changed, 71 insertions(+), 10 deletions(-)

--
2.43.0