public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] s2ram: add arch irq disable/enable hooks
@ 2007-04-19 11:00 Johannes Berg
  2007-04-19 21:55 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 34+ messages in thread
From: Johannes Berg @ 2007-04-19 11:00 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-pm

For powermac, we need to do some things between suspending devices and
device_power_off, for example setting the decrementer. This patch
allows architectures to define arch_s2ram_{en,dis}able_irqs in their
asm/suspend.h to have control over this step.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>

---
 kernel/power/main.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

--- wireless-dev.orig/kernel/power/main.c	2007-04-17 18:52:24.536830941 +0200
+++ wireless-dev/kernel/power/main.c	2007-04-17 19:09:40.966830941 +0200
@@ -128,13 +128,22 @@ static int suspend_prepare(suspend_state
 	return error;
 }
 
+#ifndef arch_s2ram_disable_irqs
+#define arch_s2ram_disable_irqs(flags) local_irq_save(*flags)
+#endif
+
+#ifndef arch_s2ram_enable_irqs
+#define arch_s2ram_enable_irqs(flags) local_irq_restore(*flags)
+#endif
+
 
 int suspend_enter(suspend_state_t state)
 {
 	int error = 0;
 	unsigned long flags;
 
-	local_irq_save(flags);
+	arch_s2ram_disable_irqs(&flags);
+	BUG_ON(!irqs_disabled());
 
 	if ((error = device_power_down(PMSG_SUSPEND))) {
 		printk(KERN_ERR "Some devices failed to power down\n");
@@ -143,7 +152,8 @@ int suspend_enter(suspend_state_t state)
 	error = pm_ops->enter(state);
 	device_power_up();
  Done:
-	local_irq_restore(flags);
+	arch_s2ram_enable_irqs(&flags);
+	BUG_ON(irqs_disabled());
 	return error;
 }
 

^ permalink raw reply	[flat|nested] 34+ messages in thread
* [PATCH] pm_ops: add irq enable/disable hooks
@ 2007-04-05 21:54 Johannes Berg
  2007-04-17 17:18 ` [PATCH] s2ram: add arch irq disable/enable hooks Johannes Berg
  0 siblings, 1 reply; 34+ messages in thread
From: Johannes Berg @ 2007-04-05 21:54 UTC (permalink / raw)
  To: linux-pm; +Cc: Pavel Machek

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.irq_off and pm_ops.irq_on which will be called instead
of disabling/enabling irqs so platforms can do a bit more work there if
necessary.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>

---
My previous patches moving to the pm_ops interface for powermac were
buggy due to exactly this issue, but the bug never surfaced on my
machine, only on machines with an Apple Desktop Bus (or an emulation
thereof)

Does this look ok to you? Would you want different names? Should I stick
in a BUG_ON(interrupts_enabled()) or such?

 include/linux/pm.h  |   10 ++++++++++
 kernel/power/main.c |   10 ++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

--- wireless-dev.orig/include/linux/pm.h	2007-04-05 18:14:07.948549941 +0200
+++ wireless-dev/include/linux/pm.h	2007-04-05 23:15:29.934829459 +0200
@@ -131,9 +131,17 @@ typedef int __bitwise suspend_disk_metho
  * @prepare: Prepare the platform for the given suspend state. Can return a
  *	negative error code if necessary.
  *
+ * @irq_off: If assigned, the generic suspend code does not turn off IRQs
+ *	but relies on this callback instead. 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.
  *
+ * @irq_on: If assigned, the generic suspend code does not turn on IRQs
+ *	but relies on this callback instead. 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.
  *
@@ -152,7 +160,9 @@ typedef int __bitwise suspend_disk_metho
 struct pm_ops {
 	int (*valid)(suspend_state_t state);
 	int (*prepare)(suspend_state_t state);
+	void (*irq_off)(suspend_state_t state);
 	int (*enter)(suspend_state_t state);
+	void (*irq_on)(suspend_state_t state);
 	int (*finish)(suspend_state_t state);
 	suspend_disk_method_t pm_disk_mode;
 };
--- wireless-dev.orig/kernel/power/main.c	2007-04-05 18:14:07.988549941 +0200
+++ wireless-dev/kernel/power/main.c	2007-04-05 18:25:21.108549941 +0200
@@ -117,7 +117,10 @@ int suspend_enter(suspend_state_t state)
 	int error = 0;
 	unsigned long flags;
 
-	local_irq_save(flags);
+	if (pm_ops->irq_off)
+		pm_ops->irq_off(state);
+	else
+		local_irq_save(flags);
 
 	if ((error = device_power_down(PMSG_SUSPEND))) {
 		printk(KERN_ERR "Some devices failed to power down\n");
@@ -126,7 +129,10 @@ int suspend_enter(suspend_state_t state)
 	error = pm_ops->enter(state);
 	device_power_up();
  Done:
-	local_irq_restore(flags);
+	if (pm_ops->irq_on)
+		pm_ops->irq_on(state);
+	else
+		local_irq_restore(flags);
 	return error;
 }
 

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

end of thread, other threads:[~2007-04-26 11:02 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-19 11:00 [PATCH] s2ram: add arch irq disable/enable hooks Johannes Berg
2007-04-19 21:55 ` Andrew Morton
2007-04-20 15:34   ` Johannes Berg
2007-04-20  6:57 ` Greg KH
2007-04-20 15:31   ` Johannes Berg
2007-04-20 17:39     ` Greg KH
2007-04-20 19:37       ` Johannes Berg
2007-04-20 19:44         ` Andrew Morton
2007-04-20 19:51           ` Johannes Berg
2007-04-20 20:36             ` Rafael J. Wysocki
2007-04-20 20:51               ` Johannes Berg
2007-04-20 21:08                 ` Rafael J. Wysocki
2007-04-21 13:57 ` Johannes Berg
2007-04-21 14:07   ` Pavel Machek
2007-04-21 15:41   ` David Brownell
2007-04-21 16:16     ` Johannes Berg
2007-04-21 16:55       ` David Brownell
2007-04-21 17:01         ` Johannes Berg
2007-04-21 17:06           ` David Brownell
2007-04-21 17:49             ` Johannes Berg
2007-04-21 21:47               ` Pavel Machek
2007-04-21 22:04                 ` Johannes Berg
2007-04-21 21:45             ` Pavel Machek
2007-04-22  3:10               ` David Brownell
2007-04-22 13:09                 ` Pavel Machek
2007-04-26 11:02                   ` David Woodhouse
2007-04-21 21:44     ` Pavel Machek
2007-04-22  3:05       ` David Brownell
2007-04-22 13:13         ` Pavel Machek
2007-04-24 13:51           ` Johannes Berg
2007-04-24 18:16             ` Pavel Machek
2007-04-25  3:45               ` David Brownell
  -- strict thread matches above, loose matches on Subject: below --
2007-04-05 21:54 [PATCH] pm_ops: add irq enable/disable hooks Johannes Berg
2007-04-17 17:18 ` [PATCH] s2ram: add arch irq disable/enable hooks Johannes Berg
2007-04-18 11:27   ` Pavel Machek

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