aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 611ccde84778..de564b386052 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -972,7 +972,7 @@ static void
972sd_spinup_disk(struct scsi_disk *sdkp, char *diskname) 972sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
973{ 973{
974 unsigned char cmd[10]; 974 unsigned char cmd[10];
975 unsigned long spintime_value = 0; 975 unsigned long spintime_expire = 0;
976 int retries, spintime; 976 int retries, spintime;
977 unsigned int the_result; 977 unsigned int the_result;
978 struct scsi_sense_hdr sshdr; 978 struct scsi_sense_hdr sshdr;
@@ -1049,12 +1049,27 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
1049 scsi_execute_req(sdkp->device, cmd, DMA_NONE, 1049 scsi_execute_req(sdkp->device, cmd, DMA_NONE,
1050 NULL, 0, &sshdr, 1050 NULL, 0, &sshdr,
1051 SD_TIMEOUT, SD_MAX_RETRIES); 1051 SD_TIMEOUT, SD_MAX_RETRIES);
1052 spintime_value = jiffies; 1052 spintime_expire = jiffies + 100 * HZ;
1053 spintime = 1;
1053 } 1054 }
1054 spintime = 1;
1055 /* Wait 1 second for next try */ 1055 /* Wait 1 second for next try */
1056 msleep(1000); 1056 msleep(1000);
1057 printk("."); 1057 printk(".");
1058
1059 /*
1060 * Wait for USB flash devices with slow firmware.
1061 * Yes, this sense key/ASC combination shouldn't
1062 * occur here. It's characteristic of these devices.
1063 */
1064 } else if (sense_valid &&
1065 sshdr.sense_key == UNIT_ATTENTION &&
1066 sshdr.asc == 0x28) {
1067 if (!spintime) {
1068 spintime_expire = jiffies + 5 * HZ;
1069 spintime = 1;
1070 }
1071 /* Wait 1 second for next try */
1072 msleep(1000);
1058 } else { 1073 } else {
1059 /* we don't understand the sense code, so it's 1074 /* we don't understand the sense code, so it's
1060 * probably pointless to loop */ 1075 * probably pointless to loop */
@@ -1066,8 +1081,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
1066 break; 1081 break;
1067 } 1082 }
1068 1083
1069 } while (spintime && 1084 } while (spintime && time_before_eq(jiffies, spintime_expire));
1070 time_after(spintime_value + 100 * HZ, jiffies));
1071 1085
1072 if (spintime) { 1086 if (spintime) {
1073 if (scsi_status_is_good(the_result)) 1087 if (scsi_status_is_good(the_result))