scsi: ncr5380: Improve target selection robustness
authorFinn Thain <fthain@telegraphics.com.au>
Sun, 15 Jan 2017 23:50:57 +0000 (18:50 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 1 Feb 2017 02:38:58 +0000 (21:38 -0500)
Handle timeout or bus phase change errors that could occur when sending
the IDENTIFY message.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Tested-by: Ondrej Zary <linux@rainbow-software.org>
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/NCR5380.c

index 518d101..acc3344 100644 (file)
@@ -1165,8 +1165,16 @@ static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *instance,
        data = tmp;
        phase = PHASE_MSGOUT;
        NCR5380_transfer_pio(instance, &phase, &len, &data);
+       if (len) {
+               NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
+               cmd->result = DID_ERROR << 16;
+               complete_cmd(instance, cmd);
+               dsprintk(NDEBUG_SELECTION, instance, "IDENTIFY message transfer failed\n");
+               cmd = NULL;
+               goto out;
+       }
+
        dsprintk(NDEBUG_SELECTION, instance, "nexus established.\n");
-       /* XXX need to handle errors here */
 
        hostdata->connected = cmd;
        hostdata->busy[cmd->device->id] |= 1 << cmd->device->lun;