Re: [PATCH v2 0/2] gpio: fix sleeping-in-atomic in shared-proxy; restore meson non-sleeping
Bartosz Golaszewski <[email protected]>
| Newsgroups | org.infradead.lists.linux-amlogic,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAMRc=Mcz=GPrjnvQ0Q6VxfqHDO0W3yq7FpRb=bPi-Jxu-GFuqA@mail.gmail.com> |
On Thu, 25 Jun 2026 13:57:16 +0200, Viacheslav Bocharov <[email protected]> said: > gpio-shared-proxy chooses its descriptor lock (mutex vs spinlock) from > the underlying chip's can_sleep, but under that lock it calls config and > direction ops that reach sleeping pinctrl paths. On a controller with > non-sleeping MMIO value ops the lock is a spinlock, so a sleeping call > runs from atomic context: > > BUG: sleeping function called from invalid context > ... pinctrl_gpio_set_config <- gpiochip_generic_config > <- gpio_shared_proxy_set_config (voting spinlock held) > <- ... <- mmc_pwrseq_simple_probe > > This was reported on Khadas VIM3 and worked around for Amlogic by > commit 28f240683871 ("pinctrl: meson: mark the GPIO controller as > sleeping"), which marked the whole meson controller sleeping. That > workaround broke atomic value-path consumers: w1-gpio (1-Wire bitbang) > no longer detects devices, because its IRQ-disabled read slot calls the > non-cansleep gpiod_*_value() and now hits WARN_ON(can_sleep) per bit. > > Patch 1 fixes the proxy locking generically (always a sleeping mutex). > Patch 2 then restores meson can_sleep=false, fixing 1-Wire. > > Patch 1 has a trade-off: a proxied GPIO becomes sleeping, so consumers > gating on gpiod_cansleep() change behaviour. No current device needs > atomic (non-cansleep) value access on a shared GPIO -- every report > (Khadas VIM3, ODROID-M1, my test on JetHub D1+) is a shared reset line > (eMMC/SDIO pwrseq or PCIe reset) driven through the cansleep accessors, > which is what the proxy exists to vote on; bit-banging that needs atomic > access cannot work through voting anyway. An alternative that keeps > atomic value access (split locking) is possible but adds a second lock > and new race windows, so this series takes the simpler mutex-only > approach. > > The two are a unit: patch 2 must not be applied without patch 1, > otherwise the original VIM3 splat returns on boards that share a meson > GPIO -- please keep the order. I have not Cc'd stable; I will request > stable backports separately once both patches have landed. > > Changes since v1: > - gpio: shared-proxy: open-code the descriptor mutex; drop the > gpio_shared_desc_lock guard and the gpio_shared_lockdep_assert() > helper, move the mutex rationale to the can_sleep assignment. No > functional change. > > v1: https://lore.kernel.org/linux-gpio/[email protected]/ > > Viacheslav Bocharov (2): > gpio: shared-proxy: always serialize with a sleeping mutex > pinctrl: meson: restore non-sleeping GPIO access > > drivers/gpio/gpio-shared-proxy.c | 66 +++++++++++---------------- > drivers/gpio/gpiolib-shared.c | 9 +--- > drivers/gpio/gpiolib-shared.h | 28 +----------- > drivers/pinctrl/meson/pinctrl-meson.c | 2 +- > 4 files changed, 30 insertions(+), 75 deletions(-) > > > base-commit: 840ef6c78e6a2f694b578ecb9063241c992aaa9e > -- > 2.54.0 > > I have no idea what's wrong but I'm still getting two copies of each email as separate messages to my inbox. I'm not seeing it with anyone else. I think there's some issue with your setup. Bart _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic