The FTDI devices default to a very long timeout period (16ms) which is detrimental to performance. Previous patches have exposed the latency timer via sysfs attributes, but increasingly, it seems that *everyone* wants lower timeout latencies. Given that there's basically no downside (a tiny increase in host CPU utilization resulting from more IN urbs), it makes sense to make a lower timeout the default. This patch sets the latency timer to 1 when the device is probed.

Of course, the sysfs attributes remain for those who want to twiddle them.

This patch compiles against 2.6.21.3, is tested against 2.6.20.1 (it applies to 2.6.20.1 with fuzz -F4).

Signed-off-by: Edwin Olson <[EMAIL PROTECTED]>

diff -ur linux-2.6.21.3/drivers/usb/serial/ftdi_sio.c linux-2.6.21.3-eolson/drivers/usb/serial/ftdi_sio.c
--- linux-2.6.21.3/drivers/usb/serial/ftdi_sio.c	2007-05-24 17:22:47.000000000 -0400
+++ linux-2.6.21.3-eolson/drivers/usb/serial/ftdi_sio.c	2007-05-30 08:44:38.000000000 -0400
@@ -1178,9 +1178,13 @@
 static int ftdi_sio_port_probe(struct usb_serial_port *port)
 {
 	struct ftdi_private *priv;
+	struct usb_device *udev;
+	int rv;
+	char buf[1];
 
 	dbg("%s",__FUNCTION__);
 
+	udev = port->serial->dev;
 	priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
 	if (!priv){
 		err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private));
@@ -1221,6 +1225,21 @@
 
 	ftdi_determine_type (port);
 	create_sysfs_attrs(port);
+
+	/* initialize the latency timer to a more reasonable value
+	 than the power-on default. */
+	rv = usb_control_msg(udev,
+			     usb_sndctrlpipe(udev, 0),
+			     FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
+			     FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
+			     FTDI_LATENCY_TIMER_DEFAULT, priv->interface,
+			     buf, 0, WDR_TIMEOUT);
+
+	if (rv < 0) {
+		dbg("Unable to write latency timer: %i", rv);
+		return -EIO;
+	}
+
 	return 0;
 }
 
diff -ur linux-2.6.21.3/drivers/usb/serial/ftdi_sio.h linux-2.6.21.3-eolson/drivers/usb/serial/ftdi_sio.h
--- linux-2.6.21.3/drivers/usb/serial/ftdi_sio.h	2007-05-24 17:22:47.000000000 -0400
+++ linux-2.6.21.3-eolson/drivers/usb/serial/ftdi_sio.h	2007-05-30 08:34:50.000000000 -0400
@@ -22,6 +22,9 @@
  *
  */
 
+#define FTDI_LATENCY_TIMER_DEFAULT 1
+
+
 #define FTDI_VID	0x0403	/* Vendor Id */
 #define FTDI_SIO_PID	0x8372	/* Product Id SIO application of 8U100AX  */
 #define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to