From: Igor Pylypiv <ipylypiv@google.com>
To: Niklas Cassel <cassel@kernel.org>
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
Subject: Re: [PATCH v3 5/6] ata: libata: Set ATA_QCFLAG_RTF_FILLED in fill_result_tf()
Date: Fri, 28 Jun 2024 23:08:13 +0000 [thread overview]
Message-ID: <Zn9CXRMWFczmG_P3@google.com> (raw)
In-Reply-To: <Zn8ZIxQRimgVZ2S3@ryzen.lan>
On Fri, Jun 28, 2024 at 10:12:19PM +0200, Niklas Cassel wrote:
> On Wed, Jun 26, 2024 at 11:04:10PM +0000, Igor Pylypiv wrote:
> > ATA_QCFLAG_RTF_FILLED is not specific to ahci and can be used generally
> > to check if qc->result_tf contains valid data.
> >
> > Reviewed-by: Hannes Reinecke <hare@suse.de>
> > Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> > Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
> > ---
> > drivers/ata/libahci.c | 10 ----------
> > drivers/ata/libata-core.c | 8 ++++++++
> > 2 files changed, 8 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> > index 83431aae74d8..0728d445e531 100644
> > --- a/drivers/ata/libahci.c
> > +++ b/drivers/ata/libahci.c
> > @@ -2075,13 +2075,6 @@ static void ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
> > struct ahci_port_priv *pp = qc->ap->private_data;
> > u8 *rx_fis = pp->rx_fis;
> >
> > - /*
> > - * rtf may already be filled (e.g. for successful NCQ commands).
> > - * If that is the case, we have nothing to do.
> > - */
> > - if (qc->flags & ATA_QCFLAG_RTF_FILLED)
> > - return;
> > -
> > if (pp->fbs_enabled)
> > rx_fis += qc->dev->link->pmp * AHCI_RX_FIS_SZ;
> >
> > @@ -2095,7 +2088,6 @@ static void ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
> > !(qc->flags & ATA_QCFLAG_EH)) {
> > ata_tf_from_fis(rx_fis + RX_FIS_PIO_SETUP, &qc->result_tf);
> > qc->result_tf.status = (rx_fis + RX_FIS_PIO_SETUP)[15];
> > - qc->flags |= ATA_QCFLAG_RTF_FILLED;
> > return;
> > }
> >
> > @@ -2118,12 +2110,10 @@ static void ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
> > */
> > qc->result_tf.status = fis[2];
> > qc->result_tf.error = fis[3];
> > - qc->flags |= ATA_QCFLAG_RTF_FILLED;
> > return;
> > }
> >
> > ata_tf_from_fis(rx_fis + RX_FIS_D2H_REG, &qc->result_tf);
> > - qc->flags |= ATA_QCFLAG_RTF_FILLED;
> > }
> >
> > static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask)
> > diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> > index e1bf8a19b3c8..a9fc3ec9300f 100644
> > --- a/drivers/ata/libata-core.c
> > +++ b/drivers/ata/libata-core.c
> > @@ -4801,8 +4801,16 @@ static void fill_result_tf(struct ata_queued_cmd *qc)
> > {
> > struct ata_port *ap = qc->ap;
> >
> > + /*
> > + * rtf may already be filled (e.g. for successful NCQ commands).
> > + * If that is the case, we have nothing to do.
> > + */
> > + if (qc->flags & ATA_QCFLAG_RTF_FILLED)
> > + return;
> > +
> > qc->result_tf.flags = qc->tf.flags;
>
> One functional change that I can see from this is that after this commit,
> we will no longer do: qc->result_tf.flags = qc->tf.flags;
> if ATA_QCFLAG_RTF_FILLED was set.
Nice catch, Niklas! I'll fix it in v4. Thank you!
>
> e.g. ata_scsi_set_passthru_sense_fields() and ata_gen_ata_sense()
> makes use of result_tf->flags, so we probably still want to do this.
>
>
> Perhaps keep this function as you have it and simply do:
>
> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> index 0728d445e531..fdfa7b266218 100644
> --- a/drivers/ata/libahci.c
> +++ b/drivers/ata/libahci.c
> @@ -2148,6 +2148,7 @@ static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask)
> if (qc && ata_is_ncq(qc->tf.protocol)) {
> qc->result_tf.status = status;
> qc->result_tf.error = error;
> + qc->result_tf.flags = qc->tf.flags;
> qc->flags |= ATA_QCFLAG_RTF_FILLED;
> }
> done_mask &= ~(1ULL << tag);
> @@ -2172,6 +2173,7 @@ static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask)
> fis += RX_FIS_SDB;
> qc->result_tf.status = fis[2];
> qc->result_tf.error = fis[3];
> + qc->result_tf.flags = qc->tf.flags;
> qc->flags |= ATA_QCFLAG_RTF_FILLED;
> }
> done_mask &= ~(1ULL << tag);
>
>
>
> > ap->ops->qc_fill_rtf(qc);
> > + qc->flags |= ATA_QCFLAG_RTF_FILLED;
> > }
> >
> > static void ata_verify_xfer(struct ata_queued_cmd *qc)
> > --
> > 2.45.2.803.g4e1b14247a-goog
> >
next prev parent reply other threads:[~2024-06-28 23:08 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 23:04 [PATCH v3 0/6] ATA PASS-THROUGH sense data fixes Igor Pylypiv
2024-06-26 23:04 ` [PATCH v3 1/6] ata: libata-scsi: Fix offsets for the fixed format sense data Igor Pylypiv
2024-06-27 12:08 ` Niklas Cassel
2024-06-27 21:21 ` Igor Pylypiv
2024-06-28 6:47 ` Hannes Reinecke
2024-06-28 15:49 ` Niklas Cassel
2024-06-28 18:25 ` Niklas Cassel
2024-06-28 23:17 ` Igor Pylypiv
2024-06-26 23:04 ` [PATCH v3 2/6] ata: libata-scsi: Do not overwrite valid sense data when CK_COND=1 Igor Pylypiv
2024-06-27 0:16 ` Damien Le Moal
2024-06-27 20:55 ` Igor Pylypiv
2024-06-28 3:48 ` Damien Le Moal
2024-06-27 14:14 ` Niklas Cassel
2024-06-27 15:15 ` Niklas Cassel
2024-06-27 21:54 ` Igor Pylypiv
2024-06-28 18:44 ` Niklas Cassel
2024-06-28 23:31 ` Igor Pylypiv
2024-06-29 3:09 ` Niklas Cassel
2024-07-01 20:00 ` Igor Pylypiv
2024-06-26 23:04 ` [PATCH v3 3/6] ata: libata-scsi: Remove redundant sense_buffer memsets Igor Pylypiv
2024-06-26 23:04 ` [PATCH v3 4/6] ata: libata-scsi: Do not pass ATA device id to ata_to_sense_error() Igor Pylypiv
2024-06-26 23:04 ` [PATCH v3 5/6] ata: libata: Set ATA_QCFLAG_RTF_FILLED in fill_result_tf() Igor Pylypiv
2024-06-28 20:12 ` Niklas Cassel
2024-06-28 23:08 ` Igor Pylypiv [this message]
2024-06-26 23:04 ` [PATCH v3 6/6] ata: libata-scsi: Check ATA_QCFLAG_RTF_FILLED before using result_tf Igor Pylypiv
2024-06-27 0:19 ` Damien Le Moal
2024-06-27 22:03 ` Igor Pylypiv
2024-06-27 6:16 ` Hannes Reinecke
2024-06-28 19:42 ` Niklas Cassel
2024-06-28 23:15 ` 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=Zn9CXRMWFczmG_P3@google.com \
--to=ipylypiv@google.com \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=hare@suse.de \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@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