public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: mru@kth.se (Måns Rullgård)
To: linux-kernel@vger.kernel.org
Subject: Re: USB 2.0 mass storage problem
Date: Sun, 08 Feb 2004 14:07:22 +0100	[thread overview]
Message-ID: <yw1xfzdlu3cl.fsf@kth.se> (raw)
In-Reply-To: 200402081214.i18CEWe00689@mailgate01.ctimail.com

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

"Francis, Chong Chan Fai" <francis.ccf@polyu.edu.hk> writes:

>> This looks like the drive is using a buggy Genesys USB-to-IDE bridge.
>> Run lsusb and check.  There was a workaround kernel patch floating
>> around here about a month ago.
>
> Thank you for your help, 
> but could you please provide some more key words so that I can find those
> messages? Thanks.

It was one of the attached patches.  I don't remember which one.

-- 
Måns Rullgård
mru@kth.se


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: usb-storage.diff --]
[-- Type: text/x-patch, Size: 2662 bytes --]

===== scsiglue.c 1.62 vs edited =====
--- 1.62/drivers/usb/storage/scsiglue.c Fri Nov 14 04:15:20 2003
+++ edited/drivers/usb/storage/scsiglue.c	Tue Dec 16 10:56:12 2003
@@ -219,6 +219,21 @@
 	return result < 0 ? FAILED : SUCCESS;
 }
 
+/* Report a driver-initiated device reset to the SCSI layer.
+ * Calling this for a SCSI-initiated reset is unnecessary but harmless. */
+void usb_stor_report_device_reset(struct us_data *us)
+{
+	int i;
+
+	scsi_lock(us->host);
+	scsi_report_device_reset(us->host, 0, 0);
+	if (us->flags & US_FL_SCM_MULT_TARG) {
+		for (i = 1; i < 8; ++i)
+			scsi_report_device_reset(us->host, 0, i);
+	}
+	scsi_unlock(us->host);
+}
+
 /***********************************************************************
  * /proc/scsi/ functions
  ***********************************************************************/
===== scsiglue.h 1.7 vs edited =====
--- 1.7/drivers/usb/storage/scsiglue.h	Mon Jul 28 14:29:04 2003
+++ edited/drivers/usb/storage/scsiglue.h	Tue Dec 16 10:56:31 2003
@@ -44,6 +44,9 @@
 #include <linux/blkdev.h>
 #include "scsi.h"
 #include "hosts.h"
+#include "usb.h"
+
+extern void usb_stor_report_device_reset(struct us_data *us);
 
 extern unsigned char usb_stor_sense_notready[18];
 extern unsigned char usb_stor_sense_invalidCDB[18];
===== 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	Tue Dec 16 11:41:27 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) {
@@ -1066,6 +1077,9 @@
 {
 	int result;
 	int result2;
+
+	/* Let the SCSI layer know we are doing a reset */
+	usb_stor_report_device_reset(us);
 
 	/* A 20-second timeout may seem rather long, but a LaCie
 	 *  StudioDrive USB2 device takes 16+ seconds to get going

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: usb-storage-csw.diff --]
[-- Type: text/x-patch, Size: 449 bytes --]

--- 1.112/drivers/usb/storage/transport.c       Fri Sep 26 12:37:45 2003
+++ edited/drivers/usb/storage/transport.c      Mon Dec  1 14:06:19 2003
@@ -985,7 +985,7 @@
				bcs, US_BULK_CS_WRAP_LEN, NULL);
 
	/* did the attempt to read the CSW fail? */
-	if (result == USB_STOR_XFER_STALLED) {
+	if (result == USB_STOR_XFER_STALLED || result == USB_STOR_XFER_SHORT) {
 
		/* get the status again */
		US_DEBUGP("Attempting to get CSW (2nd try)...\n");

  reply	other threads:[~2004-02-08 13:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-08  6:11 USB 2.0 mass storage problem Francis, Chong Chan Fai
2004-02-08  6:34 ` Mike Fedyk
2004-02-08  6:58   ` Francis, Chong Chan Fai
2004-02-08  9:08     ` Mike Fedyk
2004-02-08 11:24 ` Måns Rullgård
2004-02-08 12:15   ` Francis, Chong Chan Fai
2004-02-08 13:07     ` Måns Rullgård [this message]
2004-02-09 11:37       ` Francis, Chong Chan Fai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yw1xfzdlu3cl.fsf@kth.se \
    --to=mru@kth.se \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox