All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: serial: ftdi_sio: fix extreme low-latency setting
@ 2017-01-25 14:35 Johan Hovold
  2017-01-25 15:06 ` Greg Kroah-Hartman
  2017-01-25 15:19 ` David Laight
  0 siblings, 2 replies; 6+ messages in thread
From: Johan Hovold @ 2017-01-25 14:35 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman; +Cc: Antoine Aubert, stable, Johan Hovold

Since commit 557aaa7ffab6 ("ft232: support the ASYNC_LOW_LATENCY
flag") the FTDI driver has been using a receive latency-timer value of
1 ms instead of the device default of 16 ms.

The latency timer is used to periodically empty a non-full receive
buffer, but a status header is always sent when the timer expires
including when the buffer is empty. This means that a two-byte bulk
message is received every millisecond also for an otherwise idle port as
long as it is open.

Let's restore the pre-2009 behaviour which reduces rate of status
messages to 1/16th (e.g. interrupt frequency drops from 1 kHz to 62.5
Hz) by not setting ASYNC_LOW_LATENCY by default.

Anyone willing to pay the price for the minimum-latency behaviour should
set the flag explicitly instead using the TIOCSSERIAL ioctl or a tool
such as setserial (e.g. setserial /dev/ttyUSB0 low_latency).

Note that since commit 0cbd81a9f6ba ("USB: ftdi_sio: remove
tty->low_latency") the ASYNC_LOW_LATENCY flag has no other effects but
to set a minimal latency timer.

Reported-by: Antoine Aubert <a.aubert@overkiz.com>
Fixes: 557aaa7ffab6 ("ft232: support the ASYNC_LOW_LATENCY flag")
Cc: stable <stable@vger.kernel.org>	# v2.6.31
Signed-off-by: Johan Hovold <johan@kernel.org>
---

Greg,

I've been aware of this overhead for a while, but never realised it was
actually a regression introduced in 2009.

Fixing something like this after such a long time obviously means
risking a regression for anyone who is now relying on the new default
behaviour instead. I still think it's reasonable in this case to restore
the earlier behaviour given the penalty everyone else is paying for a
minimal-latency behaviour that they likely do not need or want.

Whether this should go to stable is a different question. Perhaps the
stable tag is not warranted, and this should just be the default
behaviour going forward? What do you think?

Thanks,
Johan



 drivers/usb/serial/ftdi_sio.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index b064fad8e3ee..4bd556d9307d 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1805,8 +1805,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
 
 	mutex_init(&priv->cfg_lock);
 
-	priv->flags = ASYNC_LOW_LATENCY;
-
 	if (quirk && quirk->port_probe)
 		quirk->port_probe(priv);
 
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] USB: serial: ftdi_sio: fix extreme low-latency setting
  2017-01-25 14:35 [PATCH] USB: serial: ftdi_sio: fix extreme low-latency setting Johan Hovold
@ 2017-01-25 15:06 ` Greg Kroah-Hartman
  2017-01-25 15:14   ` Johan Hovold
  2017-01-25 15:19 ` David Laight
  1 sibling, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-25 15:06 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-usb, Antoine Aubert, stable

On Wed, Jan 25, 2017 at 03:35:20PM +0100, Johan Hovold wrote:
> Since commit 557aaa7ffab6 ("ft232: support the ASYNC_LOW_LATENCY
> flag") the FTDI driver has been using a receive latency-timer value of
> 1 ms instead of the device default of 16 ms.
> 
> The latency timer is used to periodically empty a non-full receive
> buffer, but a status header is always sent when the timer expires
> including when the buffer is empty. This means that a two-byte bulk
> message is received every millisecond also for an otherwise idle port as
> long as it is open.
> 
> Let's restore the pre-2009 behaviour which reduces rate of status
> messages to 1/16th (e.g. interrupt frequency drops from 1 kHz to 62.5
> Hz) by not setting ASYNC_LOW_LATENCY by default.
> 
> Anyone willing to pay the price for the minimum-latency behaviour should
> set the flag explicitly instead using the TIOCSSERIAL ioctl or a tool
> such as setserial (e.g. setserial /dev/ttyUSB0 low_latency).
> 
> Note that since commit 0cbd81a9f6ba ("USB: ftdi_sio: remove
> tty->low_latency") the ASYNC_LOW_LATENCY flag has no other effects but
> to set a minimal latency timer.
> 
> Reported-by: Antoine Aubert <a.aubert@overkiz.com>
> Fixes: 557aaa7ffab6 ("ft232: support the ASYNC_LOW_LATENCY flag")
> Cc: stable <stable@vger.kernel.org>	# v2.6.31
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> 
> Greg,
> 
> I've been aware of this overhead for a while, but never realised it was
> actually a regression introduced in 2009.
> 
> Fixing something like this after such a long time obviously means
> risking a regression for anyone who is now relying on the new default
> behaviour instead. I still think it's reasonable in this case to restore
> the earlier behaviour given the penalty everyone else is paying for a
> minimal-latency behaviour that they likely do not need or want.
> 
> Whether this should go to stable is a different question. Perhaps the
> stable tag is not warranted, and this should just be the default
> behaviour going forward? What do you think?

I think the stable tag is warrented here.  Do you want me to take this
patch now into my usb-linus tree, or will you include it in a pull
request?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] USB: serial: ftdi_sio: fix extreme low-latency setting
  2017-01-25 15:06 ` Greg Kroah-Hartman
@ 2017-01-25 15:14   ` Johan Hovold
  2017-01-25 15:42     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2017-01-25 15:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Johan Hovold, linux-usb, Antoine Aubert, stable

On Wed, Jan 25, 2017 at 04:06:47PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Jan 25, 2017 at 03:35:20PM +0100, Johan Hovold wrote:
> > Since commit 557aaa7ffab6 ("ft232: support the ASYNC_LOW_LATENCY
> > flag") the FTDI driver has been using a receive latency-timer value of
> > 1 ms instead of the device default of 16 ms.
> > 
> > The latency timer is used to periodically empty a non-full receive
> > buffer, but a status header is always sent when the timer expires
> > including when the buffer is empty. This means that a two-byte bulk
> > message is received every millisecond also for an otherwise idle port as
> > long as it is open.
> > 
> > Let's restore the pre-2009 behaviour which reduces rate of status
> > messages to 1/16th (e.g. interrupt frequency drops from 1 kHz to 62.5
> > Hz) by not setting ASYNC_LOW_LATENCY by default.
> > 
> > Anyone willing to pay the price for the minimum-latency behaviour should
> > set the flag explicitly instead using the TIOCSSERIAL ioctl or a tool
> > such as setserial (e.g. setserial /dev/ttyUSB0 low_latency).
> > 
> > Note that since commit 0cbd81a9f6ba ("USB: ftdi_sio: remove
> > tty->low_latency") the ASYNC_LOW_LATENCY flag has no other effects but
> > to set a minimal latency timer.
> > 
> > Reported-by: Antoine Aubert <a.aubert@overkiz.com>
> > Fixes: 557aaa7ffab6 ("ft232: support the ASYNC_LOW_LATENCY flag")
> > Cc: stable <stable@vger.kernel.org>	# v2.6.31
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > ---
> > 
> > Greg,
> > 
> > I've been aware of this overhead for a while, but never realised it was
> > actually a regression introduced in 2009.
> > 
> > Fixing something like this after such a long time obviously means
> > risking a regression for anyone who is now relying on the new default
> > behaviour instead. I still think it's reasonable in this case to restore
> > the earlier behaviour given the penalty everyone else is paying for a
> > minimal-latency behaviour that they likely do not need or want.
> > 
> > Whether this should go to stable is a different question. Perhaps the
> > stable tag is not warranted, and this should just be the default
> > behaviour going forward? What do you think?
> 
> I think the stable tag is warrented here.  Do you want me to take this
> patch now into my usb-linus tree, or will you include it in a pull
> request?

I'll include it in a pull request. I was gonna apply it for -next, but
if you prefer I can send it along with some new device ids I have queued
up for 4.10-rc?

Thanks,
Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] USB: serial: ftdi_sio: fix extreme low-latency setting
  2017-01-25 14:35 [PATCH] USB: serial: ftdi_sio: fix extreme low-latency setting Johan Hovold
  2017-01-25 15:06 ` Greg Kroah-Hartman
@ 2017-01-25 15:19 ` David Laight
  1 sibling, 0 replies; 6+ messages in thread
From: David Laight @ 2017-01-25 15:19 UTC (permalink / raw)
  To: 'Johan Hovold', linux-usb, Greg Kroah-Hartman
  Cc: Antoine Aubert, stable

From: Johan Hovold
> Sent: 25 January 2017 14:35
> Since commit 557aaa7ffab6 ("ft232: support the ASYNC_LOW_LATENCY
> flag") the FTDI driver has been using a receive latency-timer value of
> 1 ms instead of the device default of 16 ms.
> 
> The latency timer is used to periodically empty a non-full receive
> buffer, but a status header is always sent when the timer expires
> including when the buffer is empty. This means that a two-byte bulk
> message is received every millisecond also for an otherwise idle port as
> long as it is open.
...

I'd wondered what all those packets were.
It seems beyond stupid that the hardware is sending them at all.

	David


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] USB: serial: ftdi_sio: fix extreme low-latency setting
  2017-01-25 15:14   ` Johan Hovold
@ 2017-01-25 15:42     ` Greg Kroah-Hartman
  2017-01-25 16:02       ` Johan Hovold
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-25 15:42 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-usb, Antoine Aubert, stable

On Wed, Jan 25, 2017 at 04:14:36PM +0100, Johan Hovold wrote:
> On Wed, Jan 25, 2017 at 04:06:47PM +0100, Greg Kroah-Hartman wrote:
> > On Wed, Jan 25, 2017 at 03:35:20PM +0100, Johan Hovold wrote:
> > > Since commit 557aaa7ffab6 ("ft232: support the ASYNC_LOW_LATENCY
> > > flag") the FTDI driver has been using a receive latency-timer value of
> > > 1 ms instead of the device default of 16 ms.
> > > 
> > > The latency timer is used to periodically empty a non-full receive
> > > buffer, but a status header is always sent when the timer expires
> > > including when the buffer is empty. This means that a two-byte bulk
> > > message is received every millisecond also for an otherwise idle port as
> > > long as it is open.
> > > 
> > > Let's restore the pre-2009 behaviour which reduces rate of status
> > > messages to 1/16th (e.g. interrupt frequency drops from 1 kHz to 62.5
> > > Hz) by not setting ASYNC_LOW_LATENCY by default.
> > > 
> > > Anyone willing to pay the price for the minimum-latency behaviour should
> > > set the flag explicitly instead using the TIOCSSERIAL ioctl or a tool
> > > such as setserial (e.g. setserial /dev/ttyUSB0 low_latency).
> > > 
> > > Note that since commit 0cbd81a9f6ba ("USB: ftdi_sio: remove
> > > tty->low_latency") the ASYNC_LOW_LATENCY flag has no other effects but
> > > to set a minimal latency timer.
> > > 
> > > Reported-by: Antoine Aubert <a.aubert@overkiz.com>
> > > Fixes: 557aaa7ffab6 ("ft232: support the ASYNC_LOW_LATENCY flag")
> > > Cc: stable <stable@vger.kernel.org>	# v2.6.31
> > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > ---
> > > 
> > > Greg,
> > > 
> > > I've been aware of this overhead for a while, but never realised it was
> > > actually a regression introduced in 2009.
> > > 
> > > Fixing something like this after such a long time obviously means
> > > risking a regression for anyone who is now relying on the new default
> > > behaviour instead. I still think it's reasonable in this case to restore
> > > the earlier behaviour given the penalty everyone else is paying for a
> > > minimal-latency behaviour that they likely do not need or want.
> > > 
> > > Whether this should go to stable is a different question. Perhaps the
> > > stable tag is not warranted, and this should just be the default
> > > behaviour going forward? What do you think?
> > 
> > I think the stable tag is warrented here.  Do you want me to take this
> > patch now into my usb-linus tree, or will you include it in a pull
> > request?
> 
> I'll include it in a pull request. I was gonna apply it for -next, but
> if you prefer I can send it along with some new device ids I have queued
> up for 4.10-rc?

-next is probably good, it's not like there is a rush for it :)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] USB: serial: ftdi_sio: fix extreme low-latency setting
  2017-01-25 15:42     ` Greg Kroah-Hartman
@ 2017-01-25 16:02       ` Johan Hovold
  0 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2017-01-25 16:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Johan Hovold, linux-usb, Antoine Aubert, stable

On Wed, Jan 25, 2017 at 04:42:01PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Jan 25, 2017 at 04:14:36PM +0100, Johan Hovold wrote:
> > On Wed, Jan 25, 2017 at 04:06:47PM +0100, Greg Kroah-Hartman wrote:
> > > On Wed, Jan 25, 2017 at 03:35:20PM +0100, Johan Hovold wrote:
> > > > Since commit 557aaa7ffab6 ("ft232: support the ASYNC_LOW_LATENCY
> > > > flag") the FTDI driver has been using a receive latency-timer value of
> > > > 1 ms instead of the device default of 16 ms.
> > > > 
> > > > The latency timer is used to periodically empty a non-full receive
> > > > buffer, but a status header is always sent when the timer expires
> > > > including when the buffer is empty. This means that a two-byte bulk
> > > > message is received every millisecond also for an otherwise idle port as
> > > > long as it is open.
> > > > 
> > > > Let's restore the pre-2009 behaviour which reduces rate of status
> > > > messages to 1/16th (e.g. interrupt frequency drops from 1 kHz to 62.5
> > > > Hz) by not setting ASYNC_LOW_LATENCY by default.
> > > > 
> > > > Anyone willing to pay the price for the minimum-latency behaviour should
> > > > set the flag explicitly instead using the TIOCSSERIAL ioctl or a tool
> > > > such as setserial (e.g. setserial /dev/ttyUSB0 low_latency).
> > > > 
> > > > Note that since commit 0cbd81a9f6ba ("USB: ftdi_sio: remove
> > > > tty->low_latency") the ASYNC_LOW_LATENCY flag has no other effects but
> > > > to set a minimal latency timer.
> > > > 
> > > > Reported-by: Antoine Aubert <a.aubert@overkiz.com>
> > > > Fixes: 557aaa7ffab6 ("ft232: support the ASYNC_LOW_LATENCY flag")
> > > > Cc: stable <stable@vger.kernel.org>	# v2.6.31
> > > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > > ---
> > > > 
> > > > Greg,
> > > > 
> > > > I've been aware of this overhead for a while, but never realised it was
> > > > actually a regression introduced in 2009.
> > > > 
> > > > Fixing something like this after such a long time obviously means
> > > > risking a regression for anyone who is now relying on the new default
> > > > behaviour instead. I still think it's reasonable in this case to restore
> > > > the earlier behaviour given the penalty everyone else is paying for a
> > > > minimal-latency behaviour that they likely do not need or want.
> > > > 
> > > > Whether this should go to stable is a different question. Perhaps the
> > > > stable tag is not warranted, and this should just be the default
> > > > behaviour going forward? What do you think?
> > > 
> > > I think the stable tag is warrented here.  Do you want me to take this
> > > patch now into my usb-linus tree, or will you include it in a pull
> > > request?
> > 
> > I'll include it in a pull request. I was gonna apply it for -next, but
> > if you prefer I can send it along with some new device ids I have queued
> > up for 4.10-rc?
> 
> -next is probably good, it's not like there is a rush for it :)

True. Don't really wanna think about how much power has been wasted on
these insane interrupt rates considering the number of these devices
that are out there though...

Now applied for -next, with a stable dependency on patch already in my
tree which did not need to be backported while ASYNC_LOW_LATENCY was
set.

Thanks,
Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-25 16:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-25 14:35 [PATCH] USB: serial: ftdi_sio: fix extreme low-latency setting Johan Hovold
2017-01-25 15:06 ` Greg Kroah-Hartman
2017-01-25 15:14   ` Johan Hovold
2017-01-25 15:42     ` Greg Kroah-Hartman
2017-01-25 16:02       ` Johan Hovold
2017-01-25 15:19 ` David Laight

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.