ACPI: _PTS ordering needs fixing for pre ACPI 3.0 systems (was: Re: x86: Increase PCIBIOS_MIN_IO to 0x1500 to fix nForce 4 suspend-to-RAM)

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Robert Hancock <hancockr@...>
Cc: Linus Torvalds <torvalds@...>, Rafael J. Wysocki <rjw@...>, H. Peter Anvin <hpa@...>, Linux Kernel Mailing List <linux-kernel@...>, Greg KH <gregkh@...>, Ingo Molnar <mingo@...>, Thomas Gleixner <tglx@...>, Len Brown <lenb@...>, Andrew Morton <akpm@...>, pm list <linux-pm@...>, <linux-acpi@...>
Date: Monday, December 24, 2007 - 10:41 pm

Adding Linux-ACPI to CC.

On Tuesday 25 December 2007 00:03:25 Carlos Corbacho wrote:

The following is a hack to illustrate what I'm getting at (this is
tested on x86-64) (it's a hack since it does all the ACPI prepare bits
during set_target() for the pre ACPI 3.0 systems, rather than prepare() -
whether this can be cleaned up to move out just the _PTS() call, I don't
know).

It abuses suspend_ops->set_target(), but was the easiest way to quickly
demonstrate this (since the kerneldoc for set_target() says it will always
be executed before we suspend the devices).

-Carlos
---

 drivers/acpi/sleep/main.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)


diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 96d23b3..89e708b 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -77,8 +77,19 @@ static int acpi_pm_set_target(suspend_state_t pm_state)
 	} else {
 		printk(KERN_ERR "ACPI does not support this state: %d\n",
 			pm_state);
-		error = -ENOSYS;
+		return -ENOSYS;
 	}
+
+	/*
+	 * For ACPI 1.0 and 2.0 systems, we must run the preparation methods
+	 * before we put the devices into low power mode.
+	 */
+	if (acpi_gbl_FADT.header.revision < 3) {
+		error = acpi_sleep_prepare(acpi_target_sleep_state);
+		if (error)
+			acpi_target_sleep_state = ACPI_STATE_S0;
+	}
+
 	return error;
 }
 
@@ -91,10 +102,17 @@ static int acpi_pm_set_target(suspend_state_t pm_state)
 
 static int acpi_pm_prepare(void)
 {
-	int error = acpi_sleep_prepare(acpi_target_sleep_state);
+	int error = 0;
 
-	if (error)
-		acpi_target_sleep_state = ACPI_STATE_S0;
+	/*
+	 * For ACPI 3.0 or newer systems, we must run the preparation methods
+	 * after we put the devices into low power mode.
+	 */
+	if (acpi_gbl_FADT.header.revision >= 3) {
+		error = acpi_sleep_prepare(acpi_target_sleep_state);
+		if (error)
+			acpi_target_sleep_state = ACPI_STATE_S0;
+	}
 
 	return error;
 }
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: x86: Increase PCIBIOS_MIN_IO to 0x1500 to fix nForce 4 s..., Rafael J. Wysocki, (Tue Dec 25, 9:26 am)
Re: x86: Increase PCIBIOS_MIN_IO to 0x1500 to fix nForce 4 s..., Rafael J. Wysocki, (Tue Dec 25, 2:26 pm)
Re: x86: Increase PCIBIOS_MIN_IO to 0x1500 to fix nForce 4 s..., Rafael J. Wysocki, (Tue Dec 25, 10:11 am)
ACPI: _PTS ordering needs fixing for pre ACPI 3.0 systems (..., Carlos Corbacho, (Mon Dec 24, 10:41 pm)
Re: ACPI: _PTS ordering needs fixing for pre ACPI 3.0 syste..., Rafael J. Wysocki, (Tue Dec 25, 9:36 am)
Re: ACPI: _PTS ordering needs fixing for pre ACPI 3.0 syste..., Rafael J. Wysocki, (Tue Dec 25, 10:07 am)