* [PATCH] Device runtime suspend/resume fixes
@ 2004-05-26 0:11 Todd Poynor
2004-05-26 5:22 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Todd Poynor @ 2004-05-26 0:11 UTC (permalink / raw)
To: greg, mochel, linux-kernel
(1) Set device power state at runtime resume (as is done for runtime
suspend) so that a later suspend does not think the device is still
suspended (refusing to suspend it again).
(2) Move devices from the active list to the off list only when
suspending all devices as part of a system suspend, not for runtime
suspend. This matches the resume code, which only moves devices from
off to active during system resume, such that runtime resume currently
doesn't move the suspended device back to the active list. (This also
avoids reordering the device list for runtime suspends; the list is in
order of registration and suspend/resume works best that way -- granted,
more sweeping improvements in how device dependencies are accounted for
in the suspend/resume order are also needed someday.)
Runtime device suspend/resume is in some cases used frequently on
battery-powered embedded devices, to save additional power and to handle
device power state interactions with overall system power state on
certain platforms.
--- linux-2.6.6-orig/drivers/base/power/suspend.c 2004-05-10 11:22:58.000000000 -0700
+++ linux-2.6.6-pm/drivers/base/power/suspend.c 2004-05-23 00:07:51.000000000 -0700
@@ -42,13 +42,6 @@
if (dev->bus && dev->bus->suspend)
error = dev->bus->suspend(dev,state);
- if (!error) {
- list_del(&dev->power.entry);
- list_add(&dev->power.entry,&dpm_off);
- } else if (error == -EAGAIN) {
- list_del(&dev->power.entry);
- list_add(&dev->power.entry,&dpm_off_irq);
- }
return error;
}
@@ -81,12 +74,16 @@
while(!list_empty(&dpm_active)) {
struct list_head * entry = dpm_active.prev;
struct device * dev = to_device(entry);
- if ((error = suspend_device(dev,state))) {
- if (error != -EAGAIN)
- goto Error;
- else
- error = 0;
- }
+ error = suspend_device(dev,state);
+
+ if (!error) {
+ list_del(&dev->power.entry);
+ list_add(&dev->power.entry,&dpm_off);
+ } else if (error == -EAGAIN) {
+ list_del(&dev->power.entry);
+ list_add(&dev->power.entry,&dpm_off_irq);
+ } else
+ goto Error;
}
Done:
up(&dpm_sem);
--- linux-2.6.6-orig/drivers/base/power/runtime.c 2004-05-10 11:22:58.000000000 -0700
+++ linux-2.6.6-pm/drivers/base/power/runtime.c 2004-05-25 16:07:57.254838016 -0700
@@ -12,9 +12,14 @@
static void runtime_resume(struct device * dev)
{
+ int error;
+
if (!dev->power.power_state)
return;
- resume_device(dev);
+ if (!(error = resume_device(dev)))
+ dev->power.power_state = 0;
+
+ return error;
}
--
Todd
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Device runtime suspend/resume fixes
2004-05-26 0:11 [PATCH] Device runtime suspend/resume fixes Todd Poynor
@ 2004-05-26 5:22 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2004-05-26 5:22 UTC (permalink / raw)
To: Todd Poynor; +Cc: greg, mochel, linux-kernel
Todd Poynor <tpoynor@mvista.com> wrote:
>
> --- linux-2.6.6-orig/drivers/base/power/runtime.c 2004-05-10 11:22:58.000000000 -0700
> +++ linux-2.6.6-pm/drivers/base/power/runtime.c 2004-05-25 16:07:57.254838016 -0700
> @@ -12,9 +12,14 @@
>
> static void runtime_resume(struct device * dev)
> {
> + int error;
> +
> if (!dev->power.power_state)
> return;
> - resume_device(dev);
> + if (!(error = resume_device(dev)))
> + dev->power.power_state = 0;
> +
> + return error;
> }
err, this function needs a bit of work in the return value department...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-05-26 5:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-26 0:11 [PATCH] Device runtime suspend/resume fixes Todd Poynor
2004-05-26 5:22 ` Andrew Morton
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®