]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ata: libata-core: Set ATA_QCFLAG_RTF_FILLED in fill_result_tf()
authorIgor Pylypiv <ipylypiv@google.com>
Tue, 2 Jul 2024 02:47:34 +0000 (02:47 +0000)
committerNiklas Cassel <cassel@kernel.org>
Wed, 3 Jul 2024 08:51:41 +0000 (10:51 +0200)
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>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
Link: https://lore.kernel.org/r/20240702024735.1152293-7-ipylypiv@google.com
Signed-off-by: Niklas Cassel <cassel@kernel.org>
drivers/ata/libahci.c
drivers/ata/libata-core.c

index 83431aae74d8b1648b59e2a7e4d3a61b82e642b4..fdfa7b2662180b6593c7133f516edd0c5a8a048f 100644 (file)
@@ -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);
index 4f35aab81a0a38c7d25ffcafefe0dd9aa4135d22..45e3acb466c32a761d0500108f3a8c1fae511492 100644 (file)
@@ -4794,8 +4794,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)