linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: fengxiangjun <fengxiangjun@neusoft.com>
Cc: Robert Hancock <hancockrwd@gmail.com>,
	linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org
Subject: Re: 2.6.32.2 SATA link detect failed, 2.6.32.1 works fine
Date: Fri, 25 Dec 2009 22:39:35 +0900	[thread overview]
Message-ID: <4B34C097.1000206@kernel.org> (raw)
In-Reply-To: <alpine.LNX.2.00.0912250931510.1680@darkstar.example.net>

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

On 12/25/2009 10:35 AM, fengxiangjun wrote:
>> Hmmm... SControl DET hasn't been cleared.  Does the attached patch
>> make any difference?
> 
> After 5 successful reboots, I think the patch does fix the problem.
> Thank you very much.

Can you please try this one?  Retry logic was wrong in the original
patch.  With this patch, you should see one "link resume succeeded
after %d retries" message when the original kernel would have failed
probe.  Can you please test this patch and post boot log with such
message?

Thanks.

-- 
tejun

[-- Attachment #2: retry-link-resume.patch --]
[-- Type: text/x-patch, Size: 2071 bytes --]

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 22ff51b..40940dd 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3790,21 +3790,40 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
 int sata_link_resume(struct ata_link *link, const unsigned long *params,
 		     unsigned long deadline)
 {
+	int tries = ATA_LINK_RESUME_TRIES;
 	u32 scontrol, serror;
 	int rc;
 
 	if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
 		return rc;
 
-	scontrol = (scontrol & 0x0f0) | 0x300;
+	do {
+		scontrol = (scontrol & 0x0f0) | 0x300;
+		if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol)))
+			return rc;
+		/*
+		 * Some PHYs react badly if SStatus is pounded
+		 * immediately after resuming.  Delay 200ms before
+		 * debouncing.
+		 */
+		msleep(200);
 
-	if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol)))
-		return rc;
+		/* is SControl restored correctly? */
+		if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
+			return rc;
+	} while ((scontrol & 0xf0f) != 0x300 && --tries);
 
-	/* Some PHYs react badly if SStatus is pounded immediately
-	 * after resuming.  Delay 200ms before debouncing.
-	 */
-	msleep(200);
+	if ((scontrol & 0xf0f) != 0x300) {
+		ata_link_printk(link, KERN_ERR,
+				"failed to resume link (SControl %X)\n",
+				scontrol);
+		return 0;
+	}
+
+	if (tries < ATA_LINK_RESUME_TRIES)
+		ata_link_printk(link, KERN_WARNING,
+				"link resume succeeded after %d retries\n",
+				ATA_LINK_RESUME_TRIES - tries);
 
 	if ((rc = sata_link_debounce(link, params, deadline)))
 		return rc;
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 6a9c4dd..7311225 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -354,6 +354,9 @@ enum {
 	/* max tries if error condition is still set after ->error_handler */
 	ATA_EH_MAX_TRIES	= 5,
 
+	/* sometimes resuming a link requires several retries */
+	ATA_LINK_RESUME_TRIES	= 5,
+
 	/* how hard are we gonna try to probe/recover devices */
 	ATA_PROBE_MAX_TRIES	= 3,
 	ATA_EH_DEV_TRIES	= 3,

  reply	other threads:[~2009-12-25 13:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-21 11:12 2.6.32.2 SATA link detect failed, 2.6.32.1 works fine fengxiangjun
2009-12-22  0:31 ` Robert Hancock
2009-12-22  1:02   ` fengxiangjun
2009-12-22  1:08     ` Robert Hancock
2009-12-22  2:02       ` fengxiangjun
2009-12-23  8:55         ` Tejun Heo
2009-12-23  9:29           ` fengxiangjun
2009-12-23 12:02             ` Bjarke Istrup Pedersen
2009-12-24  1:21               ` fengxiangjun
2009-12-24  7:33             ` Tejun Heo
2009-12-24  7:45               ` fengxiangjun
2009-12-24  7:51                 ` Tejun Heo
2009-12-24  7:58                   ` fengxiangjun
2009-12-24 12:15                     ` fengxiangjun
2009-12-24 12:40                       ` Tejun Heo
2009-12-25  1:35                         ` fengxiangjun
2009-12-25 13:39                           ` Tejun Heo [this message]
2009-12-26  1:25                             ` fengxiangjun
2009-12-28 10:02                               ` Tejun Heo
2009-12-29  1:08                                 ` fengxiangjun

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=4B34C097.1000206@kernel.org \
    --to=tj@kernel.org \
    --cc=fengxiangjun@neusoft.com \
    --cc=hancockrwd@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).