Re: [PATCH] gpio: virtuser: refuse the atomic attributes for lines that can sleep

From: Bartosz Golaszewski

Date: Wed Dec 02 2026 - 03:48:04 EST


On Tue, Dec 01, 2026 at 10:49:50PM +0800, Lin Tzu Yang wrote:
> The *_atomic debugfs attributes run the non-sleeping GPIO calls from a
> hard irq_work, but they are created for every line, also for lines on
> chips that can sleep. Using them on such a line, for example one of
> gpio-sim, makes gpiolib warn and the chip driver sleep in hard
> interrupt context. Reading value_atomic of a gpio-sim line gives:
>
> WARNING: drivers/gpio/gpiolib.c:3689 at gpiod_get_value+0xb4/0x128
> BUG: sleeping function called from invalid context at kernel/locking/mutex.c:623
> [ BUG: Invalid wait context ]
> cat/108 is trying to lock:
> (mutex_){+.+.}-{4:4}, at: gpio_sim_get+0x30/0xb4
> ...
> gpio_sim_get+0x30/0xb4
> gpiochip_get+0x78/0x150
> gpiod_get_raw_value_commit+0x10c/0x2ac
> gpiod_get_value+0x74/0x128
> gpio_virtuser_get_value_atomic+0x34/0x9c
> irq_work_single+0xb0/0x1e0
>
> and value_atomic writes and values_atomic reads and writes hit the
> matching warnings in gpiod_set_value() and the array helpers.
>
> Return -EOPNOTSUPP from the atomic variants when a line can sleep,
> before queueing the irq_work. Lines on chips that don't sleep behave
> as before.
>
> Fixes: 91581c4b3f29 ("gpio: virtuser: new virtual testing driver for the GPIO API")
> Signed-off-by: Lin Tzu Yang <rongh7426@xxxxxxxxx>
> ---

Thanks for the catch. Makes perfect sense so I queued it right away for
fixes.

Bart