Patchwork ahci: pp->active_link is not reliable when FBS is enabled

login
register
mail settings
Submitter Shane Huang
Date March 16, 2010, 10:08 a.m.
Message ID <1268734135.3515.4.camel@zm-desktop>
Download mbox | patch
Permalink /patch/47831/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Shane Huang - March 16, 2010, 10:08 a.m.
pp->active_link is not reliable when FBS is enabled.
Both PORT_SCR_ACT and PORT_CMD_ISSUE should be checked
because mixed NCQ and non-NCQ commands may be in flight.

Signed-off-by: Shane Huang <shane.huang@amd.com>
---
 drivers/ata/ahci.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jeff Garzik - March 17, 2010, 7:59 p.m.
On 03/16/2010 06:08 AM, Shane Huang wrote:
> pp->active_link is not reliable when FBS is enabled.
> Both PORT_SCR_ACT and PORT_CMD_ISSUE should be checked
> because mixed NCQ and non-NCQ commands may be in flight.
>
> Signed-off-by: Shane Huang<shane.huang@amd.com>
> ---
>   drivers/ata/ahci.c |   23 +++++++++++++++++------
>   1 files changed, 17 insertions(+), 6 deletions(-)

applied #upstream-fixes


--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 6bd930b..e009a66 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -2263,7 +2263,7 @@  static void ahci_port_intr(struct ata_port *ap)
 	struct ahci_port_priv *pp = ap->private_data;
 	struct ahci_host_priv *hpriv = ap->host->private_data;
 	int resetting = !!(ap->pflags & ATA_PFLAG_RESETTING);
-	u32 status, qc_active;
+	u32 status, qc_active = 0;
 	int rc;
 
 	status = readl(port_mmio + PORT_IRQ_STAT);
@@ -2321,11 +2321,22 @@  static void ahci_port_intr(struct ata_port *ap)
 		}
 	}
 
-	/* pp->active_link is valid iff any command is in flight */
-	if (ap->qc_active && pp->active_link->sactive)
-		qc_active = readl(port_mmio + PORT_SCR_ACT);
-	else
-		qc_active = readl(port_mmio + PORT_CMD_ISSUE);
+	/* pp->active_link is not reliable once FBS is enabled, both
+	 * PORT_SCR_ACT and PORT_CMD_ISSUE should be checked because
+	 * NCQ and non-NCQ commands may be in flight at the same time.
+	 */
+	if (pp->fbs_enabled) {
+		if (ap->qc_active) {
+			qc_active = readl(port_mmio + PORT_SCR_ACT);
+			qc_active |= readl(port_mmio + PORT_CMD_ISSUE);
+		}
+	} else {
+		/* pp->active_link is valid iff any command is in flight */
+		if (ap->qc_active && pp->active_link->sactive)
+			qc_active = readl(port_mmio + PORT_SCR_ACT);
+		else
+			qc_active = readl(port_mmio + PORT_CMD_ISSUE);
+	}
 
 	rc = ata_qc_complete_multiple(ap, qc_active);