linux-ide.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: Thu, 24 Dec 2009 21:40:51 +0900	[thread overview]
Message-ID: <4B336153.8090206@kernel.org> (raw)
In-Reply-To: <alpine.LNX.2.00.0912242010350.1691@darkstar.example.net>

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

Hello,

On 12/24/2009 09:15 PM, fengxiangjun wrote:
> Here is it, and I hope it help. And merry xmas, ;)
> 
> ata1.00: SATA link down (SStatus 0 SControl 301)

Hmmm... SControl DET hasn't been cleared.  Does the attached patch
make any difference?

-- 
tejun

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

diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 19136a7..5bc31d2 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -173,6 +173,8 @@ static int piix_sidpr_scr_read(struct ata_link *link,
 			       unsigned int reg, u32 *val);
 static int piix_sidpr_scr_write(struct ata_link *link,
 				unsigned int reg, u32 val);
+static int piix_sidpr_hardreset(struct ata_link *link, unsigned int *class,
+				unsigned long deadline);
 #ifdef CONFIG_PM
 static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
 static int piix_pci_device_resume(struct pci_dev *pdev);
@@ -334,9 +336,9 @@ static struct ata_port_operations piix_sata_ops = {
 
 static struct ata_port_operations piix_sidpr_sata_ops = {
 	.inherits		= &piix_sata_ops,
-	.hardreset		= sata_std_hardreset,
 	.scr_read		= piix_sidpr_scr_read,
 	.scr_write		= piix_sidpr_scr_write,
+	.hardreset		= piix_sidpr_hardreset,
 };
 
 static const struct piix_map_db ich5_map_db = {
@@ -962,6 +964,18 @@ static int piix_sidpr_scr_write(struct ata_link *link,
 	return 0;
 }
 
+static int piix_sidpr_hardreset(struct ata_link *link, unsigned int *class,
+				unsigned long deadline)
+{
+	const unsigned long *timing = sata_deb_timing_hotplug;
+	bool online;
+	int rc;
+
+	/* do hardreset */
+	rc = sata_link_hardreset(link, timing, deadline, &online, NULL);
+	return online ? -EAGAIN : rc;
+}
+
 #ifdef CONFIG_PM
 static int piix_broken_suspend(void)
 {
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 22ff51b..bb19319 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3731,7 +3731,7 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
 	unsigned long interval = params[0];
 	unsigned long duration = params[1];
 	unsigned long last_jiffies, t;
-	u32 last, cur;
+	u32 last, cur, xxx;
 	int rc;
 
 	t = ata_deadline(jiffies, params[2]);
@@ -3740,7 +3740,9 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
 
 	if ((rc = sata_scr_read(link, SCR_STATUS, &cur)))
 		return rc;
+	xxx = cur;
 	cur &= 0xf;
+	ata_link_printk(link, KERN_INFO, "XXX debounce start, SStatus=%x\n", xxx);
 
 	last = cur;
 	last_jiffies = jiffies;
@@ -3749,6 +3751,7 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
 		msleep(interval);
 		if ((rc = sata_scr_read(link, SCR_STATUS, &cur)))
 			return rc;
+		xxx = cur;
 		cur &= 0xf;
 
 		/* DET stable? */
@@ -3756,8 +3759,12 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
 			if (cur == 1 && time_before(jiffies, deadline))
 				continue;
 			if (time_after(jiffies,
-				       ata_deadline(last_jiffies, duration)))
+				       ata_deadline(last_jiffies, duration))) {
+				ata_link_printk(link, KERN_INFO,
+						"XXX debounce done, SStatus=%x, DET stable for %u msecs\n",
+						xxx, jiffies_to_msecs(jiffies - last_jiffies));
 				return 0;
+			}
 			continue;
 		}
 
@@ -3791,15 +3798,30 @@ int sata_link_resume(struct ata_link *link, const unsigned long *params,
 		     unsigned long deadline)
 {
 	u32 scontrol, serror;
-	int rc;
+	int tries = 3, 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;
+		if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol)))
+			return rc;
+
+		if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
+			return rc;
+
+		/* is SControl restored correctly? */
+		if ((scontrol & 0xf0f) != 0x300)
+			break;
+
+		msleep(100);
+
+		ata_link_printk(link, KERN_WARNING,
+				"failed to restore SControl=%x%s\n",
+				scontrol, tries > 1 ? ", retrying" : "");
+	} while (--tries);
 
 	/* Some PHYs react badly if SStatus is pounded immediately
 	 * after resuming.  Delay 200ms before debouncing.

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

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <alpine.LNX.2.00.0912211855460.1689@darkstar.example.net>
     [not found] ` <4B30134C.1050609@gmail.com>
     [not found]   ` <alpine.LNX.2.00.0912220859060.1686@darkstar.example.net>
2009-12-22  1:08     ` 2.6.32.2 SATA link detect failed, 2.6.32.1 works fine 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 [this message]
2009-12-25  1:35                         ` fengxiangjun
2009-12-25 13:39                           ` Tejun Heo
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=4B336153.8090206@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).