From: Niklas Cassel <cassel@kernel.org>
To: Igor Pylypiv <ipylypiv@google.com>
Cc: Damien Le Moal <dlemoal@kernel.org>, Tejun Heo <tj@kernel.org>,
Hannes Reinecke <hare@suse.de>,
linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org,
Akshat Jain <akshatzen@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v4 1/8] ata: libata-scsi: Fix offsets for the fixed format sense data
Date: Mon, 1 Jul 2024 23:09:57 +0200 [thread overview]
Message-ID: <ZoMbJX7VupfIPfBp@ryzen.lan> (raw)
In-Reply-To: <20240701195758.1045917-2-ipylypiv@google.com>
On Mon, Jul 01, 2024 at 07:57:51PM +0000, Igor Pylypiv wrote:
> 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 <akshatzen@google.com>
> Fixes: 11093cb1ef56 ("libata-scsi: generate correct ATA pass-through sense")
> Cc: stable@vger.kernel.org
> Reviewed-by: Hannes Reinecke <hare@suse.de>
> Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
> ---
> drivers/ata/libata-scsi.c | 26 +++++++++++++-------------
> 1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index bb4d30d377ae..a9e44ad4c2de 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -855,7 +855,6 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
> struct scsi_cmnd *cmd = qc->scsicmd;
> struct ata_taskfile *tf = &qc->result_tf;
> unsigned char *sb = cmd->sense_buffer;
> - unsigned char *desc = sb + 8;
> u8 sense_key, asc, ascq;
>
> memset(sb, 0, SCSI_SENSE_BUFFERSIZE);
> @@ -877,7 +876,8 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
> scsi_build_sense(cmd, 1, RECOVERED_ERROR, 0, 0x1D);
> }
>
> - if ((cmd->sense_buffer[0] & 0x7f) >= 0x72) {
> + if ((sb[0] & 0x7f) >= 0x72) {
> + unsigned char *desc;
> u8 len;
>
> /* descriptor format */
> @@ -916,21 +916,21 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
> }
> } else {
> /* Fixed sense format */
> - desc[0] = tf->error;
> - desc[1] = tf->status;
> - desc[2] = tf->device;
> - desc[3] = tf->nsect;
> - desc[7] = 0;
> + sb[0] |= 0x80;
> + sb[3] = tf->error;
> + sb[4] = tf->status;
> + sb[5] = tf->device;
> + sb[6] = tf->nsect;
> if (tf->flags & ATA_TFLAG_LBA48) {
> - desc[8] |= 0x80;
> + sb[8] |= 0x80;
> if (tf->hob_nsect)
> - desc[8] |= 0x40;
> + sb[8] |= 0x40;
> if (tf->hob_lbal || tf->hob_lbam || tf->hob_lbah)
> - desc[8] |= 0x20;
> + sb[8] |= 0x20;
> }
> - desc[9] = tf->lbal;
> - desc[10] = tf->lbam;
> - desc[11] = tf->lbah;
> + sb[9] = tf->lbal;
> + sb[10] = tf->lbam;
> + sb[11] = tf->lbah;
> }
> }
>
> --
> 2.45.2.803.g4e1b14247a-goog
>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
next prev parent reply other threads:[~2024-07-01 21:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 19:57 [PATCH v4 0/8] ATA PASS-THROUGH sense data fixes Igor Pylypiv
2024-07-01 19:57 ` [PATCH v4 1/8] ata: libata-scsi: Fix offsets for the fixed format sense data Igor Pylypiv
2024-07-01 21:09 ` Niklas Cassel [this message]
2024-07-01 19:57 ` [PATCH v4 2/8] ata: libata-scsi: Do not overwrite valid sense data when CK_COND=1 Igor Pylypiv
2024-07-01 21:15 ` Niklas Cassel
2024-07-01 19:57 ` [PATCH v4 3/8] ata: libata-scsi: Honour the D_SENSE bit for CK_COND=1 and no error Igor Pylypiv
2024-07-01 21:12 ` Niklas Cassel
2024-07-01 19:57 ` [PATCH v4 4/8] ata: libata-scsi: Remove redundant sense_buffer memsets Igor Pylypiv
2024-07-01 21:12 ` Niklas Cassel
2024-07-01 19:57 ` [PATCH v4 5/8] ata: libata-scsi: Do not pass ATA device id to ata_to_sense_error() Igor Pylypiv
2024-07-01 21:12 ` Niklas Cassel
2024-07-01 19:57 ` [PATCH v4 6/8] ata: libata-core: Set ATA_QCFLAG_RTF_FILLED in fill_result_tf() Igor Pylypiv
2024-07-01 21:13 ` Niklas Cassel
2024-07-01 19:57 ` [PATCH v4 7/8] ata: libata-scsi: Check ATA_QCFLAG_RTF_FILLED before using result_tf Igor Pylypiv
2024-07-01 21:13 ` Niklas Cassel
2024-07-01 19:57 ` [PATCH v4 8/8] ata: libata-scsi: Make ata_scsi_qc_complete() more readable Igor Pylypiv
2024-07-01 21:15 ` Niklas Cassel
2024-07-02 2:50 ` Igor Pylypiv
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZoMbJX7VupfIPfBp@ryzen.lan \
--to=cassel@kernel.org \
--cc=akshatzen@google.com \
--cc=dlemoal@kernel.org \
--cc=hare@suse.de \
--cc=ipylypiv@google.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).