Re: [PATCH 0/5] gpio: cdev: bail out of poll() if the device goes down

From: Kent Gibson
Date: Thu Aug 17 2023 - 00:42:29 EST


On Wed, Aug 16, 2023 at 11:41:06PM +0200, Linus Walleij wrote:
> On Wed, Aug 16, 2023 at 2:20 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
>
> > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> >
> > Wake up all three wake queues (the one associated with the character
> > device file, the one for V1 line events and the V2 line request one)
> > when the underlying GPIO device is unregistered. This way we won't get
> > stuck in poll() after the chip is gone as user-space will be forced to
> > go back into a new system call and will see that gdev->chip is NULL.
> >
> > Bartosz Golaszewski (5):
> > gpio: cdev: ignore notifications other than line status changes
> > gpio: cdev: rename the notifier block and notify callback
> > gpio: cdev: wake up chardev poll() on device unbind
> > gpio: cdev: wake up linereq poll() on device unbind
> > gpio: cdev: wake up lineevent poll() on device unbind
>
> I see why this is needed and while the whole notification chain
> is a bit clunky I really cannot think about anything better so:
> Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
>

The issue I have is with the repurposing/reuse of the existing notifier
block that sends line changed events to the chardev.
Correct me if I'm wrong, but now all line requests will receive those
events as well.
They have no business receiving those events, and it scales badly.

My preference would be for a separate nb for the chip removal to keep
those two classes of events distinct.

Cheers,
Kent.