Re: [PATCH] USB: serial: Support attaching serdev devices
From: Alban Bedel
Date: Mon Sep 21 2026 - 12:25:11 EST
On Fri, 18 Sep 2026 16:56:38 +0200
Johan Hovold <johan@xxxxxxxxxx> wrote:
> On Thu, Sep 17, 2026 at 05:21:52PM +0200, Alban Bedel wrote:
> > On Thu, 17 Sep 2026 15:08:11 +0100
> > Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> > > Please read the archives for why we don't want to do this unless/until
> > > serdev is "fixed" to properly handle dynamic device removals.
> >
> > All I could find is the "USB-Serial serdev support" thread from last
> > year which sadly doesn't provides much details. Like Marco Felsch back
> > then I tested disabling/enabling the USB port and didn't have any
> > issue, the serdev device get removed and added back just fine. In my
> > case the serdev driver provides an I2C bus, all devices on it get
> > removed and added back again as well and work just fine.
> >
> > I really fail to see an issue in pratice, would you care to explain
> > what I'm missing here?
>
> Serial drivers use hangups when tearing down their ports. Serdev does
> not support that so the port is shut down underneath the serdev client
> while still in use, which can lead to all sorts of issues.
Hangup from modem status are ignored because serdev set C_CLOCAL. So
that only leave the hangup sent when the USB device is disconnected.
But in this case, right after the hangup, the tty port device is
removed, which in turn remove the serdev device. At this point there no
way to comunicate with the tty anymore anyway, so I don't see what
signaling the hangup to the serdev device right before it get removed
would add.
Over the weekend I did some further test with a loopback cable and a
test serdev driver that continuously read/write on the tty. I could
disconnect and reconnect the USB device without any real issue.
check_tty_count() produce a warning because the serdev open is not
accounted for but that should be easy to fix.
One thing that I can see going wrong is if a serdev driver if waiting
on a write with a very long timeout. If the tty goes away while it is
waiting the wait is currently not interrupted which prevent the device
from being removed. But this is a more generic issue in serdev as that
could also happen by unbinding the serdev driver.
Alban