public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tomas Styblo <tripie@cpan.org>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] JMicron JM20337 USB-SATA data corruption bugfix - device 152d:2338
Date: Sun, 20 Jul 2008 07:13:27 +0200	[thread overview]
Message-ID: <20080720051326.GA5478@notebook.homenet.local> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1457 bytes --]



Hello,

this message includes a patch that provides a workaround for
a silent data corruption bug caused by incorrect error handling in
the JMicron JM20337 Hi-Speed USB to SATA & PATA Combo Bridge chipset,
USB device id 152d:2338.


- the problem occurs quite rarely, approx. once for 
  every 20 GB of transfered data during heavy load

- it seems that only read operations are affected

- the problem is accompanied by these messages in syslog each
  time it occurs:

May 17 15:06:56 kernel: sd 6:0:0:0: [sdb] Sense Key : 0x0 [current] 
May 17 15:06:56 kernel: sd 6:0:0:0: [sdb] ASC=0x0 ASCQ=0x0

- the bug is not detected as an error and incorrect data is returned, 
  causing insidious data corruption

- tested with 3 external disk enclosures (Akasa Integral AK-ENP2SATA-BL) 
  with different disks on different computers, with kernel 2.6.24 and 2.6.25

- the patch provides a crude workaround by detecting the error condition
  and retrying the faulty transfer


The fix needs a review as I don't know much about USB and SCSI.  
It's possible that this approach is wrong and that the problem should
be fixed somewhere else.

There are other problems with this chipset that make it necessary 
to disconnect and power off the enclosure from time to time, but at least
there's no data corruption anymore.


-- 
Tomas Styblo <tripie@cpan.org>
PGP: C97EA4B6 / 817E B8A8 1AFD 3256 3181  A730 85CF 7BEB C97E A4B6

[-- Attachment #1.2: linux-kernel-2.6.25.9-usb-storage-jmicron-JM20337-no-sense-bugfix.patch --]
[-- Type: text/plain, Size: 1239 bytes --]

--- linux-2.6.25.9/drivers/usb/storage/transport.c.orig	2008-06-24 23:09:06.000000000 +0200
+++ linux-2.6.25.9/drivers/usb/storage/transport.c	2008-07-20 05:14:32.000000000 +0200
@@ -661,6 +661,21 @@ void usb_stor_invoke_transport(struct sc
 			srb->result = SAM_STAT_GOOD;
 			srb->sense_buffer[0] = 0x0;
 		}
+
+        /* JMicron JM20337 chipset bug workaround - BEGIN */
+		if (us->pusb_dev->descriptor.idVendor == 0x152d && 
+            us->pusb_dev->descriptor.idProduct == 0x2338 && 
+            result == USB_STOR_TRANSPORT_FAILED &&
+			/* Filemark 0, ignore EOM, ILI 0, no sense */
+				(srb->sense_buffer[2] & 0xaf) == 0 &&
+			/* No ASC or ASCQ */
+				srb->sense_buffer[12] == 0 &&
+				srb->sense_buffer[13] == 0) {
+            printk(KERN_WARNING "USB Storage - Working around the JMicron JM20337 chipset bug (idVendor=%04x, idProduct=%04x, NO_SENSE, ASC=0, ASCQ=0) - retrying the read operation\n", us->pusb_dev->descriptor.idVendor, us->pusb_dev->descriptor.idProduct);
+		    srb->result = (DID_ERROR << 16) | (SUGGEST_RETRY << 24);
+            return;
+        }
+        /* JMicron JM20337 chipset bug workaround - END */
 	}
 
 	/* Did we transfer less than the minimum amount required? */

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2008-07-20  5:24 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-20  5:13 Tomas Styblo [this message]
     [not found] <fa.eWQqoO1e4Mdhu8SK5jzMFAI/3NU@ifi.uio.no>
2008-07-21 19:37 ` [PATCH] JMicron JM20337 USB-SATA data corruption bugfix - device 152d:2338 Robert Hancock
2008-07-22  2:37   ` Alan Stern
2008-07-22  9:03     ` Tomas Styblo
2008-07-23  2:38       ` Alan Stern
2008-07-23 23:20         ` Robert Hancock
2008-07-24  3:42           ` Alan Stern
2008-07-30 19:55             ` Robert Hancock
2008-07-30 21:07               ` Alan Stern
2008-08-01 21:15                 ` Alex Buell
2008-08-01 22:22                   ` Alex Buell
2008-08-02  2:32                     ` Robert Hancock
2008-08-02 23:49                     ` Alan Stern
2008-08-03  9:07                       ` Alex Buell
2008-08-04 16:48                         ` Alan Stern
2008-08-04 20:17                           ` Alex Buell
2008-08-04 20:45                             ` Alan Stern
2008-09-02 12:10                               ` Thiago Galesi
2008-09-02 15:02                                 ` Alan Stern
2008-09-02 16:07                                   ` Thiago Galesi
2008-09-02 19:19                                     ` Alan Stern
2008-09-02 20:16                                       ` Thiago Galesi
2008-09-02 21:06                                         ` Alan Stern
2008-09-04 12:09                                           ` Thiago Galesi
2008-09-04 14:03                                             ` Alan Stern
2008-09-04 15:17                                               ` Thiago Galesi
2008-09-04 15:26                                                 ` Alan Stern
2008-07-25  8:44           ` Tomas Styblo
2008-07-25  8:54             ` Robert Hancock
2008-07-22  5:11   ` Tomas Styblo
2008-07-22  5:31     ` Robert Hancock
2008-07-22  6:11       ` Tomas Styblo
2008-07-22  8:45         ` Robert Hancock
2008-07-24  6:15           ` Alex Buell
2008-07-29 21:09           ` Alex Buell

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=20080720051326.GA5478@notebook.homenet.local \
    --to=tripie@cpan.org \
    --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