scsi: ata: libata: Change ata_eh_request_sense() to not set CHECK_CONDITION
authorNiklas Cassel <niklas.cassel@wdc.com>
Thu, 11 May 2023 01:13:46 +0000 (03:13 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 22 May 2023 21:05:19 +0000 (17:05 -0400)
commit24aeebbf8ea94b5c0cde06350b06e79f5beb28ae
tree02a3cc70b84212bd3c09665ab222e54291404d5e
parent91a8967ca7f4b8eabe021b1ba974a992cfca2a07
scsi: ata: libata: Change ata_eh_request_sense() to not set CHECK_CONDITION

Currently, ata_eh_request_sense() unconditionally sets the scsicmd->result
to SAM_STAT_CHECK_CONDITION.

For Command Duration Limits policy 0xD:

  The device shall complete the command without error (SAM_STAT_GOOD) with
  the additional sense code set to DATA CURRENTLY UNAVAILABLE.

It is perfectly fine to have sense data for a command that returned
completion without error.

In order to support for CDL policy 0xD, we have to remove this assumption
that having sense data means that the command failed
(SAM_STAT_CHECK_CONDITION).

Change ata_eh_request_sense() to not set SAM_STAT_CHECK_CONDITION, and
instead move the setting of SAM_STAT_CHECK_CONDITION to the single caller
that wants SAM_STAT_CHECK_CONDITION set, that way ata_eh_request_sense()
can be reused in a follow-up patch that adds support for CDL policy 0xD.

The only caller of ata_eh_request_sense() is protected by: if (!(qc->flags
& ATA_QCFLAG_SENSE_VALID)), so we can remove this duplicated check from
ata_eh_request_sense() itself.

Additionally, ata_eh_request_sense() is only called from
ata_eh_analyze_tf(), which is only called when iteratating the QCs using
ata_qc_for_each_raw(), which does not include the internal tag, so cmd can
never be NULL (all non-internal commands have qc->scsicmd set), so remove
the !cmd check as well.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Link: https://lore.kernel.org/r/20230511011356.227789-14-nks@flawful.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ata/libata-eh.c