Skip to contentSkip to conversation

s2ram: add arch irq disable/enable hooks

PATCH In review Johannes Berg 7 participants 32 messages Apr 19, 2007 – Apr 26, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s2ram: add arch irq disable/enable hooks

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.

---
 kernel/power/main.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
kernel/power/main.c +12 -2
@@ -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;
 }
 
#1 lore raw
Quoted 5 lines · On Thu, 19 Apr 2007 13:00:11 +0200 Johannes Berg <[email protected]>…

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.

what on earth is a decrementer?

Quoted 17 lines
---
 kernel/power/main.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
kernel/power/main.c +6 -0
@@ -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)

kernel/power/main.c static int suspend_prepare(suspend_state · line 145

Quoted 10 lines
kernel/power/main.c +3 -1
+#endif
+
 
 int suspend_enter(suspend_state_t state)
 {
 	int error = 0;
 	unsigned long flags;
 
-	local_irq_save(flags);
+	arch_s2ram_disable_irqs(&flags);

hm, ugly. We could use attribute(weak) here, so we don't force architectures to implement this with a macro. But whatever.

It might be nice to identify which arch header is supposed to define arch_s2ram_disable_irqs, perhaps via an explicit inclusion of that header.

#3 lore raw
In reply to Johannes Berg
Quoted 14 lines · Johannes Berg

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.

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

kernel/power/main.c static int suspend_prepare(suspend_state · line 137

Quoted 10 lines
kernel/power/main.c +7 -0
@@ -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

Can't you just make this a "weak" symbol and override it in your ppc code if you really need it, and make a "real" function here in this file for all other arches?

thanks,

greg k-h

#4 lore raw
Quoted 3 lines · Greg KH

Can't you just make this a "weak" symbol and override it in your ppc code if you really need it, and make a "real" function here in this file for all other arches?

I'm not opposed to that. How do I do that?

johannes

#2 lore raw
In reply to Andrew Morton
Quoted 1 line · Andrew Morton

what on earth is a decrementer?

BenH explained it here:
http://thread.gmane.org/gmane.linux.power-management.general/5088/focus=5230

Quoted 2 lines

It might be nice to identify which arch header is supposed to define arch_s2ram_disable_irqs, perhaps via an explicit inclusion of that header.

It's supposed to go into asm/suspend.h which is included from linux/suspend.h. I thought about doing it explicitly but opted against it in the end. But if I change it to be a weak symbol (somebody tell me how to please) then that will be moot.

johannes

#5 lore raw
In reply to Johannes Berg
Quoted 7 lines · Johannes Berg
Quoted 3 lines · Greg KH

Can't you just make this a "weak" symbol and override it in your ppc code if you really need it, and make a "real" function here in this file for all other arches?

I'm not opposed to that. How do I do that?

Look at the other examples in the kernel, pcibios_disable_device is one such example.

thanks,

greg k-h

#6 lore raw

PATCH 1/1 s2ram: add arch irq disable/enable hooks

Thanks. Does this look good?

Haven't tested it yet but I don't see a reason it shouldn't work for me.

Sparse will probably complain about this, should I define them somewhere?

---
 kernel/power/main.c |   27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
kernel/power/main.c +25 -2
@@ -128,13 +128,35 @@ static int suspend_prepare(suspend_state
 	return error;
 }
 
+/**
+ * arch_s2ram_disable_irqs - disable IRQs for suspend
+ *
+ * Disables IRQs (in the default case) and allows architectures
+ * to override it if more needs to be done.
+ */
+void __attribute__ ((weak)) arch_s2ram_disable_irqs(unsigned long *flags)
+{
+	local_irq_save(*flags);
+}
+
+/**
+ * arch_s2ram_enable_irqs - enable IRQs after suspend
+ *
+ * Enables IRQs (in the default case) and allows architectures
+ * to override it if more needs to be done.
+ */
+void __attribute__ ((weak)) arch_s2ram_enable_irqs(unsigned long *flags)
+{
+	local_irq_restore(*flags);
+}
 
 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 +165,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;
 }
 
#7 lore raw
Quoted 12 lines · On Fri, 20 Apr 2007 21:37:18 +0200 Johannes Berg <[email protected]>…

int suspend_enter(suspend_state_t state)
{

kernel/power/main.c +2 -1
 	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");

kernel/power/main.c int suspend_enter(suspend_state_t state) · line 171

Quoted 8 lines
kernel/power/main.c +2 -1
@@ -143,7 +165,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;
 }

The second BUG_ON() looks a bit fishy to me. If someone calls suspend_enter() with local interrupts disabled, it will trigger.

#8 lore raw
Quoted 8 lines · Andrew Morton

kernel/power/main.c int suspend_enter(suspend_state_t state) · line 171

Quoted 5 lines
kernel/power/main.c +2 -1
-	local_irq_restore(flags);
+	arch_s2ram_enable_irqs(&flags);
+	BUG_ON(irqs_disabled());
 	return error;
 }

The second BUG_ON() looks a bit fishy to me. If someone calls suspend_enter() with local interrupts disabled, it will trigger.

Huh, hm, I don't think it's valid to do that. I'm not sure why the code does irq_save/restore instead of just disable/enable. The only users of this function are in the power management core code (main.c and user.c) and they certainly always call it with interrupts enabled, the entry point for other users is pm_suspend() and that surely cannot be called with interrupts disabled. Rafael?

johannes

#9 lore raw
Quoted 11 lines · Johannes Berg
Quoted 8 lines · Andrew Morton

kernel/power/main.c int suspend_enter(suspend_state_t state) · line 171

Quoted 5 lines
kernel/power/main.c +2 -1
-	local_irq_restore(flags);
+	arch_s2ram_enable_irqs(&flags);
+	BUG_ON(irqs_disabled());
 	return error;
 }

The second BUG_ON() looks a bit fishy to me. If someone calls suspend_enter() with local interrupts disabled, it will trigger.

Quoted 2 lines

Huh, hm, I don't think it's valid to do that. I'm not sure why the code does irq_save/restore instead of just disable/enable.

Well, I can't say why exactly suspend_enter() usues irq_save/restore, but it looks like that's not needed. For the suspend to disk we call local_irq_disable/enable() in the corresponding places and, for example, acpi_pm_enter apparently uses irq_save/restore() itself too.

Quoted 4 lines

The only users of this function are in the power management core code (main.c and user.c) and they certainly always call it with interrupts enabled, the entry point for other users is pm_suspend() and that surely cannot be called with interrupts disabled. Rafael?

That's correct, plus pm_suspend() also uses enter_state().

In fact suspend_enter() has been made extern so that we can call it from kernel/power/user.c and no one else is supposed to use it.

#10 lore raw
Quoted 2 lines · Rafael J. Wysocki

Well, I can't say why exactly suspend_enter() usues irq_save/restore, but it looks like that's not needed.

powerpc works fine just with local_irq_disable/enable, never did anything else and my new patches just ignore the *flags argument.

Quoted 3 lines

For the suspend to disk we call
local_irq_disable/enable() in the corresponding places and, for example, acpi_pm_enter apparently uses irq_save/restore() itself too.

Why would acpi_pm_enter do that? It can always assume irqs are disabled. Or does it need to enable them for something (hey, that would mean Ben is right in that it probably wants to use these new hooks...)

Quoted 6 lines
Quoted 4 lines

The only users of this function are in the power management core code (main.c and user.c) and they certainly always call it with interrupts enabled, the entry point for other users is pm_suspend() and that surely cannot be called with interrupts disabled. Rafael?

That's correct, plus pm_suspend() also uses enter_state().

Sure, but it can't be called with interrupts disabled.

Quoted 2 lines

In fact suspend_enter() has been made extern so that we can call it from kernel/power/user.c and no one else is supposed to use it.

Right.

So, any argument against re-spinning this patch, removing the unsigned long *flags stuff and using local_irq_disable/enable?

johannes

#11 lore raw
Quoted 25 lines · Johannes Berg
Quoted 2 lines · Rafael J. Wysocki

Well, I can't say why exactly suspend_enter() usues irq_save/restore, but it looks like that's not needed.

powerpc works fine just with local_irq_disable/enable, never did anything else and my new patches just ignore the *flags argument.

Quoted 3 lines

For the suspend to disk we call
local_irq_disable/enable() in the corresponding places and, for example, acpi_pm_enter apparently uses irq_save/restore() itself too.

Why would acpi_pm_enter do that? It can always assume irqs are disabled. Or does it need to enable them for something (hey, that would mean Ben is right in that it probably wants to use these new hooks...)

Quoted 6 lines
Quoted 4 lines

The only users of this function are in the power management core code (main.c and user.c) and they certainly always call it with interrupts enabled, the entry point for other users is pm_suspend() and that surely cannot be called with interrupts disabled. Rafael?

That's correct, plus pm_suspend() also uses enter_state().

Sure, but it can't be called with interrupts disabled.

Quoted 7 lines
Quoted 2 lines

In fact suspend_enter() has been made extern so that we can call it from kernel/power/user.c and no one else is supposed to use it.

Right.

So, any argument against re-spinning this patch, removing the unsigned long *flags stuff and using local_irq_disable/enable?

Not from me.

Rafael

#12 lore raw

PATCH 1/1 s2ram: add arch irq disable/enable hooks

In reply to Johannes Berg

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 have arch_s2ram_{en,dis}able_irqs functions to control this step.

This patch also replaces local_irq_save/restore with local_irq_disable/enable since the code must be called with interrupts enabled.

---
This version uses weak symbols instead of macros.

 kernel/power/main.c |   28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
kernel/power/main.c +25 -3
@@ -128,13 +128,34 @@ static int suspend_prepare(suspend_state
 	return error;
 }
 
+/**
+ * arch_s2ram_disable_irqs - disable IRQs for suspend
+ *
+ * Disables IRQs (in the default case) and allows architectures
+ * to override it if more needs to be done.
+ */
+void __attribute__ ((weak)) arch_s2ram_disable_irqs(void)
+{
+	local_irq_disable();
+}
+
+/**
+ * arch_s2ram_enable_irqs - enable IRQs after suspend
+ *
+ * Enables IRQs (in the default case) and allows architectures
+ * to override it if more needs to be done.
+ */
+void __attribute__ ((weak)) arch_s2ram_enable_irqs(void)
+{
+	local_irq_enable();
+}
 
 int suspend_enter(suspend_state_t state)
 {
 	int error = 0;
-	unsigned long flags;
 
-	local_irq_save(flags);
+	arch_s2ram_disable_irqs();
+	BUG_ON(!irqs_disabled());
 
 	if ((error = device_power_down(PMSG_SUSPEND))) {
 		printk(KERN_ERR "Some devices failed to power down\n");
@@ -143,7 +164,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();
+	BUG_ON(irqs_disabled());
 	return error;
 }
 
#13 lore raw
Quoted 10 lines · Johannes Berg

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 have arch_s2ram_{en,dis}able_irqs functions to control this step.

This patch also replaces local_irq_save/restore with local_irq_disable/enable since the code must be called with interrupts enabled.

ACK.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#14 lore raw
In reply to Johannes Berg

kernel/power/main.c static int suspend_prepare(suspend_state · line 157

Quoted 7 lines · Johannes Berg

int suspend_enter(suspend_state_t state)
{

kernel/power/main.c +1 -2
 	int error = 0;
-	unsigned long flags;
 
-	local_irq_save(flags);
+	arch_s2ram_disable_irqs();

Sorry for not highlighting this before, but these are badly misnamed. They apply for every system suspend state except PM_SUSPEND_DISK ... NOT just suspend-to-ram, as specified by the function name.

kernel/power/main.c int suspend_enter(suspend_state_t state) · line 167

Quoted 10 lines
kernel/power/main.c +2 -1
+	BUG_ON(!irqs_disabled());
 
 	if ((error = device_power_down(PMSG_SUSPEND))) {
 		printk(KERN_ERR "Some devices failed to power down\n");
@@ -143,7 +164,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();

Same here.

Quoted 5 lines
kernel/power/main.c +1 -0
+	BUG_ON(irqs_disabled());
 	return error;
 }
 
#15 lore raw
Quoted 3 lines · David Brownell

Sorry for not highlighting this before, but these are badly misnamed. They apply for every system suspend state except PM_SUSPEND_DISK ... NOT just suspend-to-ram, as specified by the function name.

Good point. arch_pm_disable_irqs?

johannes

#16 lore raw
Quoted 7 lines · Johannes Berg
Quoted 3 lines · David Brownell

Sorry for not highlighting this before, but these are badly misnamed. They apply for every system suspend state except PM_SUSPEND_DISK ... NOT just suspend-to-ram, as specified by the function name.

Good point. arch_pm_disable_irqs?

Or maybe arch_suspend_disable_irqs() ... there are PM operations that don't involve system suspend states.

- Dave

#17 lore raw
Quoted 2 lines · David Brownell

Or maybe arch_suspend_disable_irqs() ... there are PM operations that don't involve system suspend states.

Yeah, probably better and I'm fine with that, but the crowd who screamed when I noted that CONFIG_SOFTWARE_SUSPEND had nothing to do with suspend states might be confused... It should be obvious that this isn't called for suspend to disk.

johannes

#18 lore raw
Quoted 9 lines · Johannes Berg
Quoted 2 lines · David Brownell

Or maybe arch_suspend_disable_irqs() ... there are PM operations that don't involve system suspend states.

Yeah, probably better and I'm fine with that, but the crowd who screamed when I noted that CONFIG_SOFTWARE_SUSPEND had nothing to do with suspend states might be confused... It should be obvious that this isn't called for suspend to disk.

Yeah, but SOFTWARE_SUSPEND is also a misnomer. It's more of a system checkpoint/restore framework. And even userspace makes that distinction clear, calling it "Hibernate" not "Suspend".

I feel a Kconfig patch coming on ... ;)

- Dave

#19 lore raw
Quoted 2 lines · David Brownell

And even userspace makes
that distinction clear, calling it "Hibernate" not "Suspend".

But that was quite a fight, at least in the gnome camp ;)

Quoted 1 line

I feel a Kconfig patch coming on ... ;)

Not from me. But you'll get an updated one for this :)

johannes

#26 lore raw
In reply to David Brownell

Hi!

Quoted 11 lines

kernel/power/main.c static int suspend_prepare(suspend_state · line 157

Quoted 7 lines

int suspend_enter(suspend_state_t state)
{

kernel/power/main.c +1 -2
 	int error = 0;
-	unsigned long flags;
 
-	local_irq_save(flags);
+	arch_s2ram_disable_irqs();

Sorry for not highlighting this before, but these are badly misnamed. They apply for every system suspend state except PM_SUSPEND_DISK ... NOT just suspend-to-ram, as specified by the function name.

Every suspend state means "standby" and "s2ram" in this context. I think this name is better than alternatives.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#22 lore raw
In reply to David Brownell

Hi!

Quoted 9 lines
Quoted 7 lines
Quoted 2 lines

Or maybe arch_suspend_disable_irqs() ... there are PM operations that don't involve system suspend states.

Yeah, probably better and I'm fine with that, but the crowd who screamed when I noted that CONFIG_SOFTWARE_SUSPEND had nothing to do with suspend states might be confused... It should be obvious that this isn't called for suspend to disk.

Yeah, but SOFTWARE_SUSPEND is also a misnomer. It's more of a

Well, that's the way it is. "suspend" == s2ram, standby, swsusp, swsusp+S4 in kernel context.

Quoted 2 lines

system checkpoint/restore framework. And even userspace makes that distinction clear, calling it "Hibernate" not "Suspend".

Gnome deciding to confuse their users is _their_ problem.

Quoted 1 line

I feel a Kconfig patch coming on ... ;)

I do not think confusion from a change is worth the benefit.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#20 lore raw
In reply to Johannes Berg
Quoted 6 lines · Johannes Berg
Quoted 2 lines · David Brownell

And even userspace makes
that distinction clear, calling it "Hibernate" not "Suspend".

But that was quite a fight, at least in the gnome camp ;)

Yep. Maybe we'll want to change "suspend to ram -> suspend", "swsusp -> hibernate" one day, but it will be big and ugly patch confusing everyone, and I do not think that day is close.

Quoted 3 lines
Quoted 1 line

I feel a Kconfig patch coming on ... ;)

Not from me. But you'll get an updated one for this :)

Please don't. Original patch is fine.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#21 lore raw
Quoted 1 line · Pavel Machek

Please don't. Original patch is fine.

I don't care any more, I just want the hooks. Go discuss with the others and then send me an email which names you want.

johannes

#27 lore raw
In reply to Pavel Machek
Quoted 14 lines · Pavel Machek

Hi!

Quoted 11 lines

kernel/power/main.c static int suspend_prepare(suspend_state · line 157

Quoted 7 lines

int suspend_enter(suspend_state_t state)
{

kernel/power/main.c +1 -2
 	int error = 0;
-	unsigned long flags;
 
-	local_irq_save(flags);
+	arch_s2ram_disable_irqs();

Sorry for not highlighting this before, but these are badly misnamed. They apply for every system suspend state except PM_SUSPEND_DISK ... NOT just suspend-to-ram, as specified by the function name.

Quoted 2 lines

Every suspend state means "standby" and "s2ram" in this context. I think this name is better than alternatives.

Every suspend state is **NOT** s2ram though.

This is a very straightforward point. A function that's called on non-S2RAM paths shouldn't be named as if it's only for S2RAM.

Ergo, those two functions are misnamed. End of story.

- Dave

#23 lore raw
In reply to Pavel Machek
Quoted 4 lines · Pavel Machek
Quoted 2 lines

system checkpoint/restore framework. And even userspace makes that distinction clear, calling it "Hibernate" not "Suspend".

Gnome deciding to confuse their users is _their_ problem.

Hot news flash for Pavel: "hibernate" is much more widely used and understood than "software suspend". Everyone using Windows has already been trained in what it means. But even today lots of folk scratch their heads at "software suspend" ... "gee, isn't all suspending done by software?"

Quoted 3 lines
Quoted 1 line

I feel a Kconfig patch coming on ... ;)

I do not think confusion from a change is worth the benefit.

Glad you waited to see the patch before you objected!

Oh wait -- you didn't wait. Sorry, I seem to have misunderstood the process here. Could you explain this new revised Linux patch process to me?

- Dave

#24 lore raw

Hi!

Quoted 10 lines
Quoted 4 lines
Quoted 2 lines

system checkpoint/restore framework. And even userspace makes that distinction clear, calling it "Hibernate" not "Suspend".

Gnome deciding to confuse their users is _their_ problem.

Hot news flash for Pavel: "hibernate" is much more widely used and understood than "software suspend". Everyone using Windows has already been trained in what it means. But even today lots of folk scratch their heads at "software suspend" ... "gee, isn't all suspending done by software?"

Well, in apm case it is firmware, not software. That's how the name was born.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I feel a Kconfig patch coming on ... ;)

I do not think confusion from a change is worth the benefit.

Glad you waited to see the patch before you objected!

Uf I thought you were going to s/CONFIG_SOFTWARE_SUSPEND/CONFIG/HIBERNATION/ over the kernel, and wanted to spare you some time.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#28 lore raw
In reply to David Brownell
Quoted 15 lines · David Brownell
Quoted 14 lines · Pavel Machek

Hi!

Quoted 11 lines

kernel/power/main.c static int suspend_prepare(suspend_state · line 157

Quoted 7 lines

int suspend_enter(suspend_state_t state)
{

kernel/power/main.c +1 -2
 	int error = 0;
-	unsigned long flags;
 
-	local_irq_save(flags);
+	arch_s2ram_disable_irqs();

Sorry for not highlighting this before, but these are badly misnamed. They apply for every system suspend state except PM_SUSPEND_DISK ... NOT just suspend-to-ram, as specified by the function name.

Quoted 8 lines
Quoted 2 lines

Every suspend state means "standby" and "s2ram" in this context. I think this name is better than alternatives.

Every suspend state is **NOT** s2ram though.

This is a very straightforward point. A function that's called on non-S2RAM paths shouldn't be named as if it's only for S2RAM.

And the function that's called for s2ram+standby should not be named as if it's also for swsusp...

Quoted 1 line

Ergo, those two functions are misnamed. End of story.

...which is not only misnamed, it is also actively confusing. (And someone _will_ ask me to call that function from swsusp, too.

...maybe we could solve it with a big fat comment?

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#29 lore raw
Quoted 7 lines · Pavel Machek
Quoted 3 lines

This is a very straightforward point. A function that's called on non-S2RAM paths shouldn't be named as if it's only for S2RAM.

And the function that's called for s2ram+standby should not be named as if it's also for swsusp...

Quoted 6 lines
Quoted 1 line

Ergo, those two functions are misnamed. End of story.

...which is not only misnamed, it is also actively confusing. (And someone _will_ ask me to call that function from swsusp, too.

...maybe we could solve it with a big fat comment?

So how about we don't call them s2ram which is confusing since s2ram is only one suspend state we support but call them suspend as David originally proposed and add a comment that since suspend-to-disk isn't a true suspend state, they are not called there?

Has anybody figured out if (and if yes, where) we should add them to some header file?

johannes

#30 lore raw

Hi!

Quoted 12 lines
Quoted 12 lines
Quoted 3 lines

This is a very straightforward point. A function that's called on non-S2RAM paths shouldn't be named as if it's only for S2RAM.

And the function that's called for s2ram+standby should not be named as if it's also for swsusp...

Quoted 1 line

Ergo, those two functions are misnamed. End of story.

...which is not only misnamed, it is also actively confusing. (And someone _will_ ask me to call that function from swsusp, too.

Quoted 6 lines
Quoted 1 line

...maybe we could solve it with a big fat comment?

So how about we don't call them s2ram which is confusing since s2ram is only one suspend state we support but call them suspend as David originally proposed and add a comment that since suspend-to-disk isn't a true suspend state, they are not called there?

calling them ..._suspend_... and explaining in comment is probably ok.

Quoted 2 lines

Has anybody figured out if (and if yes, where) we should add them to some header file?

include/linux/pm.h is probably the right place.

Feel free to add my acked-by: and send it to akpm.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#31 lore raw
Quoted 14 lines · Pavel Machek

Hi!

Quoted 12 lines
Quoted 12 lines
Quoted 3 lines

This is a very straightforward point. A function that's called on non-S2RAM paths shouldn't be named as if it's only for S2RAM.

And the function that's called for s2ram+standby should not be named as if it's also for swsusp...

Quoted 1 line

Ergo, those two functions are misnamed. End of story.

...which is not only misnamed, it is also actively confusing. (And someone _will_ ask me to call that function from swsusp, too.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

...maybe we could solve it with a big fat comment?

So how about we don't call them s2ram which is confusing since s2ram is only one suspend state we support but call them suspend as David originally proposed and add a comment that since suspend-to-disk isn't a true suspend state, they are not called there?

calling them ..._suspend_... and explaining in comment is probably ok.

Yah, I'm fine with that too.

Quoted 11 lines
Quoted 2 lines

Has anybody figured out if (and if yes, where) we should add them to some header file?

include/linux/pm.h is probably the right place.

Feel free to add my acked-by: and send it to akpm.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#25 lore raw
In reply to Pavel Machek
Quoted 2 lines · Pavel Machek

Uf I thought you were going to s/CONFIG_SOFTWARE_SUSPEND/CONFIG/HIBERNATION/ over the kernel,

I think that's a really good idea. The small amount of churn in the short term will be far outweighed by the benefit in the long term.

Just do it.

Signature · 1 line
dwmw2