Commit 27ea252f authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] USB Storage: Notify the SCSI layer about device resets

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
parent f3c64148
......@@ -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
***********************************************************************/
......
......@@ -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];
......
......@@ -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. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment