Skip to content

Commit d2be9ea

Browse files
committed
ata: libata-scsi: Return aborted command when missing sense and result TF
ata_gen_ata_sense() is always called for a failed qc missing sense data so that a sense key, code and code qualifier can be generated using ata_to_sense_error() from the qc status and error fields of its result task file. However, if the qc does not have its result task file filled, ata_gen_ata_sense() returns early without setting a sense key. Improve this by defaulting to returning ABORTED COMMAND without any additional sense code, since we do not know the reason for the failure. The same fix is also applied in ata_gen_passthru_sense() with the additional check that the qc failed (qc->err_mask is set). Fixes: 816be86 ("ata: libata-scsi: Check ATA_QCFLAG_RTF_FILLED before using result_tf") Cc: [email protected] Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]>
1 parent cf3fc03 commit d2be9ea

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

drivers/ata/libata-scsi.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,8 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
938938
if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) {
939939
ata_dev_dbg(dev,
940940
"missing result TF: can't generate ATA PT sense data\n");
941+
if (qc->err_mask)
942+
ata_scsi_set_sense(dev, cmd, ABORTED_COMMAND, 0, 0);
941943
return;
942944
}
943945

@@ -992,8 +994,8 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc)
992994

993995
if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) {
994996
ata_dev_dbg(dev,
995-
"missing result TF: can't generate sense data\n");
996-
return;
997+
"Missing result TF: reporting aborted command\n");
998+
goto aborted;
997999
}
9981000

9991001
/* Use ata_to_sense_error() to map status register bits
@@ -1004,13 +1006,15 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc)
10041006
ata_to_sense_error(tf->status, tf->error,
10051007
&sense_key, &asc, &ascq);
10061008
ata_scsi_set_sense(dev, cmd, sense_key, asc, ascq);
1007-
} else {
1008-
/* Could not decode error */
1009-
ata_dev_warn(dev, "could not decode error status 0x%x err_mask 0x%x\n",
1010-
tf->status, qc->err_mask);
1011-
ata_scsi_set_sense(dev, cmd, ABORTED_COMMAND, 0, 0);
10121009
return;
10131010
}
1011+
1012+
/* Could not decode error */
1013+
ata_dev_warn(dev,
1014+
"Could not decode error 0x%x, status 0x%x (err_mask=0x%x)\n",
1015+
tf->error, tf->status, qc->err_mask);
1016+
aborted:
1017+
ata_scsi_set_sense(dev, cmd, ABORTED_COMMAND, 0, 0);
10141018
}
10151019

10161020
void ata_scsi_sdev_config(struct scsi_device *sdev)

0 commit comments

Comments
 (0)