linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ahci: retry enabling AHCI a few times before spitting out WARN_ON()
@ 2008-04-23 11:52 Tejun Heo
  2008-04-24  0:24 ` Volker Armin Hemmann
  2008-04-25  4:47 ` Jeff Garzik
  0 siblings, 2 replies; 18+ messages in thread
From: Tejun Heo @ 2008-04-23 11:52 UTC (permalink / raw)
  To: Jeff Garzik, IDE/ATA development list, Peer Chen,
	Hemmann, Volker Armin

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>
---
 drivers/ata/ahci.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 739ba3f..711b5d7 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);
 }
 
 /**

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2008-04-25  4:47 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-23 11:52 [PATCH] ahci: retry enabling AHCI a few times before spitting out WARN_ON() Tejun Heo
2008-04-24  0:24 ` Volker Armin Hemmann
2008-04-24  1:34   ` Tejun Heo
2008-04-24  1:51     ` Volker Armin Hemmann
2008-04-24  2:57       ` Tejun Heo
2008-04-24  3:28         ` Volker Armin Hemmann
2008-04-24  3:36           ` Tejun Heo
2008-04-24  3:57             ` Volker Armin Hemmann
2008-04-24  4:01               ` Tejun Heo
2008-04-24  4:15                 ` Volker Armin Hemmann
2008-04-24  4:20                   ` Tejun Heo
2008-04-24  4:32                     ` Volker Armin Hemmann
2008-04-25  0:17                     ` Volker Armin Hemmann
2008-04-25  0:44                       ` Tejun Heo
2008-04-25  1:17                         ` Volker Armin Hemmann
2008-04-25  1:59                           ` Tejun Heo
2008-04-25  2:40                             ` Volker Armin Hemmann
2008-04-25  4:47 ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).