linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Jeff Garzik <jeff@garzik.org>,
	IDE/ATA development list <linux-ide@vger.kernel.org>,
	Peer Chen <pchen@nvidia.com>,
	"Hemmann, Volker Armin" <volker.armin.hemmann@tu-clausthal.de>
Subject: [PATCH] ahci: retry enabling AHCI a few times before spitting out WARN_ON()
Date: Wed, 23 Apr 2008 20:52:58 +0900	[thread overview]
Message-ID: <480F231A.7020401@gmail.com> (raw)

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);
 }
 
 /**

             reply	other threads:[~2008-04-23 11:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-23 11:52 Tejun Heo [this message]
2008-04-24  0:24 ` [PATCH] ahci: retry enabling AHCI a few times before spitting out WARN_ON() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=480F231A.7020401@gmail.com \
    --to=htejun@gmail.com \
    --cc=jeff@garzik.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=pchen@nvidia.com \
    --cc=volker.armin.hemmann@tu-clausthal.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).