diff options
author | Tejun Heo <htejun@gmail.com> | 2008-07-18 19:14:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-08-01 11:50:50 -0700 |
commit | c2a0d55885173608ecdd5b653969e5228b5b70c0 (patch) | |
tree | 77b40bf9d884e9d6c1692425bc3f82f765400f33 | |
parent | 97ed97fb560c5e40eb6dbed8b2ba01a1a4bc22ca (diff) |
ahci: retry enabling AHCI a few times before spitting out WARN_ON()
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@gmail.com>
Cc: Peer Chen <pchen@nvidia.com>
Cc: Volker Armin Hemmann <volker.armin.hemmann@tu-clausthal.de>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Cc: Chuck Ebbert <cebbert@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/ata/ahci.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index b1eb4e24c86..d630502472d 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -634,16 +634,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); } /** |