Skip to contentSkip to conversation

PATCH: Call acpi_leave_sleep_state before resuming devices

PATCH Stefan Dösinger 2 participants 3 messages Jan 25, 2005 – Jan 26, 2005 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Hello,
The attached patch introduces 2 new suspend/resume functions, pm_ops->setup and pm_ops->leave. These are used to correct the order of suspending/resuming devices and calling acpi functions.

Some notebooks, like my Acer Travelmate 800 and the Samsung P3 notebook have big resume problems which are solved by calling acpi_leave_sleep_state before resuming the devices. I fix this by introducing a new function, acpi_pm_leave, which is called before devices are resumed which calls acpi_leave_sleep_state and disables the wakeup devices(yes, this was the resume-finish-split patch). Shaohua also sugested that _PTS should be called after suspending devices, so I created acpi_pm_setup and moved the content of acpi_pm_prepare there.

There are now 5 suspend/resume functions:

prepare: It's called before devices are suspended
setup: Called after device suspend but before finally going to sleep
enter: Last suspend function
leave: Called before devices are beeing resumed
finish: Last function, called after device resume

Acked-by Pavel Machek
Signed-off-by Stefan Dösinger

Stefan

linux/pm.h renamed from include/linux/pm.h +5 -3
@@ -206,9 +206,11 @@
 
 struct pm_ops {
 	suspend_disk_method_t pm_disk_mode;
-	int (*prepare)(suspend_state_t state);
-	int (*enter)(suspend_state_t state);
-	int (*finish)(suspend_state_t state);
+	int (*prepare)(suspend_state_t state);		/*Called before suspending devices*/
+	int (*setup)(suspend_state_t state);		/*Called after device suspend*/
+	int (*enter)(suspend_state_t state);		/*To Finally enter the sleep state*/
+	int (*leave)(suspend_state_t state);		/*Before device wakeup*/
+	int (*finish)(suspend_state_t state);		/*After device wakeup*/
 };
 
 extern void pm_set_ops(struct pm_ops *);
power/main.c renamed from kernel/power/main.c +8 -0
@@ -67,6 +67,12 @@
 
 	if ((error = device_suspend(state)))
 		goto Finish;
+
+	if (pm_ops->setup) {
+		if ((error = pm_ops->setup(state)))
+			goto Finish;
+	}
+
 	return 0;
  Finish:
 	if (pm_ops->finish)
@@ -104,6 +110,8 @@
 
 static void suspend_finish(suspend_state_t state)
 {
+	if (pm_ops && pm_ops->leave)
+		pm_ops->leave(state);
 	device_resume();
 	if (pm_ops && pm_ops->finish)
 		pm_ops->finish(state);
acpi/sleep/main.c renamed from drivers/acpi/sleep/main.c +21 -6
@@ -36,7 +36,7 @@
 static int init_8259A_after_S1;
 
 /**
- *	acpi_pm_prepare - Do preliminary suspend work.
+ *	acpi_pm_setup - Do preliminary suspend work.
  *	@pm_state:		suspend state we're entering.
  *
  *	Make sure we support the state. If we do, and we need it, set the
@@ -44,7 +44,7 @@
  *	wakeup code to the waking vector. 
  */
 
-static int acpi_pm_prepare(suspend_state_t pm_state)
+static int acpi_pm_setup(suspend_state_t pm_state)
 {
 	u32 acpi_state = acpi_suspend_states[pm_state];
 
@@ -130,7 +130,23 @@
 	return ACPI_SUCCESS(status) ? 0 : -EFAULT;
 }
 
+/**
+ *	acpi_pm_leave - Make system ready to resume devices.
+ *	@pm_state:		State we're coming out of.
+ *
+ *	This is called after we wake back up and before device
+ *	resume methods are called.
+ */
 
+static int acpi_pm_leave(suspend_state_t pm_state)
+{
+	u32 acpi_state = acpi_suspend_states[pm_state];
+
+	acpi_leave_sleep_state(acpi_state);
+	acpi_disable_wakeup_device(acpi_state);
+
+	return 0;
+}
 /**
  *	acpi_pm_finish - Finish up suspend sequence.
  *	@pm_state:		State we're coming out of.
@@ -143,9 +159,6 @@
 {
 	u32 acpi_state = acpi_suspend_states[pm_state];
 
-	acpi_leave_sleep_state(acpi_state);
-	acpi_disable_wakeup_device(acpi_state);
-
 	/* reset firmware waking vector */
 	acpi_set_firmware_waking_vector((acpi_physical_address) 0);
 
@@ -171,8 +184,10 @@
 }
 
 static struct pm_ops acpi_pm_ops = {
-	.prepare	= acpi_pm_prepare,
+	.prepare	= NULL,
+	.setup		= acpi_pm_setup,
 	.enter		= acpi_pm_enter,
+	.leave		= acpi_pm_leave,
 	.finish		= acpi_pm_finish,
 };
 
#2 lore raw
In reply to a message not in the archive

Hi.

Quoted 4 lines · Stefan Dösinger

Hello,
The attached patch introduces 2 new suspend/resume functions, pm_ops->setup and pm_ops->leave. These are used to correct the order of suspending/resuming devices and calling acpi functions.

Just so I have it clear, this is a separate patch to Li Shaohua's set, isn't it? Sorry if it's a lame question - too many patches floating around.

Regards,

Nigel

Signature · 13 lines
Nigel Cunningham
Software Engineer
Cyclades Corporation

http://cyclades.com



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
#3 lore raw

Am Mittwoch, 26. Januar 2005 06:45 schrieb Nigel Cunningham:

Quoted 11 lines

Hi.

Quoted 4 lines · Stefan Dösinger

Hello,
The attached patch introduces 2 new suspend/resume functions, pm_ops->setup and pm_ops->leave. These are used to correct the order of suspending/resuming devices and calling acpi functions.

Just so I have it clear, this is a separate patch to Li Shaohua's set, isn't it? Sorry if it's a lame question - too many patches floating around.

Yes, this is a seperate patch. I just had a look at Lo Shaohua's patches and they do not cover this one.

Stefan

-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl