Re: [PATCH v4] USB: serial: ftdi_sio: implement GPIO support for FT-X devices

From: Johan Hovold
Date: Tue Sep 18 2018 - 07:20:21 EST


On Tue, Sep 18, 2018 at 10:27:58AM +0000, Karoly Pados wrote:

> >> Does that mean something can call into our module while this method is running?
> >> If not, I'm clueless about the possible race here.
> >
> > Correct, you can get gpio callbacks until the gpio chip has been
> > deregistered (anything coming in after that would be a gpiolib bug).
>
> I'm just puzzled by the fact that this can still happen even while the port
> removal code is running. It also makes me ask the question what else here can
> run in parallel. Don't we need mutexes here-and-there in the ftx gpio functions too
> in this case? Or does gpiolib make sure to serialize multiple pin and direction
> setting calls?

Good point. The old sysfs interface would keep things serialised, but
the new chardev-based one does not (nor does the in-kernel interface).

So yeah, we need to add a mutex protecting the gpio state (i.e.
direction and value).

Thanks,
Johan