]> www.infradead.org Git - users/hch/configfs.git/commit
ata: libata-scsi: Do not overwrite valid sense data when CK_COND=1
authorIgor Pylypiv <ipylypiv@google.com>
Tue, 2 Jul 2024 02:47:30 +0000 (02:47 +0000)
committerNiklas Cassel <cassel@kernel.org>
Wed, 3 Jul 2024 08:51:41 +0000 (10:51 +0200)
commit97981926224afe17ba3e22e0c2b7dd8b516ee574
tree8aaeadcb3d55d3aed9a711e71c1faf3c77d68802
parent38dab832c3f4154968f95b267a3bb789e87554b0
ata: libata-scsi: Do not overwrite valid sense data when CK_COND=1

Current ata_gen_passthru_sense() code performs two actions:
1. Generates sense data based on the ATA 'status' and ATA 'error' fields.
2. Populates "ATA Status Return sense data descriptor" / "Fixed format
   sense data" with ATA taskfile fields.

The problem is that #1 generates sense data even when a valid sense data
is already present (ATA_QCFLAG_SENSE_VALID is set). Factoring out #2 into
a separate function allows us to generate sense data only when there is
no valid sense data (ATA_QCFLAG_SENSE_VALID is not set).

As a bonus, we can now delete a FIXME comment in atapi_qc_complete()
which states that we don't want to translate taskfile registers into
sense descriptors for ATAPI.

Additionally, always set SAM_STAT_CHECK_CONDITION when CK_COND=1 because
SAT specification mandates that SATL shall return CHECK CONDITION if
the CK_COND bit is set.

The ATA PASS-THROUGH handling logic in ata_scsi_qc_complete() is hard
to read/understand. Improve the readability of the code by moving checks
into self-explanatory boolean variables.

Cc: stable@vger.kernel.org # 4.19+
Co-developed-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
Link: https://lore.kernel.org/r/20240702024735.1152293-3-ipylypiv@google.com
Signed-off-by: Niklas Cassel <cassel@kernel.org>
drivers/ata/libata-scsi.c