linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH v4 6/8] ata: libata-core: Set ATA_QCFLAG_RTF_FILLED in fill_result_tf()
Date: Mon, 1 Jul 2024 23:13:08 +0200	[thread overview]
Message-ID: <ZoMb5HjHFxcfFJdD@ryzen.lan> (raw)
In-Reply-To: <20240701195758.1045917-7-ipylypiv@google.com>

On Mon, Jul 01, 2024 at 07:57:56PM +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     | 12 ++----------
>  drivers/ata/libata-core.c |  8 ++++++++
>  2 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> index 83431aae74d8..fdfa7b266218 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)
> @@ -2158,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);
> @@ -2182,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);
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index 74b59b78d278..949662bc50e4 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -4800,8 +4800,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;
>  	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
> 

Reviewed-by: Niklas Cassel <cassel@kernel.org>

  reply	other threads:[~2024-07-01 21:13 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
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 [this message]
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=ZoMb5HjHFxcfFJdD@ryzen.lan \
    --to=cassel@kernel.org \
    --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=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).