This is another patch from Alan Stern.  Apparently, the SCSI layer needs
notification of certain reset events when initiated from the LLDD.

Greg, please apply.  This should apply to your tree with some fuzz, but it
will apply.  If you want me to re-generate the patch instead, just let me
know.

Matt

----- Forwarded message from Alan Stern <[EMAIL PROTECTED]> -----

Date: Wed, 17 Dec 2003 10:13:42 -0500 (EST)
From: Alan Stern <[EMAIL PROTECTED]>
Subject: PATCH: (as160)  Notify the SCSI layer about device resets
To: Matthew Dharm <[EMAIL PROTECTED]>
cc: USB Storage List <[EMAIL PROTECTED]>
X-Spam-Status: No, hits=-3.2 required=5.0
        tests=AWL,EMAIL_ATTRIBUTION,IN_REP_TO,PATCH_UNIFIED_DIFF,
              QUOTED_EMAIL_TEXT,SPAM_PHRASE_00_01,USER_AGENT_PINE
        version=2.44

Matt:

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


===== 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 < us->host->max_id; ++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
@@ -1066,6 +1066,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


----- End forwarded message -----

-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

It was a new hope.
                                        -- Dust Puppy
User Friendly, 12/25/1998

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to