* [PATCH 1/2] ata: libata-sata: Save all fields from sense data descriptor
@ 2025-04-11 13:25 Niklas Cassel
2025-04-11 13:25 ` [PATCH 2/2] ata: libata-sata: Simplify sense_valid fetching Niklas Cassel
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Niklas Cassel @ 2025-04-11 13:25 UTC (permalink / raw)
To: Damien Le Moal; +Cc: linux-ide, Igor Pylypiv, Niklas Cassel
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: 18bd7718b5c4 ("scsi: ata: libata: Handle completion of CDL commands using policy 0xD")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
This is basically v3 of the patch that was previously sent out here:
https://lore.kernel.org/linux-ide/20250409084546.121694-2-cassel@kernel.org/
drivers/ata/libata-sata.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
index ba300cc0a3a3..2e4463d3a356 100644
--- a/drivers/ata/libata-sata.c
+++ b/drivers/ata/libata-sata.c
@@ -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,
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] ata: libata-sata: Simplify sense_valid fetching
2025-04-11 13:25 [PATCH 1/2] ata: libata-sata: Save all fields from sense data descriptor Niklas Cassel
@ 2025-04-11 13:25 ` Niklas Cassel
2025-04-14 17:58 ` Igor Pylypiv
2025-04-15 6:51 ` Hannes Reinecke
2025-04-14 17:51 ` [PATCH 1/2] ata: libata-sata: Save all fields from sense data descriptor Igor Pylypiv
2025-04-15 6:49 ` Hannes Reinecke
2 siblings, 2 replies; 7+ messages in thread
From: Niklas Cassel @ 2025-04-11 13:25 UTC (permalink / raw)
To: Damien Le Moal; +Cc: linux-ide, Igor Pylypiv, Niklas Cassel
While the sense_valid field is 47 bits according to the specification,
we are currently only fetching 32 bits, because these are the only
bits that represent the tags (0-31), which is all we care about.
Thus, replace the existing logic with a simple get_unaligned_le32().
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
drivers/ata/libata-sata.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
index 2e4463d3a356..5ba79a1053ea 100644
--- a/drivers/ata/libata-sata.c
+++ b/drivers/ata/libata-sata.c
@@ -1529,8 +1529,7 @@ int ata_eh_get_ncq_success_sense(struct ata_link *link)
return -EIO;
}
- sense_valid = (u64)buf[8] | ((u64)buf[9] << 8) |
- ((u64)buf[10] << 16) | ((u64)buf[11] << 24);
+ sense_valid = get_unaligned_le32(&buf[8]);
extended_sense = get_unaligned_le16(&buf[14]);
aux_icc_valid = extended_sense & BIT(15);
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] ata: libata-sata: Save all fields from sense data descriptor
2025-04-11 13:25 [PATCH 1/2] ata: libata-sata: Save all fields from sense data descriptor Niklas Cassel
2025-04-11 13:25 ` [PATCH 2/2] ata: libata-sata: Simplify sense_valid fetching Niklas Cassel
@ 2025-04-14 17:51 ` Igor Pylypiv
2025-04-15 6:49 ` Hannes Reinecke
2 siblings, 0 replies; 7+ messages in thread
From: Igor Pylypiv @ 2025-04-14 17:51 UTC (permalink / raw)
To: Niklas Cassel; +Cc: Damien Le Moal, linux-ide
On Fri, Apr 11, 2025 at 03:25:23PM +0200, Niklas Cassel wrote:
> 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: 18bd7718b5c4 ("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>
Thanks,
Igor
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] ata: libata-sata: Simplify sense_valid fetching
2025-04-11 13:25 ` [PATCH 2/2] ata: libata-sata: Simplify sense_valid fetching Niklas Cassel
@ 2025-04-14 17:58 ` Igor Pylypiv
2025-04-15 6:51 ` Hannes Reinecke
1 sibling, 0 replies; 7+ messages in thread
From: Igor Pylypiv @ 2025-04-14 17:58 UTC (permalink / raw)
To: Niklas Cassel; +Cc: Damien Le Moal, linux-ide
On Fri, Apr 11, 2025 at 03:25:24PM +0200, Niklas Cassel wrote:
> While the sense_valid field is 47 bits according to the specification,
> we are currently only fetching 32 bits, because these are the only
> bits that represent the tags (0-31), which is all we care about.
>
> Thus, replace the existing logic with a simple get_unaligned_le32().
>
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> drivers/ata/libata-sata.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
> index 2e4463d3a356..5ba79a1053ea 100644
> --- a/drivers/ata/libata-sata.c
> +++ b/drivers/ata/libata-sata.c
> @@ -1529,8 +1529,7 @@ int ata_eh_get_ncq_success_sense(struct ata_link *link)
> return -EIO;
> }
>
> - sense_valid = (u64)buf[8] | ((u64)buf[9] << 8) |
> - ((u64)buf[10] << 16) | ((u64)buf[11] << 24);
> + sense_valid = get_unaligned_le32(&buf[8]);
sense_valid is u64, should we update it to u32? We can also simplify
the sense_valid bit check to use the BIT() macro.
> extended_sense = get_unaligned_le16(&buf[14]);
> aux_icc_valid = extended_sense & BIT(15);
>
> --
> 2.49.0
>
Thanks,
Igor
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] ata: libata-sata: Save all fields from sense data descriptor
2025-04-11 13:25 [PATCH 1/2] ata: libata-sata: Save all fields from sense data descriptor Niklas Cassel
2025-04-11 13:25 ` [PATCH 2/2] ata: libata-sata: Simplify sense_valid fetching Niklas Cassel
2025-04-14 17:51 ` [PATCH 1/2] ata: libata-sata: Save all fields from sense data descriptor Igor Pylypiv
@ 2025-04-15 6:49 ` Hannes Reinecke
2 siblings, 0 replies; 7+ messages in thread
From: Hannes Reinecke @ 2025-04-15 6:49 UTC (permalink / raw)
To: Niklas Cassel, Damien Le Moal; +Cc: linux-ide, Igor Pylypiv
On 4/11/25 15:25, Niklas Cassel wrote:
> 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: 18bd7718b5c4 ("scsi: ata: libata: Handle completion of CDL commands using policy 0xD")
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> This is basically v3 of the patch that was previously sent out here:
> https://lore.kernel.org/linux-ide/20250409084546.121694-2-cassel@kernel.org/
>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] ata: libata-sata: Simplify sense_valid fetching
2025-04-11 13:25 ` [PATCH 2/2] ata: libata-sata: Simplify sense_valid fetching Niklas Cassel
2025-04-14 17:58 ` Igor Pylypiv
@ 2025-04-15 6:51 ` Hannes Reinecke
2025-04-15 7:34 ` Niklas Cassel
1 sibling, 1 reply; 7+ messages in thread
From: Hannes Reinecke @ 2025-04-15 6:51 UTC (permalink / raw)
To: Niklas Cassel, Damien Le Moal; +Cc: linux-ide, Igor Pylypiv
On 4/11/25 15:25, Niklas Cassel wrote:
> While the sense_valid field is 47 bits according to the specification,
> we are currently only fetching 32 bits, because these are the only
> bits that represent the tags (0-31), which is all we care about.
>
> Thus, replace the existing logic with a simple get_unaligned_le32().
>
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> drivers/ata/libata-sata.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
> index 2e4463d3a356..5ba79a1053ea 100644
> --- a/drivers/ata/libata-sata.c
> +++ b/drivers/ata/libata-sata.c
> @@ -1529,8 +1529,7 @@ int ata_eh_get_ncq_success_sense(struct ata_link *link)
> return -EIO;
> }
>
> - sense_valid = (u64)buf[8] | ((u64)buf[9] << 8) |
> - ((u64)buf[10] << 16) | ((u64)buf[11] << 24);
> + sense_valid = get_unaligned_le32(&buf[8]);
> extended_sense = get_unaligned_le16(&buf[14]);
> aux_icc_valid = extended_sense & BIT(15);
>
Description is ever so misleading; we never fetched 47 bits to start
with. All we do is simplify the logic.
But whatever.
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] ata: libata-sata: Simplify sense_valid fetching
2025-04-15 6:51 ` Hannes Reinecke
@ 2025-04-15 7:34 ` Niklas Cassel
0 siblings, 0 replies; 7+ messages in thread
From: Niklas Cassel @ 2025-04-15 7:34 UTC (permalink / raw)
To: Hannes Reinecke; +Cc: Damien Le Moal, linux-ide, Igor Pylypiv
On Tue, Apr 15, 2025 at 08:51:46AM +0200, Hannes Reinecke wrote:
> On 4/11/25 15:25, Niklas Cassel wrote:
> > While the sense_valid field is 47 bits according to the specification,
> > we are currently only fetching 32 bits, because these are the only
> > bits that represent the tags (0-31), which is all we care about.
> >
> > Thus, replace the existing logic with a simple get_unaligned_le32().
> >
> > Signed-off-by: Niklas Cassel <cassel@kernel.org>
> > ---
> > drivers/ata/libata-sata.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
> > index 2e4463d3a356..5ba79a1053ea 100644
> > --- a/drivers/ata/libata-sata.c
> > +++ b/drivers/ata/libata-sata.c
> > @@ -1529,8 +1529,7 @@ int ata_eh_get_ncq_success_sense(struct ata_link *link)
> > return -EIO;
> > }
> > - sense_valid = (u64)buf[8] | ((u64)buf[9] << 8) |
> > - ((u64)buf[10] << 16) | ((u64)buf[11] << 24);
> > + sense_valid = get_unaligned_le32(&buf[8]);
> > extended_sense = get_unaligned_le16(&buf[14]);
> > aux_icc_valid = extended_sense & BIT(15);
>
> Description is ever so misleading; we never fetched 47 bits to start
> with. All we do is simplify the logic.
> But whatever.
IMO, that is exactly what I wrote :)
Nevertheless, I clarified the commit message in V2.
Kind regards,
Niklas
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-04-15 7:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 13:25 [PATCH 1/2] ata: libata-sata: Save all fields from sense data descriptor Niklas Cassel
2025-04-11 13:25 ` [PATCH 2/2] ata: libata-sata: Simplify sense_valid fetching Niklas Cassel
2025-04-14 17:58 ` Igor Pylypiv
2025-04-15 6:51 ` Hannes Reinecke
2025-04-15 7:34 ` Niklas Cassel
2025-04-14 17:51 ` [PATCH 1/2] ata: libata-sata: Save all fields from sense data descriptor Igor Pylypiv
2025-04-15 6:49 ` Hannes Reinecke
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).