[PATCH] SATA / AHCI: Do not play with the link PM during suspend to RAM (was: Re: HDD not suspending properly / dead on resume)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

On Saturday, July 10, 2010, Tejun Heo wrote:

That didn't help, but the appended patch fixes the problem for me.

Thanks,
Rafael

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

My Acer Ferrari One occasionally loses communication with the disk
(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 track this issue down to the link PM manipulations
carried out by ata_host_suspend(), which probably means that the
SSD's firmware is not implemented correctly.  However, the AHCI
driver, which is used on the affected box, doesn't really need to do
anything with the link PM during suspend to RAM, because the whole
controller is going to be put into D3 by ata_pci_device_do_suspend()
immediately 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 fixes the problem and
makes sense as a general optimization.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/ata/ahci.c |   11 ++++++++++-
 1 file changed, 10 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)
+		pdev->dev.power.power_state = mesg;
+	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)
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
HDD not suspending properly / dead on resume, Stephan Diestelhorst, (Fri Jul 9, 8:50 am)
Re: HDD not suspending properly / dead on resume, Stephan Diestelhorst, (Fri Jul 9, 2:47 pm)
Re: HDD not suspending properly / dead on resume, Rafael J. Wysocki, (Fri Jul 9, 2:53 pm)
Re: HDD not suspending properly / dead on resume, Stephan Diestelhorst, (Fri Jul 9, 4:04 pm)
Re: HDD not suspending properly / dead on resume, Rafael J. Wysocki, (Fri Jul 9, 5:06 pm)
Re: HDD not suspending properly / dead on resume, Stephan Diestelhorst, (Fri Jul 9, 11:50 pm)
Re: HDD not suspending properly / dead on resume, Tejun Heo, (Sat Jul 10, 3:03 am)
Re: HDD not suspending properly / dead on resume, Rafael J. Wysocki, (Sat Jul 10, 6:08 am)
Re: HDD not suspending properly / dead on resume, Rafael J. Wysocki, (Sat Jul 10, 6:45 am)
Re: HDD not suspending properly / dead on resume, Maciej Rutecki, (Mon Jul 12, 8:35 am)
[PATCH] SATA / AHCI: Do not play with the link PM during s ..., Rafael J. Wysocki, (Wed Jul 28, 2:50 pm)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Mon Aug 2, 1:48 pm)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Tue Aug 3, 1:36 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Rafael J. Wysocki, (Thu Aug 5, 12:58 pm)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Thu Aug 5, 11:30 pm)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Fri Aug 6, 2:04 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Tue Aug 17, 12:51 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Tue Aug 17, 2:32 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Tue Aug 17, 3:29 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Tue Aug 17, 3:51 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Rafael J. Wysocki, (Tue Aug 17, 4:19 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Tue Aug 17, 5:10 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Tue Aug 17, 2:28 pm)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Thu Aug 19, 9:23 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Rafael J. Wysocki, (Mon Aug 23, 11:58 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Tue Aug 24, 9:07 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Tue Aug 24, 9:11 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Rafael J. Wysocki, (Tue Aug 24, 1:39 pm)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Thu Aug 26, 9:15 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Rafael J. Wysocki, (Thu Aug 26, 11:24 am)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Rafael J. Wysocki, (Thu Aug 26, 4:09 pm)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Rafael J. Wysocki, (Thu Aug 26, 4:46 pm)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Rafael J. Wysocki, (Fri Aug 27, 4:35 pm)
Re: [PATCH] SATA / AHCI: Do not play with the link PM duri ..., Stephan Diestelhorst, (Thu Sep 2, 7:31 am)
Re: [PATCH] libata: skip EH autopsy and recovery during su ..., Stephan Diestelhorst, (Thu Sep 2, 7:33 am)
Re: [PATCH] libata: skip EH autopsy and recovery during su ..., Stephan Diestelhorst, (Thu Sep 2, 1:52 pm)
Re: [PATCH] libata: skip EH autopsy and recovery during su ..., Stephan Diestelhorst, (Tue Sep 7, 4:54 am)