OSDN Git Service

scsi: NCR5380: Unconditionally clear ICR after do_abort()
authorFinn Thain <fthain@telegraphics.com.au>
Sat, 16 Nov 2019 03:36:57 +0000 (14:36 +1100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 20 Nov 2019 02:37:34 +0000 (21:37 -0500)
When do_abort() succeeds, the target will go to BUS FREE phase and there
will be no connected command. Therefore, that function should clear the
Initiator Command Register before returning. It already does so in case of
NCR5380_poll_politely() failure; do the same for the other error case too,
that is, NCR5380_transfer_pio() failure.

Cc: Michael Schmitz <schmitzmic@gmail.com>
Cc: Ondrej Zary <linux@zary.sk>
Link: https://lore.kernel.org/r/4277b28ee2551f884aefa85965ef3c498344f301.1573875417.git.fthain@telegraphics.com.au
Reviewed-and-tested-by: Michael Schmitz <schmitzmic@gmail.com>
Tested-by: Ondrej Zary <linux@zary.sk>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/NCR5380.c

index b040b83..43745f2 100644 (file)
@@ -1392,7 +1392,7 @@ static void do_reset(struct Scsi_Host *instance)
  * MESSAGE OUT phase and sending an ABORT message.
  * @instance: relevant scsi host instance
  *
- * Returns 0 on success, -1 on failure.
+ * Returns 0 on success, negative error code on failure.
  */
 
 static int do_abort(struct Scsi_Host *instance)
@@ -1417,7 +1417,7 @@ static int do_abort(struct Scsi_Host *instance)
 
        rc = NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ, SR_REQ, 10 * HZ);
        if (rc < 0)
-               goto timeout;
+               goto out;
 
        tmp = NCR5380_read(STATUS_REG) & PHASE_MASK;
 
@@ -1428,7 +1428,7 @@ static int do_abort(struct Scsi_Host *instance)
                              ICR_BASE | ICR_ASSERT_ATN | ICR_ASSERT_ACK);
                rc = NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ, 0, 3 * HZ);
                if (rc < 0)
-                       goto timeout;
+                       goto out;
                NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
        }
 
@@ -1437,17 +1437,17 @@ static int do_abort(struct Scsi_Host *instance)
        len = 1;
        phase = PHASE_MSGOUT;
        NCR5380_transfer_pio(instance, &phase, &len, &msgptr);
+       if (len)
+               rc = -ENXIO;
 
        /*
         * If we got here, and the command completed successfully,
         * we're about to go into bus free state.
         */
 
-       return len ? -1 : 0;
-
-timeout:
+out:
        NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-       return -1;
+       return rc;
 }
 
 /*
@@ -2279,7 +2279,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
                dsprintk(NDEBUG_ABORT, instance, "abort: cmd %p is connected\n", cmd);
                hostdata->connected = NULL;
                hostdata->dma_len = 0;
-               if (do_abort(instance)) {
+               if (do_abort(instance) < 0) {
                        set_host_byte(cmd, DID_ERROR);
                        complete_cmd(instance, cmd);
                        result = FAILED;