[Ftdi-usb-sio-devel] Interleaved write/read operations on ftdi_sio seem to cause an error
Brought to you by:
bryder
From: David D. <dav...@ll...> - 2009-01-28 08:15:17
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, In our setup, we have a PC with its USB connected to a FTDI245BL chip connected to a (hardware) FIFO: we (the PC) first write 128 bytes to the FTDI, and then we expect to read back the exact same bytes from the FTDI. That is: the fifo first stores all the 128 bytes we write, then immediatly (a few nanoseconds later) sends them back to us, all this via the FTDI of course. I am running intrepid with kernel 2.6.27-9 on an UP IA32 (Pentium 4) machine (2.4GHz). The problem I am reporting is also reproducible with the ftdi_sio module recompiled from a vanilla kernel.org's 2.6.27.9 kernel. My kernel is not tainted. So, our setup works "most" of the time: we can do thousands of such write/read sessions of 128 bytes in a row. But at some point the read() returns with a length of '0', even though we did have everything written to our FIFO device (we checked with a digital analyzer), and sent back by our FIFO device to the FTDI (likewise). So I guess the FTDI sent everything back to the host (at least the debug below seems to confirm). The problem seems to happen independently on the size of our FIFO device / the size of the data packets we are using (we tried 32, 128, 256, 2048 bytes); however, the larger they are, the easier we get the bug. Moreover, it seems related to the load on the PC: the more it is loaded, the more likely this bug is going to show up. All this tends to suggest this bug is some kind of driver (synchronization ?) problem. When I load the ftdi_sio module in debug mode, I get the following messages when the write/read *works*: - -------------------------------------------------------------------- [72206.672669] ftdi_sio ttyUSB0: ftdi_write - length = 128, data = be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd [72206.672744] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: ftdi_write write returning: 128 [72206.673520] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: ftdi_write_bulk_callback - port 0 [72206.688570] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: ftdi_read_bulk_callback - port 0 [72206.688577] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: ftdi_process_read - port 0 - -------------------------------------------------------------------- And when it *does not work* (ie. read() returns 0), we get: - -------------------------------------------------------------------- [72206.720802] ftdi_sio ttyUSB0: ftdi_write - length = 128, data = d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 [72206.720875] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: ftdi_write write returning: 128 [72206.721639] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: ftdi_read_bulk_callback - port 0 [72206.721645] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: (this is ok on close) nonzero read bulk status received: -75 [72206.721652] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: ftdi_write_bulk_callback - port 0 [72206.856067] hub 4-0:1.0: port 2 disabled by hub (EMI?), re-enabling... [72206.856076] usb 4-2: USB disconnect, address 43 [72206.859191] ftdi_sio 4-2:1.0: device disconnected [72206.859712] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: ftdi_close [72206.859722] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: ftdi_shutdown [72206.859748] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: ftdi_sio_port_remove [72206.859752] /tmp/linux-2.6.27.9/drivers/usb/serial/ftdi_sio.c: remove_sysfs_attrs [72206.860121] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0 - -------------------------------------------------------------------- When it fails, I always had the write callback called /after/ the read callback (as is the case above). But I am not sure it does NEVER happen when everything is fine too. I can send the full traces to whoever wants to analyze them. Code-wise, I do have a problem figuring out what this "-75" return value stands for. Maybe it could help, maybe it should be ignored in some cases. Looking at the code, it seems that the snippet involved is: - -------------------------------------------------------------------- static void ftdi_read_bulk_callback(struct urb *urb) { [...] int status = urb->status; [...] if (status) { /* This will happen at close every time so it is a dbg not an err */ dbg("(this is ok on close) nonzero read bulk status received: %d", status); return; } [...] } - -------------------------------------------------------------------- So, to summarize my thoughts: could it be that the write/read callbacks are not allowed to get interleaved ? Or is it something else ? What does a status of -75 mean ? I can provide any further information on request. Thanks a lot for any help ! -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkmAE/8ACgkQld7vhusVrCEhkgCfbOO0m4T00Qsc8FGHB31LSqee Qn0AoIyz7n2WS+XIqKtdWkCM2Qu2P1Wb =bWPC -----END PGP SIGNATURE----- |