X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fusb%2Fstorage%2Fscsiglue.c;h=f903d396927de4dc18213b3443af55bc17a85eeb;hb=5237fac468d9ad78bc9c09d26426b3425b876540;hp=1bdd36765815fb981dca458a8e76c4b7d1820366;hpb=86090fcac5e27b630656fe3d963a6b80e26dac44;p=linux-2.6.git diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 1bdd36765..f903d3969 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -159,14 +159,18 @@ static int command_abort( Scsi_Cmnd *srb ) return FAILED; } - /* Set state to ABORTING, set the ABORTING bit, and release the lock */ + /* Set state to ABORTING and set the ABORTING bit, but only if + * a device reset isn't already in progress (to avoid interfering + * with the reset). To prevent races with auto-reset, we must + * stop any ongoing USB transfers while still holding the host + * lock. */ us->sm_state = US_STATE_ABORTING; - set_bit(US_FLIDX_ABORTING, &us->flags); + if (!test_bit(US_FLIDX_RESETTING, &us->flags)) { + set_bit(US_FLIDX_ABORTING, &us->flags); + usb_stor_stop_transport(us); + } scsi_unlock(host); - /* Stop an ongoing USB transfer */ - usb_stor_stop_transport(us); - /* Wait for the aborted command to finish */ wait_for_completion(&us->notify); @@ -254,18 +258,17 @@ static int bus_reset( Scsi_Cmnd *srb ) } /* Report a driver-initiated device reset to the SCSI layer. - * Calling this for a SCSI-initiated reset is unnecessary but harmless. */ + * Calling this for a SCSI-initiated reset is unnecessary but harmless. + * The caller must own the SCSI host lock. */ 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); } /*********************************************************************** @@ -395,7 +398,7 @@ struct scsi_host_template usb_stor_host_template = { .sg_tablesize = SG_ALL, /* limit the total size of a transfer to 120 KB */ - .max_sectors = 240, + .max_sectors = 256, /* merge commands... this seems to help performance, but * periodically someone should test to see which setting is more