This patch should help with some Genesys Logic devices. It's not a 'silver bullet', but it does help some without interfereing with other devices.
Greg, please apply.
Matt
----- Forwarded message from Alan Stern <[EMAIL PROTECTED]> -----
Date: Wed, 17 Dec 2003 10:31:37 -0500 (EST)
From: Alan Stern <[EMAIL PROTECTED]>
Subject: PATCH: (as161) Handle excess 0-length data packets
To: Matthew Dharm <[EMAIL PROTECTED]>
cc: USB Storage List <[EMAIL PROTECTED]>
X-Spam-Status: No, hits=-1.6 required=5.0
tests=AWL,PATCH_UNIFIED_DIFF,SPAM_PHRASE_00_01,USER_AGENT_PINE version=2.44
Matt:
This patch is an attempt to cope with Genesys Logic's, shall we say,
creative approach to implementing the USB protocols. Their high-speed
mass storage devices sometimes add an excess 0-length packet to the end of
a data phase transmission. Of course we don't read that packet as part of
the data phase; we see it as a 0-length CSW message. The real CSW follows
immediately after. (Or sometimes a STALL follows immediately after, with
the real CSW coming after that!)
The patch checks the results of the first attempt to read the CSW. If it
sees a normal packet (not a STALL) with length 0, it retries the read.
Reports from two users indicate that it improves the performance of their
USB-2 DVD drives.
Alan Stern
===== transport.c 1.113 vs edited =====
--- 1.113/drivers/usb/storage/transport.c Fri Oct 24 11:05:36 2003
+++ edited/drivers/usb/storage/transport.c Mon Dec 15 15:11:03 2003
@@ -929,6 +929,7 @@
unsigned int residue;
int result;
int fake_sense = 0;
+ unsigned int cswlen;
/* set up the command wrapper */
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
@@ -985,7 +986,17 @@
/* get CSW for device status */
US_DEBUGP("Attempting to get CSW...\n");
result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
- bcs, US_BULK_CS_WRAP_LEN, NULL);
+ bcs, US_BULK_CS_WRAP_LEN, &cswlen);
+
+ /* Some broken devices add unnecessary zero-length packets to the
+ * end of their data transfers. Such packets show up as 0-length
+ * CSWs. If we encounter such a thing, try to read the CSW again.
+ */
+ if (result == USB_STOR_XFER_SHORT && cswlen == 0) {
+ US_DEBUGP("Received 0-length CSW; retrying...\n");
+ result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
+ bcs, US_BULK_CS_WRAP_LEN, &cswlen);
+ }
/* did the attempt to read the CSW fail? */
if (result == USB_STOR_XFER_STALLED) {
----- End forwarded message -----
--
Matthew Dharm Home: [EMAIL PROTECTED]
Maintainer, Linux USB Mass Storage Driver
You suck Stef.
-- Greg
User Friendly, 11/29/97
pgp00000.pgp
Description: PGP signature
