Re: [PATCH v6 4/8] gpiolib: cdev: don't sleep in the SRCU read section in read()

From: Kent Gibson

Date: Wed Nov 18 2026 - 10:40:57 EST


On Mon, Nov 16, 2026 at 03:47:07PM +0200, Adrian Ambrozewicz wrote:
> linereq_read(), lineevent_read() and lineinfo_watch_read() stay in the
> gdev->srcu read section while they sleep waiting for an event, so
> gpiochip_remove() blocks in synchronize_srcu() until an event arrives
> or the reader is signalled. The device lock is held meanwhile, which
> also blocks device_shutdown():
>
> task:init state:D stack:0 pid:1 tgid:1 ppid:0
> Call Trace:
> __synchronize_srcu
> gpiochip_remove
> devres_release_all
> device_release_driver_internal
> platform_device_unregister
> gpio_sim_device_deactivate
>
> Check the chip in a scoped SRCU section only; nothing after the check
> dereferences it. End the wait once the chip is gone, and return -ENODEV
> if there is no event to report.
>
> Reproduced with gpio-sim: setting "live" to 0 hangs while a reader is
> blocked in read() on a line request; with this change, the write
> returns at once and read() fails with -ENODEV.
>

Reviewed-by: Kent Gibson <warthog618@xxxxxxxxx>

Cheers,
Kent.