public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* PATCH: Call acpi_leave_sleep_state before resuming devices
       [not found]     ` <20041226194039.GC1739-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
@ 2004-12-30 21:39       ` Stefan Dösinger
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Dösinger @ 2004-12-30 21:39 UTC (permalink / raw)
  To: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: Pavel Machek, len.brown-ral2JQCrhuEAvxtiuMwx3w, Li, Shaohua,
	Carl-Daniel Hailfinger, Johan Vromans

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

Hello,

Here's again the resume-finish-split patch, this time CC-ed to Len.

This patch splits up acpi_pm_leave. It introduces acpi_pm_leave which calls 
acpi_leave_sleep_state and acpi_disable_wakeup_device before resuming the 
devices. This improves S3 resume on an Acer Travelmate 800 and on the Samsung 
P3 notebook.

Some archive references:
http://sourceforge.net/mailarchive/message.php?msg_id=9091506
http://sourceforge.net/mailarchive/message.php?msg_id=10315947

The background is that any write access to the pci config registers of some 
devices(sound card, usb 2.0 controler, and modem) cause a system lockup if 
they are called before acpi_leave_sleep_state and acpi_disable_wakeup_device 
were called. This is on an Acer Travelmate 803 Notebook, and it seems to be 
the same on other systems.

I sent the patch to the list, but it seems that nobody noticed it and I forgot 
to send it again. Here is an updated patch against 2.6.10. I can't promise 
that it doesn't break other systems. Someone should make sure that 
pm_ops->leave is set to NULL for apm. I haven't found this in the apm code 
yet.

Cheers,
Stefan Dösinger

[-- Attachment #2: resume-finish-split.patch --]
[-- Type: text/x-diff, Size: 1855 bytes --]

--- linux-2.6.10/include/linux/pm.h	2004-12-26 15:25:39.639998872 +0100
+++ include/linux/pm.h	2004-12-26 15:27:10.885127504 +0100
@@ -208,6 +208,7 @@
 	suspend_disk_method_t pm_disk_mode;
 	int (*prepare)(suspend_state_t state);
 	int (*enter)(suspend_state_t state);
+	int (*leave)(suspend_state_t state);
 	int (*finish)(suspend_state_t state);
 };
 
--- linux-2.6.10/kernel/power/main.c	2004-12-26 15:25:54.377758392 +0100
+++ kernel/power/main.c	2004-12-26 15:26:31.472119192 +0100
@@ -104,6 +104,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);
--- linux-2.6.10/drivers/acpi/sleep/main.c	2004-12-26 15:25:20.314936728 +0100
+++ drivers/acpi/sleep/main.c	2004-12-26 15:28:49.253173288 +0100
@@ -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);
 
@@ -173,6 +186,7 @@
 static struct pm_ops acpi_pm_ops = {
 	.prepare	= acpi_pm_prepare,
 	.enter		= acpi_pm_enter,
+	.leave		= acpi_pm_leave,
 	.finish		= acpi_pm_finish,
 };
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: PATCH: Call acpi_leave_sleep_state before resuming devices
@ 2005-01-10  2:19 Li, Shaohua
  0 siblings, 0 replies; 5+ messages in thread
From: Li, Shaohua @ 2005-01-10  2:19 UTC (permalink / raw)
  To: Stefan D?singer, acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: Pavel Machek, Brown, Len, Carl-Daniel Hailfinger, Johan Vromans

>
>Here's again the resume-finish-split patch, this time CC-ed to Len.
>
>This patch splits up acpi_pm_leave. It introduces acpi_pm_leave which
calls
>acpi_leave_sleep_state and acpi_disable_wakeup_device before resuming
the
>devices. This improves S3 resume on an Acer Travelmate 800 and on the
>Samsung
>P3 notebook.
>
>Some archive references:
>http://sourceforge.net/mailarchive/message.php?msg_id=9091506
>http://sourceforge.net/mailarchive/message.php?msg_id=10315947
>
>The background is that any write access to the pci config registers of
some
>devices(sound card, usb 2.0 controler, and modem) cause a system lockup
if
>they are called before acpi_leave_sleep_state and
>acpi_disable_wakeup_device
>were called. This is on an Acer Travelmate 803 Notebook, and it seems
to be
>the same on other systems.
>
>I sent the patch to the list, but it seems that nobody noticed it and I
>forgot
>to send it again. Here is an updated patch against 2.6.10. I can't
promise
>that it doesn't break other systems. Someone should make sure that
>pm_ops->leave is set to NULL for apm. I haven't found this in the apm
code
>yet.
ACPI spec also said _PTS (in 'acpi_enter_sleep_state_prep') should be
called after all devices are suspend (ACPI sepc 3.0 P401), could you
please also change the order of device suspend and
'acpi_enter_sleep_state_prep'?

Thanks,
Shaohua


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* PATCH: Call acpi_leave_sleep_state before resuming devices
@ 2005-01-25 19:36 Stefan Dösinger
       [not found] ` <200501252036.32045.stefandoesinger-RbZlAiThDcE@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Dösinger @ 2005-01-25 19:36 UTC (permalink / raw)
  To: Brown, Len; +Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andrew Morton

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

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

[-- Attachment #2: suspend.diff --]
[-- Type: text/x-diff, Size: 2994 bytes --]

--- linux-2.6.9/include/linux/pm.h	2005-01-20 14:04:54.248337144 +0100
+++ include/linux/pm.h	2005-01-20 14:03:12.000000000 +0100
@@ -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 *);
--- linux-2.6.9/kernel/power/main.c	2005-01-20 14:04:54.463304464 +0100
+++ kernel/power/main.c	2005-01-20 14:10:36.499307088 +0100
@@ -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);
--- linux-2.6.9/drivers/acpi/sleep/main.c	2005-01-20 14:04:47.382380928 +0100
+++ drivers/acpi/sleep/main.c	2005-01-20 14:12:29.234168784 +0100
@@ -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,
 };
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: Call acpi_leave_sleep_state before resuming devices
       [not found] ` <200501252036.32045.stefandoesinger-RbZlAiThDcE@public.gmane.org>
@ 2005-01-26  5:45   ` Nigel Cunningham
  2005-01-26 14:11     ` Stefan Dösinger
  0 siblings, 1 reply; 5+ messages in thread
From: Nigel Cunningham @ 2005-01-26  5:45 UTC (permalink / raw)
  To: Stefan Dösinger; +Cc: Brown, Len, ACPI List, Andrew Morton, Pavel Machek

Hi.

On Wed, 2005-01-26 at 06:36, Stefan Dösinger wrote:
> 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
-- 
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: Call acpi_leave_sleep_state before resuming devices
  2005-01-26  5:45   ` Nigel Cunningham
@ 2005-01-26 14:11     ` Stefan Dösinger
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Dösinger @ 2005-01-26 14:11 UTC (permalink / raw)
  To: ncunningham-jjFNsPSvq+iXDw4h08c5KA
  Cc: Brown, Len, ACPI List, Andrew Morton, Pavel Machek

Am Mittwoch, 26. Januar 2005 06:45 schrieb Nigel Cunningham:
> Hi.
>
> On Wed, 2005-01-26 at 06:36, Stefan Dösinger wrote:
> > 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-01-26 14:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-25 19:36 PATCH: Call acpi_leave_sleep_state before resuming devices Stefan Dösinger
     [not found] ` <200501252036.32045.stefandoesinger-RbZlAiThDcE@public.gmane.org>
2005-01-26  5:45   ` Nigel Cunningham
2005-01-26 14:11     ` Stefan Dösinger
  -- strict thread matches above, loose matches on Subject: below --
2005-01-10  2:19 Li, Shaohua
2004-12-15  4:55 Samsung P35 and S3 suspend Carl-Daniel Hailfinger
2004-12-26 14:43 ` Stefan Dösinger
     [not found]   ` <20041226194039.GC1739@elf.ucw.cz>
     [not found]     ` <20041226194039.GC1739-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2004-12-30 21:39       ` PATCH: Call acpi_leave_sleep_state before resuming devices Stefan Dösinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox