Skip to contentSkip to conversation

RFC: additional event for pm_notifier

PATCH Sebastian Ott 2 participants 11 messages Mar 17, 2010 – Mar 31, 2010

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

hi,

on s390 certain hw features which we normally enable in our init calls, get reset while restoring the hibernation image. so we need a trigger to reenable them before the device callbacks are called.

is it possible to add an additional event for the existing pm_notifier (something like the attached patch)?

regards
sebastian

---
 include/linux/notifier.h |    1 +
 kernel/power/hibernate.c |    2 ++
 2 files changed, 3 insertions(+)
include/linux/notifier.h +2 -0
Index: linux-2.6/include/linux/notifier.h
===================================================================
@@ -250,6 +250,8 @@ static inline int notifier_to_errno(int 
 #define PM_POST_SUSPEND		0x0004 /* Suspend finished */
 #define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
 #define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define PM_RESTORE_FINISHED	0x0007 /* Image restored, called prior to
+					  device callbacks */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and
kernel/power/hibernate.c +2 -0
Index: linux-2.6/kernel/power/hibernate.c
===================================================================
@@ -290,6 +290,8 @@ static int create_image(int platform_mod
 	if (!in_suspend)
 		platform_leave(platform_mode);
 
+	pm_notifier_call_chain(PM_RESTORE_FINISHED);
+
  Power_up:
 	sysdev_resume();
 	/* NOTE:  dpm_resume_noirq() is just a resume() for devices
#1 lore raw
Quoted 38 lines · Sebastian Ott

hi,

on s390 certain hw features which we normally enable in our init calls, get reset while restoring the hibernation image. so we need a trigger to reenable them before the device callbacks are called.

is it possible to add an additional event for the existing pm_notifier (something like the attached patch)?

regards
sebastian

---
 include/linux/notifier.h |    1 +
 kernel/power/hibernate.c |    2 ++
 2 files changed, 3 insertions(+)

Index: linux-2.6/include/linux/notifier.h
===================================================================

include/linux/notifier.h +2 -0
@@ -250,6 +250,8 @@ static inline int notifier_to_errno(int 
 #define PM_POST_SUSPEND		0x0004 /* Suspend finished */
 #define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
 #define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define PM_RESTORE_FINISHED	0x0007 /* Image restored, called prior to
+					  device callbacks */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and

Index: linux-2.6/kernel/power/hibernate.c
===================================================================

kernel/power/hibernate.c static int create_image(int platform_mod · line 293

Quoted 4 lines
kernel/power/hibernate.c +1 -0
@@ -290,6 +290,8 @@ static int create_image(int platform_mod
 	if (!in_suspend)
 		platform_leave(platform_mode);
 
+	pm_notifier_call_chain(PM_RESTORE_FINISHED);

Hmm. Why can't you put that in platform_leave()?

kernel/power/hibernate.c static int create_image(int platform_mod · line 297

Quoted 4 lines
kernel/power/hibernate.c +1 -0
+
  Power_up:
 	sysdev_resume();
 	/* NOTE:  dpm_resume_noirq() is just a resume() for devices

Rafael

#2 lore raw
Quoted 42 lines · Rafael J. Wysocki
Quoted 41 lines · Sebastian Ott

hi,

on s390 certain hw features which we normally enable in our init calls, get reset while restoring the hibernation image. so we need a trigger to reenable them before the device callbacks are called.

is it possible to add an additional event for the existing pm_notifier (something like the attached patch)?

regards
sebastian

---
 include/linux/notifier.h |    1 +
 kernel/power/hibernate.c |    2 ++
 2 files changed, 3 insertions(+)

Index: linux-2.6/include/linux/notifier.h
===================================================================

include/linux/notifier.h +2 -0
@@ -250,6 +250,8 @@ static inline int notifier_to_errno(int 
 #define PM_POST_SUSPEND		0x0004 /* Suspend finished */
 #define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
 #define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define PM_RESTORE_FINISHED	0x0007 /* Image restored, called prior to
+					  device callbacks */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and

Index: linux-2.6/kernel/power/hibernate.c
===================================================================

kernel/power/hibernate.c +0 -0
@@ -290,6 +290,8 @@ static int create_image(int platform_mod
 	if (!in_suspend)
 		platform_leave(platform_mode);
 
Quoted 3 lines

kernel/power/hibernate.c static int create_image(int platform_mod · line 293

Quoted 1 line
kernel/power/hibernate.c +1 -0
+	pm_notifier_call_chain(PM_RESTORE_FINISHED);

Hmm. Why can't you put that in platform_leave()?

thanks for the tip - i'll try that

Quoted 8 lines

kernel/power/hibernate.c static int create_image(int platform_mod · line 297

Quoted 5 lines
kernel/power/hibernate.c +1 -0
+
  Power_up:
 	sysdev_resume();
 	/* NOTE:  dpm_resume_noirq() is just a resume() for devices

Rafael

#3 lore raw
In reply to Rafael J. Wysocki
Quoted 42 lines · Rafael J. Wysocki
Quoted 41 lines · Sebastian Ott

hi,

on s390 certain hw features which we normally enable in our init calls, get reset while restoring the hibernation image. so we need a trigger to reenable them before the device callbacks are called.

is it possible to add an additional event for the existing pm_notifier (something like the attached patch)?

regards
sebastian

---
 include/linux/notifier.h |    1 +
 kernel/power/hibernate.c |    2 ++
 2 files changed, 3 insertions(+)

Index: linux-2.6/include/linux/notifier.h
===================================================================

include/linux/notifier.h +2 -0
@@ -250,6 +250,8 @@ static inline int notifier_to_errno(int 
 #define PM_POST_SUSPEND		0x0004 /* Suspend finished */
 #define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
 #define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define PM_RESTORE_FINISHED	0x0007 /* Image restored, called prior to
+					  device callbacks */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and

Index: linux-2.6/kernel/power/hibernate.c
===================================================================

kernel/power/hibernate.c +0 -0
@@ -290,6 +290,8 @@ static int create_image(int platform_mod
 	if (!in_suspend)
 		platform_leave(platform_mode);
 
Quoted 3 lines

kernel/power/hibernate.c static int create_image(int platform_mod · line 293

Quoted 1 line
kernel/power/hibernate.c +1 -0
+	pm_notifier_call_chain(PM_RESTORE_FINISHED);

Hmm. Why can't you put that in platform_leave()?

i'm confused, are you suggesting to put the actual statement in platform_leave? this would change that all these platform_* functions are nop's if platform_mode isn't set (i need the trigger independent of the hibernation_mode)

or are you suggesting to implement platform_hibernation_ops for s390?
- this seems a bit too much since i only need one trigger, and again this depends on the hibernation_mode

Quoted 8 lines

kernel/power/hibernate.c static int create_image(int platform_mod · line 297

Quoted 5 lines
kernel/power/hibernate.c +1 -0
+
  Power_up:
 	sysdev_resume();
 	/* NOTE:  dpm_resume_noirq() is just a resume() for devices

Rafael

#4 lore raw
Quoted 49 lines · Sebastian Ott
Quoted 42 lines · Rafael J. Wysocki
Quoted 41 lines · Sebastian Ott

hi,

on s390 certain hw features which we normally enable in our init calls, get reset while restoring the hibernation image. so we need a trigger to reenable them before the device callbacks are called.

is it possible to add an additional event for the existing pm_notifier (something like the attached patch)?

regards
sebastian

---
 include/linux/notifier.h |    1 +
 kernel/power/hibernate.c |    2 ++
 2 files changed, 3 insertions(+)

Index: linux-2.6/include/linux/notifier.h
===================================================================

include/linux/notifier.h +2 -0
@@ -250,6 +250,8 @@ static inline int notifier_to_errno(int 
 #define PM_POST_SUSPEND		0x0004 /* Suspend finished */
 #define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
 #define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define PM_RESTORE_FINISHED	0x0007 /* Image restored, called prior to
+					  device callbacks */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and

Index: linux-2.6/kernel/power/hibernate.c
===================================================================

kernel/power/hibernate.c +0 -0
@@ -290,6 +290,8 @@ static int create_image(int platform_mod
 	if (!in_suspend)
 		platform_leave(platform_mode);
 
Quoted 3 lines

kernel/power/hibernate.c static int create_image(int platform_mod · line 293

Quoted 1 line
kernel/power/hibernate.c +1 -0
+	pm_notifier_call_chain(PM_RESTORE_FINISHED);

Hmm. Why can't you put that in platform_leave()?

Quoted 6 lines

i'm confused, are you suggesting to put the actual statement in platform_leave? this would change that all these platform_* functions are nop's if platform_mode isn't set (i need the trigger independent of the hibernation_mode)

or are you suggesting to implement platform_hibernation_ops for s390?

This one.

Quoted 1 line

- this seems a bit too much since i only need one trigger,

So you don't need to implement the other ones. :-)

You'll need to remove the check in hibernation_set_ops(), but that's fine.

[Well, it's outdated anyway, but only ACPI has been using it so far.]

Quoted 1 line

and again this depends on the hibernation_mode

That's fine as well. If you define the ops, "platform" will be the default and if someone wants to shoot himself in the foot by changing that, it's his problem.

Rafael

#5 lore raw
Quoted 57 lines · Rafael J. Wysocki
Quoted 49 lines · Sebastian Ott
Quoted 42 lines · Rafael J. Wysocki
Quoted 41 lines · Sebastian Ott

hi,

on s390 certain hw features which we normally enable in our init calls, get reset while restoring the hibernation image. so we need a trigger to reenable them before the device callbacks are called.

is it possible to add an additional event for the existing pm_notifier (something like the attached patch)?

regards
sebastian

---
 include/linux/notifier.h |    1 +
 kernel/power/hibernate.c |    2 ++
 2 files changed, 3 insertions(+)

Index: linux-2.6/include/linux/notifier.h
===================================================================

include/linux/notifier.h +2 -0
@@ -250,6 +250,8 @@ static inline int notifier_to_errno(int 
 #define PM_POST_SUSPEND		0x0004 /* Suspend finished */
 #define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
 #define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define PM_RESTORE_FINISHED	0x0007 /* Image restored, called prior to
+					  device callbacks */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and

Index: linux-2.6/kernel/power/hibernate.c
===================================================================

kernel/power/hibernate.c +0 -0
@@ -290,6 +290,8 @@ static int create_image(int platform_mod
 	if (!in_suspend)
 		platform_leave(platform_mode);
 
Quoted 3 lines

kernel/power/hibernate.c static int create_image(int platform_mod · line 293

Quoted 1 line
kernel/power/hibernate.c +1 -0
+	pm_notifier_call_chain(PM_RESTORE_FINISHED);

Hmm. Why can't you put that in platform_leave()?

Quoted 6 lines

i'm confused, are you suggesting to put the actual statement in platform_leave? this would change that all these platform_* functions are nop's if platform_mode isn't set (i need the trigger independent of the hibernation_mode)

or are you suggesting to implement platform_hibernation_ops for s390?

Quoted 7 lines

This one.

Quoted 1 line

- this seems a bit too much since i only need one trigger,

So you don't need to implement the other ones. :-)

You'll need to remove the check in hibernation_set_ops(), but that's fine.

Oops, scratch that. It's not enough. There are a few helper functions in kernel/power/hibernate.c that will need to be updated along with that.

Rafael

#6 lore raw
Quoted 62 lines · Rafael J. Wysocki
Quoted 61 lines · Rafael J. Wysocki
Quoted 49 lines · Sebastian Ott
Quoted 42 lines · Rafael J. Wysocki
Quoted 41 lines · Sebastian Ott

hi,

on s390 certain hw features which we normally enable in our init calls, get reset while restoring the hibernation image. so we need a trigger to reenable them before the device callbacks are called.

is it possible to add an additional event for the existing pm_notifier (something like the attached patch)?

regards
sebastian

---
 include/linux/notifier.h |    1 +
 kernel/power/hibernate.c |    2 ++
 2 files changed, 3 insertions(+)

Index: linux-2.6/include/linux/notifier.h
===================================================================

include/linux/notifier.h +2 -0
@@ -250,6 +250,8 @@ static inline int notifier_to_errno(int 
 #define PM_POST_SUSPEND		0x0004 /* Suspend finished */
 #define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
 #define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define PM_RESTORE_FINISHED	0x0007 /* Image restored, called prior to
+					  device callbacks */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and

Index: linux-2.6/kernel/power/hibernate.c
===================================================================

kernel/power/hibernate.c +0 -0
@@ -290,6 +290,8 @@ static int create_image(int platform_mod
 	if (!in_suspend)
 		platform_leave(platform_mode);
 
Quoted 3 lines

kernel/power/hibernate.c static int create_image(int platform_mod · line 293

Quoted 1 line
kernel/power/hibernate.c +1 -0
+	pm_notifier_call_chain(PM_RESTORE_FINISHED);

Hmm. Why can't you put that in platform_leave()?

Quoted 6 lines

i'm confused, are you suggesting to put the actual statement in platform_leave? this would change that all these platform_* functions are nop's if platform_mode isn't set (i need the trigger independent of the hibernation_mode)

or are you suggesting to implement platform_hibernation_ops for s390?

This one.

Quoted 1 line

- this seems a bit too much since i only need one trigger,

Quoted 9 lines
Quoted 3 lines

So you don't need to implement the other ones. :-)

You'll need to remove the check in hibernation_set_ops(), but that's fine.

Oops, scratch that. It's not enough. There are a few helper functions in kernel/power/hibernate.c that will need to be updated along with that.

Rafael

ok, thanks again. i'll try that over the weekend

sebastian

#7 lore raw
In reply to Rafael J. Wysocki
Quoted 65 lines · Rafael J. Wysocki
Quoted 49 lines · Sebastian Ott
Quoted 42 lines · Rafael J. Wysocki
Quoted 41 lines · Sebastian Ott

hi,

on s390 certain hw features which we normally enable in our init calls, get reset while restoring the hibernation image. so we need a trigger to reenable them before the device callbacks are called.

is it possible to add an additional event for the existing pm_notifier (something like the attached patch)?

regards
sebastian

---
 include/linux/notifier.h |    1 +
 kernel/power/hibernate.c |    2 ++
 2 files changed, 3 insertions(+)

Index: linux-2.6/include/linux/notifier.h
===================================================================

include/linux/notifier.h +2 -0
@@ -250,6 +250,8 @@ static inline int notifier_to_errno(int 
 #define PM_POST_SUSPEND		0x0004 /* Suspend finished */
 #define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
 #define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define PM_RESTORE_FINISHED	0x0007 /* Image restored, called prior to
+					  device callbacks */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and

Index: linux-2.6/kernel/power/hibernate.c
===================================================================

kernel/power/hibernate.c +0 -0
@@ -290,6 +290,8 @@ static int create_image(int platform_mod
 	if (!in_suspend)
 		platform_leave(platform_mode);
 
Quoted 3 lines

kernel/power/hibernate.c static int create_image(int platform_mod · line 293

Quoted 1 line
kernel/power/hibernate.c +1 -0
+	pm_notifier_call_chain(PM_RESTORE_FINISHED);

Hmm. Why can't you put that in platform_leave()?

Quoted 6 lines

i'm confused, are you suggesting to put the actual statement in platform_leave? this would change that all these platform_* functions are nop's if platform_mode isn't set (i need the trigger independent of the hibernation_mode)

or are you suggesting to implement platform_hibernation_ops for s390?

This one.

Quoted 1 line

- this seems a bit too much since i only need one trigger,

So you don't need to implement the other ones. :-)

You'll need to remove the check in hibernation_set_ops(), but that's fine.

Quoted 7 lines

[Well, it's outdated anyway, but only ACPI has been using it so far.]

Quoted 1 line

and again this depends on the hibernation_mode

That's fine as well. If you define the ops, "platform" will be the default and if someone wants to shoot himself in the foot by changing that, it's his problem.

hi,

i've got that working, but after some more thinking
i really didn't like that approach - in short, if we do that, hibernation on s390 will allways be bound to the plattform mode (with certain devices we will crash in our restore callbacks if we haven't previously enabled the hw-feature, which those devices use)

and to the your-gun-your-foot argument - if someone tests hibernation on s390 using the reboot mode he sure cannot expect the potential panic, depending on the involved devices

do you absolutely oppose against the idea of a new notifier event?

regards
sebastian

#8 lore raw
Quoted 10 lines · Sebastian Ott

hi,

i've got that working, but after some more thinking
i really didn't like that approach - in short, if we do that, hibernation on s390 will allways be bound to the plattform mode (with certain devices we will crash in our restore callbacks if we haven't previously enabled the hw-feature, which those devices use)

Quoted 3 lines

and to the your-gun-your-foot argument - if someone tests hibernation on s390 using the reboot mode he sure cannot expect the potential panic, depending on the involved devices

Well, on x86 using ACPI the reboot and shutdown modes only work by fortunate conincidence, so to speak (if at all).

That said, your argument is reasonable.

Quoted 1 line

do you absolutely oppose against the idea of a new notifier event?

Yes, I do. To the extent that I'd rather change the entire design so that the "hibernation modes" would be platform-dependent.

Thanks,
Rafael

#9 lore raw
Quoted 18 lines · Rafael J. Wysocki
Quoted 10 lines · Sebastian Ott

hi,

i've got that working, but after some more thinking
i really didn't like that approach - in short, if we do that, hibernation on s390 will allways be bound to the plattform mode (with certain devices we will crash in our restore callbacks if we haven't previously enabled the hw-feature, which those devices use)

Quoted 3 lines

and to the your-gun-your-foot argument - if someone tests hibernation on s390 using the reboot mode he sure cannot expect the potential panic, depending on the involved devices

Well, on x86 using ACPI the reboot and shutdown modes only work by fortunate conincidence, so to speak (if at all).

Quoted 6 lines

That said, your argument is reasonable.

Quoted 1 line

do you absolutely oppose against the idea of a new notifier event?

Yes, I do. To the extent that I'd rather change the entire design so that the "hibernation modes" would be platform-dependent.

ok. i implemented a hook in arch/s390

thanks
sebastian

#10 lore raw
Quoted 21 lines · Sebastian Ott
Quoted 18 lines · Rafael J. Wysocki
Quoted 10 lines · Sebastian Ott

hi,

i've got that working, but after some more thinking
i really didn't like that approach - in short, if we do that, hibernation on s390 will allways be bound to the plattform mode (with certain devices we will crash in our restore callbacks if we haven't previously enabled the hw-feature, which those devices use)

Quoted 3 lines

and to the your-gun-your-foot argument - if someone tests hibernation on s390 using the reboot mode he sure cannot expect the potential panic, depending on the involved devices

Well, on x86 using ACPI the reboot and shutdown modes only work by fortunate conincidence, so to speak (if at all).

Quoted 8 lines
Quoted 6 lines

That said, your argument is reasonable.

Quoted 1 line

do you absolutely oppose against the idea of a new notifier event?

Yes, I do. To the extent that I'd rather change the entire design so that the "hibernation modes" would be platform-dependent.

ok. i implemented a hook in arch/s390

Thanks a lot.

Rafael