* [PATCH] Leave runtime suspended devices off at system resume
@ 2004-05-26 21:43 Todd Poynor
2004-05-28 17:03 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Todd Poynor @ 2004-05-26 21:43 UTC (permalink / raw)
To: greg, mochel, linux-kernel
Currently all devices are resumed at system resume time, including any
that were individually powered off ("at runtime") prior to the system
suspend. In certain cases it can be nice to force back on individually
suspended devices, such as the display, but hopefully this policy can be
left up to userspace power managers; the kernel should probably honor
the settings previously made by userspace/drivers. This seems
preferable to requiring a power-conscious system to re-suspend devices
after a system resume; furthermore, for certain platforms (such as
XScale PXA27X) there can be disastrous consequences of powering up
devices when the system is in a state incompatible with operation of the
device.
Suggested patch does this:
(1) At system resume, checks power_state to see if the device was
suspended prior to system suspend, and skips powering on the device if
so.
(2) Does not re-suspend an already-suspended device at system suspend
(using a different method than is currently employed, which reorders the
list, see #3).
(3) Preserves the active/off device list order despite the above changes
to suspend/resume behavior, to avoid dependency problems that tend to
occur when the list is reordered.
--- linux-2.6.6-orig/drivers/base/power/suspend.c 2004-05-10 11:22:58.000000000 -0700
+++ linux-2.6.6-prevstate/drivers/base/power/suspend.c 2004-05-25 19:00:20.803379624 -0700
@@ -39,7 +39,7 @@
{
int error = 0;
- if (dev->bus && dev->bus->suspend)
+ if (dev->bus && dev->bus->suspend && ! dev->power.power_state)
error = dev->bus->suspend(dev,state);
if (!error) {
--- linux-2.6.6-orig/drivers/base/power/resume.c 2004-05-10 11:22:58.000000000 -0700
+++ linux-2.6.6-prevstate/drivers/base/power/resume.c 2004-05-25 18:07:30.978266288 -0700
@@ -35,7 +35,10 @@
struct list_head * entry = dpm_off.next;
struct device * dev = to_device(entry);
list_del_init(entry);
- resume_device(dev);
+
+ if (! dev->power.power_state)
+ resume_device(dev);
+
list_add_tail(entry,&dpm_active);
}
}
--
Todd
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Leave runtime suspended devices off at system resume
2004-05-26 21:43 [PATCH] Leave runtime suspended devices off at system resume Todd Poynor
@ 2004-05-28 17:03 ` Greg KH
2004-05-28 17:52 ` Todd Poynor
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2004-05-28 17:03 UTC (permalink / raw)
To: Todd Poynor; +Cc: mochel, linux-kernel
On Wed, May 26, 2004 at 02:43:19PM -0700, Todd Poynor wrote:
> Currently all devices are resumed at system resume time, including any
> that were individually powered off ("at runtime") prior to the system
> suspend. In certain cases it can be nice to force back on individually
> suspended devices, such as the display, but hopefully this policy can be
> left up to userspace power managers; the kernel should probably honor
> the settings previously made by userspace/drivers. This seems
> preferable to requiring a power-conscious system to re-suspend devices
> after a system resume; furthermore, for certain platforms (such as
> XScale PXA27X) there can be disastrous consequences of powering up
> devices when the system is in a state incompatible with operation of the
> device.
>
> Suggested patch does this:
>
> (1) At system resume, checks power_state to see if the device was
> suspended prior to system suspend, and skips powering on the device if
> so.
>
> (2) Does not re-suspend an already-suspended device at system suspend
> (using a different method than is currently employed, which reorders the
> list, see #3).
>
> (3) Preserves the active/off device list order despite the above changes
> to suspend/resume behavior, to avoid dependency problems that tend to
> occur when the list is reordered.
Nice, that looks good.
Applied, thanks.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Leave runtime suspended devices off at system resume
2004-05-28 17:03 ` Greg KH
@ 2004-05-28 17:52 ` Todd Poynor
0 siblings, 0 replies; 3+ messages in thread
From: Todd Poynor @ 2004-05-28 17:52 UTC (permalink / raw)
To: Greg KH; +Cc: Todd Poynor, mochel, linux-kernel
On Fri, May 28, 2004 at 10:03:15AM -0700, Greg KH wrote:
> Nice, that looks good.
>
> Applied, thanks.
Sorry, Felipe Solana found that USB drivers tweak the power.power_state
field during suspend, so we can't rely on that field to tell what to
resume. A new patch against 2.6.6 creates a separate field for the
original value, so driver mods to the field won't break resume. I'll
also send a patch against the original patch to fix trees already
updated in a moment. Thanks -- Todd
--- linux-2.6.6-orig/drivers/base/power/suspend.c 2004-05-10 11:22:58.000000000 -0700
+++ linux-2.6.6-prevstate/drivers/base/power/suspend.c 2004-05-27 13:58:01.931014888 -0700
@@ -39,7 +39,9 @@
{
int error = 0;
- if (dev->bus && dev->bus->suspend)
+ dev->power.prev_state = dev->power.power_state;
+
+ if (dev->bus && dev->bus->suspend && ! dev->power.power_state)
error = dev->bus->suspend(dev,state);
if (!error) {
--- linux-2.6.6-orig/drivers/base/power/resume.c 2004-05-10 11:22:58.000000000 -0700
+++ linux-2.6.6-prevstate/drivers/base/power/resume.c 2004-05-27 14:35:03.373304328 -0700
@@ -35,7 +35,10 @@
struct list_head * entry = dpm_off.next;
struct device * dev = to_device(entry);
list_del_init(entry);
- resume_device(dev);
+
+ if (! dev->power.prev_state)
+ resume_device(dev);
+
list_add_tail(entry,&dpm_active);
}
}
--- linux-2.6.6-orig/include/linux/pm.h 2004-05-10 11:23:56.000000000 -0700
+++ linux-2.6.6-prevstate/include/linux/pm.h 2004-05-27 14:35:37.143170528 -0700
@@ -231,6 +231,7 @@
struct dev_pm_info {
#ifdef CONFIG_PM
u32 power_state;
+ u32 prev_state;
u8 * saved_state;
atomic_t pm_users;
struct device * pm_parent;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-05-28 17:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-26 21:43 [PATCH] Leave runtime suspended devices off at system resume Todd Poynor
2004-05-28 17:03 ` Greg KH
2004-05-28 17:52 ` Todd Poynor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®