Commit ec4c6d1e authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull ata fix from Damien Le Moal:

 - Fix how sense data from the sense data for successfull NCQ commands
   log page is used to fully initialize the result_tf of a completed
   command, so that the sense data returned to the scsi layer is fully
   initialized with all the device provided information (from Niklas)

* tag 'ata-6.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux:
  ata: libata-sata: Save all fields from sense data descriptor
parents 096384de 399eab7f
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1510,6 +1510,8 @@ int ata_eh_get_ncq_success_sense(struct ata_link *link)
	unsigned int err_mask, tag;
	u8 *sense, sk = 0, asc = 0, ascq = 0;
	u64 sense_valid, val;
	u16 extended_sense;
	bool aux_icc_valid;
	int ret = 0;

	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)

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

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

		qc->result_tf.nsect = sense[6];
		qc->result_tf.hob_nsect = sense[7];
		qc->result_tf.lbal = sense[8];
		qc->result_tf.lbam = sense[9];
		qc->result_tf.lbah = sense[10];
		qc->result_tf.hob_lbal = sense[11];
		qc->result_tf.hob_lbam = sense[12];
		qc->result_tf.hob_lbah = sense[13];
		if (aux_icc_valid)
			qc->result_tf.auxiliary = get_unaligned_le32(&sense[16]);

		/* Set sense without also setting scsicmd->result */
		scsi_build_sense_buffer(dev->flags & ATA_DFLAG_D_SENSE,
					qc->scsicmd->sense_buffer, sk,