* [PATCH] swsusp: allow drivers to determine between write-resume and actual wakeup
@ 2006-06-05 9:11 Tejun Heo
2006-06-05 9:23 ` Pavel Machek
0 siblings, 1 reply; 6+ messages in thread
From: Tejun Heo @ 2006-06-05 9:11 UTC (permalink / raw)
To: pavel, Jeff Garzik, linux-kernel, linux-ide
Currently, there is no way to tell whether a device is resuming to
write swsusp image or waking up from actual software suspend. FREEZE
and SUSPEND are different operations for some devices (e.g. disks
don't spin down for FREEZE) and the resume operation for each is also
different.
This patch makes swsusp change device power state from PMSG_FREEZE to
PMSG_SUSPEND on resume from software suspend. A driver can determine
whether it's getting thawed or resuming by looking at device power
state - if FREEZE, it's getting thawed to write image; if SUSPEND,
resuming from software suspend. This patch doesn't affect drivers
which don't update device power state. Only drivers which set power
state to FREEZE after freezing are affected.
Note that the behavior introduced by this patch is more correct in
that, on resume, the last power operation done on those devices are
PMSG_SUSPEND, not PMSG_FREEZE.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
Hello, Pavel.
I'm currently working on libata suspend/resume support. libata needs
to take different actions for getting thawed and resuming, so this
patch. If you have any better idea, please let me know.
Also, another piece of information libata can use is whether the
current power operation is due to runtime (per-device) PM request or
system PM event. In ATA, many EH operations are bus-wide and it would
be better/simpler to perform PM bus-wide if possible. I think this
can be done by adding a function to query global PM state.
Thanks.
drivers/base/power/resume.c | 25 +++++++++++++++++++++++++
include/linux/pm.h | 1 +
kernel/power/swsusp.c | 4 ++++
3 files changed, 30 insertions(+), 0 deletions(-)
4f2edc42e5b0d628ba164e4f438a7255672a82a2
diff --git a/drivers/base/power/resume.c b/drivers/base/power/resume.c
index 317edbf..3e08c58 100644
--- a/drivers/base/power/resume.c
+++ b/drivers/base/power/resume.c
@@ -122,3 +122,28 @@ void device_power_up(void)
EXPORT_SYMBOL_GPL(device_power_up);
+/**
+ * device_prep_swsusp_resume - Prep for resume from swsusp
+ *
+ * Change power state of devices from PMSG_FREEZE to PMSG_SUSPEND
+ * in preparation for resume from swsusp. This allows drivers to
+ * tell whether they are resuming from frozen state to write
+ * image or from actual swsusp.
+ */
+
+void device_prep_swsusp_resume(void)
+{
+ struct device *dev;
+
+ list_for_each_entry(dev, &dpm_off_irq, power.entry)
+ if (dev->power.power_state.event == PM_EVENT_FREEZE)
+ dev->power.power_state = PMSG_SUSPEND;
+
+ down(&dpm_sem);
+ down(&dpm_list_sem);
+ list_for_each_entry(dev, &dpm_off, power.entry)
+ if (dev->power.power_state.event == PM_EVENT_FREEZE)
+ dev->power.power_state = PMSG_SUSPEND;
+ up(&dpm_list_sem);
+ up(&dpm_sem);
+}
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 66be589..3e1d79c 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -184,6 +184,7 @@ #endif
extern void device_pm_set_parent(struct device * dev, struct device * parent);
extern int device_power_down(pm_message_t state);
+extern void device_prep_swsusp_resume(void);
extern void device_power_up(void);
extern void device_resume(void);
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index c4016cb..a534f84 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -238,6 +238,10 @@ int swsusp_suspend(void)
printk(KERN_ERR "Error %d suspending\n", error);
/* Restore control flow magically appears here */
restore_processor_state();
+
+ if (!in_suspend)
+ device_prep_swsusp_resume();
+
Restore_highmem:
restore_highmem();
device_power_up();
--
1.3.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] swsusp: allow drivers to determine between write-resume and actual wakeup
2006-06-05 9:11 [PATCH] swsusp: allow drivers to determine between write-resume and actual wakeup Tejun Heo
@ 2006-06-05 9:23 ` Pavel Machek
2006-06-05 11:50 ` Tejun Heo
0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2006-06-05 9:23 UTC (permalink / raw)
To: Tejun Heo; +Cc: Jeff Garzik, linux-kernel, linux-ide
On Po 05-06-06 18:11:31, Tejun Heo wrote:
> Currently, there is no way to tell whether a device is resuming to
> write swsusp image or waking up from actual software suspend. FREEZE
> and SUSPEND are different operations for some devices (e.g. disks
> don't spin down for FREEZE) and the resume operation for each is also
> different.
>
> This patch makes swsusp change device power state from PMSG_FREEZE to
> PMSG_SUSPEND on resume from software suspend. A driver can determine
> whether it's getting thawed or resuming by looking at device power
> state - if FREEZE, it's getting thawed to write image; if SUSPEND,
> resuming from software suspend. This patch doesn't affect drivers
> which don't update device power state. Only drivers which set power
> state to FREEZE after freezing are affected.
No, sorry.
If driver is interested if previous operation was FREEZE or
SUSPEND... just store that information locally.
If you want to know if you RESUME was after normal FREEZE or if it is
after reboot, there's better patch floating around to do that.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] swsusp: allow drivers to determine between write-resume and actual wakeup
2006-06-05 9:23 ` Pavel Machek
@ 2006-06-05 11:50 ` Tejun Heo
2006-06-05 12:43 ` Tejun Heo
2006-06-05 13:17 ` Pavel Machek
0 siblings, 2 replies; 6+ messages in thread
From: Tejun Heo @ 2006-06-05 11:50 UTC (permalink / raw)
To: Pavel Machek; +Cc: Jeff Garzik, linux-kernel, linux-ide
Pavel Machek wrote:
> If you want to know if you RESUME was after normal FREEZE or if it is
> after reboot, there's better patch floating around to do that.
Yeap, this is what I'm interested in. Care to give me a pointer?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] swsusp: allow drivers to determine between write-resume and actual wakeup
2006-06-05 11:50 ` Tejun Heo
@ 2006-06-05 12:43 ` Tejun Heo
2006-06-05 13:15 ` Pavel Machek
2006-06-05 13:17 ` Pavel Machek
1 sibling, 1 reply; 6+ messages in thread
From: Tejun Heo @ 2006-06-05 12:43 UTC (permalink / raw)
To: Pavel Machek; +Cc: Jeff Garzik, linux-kernel, linux-ide
Tejun Heo wrote:
> Pavel Machek wrote:
>> If you want to know if you RESUME was after normal FREEZE or if it is
>> after reboot, there's better patch floating around to do that.
>
> Yeap, this is what I'm interested in. Care to give me a pointer?
And, one more things. As written in the first mail, for libata, it
would be nice to know if a device suspend is due to runtime PM event
(per-device) or system wide suspend. What do you think about this? If
you agree, what method do you recommend to determine that?
Thanks a lot.
--
tejun
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] swsusp: allow drivers to determine between write-resume and actual wakeup
2006-06-05 12:43 ` Tejun Heo
@ 2006-06-05 13:15 ` Pavel Machek
0 siblings, 0 replies; 6+ messages in thread
From: Pavel Machek @ 2006-06-05 13:15 UTC (permalink / raw)
To: Tejun Heo; +Cc: Jeff Garzik, linux-kernel, linux-ide
On Po 05-06-06 21:43:42, Tejun Heo wrote:
> Tejun Heo wrote:
> >Pavel Machek wrote:
> >>If you want to know if you RESUME was after normal FREEZE or if it is
> >>after reboot, there's better patch floating around to do that.
> >
> >Yeap, this is what I'm interested in. Care to give me a pointer?
>
> And, one more things. As written in the first mail, for libata, it
> would be nice to know if a device suspend is due to runtime PM event
> (per-device) or system wide suspend. What do you think about this? If
> you agree, what method do you recommend to determine that?
Currently, runtime pm is unsupported/broken; so any request can be
thought as system pm.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] swsusp: allow drivers to determine between write-resume and actual wakeup
2006-06-05 11:50 ` Tejun Heo
2006-06-05 12:43 ` Tejun Heo
@ 2006-06-05 13:17 ` Pavel Machek
1 sibling, 0 replies; 6+ messages in thread
From: Pavel Machek @ 2006-06-05 13:17 UTC (permalink / raw)
To: Tejun Heo; +Cc: Jeff Garzik, linux-kernel, linux-ide
On Po 05-06-06 20:50:56, Tejun Heo wrote:
> Pavel Machek wrote:
> >If you want to know if you RESUME was after normal FREEZE or if it is
> >after reboot, there's better patch floating around to do that.
>
> Yeap, this is what I'm interested in. Care to give me a pointer?
David Brownell had a patch to do that. I forwarded you my reply to
that mail...
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-06-05 13:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-05 9:11 [PATCH] swsusp: allow drivers to determine between write-resume and actual wakeup Tejun Heo
2006-06-05 9:23 ` Pavel Machek
2006-06-05 11:50 ` Tejun Heo
2006-06-05 12:43 ` Tejun Heo
2006-06-05 13:15 ` Pavel Machek
2006-06-05 13:17 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).