Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Johannes Berg <johannes <at> sipsolutions.net>
Subject: [PATCH v2] pm_ops: add system quiesce/activate hooks
Newsgroups: gmane.linux.power-management.general
Date: Wednesday 11th April 2007 15:54:27 UTC (over 9 years ago)
For powermac, we need to do some things between suspending devices and
device_power_off, for example setting the decrementer. This patch
introduces pm_ops.quiesce and pm_ops.activate which will be called instead
of disabling/enabling irqs so platforms get control over this step.

Since those two new calls are required, this patch also introduces default
methods that can be assigned and updates all pm_ops users to use these
defaults.

Signed-off-by: Johannes Berg <[email protected]>

---
Rafael: I don't need to change SNAPSHOT_S2RAM since it calls suspend_enter
which is where the change is.

I'm not sure if it makes sense to have this for PM_SUSPEND_DISK as well so
unless somebody comes up with a reason for now don't.

 arch/arm/common/sharpsl_pm.c            |    2 ++
 arch/arm/mach-at91/pm.c                 |    2 ++
 arch/arm/mach-omap1/pm.c                |    2 ++
 arch/arm/mach-omap2/pm.c                |    2 ++
 arch/arm/mach-pnx4008/pm.c              |    2 ++
 arch/arm/mach-pxa/pm.c                  |    2 ++
 arch/arm/mach-sa1100/pm.c               |    2 ++
 arch/arm/plat-s3c24xx/pm.c              |    2 ++
 arch/powerpc/platforms/powermac/setup.c |    2 ++
 arch/sh/boards/hp6xx/pm.c               |    2 ++
 drivers/acpi/sleep/main.c               |    7 +++++++
 include/linux/pm.h                      |   12 ++++++++++++
 kernel/power/main.c                     |   29
++++++++++++++++++++++++++---
 13 files changed, 65 insertions(+), 3 deletions(-)

--- wireless-dev.orig/include/linux/pm.h	2007-04-11 17:02:22.969481358
+0200
+++ wireless-dev/include/linux/pm.h	2007-04-11 17:02:42.609481358 +0200
@@ -135,9 +135,17 @@ typedef int __bitwise suspend_disk_metho
  * @prepare: Prepare the platform for the given suspend state. Can return
a
  *	negative error code if necessary.
  *
+ * @quiesce: This callback must be assigned and at least turn off IRQs. If
+ *	your platform requires nothing else, assign %pm_default_quiesce.
+ *	It is currently not called for %PM_SUSPEND_DISK.
+ *
  * @enter: Enter the given suspend state, must be assigned. Can return a
  *	negative error code if necessary.
  *
+ * @activate: This callback must be assigned and at least turn on IRQS. If
+ *	your platform requires nothing else, assign %pm_default_activate.
+ *	It is currently not called for %PM_SUSPEND_DISK.
+ *
  * @finish: Called when the system has left the given state and all
devices
  *	are resumed. The return value is ignored.
  *
@@ -155,7 +163,9 @@ typedef int __bitwise suspend_disk_metho
 struct pm_ops {
 	int (*valid)(suspend_state_t state);
 	int (*prepare)(suspend_state_t state);
+	void (*quiesce)(suspend_state_t state);
 	int (*enter)(suspend_state_t state);
+	void (*activate)(suspend_state_t state);
 	int (*finish)(suspend_state_t state);
 	suspend_disk_method_t pm_disk_mode;
 };
@@ -169,6 +179,8 @@ extern struct pm_ops *pm_ops;
 extern int pm_suspend(suspend_state_t state);
 
 extern int pm_valid_only_mem(suspend_state_t state);
+extern void pm_default_quiesce(suspend_state_t state);
+extern void pm_default_activate(suspend_state_t state);
 
 /*
  * Device power management
--- wireless-dev.orig/kernel/power/main.c	2007-04-11 17:02:23.149481358
+0200
+++ wireless-dev/kernel/power/main.c	2007-04-11 17:18:14.879481358 +0200
@@ -60,6 +60,28 @@ int pm_valid_only_mem(suspend_state_t st
 	return state == PM_SUSPEND_MEM;
 }
 
+/**
+ * pm_default_quiesce - default quiesce callback
+ *
+ * pm_ops drivers that need to do nothing but disable
+ * IRQs use this instead of their own code.
+ */
+void pm_default_quiesce(suspend_state_t state)
+{
+	local_irq_disable();
+}
+
+/**
+ * pm_default_activate - default activate callback
+ *
+ * pm_ops drivers that need to do nothing but enable
+ * IRQs use this instead of their own code.
+ */
+void pm_default_activate(suspend_state_t state)
+{
+	local_irq_enable();
+}
+
 
 static inline void pm_finish(suspend_state_t state)
 {
@@ -132,9 +154,9 @@ static int suspend_prepare(suspend_state
 int suspend_enter(suspend_state_t state)
 {
 	int error = 0;
-	unsigned long flags;
 
-	local_irq_save(flags);
+	pm_ops->quiesce(state);
+	BUG_ON(!irqs_disabled());
 
 	if ((error = device_power_down(PMSG_SUSPEND))) {
 		printk(KERN_ERR "Some devices failed to power down\n");
@@ -143,7 +165,8 @@ int suspend_enter(suspend_state_t state)
 	error = pm_ops->enter(state);
 	device_power_up();
  Done:
-	local_irq_restore(flags);
+	pm_ops->activate(state);
+	BUG_ON(irqs_disabled());
 	return error;
 }
 
--- wireless-dev.orig/arch/arm/common/sharpsl_pm.c	2007-04-11
17:07:50.109481358 +0200
+++ wireless-dev/arch/arm/common/sharpsl_pm.c	2007-04-11 17:08:28.439481358
+0200
@@ -767,7 +767,9 @@ static void sharpsl_apm_get_power_status
 
 static struct pm_ops sharpsl_pm_ops = {
 	.prepare	= pxa_pm_prepare,
+	.quiesce	= pm_default_quiesce,
 	.enter		= corgi_pxa_pm_enter,
+	.activate	= pm_default_activate,
 	.finish		= pxa_pm_finish,
 	.valid		= pm_valid_only_mem,
 };
--- wireless-dev.orig/arch/arm/mach-at91/pm.c	2007-04-11 17:07:50.889481358
+0200
+++ wireless-dev/arch/arm/mach-at91/pm.c	2007-04-11 17:10:17.399481358
+0200
@@ -203,7 +203,9 @@ error:
 static struct pm_ops at91_pm_ops ={
 	.valid		= at91_pm_valid_state,
 	.prepare	= at91_pm_prepare,
+	.quiesce	= pm_default_quiesce,
 	.enter		= at91_pm_enter,
+	.activate	= pm_default_activate,
 };
 
 static int __init at91_pm_init(void)
--- wireless-dev.orig/arch/arm/mach-omap1/pm.c	2007-04-11
17:07:50.219481358 +0200
+++ wireless-dev/arch/arm/mach-omap1/pm.c	2007-04-11 17:08:48.149481358
+0200
@@ -699,7 +699,9 @@ static struct irqaction omap_wakeup_irq 
 
 static struct pm_ops omap_pm_ops ={
 	.prepare	= omap_pm_prepare,
+	.quiesce	= pm_default_quiesce,
 	.enter		= omap_pm_enter,
+	.activate	= pm_default_activate,
 	.finish		= omap_pm_finish,
 	.valid		= pm_valid_only_mem,
 };
--- wireless-dev.orig/arch/arm/mach-omap2/pm.c	2007-04-11
17:07:50.349481358 +0200
+++ wireless-dev/arch/arm/mach-omap2/pm.c	2007-04-11 17:09:08.369481358
+0200
@@ -371,7 +371,9 @@ static int omap2_pm_finish(suspend_state
 
 static struct pm_ops omap_pm_ops = {
 	.prepare	= omap2_pm_prepare,
+	.quiesce	= pm_default_quiesce,
 	.enter		= omap2_pm_enter,
+	.activate	= pm_default_activate,
 	.finish		= omap2_pm_finish,
 	.valid		= pm_valid_only_mem,
 };
--- wireless-dev.orig/arch/arm/mach-pnx4008/pm.c	2007-04-11
17:07:50.539481358 +0200
+++ wireless-dev/arch/arm/mach-pnx4008/pm.c	2007-04-11 17:09:23.759481358
+0200
@@ -116,7 +116,9 @@ static int pnx4008_pm_enter(suspend_stat
 }
 
 static struct pm_ops pnx4008_pm_ops = {
+	.quiesce = pm_default_quiesce,
 	.enter = pnx4008_pm_enter,
+	.activate = pm_default_activate,
 	.valid = pm_valid_only_mem,
 };
 
--- wireless-dev.orig/arch/arm/mach-pxa/pm.c	2007-04-11 17:07:50.639481358
+0200
+++ wireless-dev/arch/arm/mach-pxa/pm.c	2007-04-11 17:09:45.959481358 +0200
@@ -225,7 +225,9 @@ EXPORT_SYMBOL_GPL(pxa_pm_finish);
 
 static struct pm_ops pxa_pm_ops = {
 	.prepare	= pxa_pm_prepare,
+	.quiesce	= pm_default_quiesce,
 	.enter		= pxa_pm_enter,
+	.activate	= pm_default_activate,
 	.finish		= pxa_pm_finish,
 	.valid		= pm_valid_only_mem,
 };
--- wireless-dev.orig/arch/arm/mach-sa1100/pm.c	2007-04-11
17:07:50.729481358 +0200
+++ wireless-dev/arch/arm/mach-sa1100/pm.c	2007-04-11 17:09:59.759481358
+0200
@@ -132,7 +132,9 @@ unsigned long sleep_phys_sp(void *sp)
 }
 
 static struct pm_ops sa11x0_pm_ops = {
+	.quiesce	= pm_default_quiesce,
 	.enter		= sa11x0_pm_enter,
+	.activate	= pm_default_activate,
 	.valid		= pm_valid_only_mem,
 };
 
--- wireless-dev.orig/arch/arm/plat-s3c24xx/pm.c	2007-04-11
17:07:50.959481358 +0200
+++ wireless-dev/arch/arm/plat-s3c24xx/pm.c	2007-04-11 17:10:36.039481358
+0200
@@ -613,7 +613,9 @@ static int s3c2410_pm_enter(suspend_stat
 }
 
 static struct pm_ops s3c2410_pm_ops = {
+	.quiesce	= pm_default_quiesce,
 	.enter		= s3c2410_pm_enter,
+	.activate	= pm_default_activate,
 	.valid		= pm_valid_only_mem,
 };
 
--- wireless-dev.orig/arch/powerpc/platforms/powermac/setup.c	2007-04-11
17:07:51.029481358 +0200
+++ wireless-dev/arch/powerpc/platforms/powermac/setup.c	2007-04-11
17:10:53.659481358 +0200
@@ -475,7 +475,9 @@ static int pmac_pm_valid(suspend_state_t
 static struct pm_ops pmac_pm_ops = {
 	.pm_disk_mode	= PM_DISK_SHUTDOWN,
 	.prepare	= pmac_pm_prepare,
+	.quiesce	= pm_default_quiesce,
 	.enter		= pmac_pm_enter,
+	.activate	= pm_default_activate,
 	.finish		= pmac_pm_finish,
 	.valid		= pmac_pm_valid,
 };
--- wireless-dev.orig/arch/sh/boards/hp6xx/pm.c	2007-04-11
17:07:51.099481358 +0200
+++ wireless-dev/arch/sh/boards/hp6xx/pm.c	2007-04-11 17:11:06.269481358
+0200
@@ -68,7 +68,9 @@ static int hp6x0_pm_enter(suspend_state_
 }
 
 static struct pm_ops hp6x0_pm_ops = {
+	.quiesce	= pm_default_quiesce,
 	.enter		= hp6x0_pm_enter,
+	.activate	= pm_default_activate,
 	.valid		= pm_valid_only_mem,
 };
 
--- wireless-dev.orig/drivers/acpi/sleep/main.c	2007-04-11
17:07:51.339481358 +0200
+++ wireless-dev/drivers/acpi/sleep/main.c	2007-04-11 17:12:49.679481358
+0200
@@ -182,10 +182,17 @@ static int acpi_pm_state_valid(suspend_s
 	}
 }
 
+/*
+ * If .quiesce or .activate are changed, keep in mind
+ * that they aren't currently called for S4. That can
+ * be changed if needed, of course.
+ */
 static struct pm_ops acpi_pm_ops = {
 	.valid = acpi_pm_state_valid,
 	.prepare = acpi_pm_prepare,
+	.quiesce = pm_default_quiesce,
 	.enter = acpi_pm_enter,
+	.activate = pm_default_activate,
 	.finish = acpi_pm_finish,
 };
 
CD: 4ms