Skip to content

Commit 399eab7

Browse files
floatiousdamien-lemoal
authored andcommitted
ata: libata-sata: Save all fields from sense data descriptor
When filling the taskfile result for a successful NCQ command, we use the SDB FIS from the FIS Receive Area, see e.g. ahci_qc_ncq_fill_rtf(). However, the SDB FIS only has fields STATUS and ERROR. For a successful NCQ command that has sense data, we will have a successful sense data descriptor, in the Sense Data for Successful NCQ Commands log. Since we have access to additional taskfile result fields, fill in these additional fields in qc->result_tf. This matches how for failing/aborted NCQ commands, we will use e.g. ahci_qc_fill_rtf() to fill in some fields, but then for the command that actually caused the NCQ error, we will use ata_eh_read_log_10h(), which provides additional fields, saving additional fields/overriding the qc->result_tf that was fetched using ahci_qc_fill_rtf(). Fixes: 18bd771 ("scsi: ata: libata: Handle completion of CDL commands using policy 0xD") Signed-off-by: Niklas Cassel <cassel@kernel.org> Reviewed-by: Igor Pylypiv <ipylypiv@google.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
1 parent 8d46a27 commit 399eab7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/ata/libata-sata.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,8 @@ int ata_eh_get_ncq_success_sense(struct ata_link *link)
15101510
unsigned int err_mask, tag;
15111511
u8 *sense, sk = 0, asc = 0, ascq = 0;
15121512
u64 sense_valid, val;
1513+
u16 extended_sense;
1514+
bool aux_icc_valid;
15131515
int ret = 0;
15141516

15151517
err_mask = ata_read_log_page(dev, ATA_LOG_SENSE_NCQ, 0, buf, 2);
@@ -1529,6 +1531,8 @@ int ata_eh_get_ncq_success_sense(struct ata_link *link)
15291531

15301532
sense_valid = (u64)buf[8] | ((u64)buf[9] << 8) |
15311533
((u64)buf[10] << 16) | ((u64)buf[11] << 24);
1534+
extended_sense = get_unaligned_le16(&buf[14]);
1535+
aux_icc_valid = extended_sense & BIT(15);
15321536

15331537
ata_qc_for_each_raw(ap, qc, tag) {
15341538
if (!(qc->flags & ATA_QCFLAG_EH) ||
@@ -1556,6 +1560,17 @@ int ata_eh_get_ncq_success_sense(struct ata_link *link)
15561560
continue;
15571561
}
15581562

1563+
qc->result_tf.nsect = sense[6];
1564+
qc->result_tf.hob_nsect = sense[7];
1565+
qc->result_tf.lbal = sense[8];
1566+
qc->result_tf.lbam = sense[9];
1567+
qc->result_tf.lbah = sense[10];
1568+
qc->result_tf.hob_lbal = sense[11];
1569+
qc->result_tf.hob_lbam = sense[12];
1570+
qc->result_tf.hob_lbah = sense[13];
1571+
if (aux_icc_valid)
1572+
qc->result_tf.auxiliary = get_unaligned_le32(&sense[16]);
1573+
15591574
/* Set sense without also setting scsicmd->result */
15601575
scsi_build_sense_buffer(dev->flags & ATA_DFLAG_D_SENSE,
15611576
qc->scsicmd->sense_buffer, sk,

0 commit comments

Comments
 (0)