All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Stephan Diestelhorst <stephan.diestelhorst@amd.com>
Cc: Tejun Heo <htejun@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>,
	"linux-pm@lists.osdl.org" <linux-pm@lists.osdl.org>,
	Stephan Diestelhorst <stephan.diestelhorst@gmail.com>
Subject: Re: [PATCH] SATA / AHCI: Do not play with the link PM during suspend to RAM
Date: Sat, 28 Aug 2010 01:35:38 +0200	[thread overview]
Message-ID: <201008280135.39005.rjw@sisk.pl> (raw)
In-Reply-To: <201008262024.35551.rjw@sisk.pl>

On Thursday, August 26, 2010, Rafael J. Wysocki wrote:
> On Thursday, August 26, 2010, Stephan Diestelhorst wrote:
> > On Tuesday 24 August 2010 18:11:22 Stephan Diestelhorst wrote:
> > > On Tuesday 24 August 2010 18:07:23 Stephan Diestelhorst wrote:
> > > > On Monday 23 August 2010 14:03:40 Tejun Heo wrote:
> > > > > On 08/19/2010 06:23 PM, Stephan Diestelhorst wrote:
> > > > > > It says "max_performance", I have not touched anyhting. So it has been
> > > > > > like that all the time. Would this explain why your patch did not show
> > > > > > the debug printout?
> > > > > 
> > > > > Hmm... okay.  Yeah, if you haven't been using IPM at all, there won't
> > > > > be any debug messages but at the same time the posted patch should
> > > > > have had the same effect as Rafael's patch as IPM path isn't traveled
> > > > > at all.  Can you please check the followings?
> > > > > 
> > [...]
> > > > > * Rafael's patch actually fixes the problem.  If you haven't been
> > > > >   using IPM at all, Rafael's patch and mine should behave exactly the
> > > > >   same (ie. no IPM operation at all during suspend/resume).  It could
> > > > >   be that you're seeing a different issue.
> > > > 
> > > > That next on my list...
> > 
> > Just did the following: Rebased Rafaels patch to 2.6.35 and tried it
> > again (with added prints to make sure I am running the right one) and
> > did >10 suspend to ram / resume cycles under I/O write load. All of
> > them worked fine (for comparison: your patch resulted in RO HDD at
> > first attempt).
> > 
> > (I had some extra prints around the suspend functions changed in
> >  Rafael's patch, tried with and without, no change--works flawlessly.)
> > 
> > What do you make of this?
> 
> I think my patch actually does more than the Tejun's one.  I need to have a
> deeper look at them both.
> 
> I'm still testing the Tejun's patch on my system where I was able to reproduce
> the problem, but so far it's been working.

I reproduced the problem with the Tejun's patch applied, so I'm now quite
sure the problem is related to the suspend of controller ports (which is done
by scheduling SCSI error handling on the controller).

Anyway, below is a new version of my patch that plays a bit nicer with
the resume code.  Can you please check if it still fixes the problem for you?

Thanks,
Rafael

---
From: Rafael J. Wysocki <rjw@sisk.pl>
Subject: SATA / AHCI: Do not play with the link PM during suspend to RAM (v2)

My Acer Ferrari One occasionally loses communication with the HDD
(which in fact is an Intel SSD) during suspend to RAM.  The symptom
is that the IDENTIFY command times out during suspend and the device
is dropped by the kernel, so it is not available during resume and
the system is unuseable as a result.  The failure is not readily
reproducible, although it happens once every several suspends and
it always happens after the disk has been shut down by the SCSI
layer's suspend routine.

I was able to trace this issue down to the scheduling of error
handling for all of the controller's ports carried out by
ata_host_suspend(), which indicates quirky hardware.  However, the
AHCI driver, which is used on the affected box, doesn't really need
to do anything with the controller's ports during suspend to RAM,
because the controller is going to be put into D3 immediately by
ata_pci_device_do_suspend() and it will undergo full reset during
the subsequent resume anyway.  For this reason, make the AHCI driver
avoid calling ata_host_suspend() during suspend to RAM which works
around the problem and makes sense as a general optimization.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/ata/ahci.c        |   11 ++++++++++-
 drivers/ata/libata-core.c |   20 ++++++++++++++++++++
 include/linux/libata.h    |    1 +
 3 files changed, 31 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/ata/ahci.c
===================================================================
--- linux-2.6.orig/drivers/ata/ahci.c
+++ linux-2.6/drivers/ata/ahci.c
@@ -595,6 +595,7 @@ static int ahci_pci_device_suspend(struc
 	struct ahci_host_priv *hpriv = host->private_data;
 	void __iomem *mmio = hpriv->mmio;
 	u32 ctl;
+	int rc = 0;
 
 	if (mesg.event & PM_EVENT_SUSPEND &&
 	    hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
@@ -614,7 +615,15 @@ static int ahci_pci_device_suspend(struc
 		readl(mmio + HOST_CTL); /* flush */
 	}
 
-	return ata_pci_device_suspend(pdev, mesg);
+	if (mesg.event == PM_EVENT_SUSPEND)
+		ata_fake_suspend(host);
+	else
+		rc = ata_host_suspend(host, mesg);
+
+	if (!rc)
+		ata_pci_device_do_suspend(pdev, mesg);
+
+	return rc;
 }
 
 static int ahci_pci_device_resume(struct pci_dev *pdev)
Index: linux-2.6/include/linux/libata.h
===================================================================
--- linux-2.6.orig/include/linux/libata.h
+++ linux-2.6/include/linux/libata.h
@@ -986,6 +986,7 @@ extern bool ata_link_online(struct ata_l
 extern bool ata_link_offline(struct ata_link *link);
 #ifdef CONFIG_PM
 extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
+extern void ata_fake_suspend(struct ata_host *host);
 extern void ata_host_resume(struct ata_host *host);
 #endif
 extern int ata_ratelimit(void);
Index: linux-2.6/drivers/ata/libata-core.c
===================================================================
--- linux-2.6.orig/drivers/ata/libata-core.c
+++ linux-2.6/drivers/ata/libata-core.c
@@ -5429,6 +5429,25 @@ int ata_host_suspend(struct ata_host *ho
 	return rc;
 }
 
+void ata_fake_suspend(struct ata_host *host)
+{
+	unsigned long flags;
+	int i;
+
+	for (i = 0; i < host->n_ports; i++) {
+		struct ata_port *ap = host->ports[i];
+
+		spin_lock_irqsave(ap->lock, flags);
+
+		ap->pm_mesg = PMSG_SUSPEND;
+		ap->pflags |= ATA_PFLAG_SUSPENDED;
+
+		spin_unlock_irqrestore(ap->lock, flags);
+	}
+
+	host->dev->power.power_state = PMSG_SUSPEND;
+}
+
 /**
  *	ata_host_resume - resume host
  *	@host: host to resume
@@ -6691,6 +6710,7 @@ EXPORT_SYMBOL_GPL(ata_link_online);
 EXPORT_SYMBOL_GPL(ata_link_offline);
 #ifdef CONFIG_PM
 EXPORT_SYMBOL_GPL(ata_host_suspend);
+EXPORT_SYMBOL_GPL(ata_fake_suspend);
 EXPORT_SYMBOL_GPL(ata_host_resume);
 #endif /* CONFIG_PM */
 EXPORT_SYMBOL_GPL(ata_id_string);

  reply	other threads:[~2010-08-27 23:37 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-09 15:50 HDD not suspending properly / dead on resume Stephan Diestelhorst
2010-07-09 15:50 ` Stephan Diestelhorst
2010-07-09 21:47 ` Stephan Diestelhorst
2010-07-09 21:53   ` Rafael J. Wysocki
2010-07-09 23:04     ` Stephan Diestelhorst
2010-07-10  0:06       ` Rafael J. Wysocki
2010-07-10  6:50         ` Stephan Diestelhorst
2010-07-10 10:03           ` Tejun Heo
2010-07-10 13:45             ` Rafael J. Wysocki
2010-07-28 21:50             ` [PATCH] SATA / AHCI: Do not play with the link PM during suspend to RAM (was: Re: HDD not suspending properly / dead on resume) Rafael J. Wysocki
2010-07-30 14:18               ` [PATCH] SATA / AHCI: Do not play with the link PM during suspend to RAM Tejun Heo
2010-08-05 16:08                 ` Tejun Heo
2010-08-05 19:58                   ` Rafael J. Wysocki
2010-08-06  6:30                   ` Stephan Diestelhorst
2010-08-06  7:06                     ` Tejun Heo
2010-08-06  9:04                       ` Stephan Diestelhorst
2010-08-17  7:51                   ` Stephan Diestelhorst
2010-08-17  8:08                     ` Tejun Heo
2010-08-17  9:32                       ` Stephan Diestelhorst
2010-08-17 10:15                         ` Tejun Heo
2010-08-17 10:29                           ` Stephan Diestelhorst
2010-08-17 10:51                             ` Stephan Diestelhorst
2010-08-17 15:04                               ` Tejun Heo
2010-08-17 21:28                                 ` Stephan Diestelhorst
2010-08-18  6:12                                   ` Tejun Heo
2010-08-19 16:23                                     ` Stephan Diestelhorst
2010-08-23 12:03                                       ` Tejun Heo
2010-08-23 18:58                                         ` Rafael J. Wysocki
2010-08-24  7:37                                           ` Tejun Heo
2010-08-24 20:39                                             ` Rafael J. Wysocki
2010-08-26 23:09                                               ` Rafael J. Wysocki
2010-08-26 23:46                                                 ` Rafael J. Wysocki
2010-09-02  9:06                                                 ` Tejun Heo
2010-09-02 10:02                                                   ` [PATCH] libata: skip EH autopsy and recovery during suspend Tejun Heo
2010-09-02 14:33                                                     ` Stephan Diestelhorst
2010-09-02 14:33                                                       ` Stephan Diestelhorst
2010-09-02 20:11                                                       ` Rafael J. Wysocki
2010-09-02 20:52                                                       ` Stephan Diestelhorst
2010-09-07 11:54                                                         ` Stephan Diestelhorst
2010-09-02 20:16                                                     ` Rafael J. Wysocki
2010-09-02 20:25                                                       ` Tejun Heo
2010-09-02 20:28                                                         ` Rafael J. Wysocki
2010-09-02 20:33                                                           ` Tejun Heo
2010-09-02 21:01                                                             ` [linux-pm] " Alan Stern
2010-09-02 21:09                                                               ` Rafael J. Wysocki
2010-09-02 21:09                                                                 ` [linux-pm] " Rafael J. Wysocki
2010-09-03  8:55                                                               ` Tejun Heo
2010-09-03 14:16                                                                 ` Alan Stern
2010-09-07 12:05                                                   ` [PATCH #upstream-fixes] " Tejun Heo
2010-08-24 16:07                                         ` [PATCH] SATA / AHCI: Do not play with the link PM during suspend to RAM Stephan Diestelhorst
2010-08-24 16:11                                           ` Stephan Diestelhorst
2010-08-26 16:15                                             ` Stephan Diestelhorst
2010-08-26 18:24                                               ` Rafael J. Wysocki
2010-08-27 23:35                                                 ` Rafael J. Wysocki [this message]
2010-09-02 14:31                                                   ` Stephan Diestelhorst
2010-09-02 14:31                                                     ` Stephan Diestelhorst
2010-08-17 11:19                           ` Rafael J. Wysocki
2010-08-17 11:29                             ` Tejun Heo
2010-08-17 12:10                               ` Stephan Diestelhorst
2010-08-17 12:09                                 ` Tejun Heo
2010-08-02 20:48               ` [PATCH] SATA / AHCI: Do not play with the link PM during suspend to RAM (was: Re: HDD not suspending properly / dead on resume) Stephan Diestelhorst
2010-08-02 21:38                 ` Rafael J. Wysocki
2010-08-03  8:36                   ` Stephan Diestelhorst
2010-08-03 21:13                     ` Rafael J. Wysocki
2010-07-10 13:08           ` HDD not suspending properly / dead on resume Rafael J. Wysocki
2010-07-12 15:35 ` Maciej Rutecki
2010-08-28 20:28 [PATCH] SATA / AHCI: Do not play with the link PM during suspend to RAM Siddhartha Jain
2010-08-30 12:55 ` Tejun Heo
2010-08-30 15:25   ` Siddhartha Jain
2010-08-30 22:26     ` Siddhartha Jain
2010-08-31  0:59       ` Siddhartha Jain
2010-08-31  2:03         ` Siddhartha Jain
2010-09-01 19:47           ` Siddhartha Jain
2010-09-02 10:09             ` Tejun Heo
2010-09-02 19:56               ` Siddhartha Jain
2010-09-03  9:04                 ` Tejun Heo
2010-10-28  2:11                   ` Siddhartha Jain
2010-10-29  5:49                     ` 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=201008280135.39005.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=htejun@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.osdl.org \
    --cc=stephan.diestelhorst@amd.com \
    --cc=stephan.diestelhorst@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.