[SCSI] sd: pause in sd_spinup_disk for slow USB devices
This patch adds a delay tailored for USB flash devices that are slow to initialize their firmware. The symptom is a repeated Unit Attention with ASC=0x28 (Not Ready to Ready transition). The patch will wait for up to 5 seconds for such devices to become ready. Normal devices won't send the repeated Unit Attention sense key and hence won't trigger the patch. This fixes a problem with James Roberts-Thomson's USB device, and I've seen several reports of other devices exhibiting the same symptoms -- presumably they will be helped as well. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
committed by
James Bottomley
parent
e47373ec1c
commit
4451e47262
@@ -984,7 +984,7 @@ static void
|
|||||||
sd_spinup_disk(struct scsi_disk *sdkp, char *diskname,
|
sd_spinup_disk(struct scsi_disk *sdkp, char *diskname,
|
||||||
struct scsi_request *SRpnt, unsigned char *buffer) {
|
struct scsi_request *SRpnt, unsigned char *buffer) {
|
||||||
unsigned char cmd[10];
|
unsigned char cmd[10];
|
||||||
unsigned long spintime_value = 0;
|
unsigned long spintime_expire = 0;
|
||||||
int retries, spintime;
|
int retries, spintime;
|
||||||
unsigned int the_result;
|
unsigned int the_result;
|
||||||
struct scsi_sense_hdr sshdr;
|
struct scsi_sense_hdr sshdr;
|
||||||
@@ -1071,12 +1071,27 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname,
|
|||||||
scsi_wait_req(SRpnt, (void *)cmd,
|
scsi_wait_req(SRpnt, (void *)cmd,
|
||||||
(void *) buffer, 0/*512*/,
|
(void *) buffer, 0/*512*/,
|
||||||
SD_TIMEOUT, SD_MAX_RETRIES);
|
SD_TIMEOUT, SD_MAX_RETRIES);
|
||||||
spintime_value = jiffies;
|
spintime_expire = jiffies + 100 * HZ;
|
||||||
|
spintime = 1;
|
||||||
}
|
}
|
||||||
spintime = 1;
|
|
||||||
/* Wait 1 second for next try */
|
/* Wait 1 second for next try */
|
||||||
msleep(1000);
|
msleep(1000);
|
||||||
printk(".");
|
printk(".");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wait for USB flash devices with slow firmware.
|
||||||
|
* Yes, this sense key/ASC combination shouldn't
|
||||||
|
* occur here. It's characteristic of these devices.
|
||||||
|
*/
|
||||||
|
} else if (sense_valid &&
|
||||||
|
sshdr.sense_key == UNIT_ATTENTION &&
|
||||||
|
sshdr.asc == 0x28) {
|
||||||
|
if (!spintime) {
|
||||||
|
spintime_expire = jiffies + 5 * HZ;
|
||||||
|
spintime = 1;
|
||||||
|
}
|
||||||
|
/* Wait 1 second for next try */
|
||||||
|
msleep(1000);
|
||||||
} else {
|
} else {
|
||||||
/* we don't understand the sense code, so it's
|
/* we don't understand the sense code, so it's
|
||||||
* probably pointless to loop */
|
* probably pointless to loop */
|
||||||
@@ -1088,8 +1103,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (spintime &&
|
} while (spintime && time_before_eq(jiffies, spintime_expire));
|
||||||
time_after(spintime_value + 100 * HZ, jiffies));
|
|
||||||
|
|
||||||
if (spintime) {
|
if (spintime) {
|
||||||
if (scsi_status_is_good(the_result))
|
if (scsi_status_is_good(the_result))
|
||||||
|
Reference in New Issue
Block a user