Skip to content

Commit 38dab83

Browse files
ipylypivfloatious
authored andcommitted
ata: libata-scsi: Fix offsets for the fixed format sense data
Correct the ATA PASS-THROUGH fixed format sense data offsets to conform to SPC-6 and SAT-5 specifications. Additionally, set the VALID bit to indicate that the INFORMATION field contains valid information. INFORMATION =========== SAT-5 Table 212 — "Fixed format sense data INFORMATION field for the ATA PASS-THROUGH commands" defines the following format: +------+------------+ | Byte | Field | +------+------------+ | 0 | ERROR | | 1 | STATUS | | 2 | DEVICE | | 3 | COUNT(7:0) | +------+------------+ SPC-6 Table 48 - "Fixed format sense data" specifies that the INFORMATION field starts at byte 3 in sense buffer resulting in the following offsets for the ATA PASS-THROUGH commands: +------------+-------------------------+ | Field | Offset in sense buffer | +------------+-------------------------+ | ERROR | 3 | | STATUS | 4 | | DEVICE | 5 | | COUNT(7:0) | 6 | +------------+-------------------------+ COMMAND-SPECIFIC INFORMATION ============================ SAT-5 Table 213 - "Fixed format sense data COMMAND-SPECIFIC INFORMATION field for ATA PASS-THROUGH" defines the following format: +------+-------------------+ | Byte | Field | +------+-------------------+ | 0 | FLAGS | LOG INDEX | | 1 | LBA (7:0) | | 2 | LBA (15:8) | | 3 | LBA (23:16) | +------+-------------------+ SPC-6 Table 48 - "Fixed format sense data" specifies that the COMMAND-SPECIFIC-INFORMATION field starts at byte 8 in sense buffer resulting in the following offsets for the ATA PASS-THROUGH commands: Offsets of these fields in the fixed sense format are as follows: +-------------------+-------------------------+ | Field | Offset in sense buffer | +-------------------+-------------------------+ | FLAGS | LOG INDEX | 8 | | LBA (7:0) | 9 | | LBA (15:8) | 10 | | LBA (23:16) | 11 | +-------------------+-------------------------+ Reported-by: Akshat Jain <[email protected]> Fixes: 11093cb ("libata-scsi: generate correct ATA pass-through sense") Cc: [email protected] Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Niklas Cassel <[email protected]> Signed-off-by: Igor Pylypiv <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Niklas Cassel <[email protected]>
1 parent e58e12c commit 38dab83

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

drivers/ata/libata-scsi.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,6 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
855855
struct scsi_cmnd *cmd = qc->scsicmd;
856856
struct ata_taskfile *tf = &qc->result_tf;
857857
unsigned char *sb = cmd->sense_buffer;
858-
unsigned char *desc = sb + 8;
859858
u8 sense_key, asc, ascq;
860859

861860
memset(sb, 0, SCSI_SENSE_BUFFERSIZE);
@@ -877,7 +876,8 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
877876
scsi_build_sense(cmd, 1, RECOVERED_ERROR, 0, 0x1D);
878877
}
879878

880-
if ((cmd->sense_buffer[0] & 0x7f) >= 0x72) {
879+
if ((sb[0] & 0x7f) >= 0x72) {
880+
unsigned char *desc;
881881
u8 len;
882882

883883
/* descriptor format */
@@ -916,21 +916,21 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
916916
}
917917
} else {
918918
/* Fixed sense format */
919-
desc[0] = tf->error;
920-
desc[1] = tf->status;
921-
desc[2] = tf->device;
922-
desc[3] = tf->nsect;
923-
desc[7] = 0;
919+
sb[0] |= 0x80;
920+
sb[3] = tf->error;
921+
sb[4] = tf->status;
922+
sb[5] = tf->device;
923+
sb[6] = tf->nsect;
924924
if (tf->flags & ATA_TFLAG_LBA48) {
925-
desc[8] |= 0x80;
925+
sb[8] |= 0x80;
926926
if (tf->hob_nsect)
927-
desc[8] |= 0x40;
927+
sb[8] |= 0x40;
928928
if (tf->hob_lbal || tf->hob_lbam || tf->hob_lbah)
929-
desc[8] |= 0x20;
929+
sb[8] |= 0x20;
930930
}
931-
desc[9] = tf->lbal;
932-
desc[10] = tf->lbam;
933-
desc[11] = tf->lbah;
931+
sb[9] = tf->lbal;
932+
sb[10] = tf->lbam;
933+
sb[11] = tf->lbah;
934934
}
935935
}
936936

0 commit comments

Comments
 (0)