--- orig/drivers/scsi/scsi_error.c Wed Sep 25 22:54:27 2002 +++ linux-rpc/drivers/scsi/scsi_error.c Wed Sep 25 22:53:44 2002 @@ -1395,14 +1395,29 @@ * completed. * * Returns: SUCCESS or FAILED + * + * Note: If the TEST UNIT READY command successfully executes, + * but returns some form of "device not ready", we wait + * a while, and retry 3 times. The device could be still + * re-initialising. */ STATIC int scsi_eh_test_and_retry(Scsi_Cmnd *SCpnt, Scsi_Cmnd **done) { - int rtn; + int rtn, tries = 3; + + do { + rtn = scsi_test_unit_ready(SCpnt); + if (rtn != SUCCESS) + return rtn; + + if (scsi_unit_is_ready(SCpnt)) + break; + + if (tries-- == 0) + return FAILED; - rtn = scsi_test_unit_ready(SCpnt); - if (rtn != SUCCESS || !scsi_unit_is_ready(SCpnt)) - return FAILED; + scsi_sleep(5 * HZ); + } while (1); rtn = scsi_eh_retry_command(SCpnt); if (rtn == SUCCESS) { @@ -1788,8 +1803,20 @@ rtn = scsi_eh_restart_device(SDpnt, done); - if (rtn != SUCCESS) + if (rtn != SUCCESS) { + SCpnt = scsi_eh_find_failed_command(SDpnt); + + /* + * This device failed again. Since a bus + * reset freed it up, chances are we've + * hit the same problem, so try the same + * solution. We also need to ensure that + * the SCSI bus is in the BUS FREE state + * so we can try to talk to other devices. + */ + scsi_try_bus_reset(SCpnt); scsi_eh_set_device_offline(SDpnt, done, "not ready or command retry failed after bus reset"); + } } } } @@ -1880,8 +1907,20 @@ for (SDloop = host->host_queue; SDloop; SDloop = SDloop->next) { rtn = scsi_eh_restart_device(SDloop, done); - if (rtn != SUCCESS) + if (rtn != SUCCESS) { + SCpnt = scsi_eh_find_failed_command(SDloop); + + /* + * This device failed again. Since a host + * reset freed it up, chances are we've + * hit the same problem, so try the same + * solution. We also need to ensure that + * the SCSI bus is in the BUS FREE state + * so we can try to talk to other devices. + */ + scsi_try_host_reset(SCpnt); scsi_eh_set_device_offline(SDloop, done, "not ready or command retry failed after host reset"); + } } } }