[patch 16/29] ahci: retry enabling AHCI a few times beforespitting out WARN_ON()

From: Greg KH
Date: Wed Jul 30 2008 - 19:38:39 EST


2.6.25-stable review patch. If anyone has any objections, please let us
know.

------------------
From: Tejun Heo <htejun@xxxxxxxxx>

commit 15fe982e429e0e6b7466719acb6cfd9dbfe47f0c upstream

ahci: retry enabling AHCI a few times before spitting out WARN_ON()

Some chips need AHCI_EN set more than once to actually set it. Try a
few times before giving up and spitting out WARN_ON().

Signed-off-by: Tejun Heo <htejun@xxxxxxxxx>
Cc: Peer Chen <pchen@xxxxxxxxxx>
Cc: Volker Armin Hemmann <volker.armin.hemmann@xxxxxxxxxxxxxxx>
Signed-off-by: Jeff Garzik <jgarzik@xxxxxxxxxx>
Cc: Chuck Ebbert <cebbert@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
drivers/ata/ahci.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -634,16 +634,27 @@ static inline void __iomem *ahci_port_ba

static void ahci_enable_ahci(void __iomem *mmio)
{
+ int i;
u32 tmp;

/* turn on AHCI_EN */
tmp = readl(mmio + HOST_CTL);
- if (!(tmp & HOST_AHCI_EN)) {
+ if (tmp & HOST_AHCI_EN)
+ return;
+
+ /* Some controllers need AHCI_EN to be written multiple times.
+ * Try a few times before giving up.
+ */
+ for (i = 0; i < 5; i++) {
tmp |= HOST_AHCI_EN;
writel(tmp, mmio + HOST_CTL);
tmp = readl(mmio + HOST_CTL); /* flush && sanity check */
- WARN_ON(!(tmp & HOST_AHCI_EN));
+ if (tmp & HOST_AHCI_EN)
+ return;
+ msleep(10);
}
+
+ WARN_ON(1);
}

/**

--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/