From: Tejun Heo Date: Wed, 23 Apr 2008 11:52:58 +0000 (+0900) Subject: ahci: retry enabling AHCI a few times before spitting out WARN_ON() X-Git-Tag: v2.6.26-rc1~1060^2~15 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15fe982e429e0e6b7466719acb6cfd9dbfe47f0c;p=linux-2.6 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 Cc: Peer Chen Cc: Volker Armin Hemmann Signed-off-by: Jeff Garzik --- diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 986e3324e3..7c4f886f1f 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -556,16 +556,27 @@ static inline void __iomem *ahci_port_base(struct ata_port *ap) 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); } /**