Skip to content

Commit fa0db8e

Browse files
committed
Revert "ata: libata-scsi: Honor the D_SENSE bit for CK_COND=1 and no error"
This reverts commit 28ab976. Sense data can be in either fixed format or descriptor format. SAT-6 revision 1, "10.4.6 Control mode page", defines the D_SENSE bit: "The SATL shall support this bit as defined in SPC-5 with the following exception: if the D_ SENSE bit is set to zero (i.e., fixed format sense data), then the SATL should return fixed format sense data for ATA PASS-THROUGH commands." The libata SATL has always kept D_SENSE set to zero by default. (It is however possible to change the value using a MODE SELECT SG_IO command.) Failed ATA PASS-THROUGH commands correctly respected the D_SENSE bit, however, successful ATA PASS-THROUGH commands incorrectly returned the sense data in descriptor format (regardless of the D_SENSE bit). Commit 28ab976 ("ata: libata-scsi: Honor the D_SENSE bit for CK_COND=1 and no error") fixed this bug for successful ATA PASS-THROUGH commands. However, after commit 28ab976 ("ata: libata-scsi: Honor the D_SENSE bit for CK_COND=1 and no error"), there were bug reports that hdparm, hddtemp, and udisks were no longer working as expected. These applications incorrectly assume the returned sense data is in descriptor format, without even looking at the RESPONSE CODE field in the returned sense data (to see which format the returned sense data is in). Considering that there will be broken versions of these applications around roughly forever, we are stuck with being bug compatible with older kernels. Cc: [email protected] # 4.19+ Reported-by: Stephan Eisvogel <[email protected]> Reported-by: Christian Heusel <[email protected]> Closes: https://lore.kernel.org/linux-ide/[email protected]/ Fixes: 28ab976 ("ata: libata-scsi: Honor the D_SENSE bit for CK_COND=1 and no error") Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Niklas Cassel <[email protected]>
1 parent 89fb4df commit fa0db8e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/ata/libata-scsi.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,19 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
951951
&sense_key, &asc, &ascq);
952952
ata_scsi_set_sense(qc->dev, cmd, sense_key, asc, ascq);
953953
} else {
954-
/* ATA PASS-THROUGH INFORMATION AVAILABLE */
955-
ata_scsi_set_sense(qc->dev, cmd, RECOVERED_ERROR, 0, 0x1D);
954+
/*
955+
* ATA PASS-THROUGH INFORMATION AVAILABLE
956+
*
957+
* Note: we are supposed to call ata_scsi_set_sense(), which
958+
* respects the D_SENSE bit, instead of unconditionally
959+
* generating the sense data in descriptor format. However,
960+
* because hdparm, hddtemp, and udisks incorrectly assume sense
961+
* data in descriptor format, without even looking at the
962+
* RESPONSE CODE field in the returned sense data (to see which
963+
* format the returned sense data is in), we are stuck with
964+
* being bug compatible with older kernels.
965+
*/
966+
scsi_build_sense(cmd, 1, RECOVERED_ERROR, 0, 0x1D);
956967
}
957968
}
958969

0 commit comments

Comments
 (0)