diff options
author | Niklas Cassel <niklas.cassel@wdc.com> | 2022-09-26 20:53:07 +0000 |
---|---|---|
committer | Damien Le Moal <damien.lemoal@opensource.wdc.com> | 2022-10-17 11:31:52 +0900 |
commit | 4b89ad8e5e1233bfe642e0185e34ad5e1cefb19e (patch) | |
tree | af9636f3e669aa8a13639b5a0e6cff74cc238a8c /drivers/ata/libata-sata.c | |
parent | 461ec040677127510d018c06e64d868e5e91be75 (diff) |
ata: libata: only set sense valid flag if sense data is valid
While this shouldn't be needed if all devices that claim that they
support NCQ autosense (ata_id_has_ncq_autosense()) and/or the sense
data reporting feature (ata_id_has_sense_reporting()), actually
supported those features.
However, there might be some old ATA devices that either have these
bits set, even when they don't support those features, or they simply
return malformed data when using those features.
These devices should be quirked, but in order to try to minimize the
impact for the users of these such devices, it was suggested by Damien
Le Moal that it might be a good idea to sanity check the sense data
received from the device. If the sense data looks bogus, then the
sense data is never added to the scsi_cmnd command.
Introduce a new function, ata_scsi_sense_is_valid(), and use it in all
places where sense data is received from the device.
Suggested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Diffstat (limited to 'drivers/ata/libata-sata.c')
-rw-r--r-- | drivers/ata/libata-sata.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c index fd4dccc25389..d6bbdfe0c455 100644 --- a/drivers/ata/libata-sata.c +++ b/drivers/ata/libata-sata.c @@ -1468,10 +1468,13 @@ void ata_eh_analyze_ncq_error(struct ata_link *link) sense_key = (qc->result_tf.auxiliary >> 16) & 0xff; asc = (qc->result_tf.auxiliary >> 8) & 0xff; ascq = qc->result_tf.auxiliary & 0xff; - ata_scsi_set_sense(dev, qc->scsicmd, sense_key, asc, ascq); - ata_scsi_set_sense_information(dev, qc->scsicmd, - &qc->result_tf); - qc->flags |= ATA_QCFLAG_SENSE_VALID; + if (ata_scsi_sense_is_valid(sense_key, asc, ascq)) { + ata_scsi_set_sense(dev, qc->scsicmd, sense_key, asc, + ascq); + ata_scsi_set_sense_information(dev, qc->scsicmd, + &qc->result_tf); + qc->flags |= ATA_QCFLAG_SENSE_VALID; + } } ehc->i.err_mask &= ~AC_ERR_DEV; |