RE: [PATCH v2 2/2] USB: serial: ftdi_sio: make explicit latency_timer sysfs write authoritative
From: Chinna Mopurigari Naveen Kumar Reddy (FTDI-SG)
Date: Mon Jun 22 2026 - 20:20:25 EST
Hi Greg,
On Mon, Jun 22, 2026 at 04:xx:xxPM +0000, Greg Kroah-Hartman wrote:
> When drivers work properly, they are quiet. Make this a debugging
> message at the most please.
Will do, thanks. I'll change it to dev_dbg() in v3.
I'll hold the respin for a day or so to collect any further review
comments (including on patch 1/2) and address them together.
Thanks,
Naveen
-----Original Message-----
From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Sent: Monday, 22 June 2026 6:19 pm
To: Chinna Mopurigari Naveen Kumar Reddy (FTDI-SG) <naveen.reddy@xxxxxxxxxxxx>
Cc: Johan Hovold <johan@xxxxxxxxxx>; linux-usb@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; Arun Pappan (FTDI-SG) <arun.pappan@xxxxxxxxxxxx>
Subject: Re: [PATCH v2 2/2] USB: serial: ftdi_sio: make explicit latency_timer sysfs write authoritative
On Mon, Jun 22, 2026 at 05:43:40PM +0800, Chinna Mopurigari Naveen Kumar Reddy wrote:
> write_latency_timer() clamps the value programmed into the FT chip's
> per-channel latency_timer register to 1 whenever ASYNC_LOW_LATENCY is
> set in priv->flags. ASYNC_LOW_LATENCY is set by userspace via
> TIOCSSERIAL, used by setserial(8), libftdi and certain tcsetattr
> paths. The interaction with the existing sysfs latency_timer
> attribute is surprising: once any of those tools has set the flag, a
> later write of "16" (or any other value) to
> /sys/bus/usb-serial/devices/ttyUSBx/latency_timer is silently clamped
> to 1 and never reaches the chip.
>
> The store path is the most explicit way userspace can ask for a
> particular latency_timer value; treat it as authoritative. On an
> explicit sysfs write, clear ASYNC_LOW_LATENCY before calling
> write_latency_timer() so the requested value is what the chip register
> actually receives. Emit a dev_info() so the override is visible.
>
> Reads continue to honour ASYNC_LOW_LATENCY (returning "1") so any
> userspace that previously inspected the attribute to confirm
> low-latency mode keeps working until it does its own explicit write.
>
> Signed-off-by: Chinna Mopurigari Naveen Kumar Reddy
> <naveen.reddy@xxxxxxxxxxxx>
> ---
> drivers/usb/serial/ftdi_sio.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/usb/serial/ftdi_sio.c
> b/drivers/usb/serial/ftdi_sio.c index 7aaa7fc1be71..e7f13eca7ae6
> 100644
> --- a/drivers/usb/serial/ftdi_sio.c
> +++ b/drivers/usb/serial/ftdi_sio.c
> @@ -1683,6 +1683,23 @@ static ssize_t latency_timer_store(struct device *dev,
> if (kstrtou8(valbuf, 10, &v))
> return -EINVAL;
>
> + /*
> + * An explicit sysfs write wins over the legacy ASYNC_LOW_LATENCY
> + * tty-flag override. Without this, if any userspace tool
> + * (setserial(8), libftdi, certain tcsetattr paths) had set
> + * ASYNC_LOW_LATENCY via TIOCSSERIAL, write_latency_timer() would
> + * silently clamp the chip register to 1 regardless of what was
> + * written to sysfs. Clearing the flag here makes sysfs the
> + * authoritative source so the next chip-side write uses exactly
> + * the value the caller asked for.
> + */
> + if (priv->flags & ASYNC_LOW_LATENCY) {
> + dev_info(&port->dev,
> + "explicit latency_timer=%u clears ASYNC_LOW_LATENCY flag\n",
> + v);
When drivers work properly, they are quiet. Make this a debugging message at the most please.
thanks,
greg k-h