Skip to content

Commit

Permalink
ahci: retry enabling AHCI a few times before spitting out WARN_ON()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tejun Heo authored and Jeff Garzik committed Apr 25, 2008
1 parent 411cb38 commit 15fe982
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drivers/ata/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 15fe982

Please sign in to comment.