]> git.hungrycats.org Git - linux/commitdiff
[PATCH] USB Storage: Notify the SCSI layer about device resets
authorAlan Stern <stern@rowland.harvard.edu>
Tue, 20 Jan 2004 08:02:47 +0000 (00:02 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Tue, 20 Jan 2004 08:02:47 +0000 (00:02 -0800)
According to James Bottomley, we need to notify the SCSI midlayer whenever
we issue a driver-initiated device reset.  That can happen in several
places, most notably following a transport error.  This patch adds
code to the reset routine to take care of it.  (Notifying about resets
requested by the midlayer itself is unnecessary but harmless.)

Alan Stern

On 15 Dec 2003, James Bottomley wrote:

> It looks like the driver sent a reset to the device on its own without
> reporting it to the mid-layer.
>
> There's an expecting_cc_ua flag in the scsi_device.  It gets set on
> error recovery actions, or if the device does something to detect or
> trigger a reset (that's the scsi_report_device_reset() and
> scsi_report_bus_reset() API's).
>
> James

drivers/usb/storage/scsiglue.c
drivers/usb/storage/scsiglue.h
drivers/usb/storage/transport.c

index 1a300b176a23daecc92518117abf470b95a4578c..72ec6987010290ad1feb5e4538bbf194344c5775 100644 (file)
@@ -229,6 +229,21 @@ static int bus_reset( Scsi_Cmnd *srb )
        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 < us->host->max_id; ++i)
+                       scsi_report_device_reset(us->host, 0, i);
+       }
+       scsi_unlock(us->host);
+}
+
 /***********************************************************************
  * /proc/scsi/ functions
  ***********************************************************************/
index ed2313530df7d3764dc9d744eb0e4f38c4877fac..7bd4eaa898a8b48f059255a36fd09db6f0fefdae 100644 (file)
@@ -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];
index b081de72c7cb0f1488f36804a38a5b2116c59bb0..0ce9c472202891ad3b9363fc5a097ba6763acd24 100644 (file)
@@ -1067,6 +1067,9 @@ static int usb_stor_reset_common(struct us_data *us,
        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
         *  following a powerup or USB attach event. */