scsi: NCR5380: Use DRIVER_SENSE to indicate valid sense data
authorFinn Thain <fthain@telegraphics.com.au>
Thu, 27 Sep 2018 01:17:11 +0000 (11:17 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Nov 2019 17:00:49 +0000 (18:00 +0100)
[ Upstream commit 070356513963be6196142acff56acc8359069fa1 ]

When sense data is valid, call set_driver_byte(cmd, DRIVER_SENSE).  Otherwise
some callers of scsi_execute() will ignore sense data.  Don't set DID_ERROR or
DID_RESET just because sense data is missing.

Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/NCR5380.c

index 5f26aa2875bd9f47c9479fc67d997e97de00849d..00397e89d652d8f65c9c4c414849af3d61b12442 100644 (file)
@@ -513,11 +513,12 @@ static void complete_cmd(struct Scsi_Host *instance,
 
        if (hostdata->sensing == cmd) {
                /* Autosense processing ends here */
-               if ((cmd->result & 0xff) != SAM_STAT_GOOD) {
+               if (status_byte(cmd->result) != GOOD) {
                        scsi_eh_restore_cmnd(cmd, &hostdata->ses);
-                       set_host_byte(cmd, DID_ERROR);
-               } else
+               } else {
                        scsi_eh_restore_cmnd(cmd, &hostdata->ses);
+                       set_driver_byte(cmd, DRIVER_SENSE);
+               }
                hostdata->sensing = NULL;
        }
 
@@ -2271,7 +2272,6 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
        if (list_del_cmd(&hostdata->autosense, cmd)) {
                dsprintk(NDEBUG_ABORT, instance,
                         "abort: removed %p from sense queue\n", cmd);
-               set_host_byte(cmd, DID_ERROR);
                complete_cmd(instance, cmd);
        }
 
@@ -2350,7 +2350,6 @@ static int NCR5380_host_reset(struct scsi_cmnd *cmd)
        list_for_each_entry(ncmd, &hostdata->autosense, list) {
                struct scsi_cmnd *cmd = NCR5380_to_scmd(ncmd);
 
-               set_host_byte(cmd, DID_RESET);
                cmd->scsi_done(cmd);
        }
        INIT_LIST_HEAD(&hostdata->autosense);