PM/reboot: call syscore_shutdown() after disable_nonboot_cpus()
PATCH 1/1 PM/reboot: call syscore_shutdown() after disable_nonboot_cpus()
As commit 40dc166c (PM / Core: Introduce struct syscore_ops for core subsystems PM) say, syscore_ops operations should be carried with one CPU on-line and interrupts disabled. However, after commit f96972f2d (kernel/sys.c: call disable_nonboot_cpus() in kernel_restart()), syscore_shutdown() is called before disable_nonboot_cpus(), so break the rules. We have a MIPS machine with a 8259A PIC, and there is an external timer (HPET) linked at 8259A. Since 8259A has been shutdown too early (by syscore_shutdown()), disable_nonboot_cpus() runs without timer interrupt, so it hangs and reboot fails. This patch call syscore_shutdown() a little later (after disable_nonboot_cpus()) to avoid reboot failure, this is the same way as poweroff does.
BTW, add disable_nonboot_cpus() in kernel_halt() for consistency.
--- kernel/sys.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
kernel/sys.c +2 -1
@@ -324,7 +324,6 @@ void kernel_restart_prepare(char *cmd) system_state =SYSTEM_RESTART ;usermodehelper_disable ();device_shutdown (); -syscore_shutdown (); }/**
@@ -370,6 +369,7 @@ void kernel_restart(char *cmd) {kernel_restart_prepare (cmd);disable_nonboot_cpus (); +syscore_shutdown ();if (!cmd)printk (KERN_EMERG "Restarting system.\n" );else
@@ -395,6 +395,7 @@ static void kernel_shutdown_prepare(enum system_states state)void kernel_halt (void ) {kernel_shutdown_prepare (SYSTEM_HALT ); +disable_nonboot_cpus ();syscore_shutdown ();printk (KERN_EMERG "System halted.\n" );kmsg_dump (KMSG_DUMP_HALT );
Signature · 1 line
1.7.7.3
Quoted 12 lines · Huacai Chen
As commit
40dc166c(PM / Core: Introduce structsyscore_opsfor core subsystems PM) say,syscore_opsoperations should be carried with one CPU on-line and interrupts disabled. However, after commitf96972f2d(kernel/sys.c: calldisable_nonboot_cpus()inkernel_restart()),syscore_shutdown()is called beforedisable_nonboot_cpus(), so break the rules. We have a MIPS machine with a 8259A PIC, and there is an external timer (HPET) linked at 8259A. Since 8259A has been shutdown too early (bysyscore_shutdown()),disable_nonboot_cpus()runs without timer interrupt, so it hangs and reboot fails. This patch callsyscore_shutdown()a little later (afterdisable_nonboot_cpus()) to avoid reboot failure, this is the same way as poweroff does.
Quoted 4 lines
BTW, add
disable_nonboot_cpus()inkernel_halt()for consistency.Signed-off-by Huacai Chen <[email protected]>Cc <[email protected]>
While I agree with the changes, I'm not sure if I'm the right maintainer, as this isn't really PM code.
Andrew, should I take this?
Rafael
Quoted 33 lines
--- kernel/sys.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)kernel/sys.c +2
-1@@ -324,7 +324,6 @@ void kernel_restart_prepare(char *cmd) system_state =SYSTEM_RESTART ;usermodehelper_disable ();device_shutdown (); -syscore_shutdown (); }/** @@ -370,6 +369,7 @@ void kernel_restart(char *cmd) {kernel_restart_prepare (cmd);disable_nonboot_cpus (); +syscore_shutdown ();if (!cmd)printk (KERN_EMERG "Restarting system.\n" );else @@ -395,6 +395,7 @@ static void kernel_shutdown_prepare(enum system_states state)void kernel_halt (void ) {kernel_shutdown_prepare (SYSTEM_HALT ); +disable_nonboot_cpus ();syscore_shutdown ();printk (KERN_EMERG "System halted.\n" );kmsg_dump (KMSG_DUMP_HALT );
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Greg KH
maintainerQuoted 15 lines · Rafael J. Wysocki
Quoted 14 lines · Huacai Chen
As commit
40dc166c(PM / Core: Introduce structsyscore_opsfor core subsystems PM) say,syscore_opsoperations should be carried with one CPU on-line and interrupts disabled. However, after commitf96972f2d(kernel/sys.c: calldisable_nonboot_cpus()inkernel_restart()),syscore_shutdown()is called beforedisable_nonboot_cpus(), so break the rules. We have a MIPS machine with a 8259A PIC, and there is an external timer (HPET) linked at 8259A. Since 8259A has been shutdown too early (bysyscore_shutdown()),disable_nonboot_cpus()runs without timer interrupt, so it hangs and reboot fails. This patch callsyscore_shutdown()a little later (afterdisable_nonboot_cpus()) to avoid reboot failure, this is the same way as poweroff does.BTW, add
disable_nonboot_cpus()inkernel_halt()for consistency.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Huacai Chen <[email protected]>Cc <[email protected]>While I agree with the changes, I'm not sure if I'm the right maintainer, as this isn't really PM code.
Andrew, should I take this?
Andrew is on vacation for a few weeks, so you might need to take this through your tree.
greg k-h
Quoted 19 lines · Greg KH
Quoted 18 lines · Rafael J. Wysocki
Quoted 16 lines · Huacai Chen
As commit
40dc166c(PM / Core: Introduce structsyscore_opsfor core subsystems PM) say,syscore_opsoperations should be carried with one CPU on-line and interrupts disabled. However, after commitf96972f2d(kernel/sys.c: calldisable_nonboot_cpus()inkernel_restart()),syscore_shutdown()is called beforedisable_nonboot_cpus(), so break the rules. We have a MIPS machine with a 8259A PIC, and there is an external timer (HPET) linked at 8259A. Since 8259A has been shutdown too early (bysyscore_shutdown()),disable_nonboot_cpus()runs without timer interrupt, so it hangs and reboot fails. This patch callsyscore_shutdown()a little later (afterdisable_nonboot_cpus()) to avoid reboot failure, this is the same way as poweroff does.BTW, add
disable_nonboot_cpus()inkernel_halt()for consistency.Signed-off-by Huacai Chen <[email protected]>Cc <[email protected]>
Quoted 7 lines
Quoted 4 lines
While I agree with the changes, I'm not sure if I'm the right maintainer, as this isn't really PM code.
Andrew, should I take this?
Andrew is on vacation for a few weeks, so you might need to take this through your tree.
OK
But, it looks like we should actually disable interrupts on the remaining CPU after we've called disable_nonboot_cpus() so that the syscore_shutdown() assumptions are satisfied which the patch doesn't do.
Chen (I apologize if that's not the right part of your full name to use here), do you think that's not necessary and if so, then for what reason?
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 33 lines · Greg KH
Quoted 21 lines · Rafael J. Wysocki
Quoted 3 lines · Huacai Chen
Quoted 2 lines
As commit
40dc166c(PM / Core: Introduce structsyscore_opsfor core subsystems PM) say,syscore_opsoperations should be carried withone
Quoted 6 lines
Quoted 6 lines
CPU on-line and interrupts disabled. However, after commit
f96972f2d(kernel/sys.c: calldisable_nonboot_cpus()inkernel_restart()),syscore_shutdown()is called beforedisable_nonboot_cpus(), so break the rules. We have a MIPS machine with a 8259A PIC, and there is an external timer (HPET) linked at 8259A. Since 8259A has been shutdown too early (bysyscore_shutdown()),disable_nonboot_cpus()runswithout
Quoted 9 lines
Quoted 8 lines
timer interrupt, so it hangs and reboot fails. This patch call
syscore_shutdown()a little later (afterdisable_nonboot_cpus()) to avoid reboot failure, this is the same way as poweroff does.BTW, add
disable_nonboot_cpus()inkernel_halt()for consistency.Signed-off-by Huacai Chen <[email protected]>Cc <[email protected]>Quoted 8 lines
Quoted 1 line
While I agree with the changes, I'm not sure if I'm the right
maintainer,
Quoted 3 lines
as this isn't really PM code.
Andrew, should I take this?
Andrew is on vacation for a few weeks, so you might need to take this through your tree.
OK
Quoted 8 lines
But, it looks like we should actually disable interrupts on the remaining CPU after we've called
disable_nonboot_cpus()so that thesyscore_shutdown()
assumptions are satisfied which the patch doesn't do.Chen (I apologize if that's not the right part of your full name to use here),
do you think that's not necessary and if so, then for what reason?
Reboot and poweroff are both OK after I move syscore_shutdown(), I also don't know whether we should disable interrupts. Since you are the author of commit 40dc166c (PM / Core: Introduce struct syscore_ops for core subsystems
PM), please tell me why syscore_shutdown() need interrupt disabled? (I just
know that syscore_shutdown() will cause disable_nonboot_cpus() hang)
BTW, Chen is my last name and you needn't worry about this.
Quoted 8 lines
Rafael
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 38 lines · On Monday, April 08, 2013 10:51:45 AM [email protected] wrote:
Quoted 38 lines · Greg KH
Quoted 21 lines · Rafael J. Wysocki
Quoted 3 lines · Huacai Chen
Quoted 2 lines
As commit
40dc166c(PM / Core: Introduce structsyscore_opsfor core subsystems PM) say,syscore_opsoperations should be carried withone
Quoted 6 lines
Quoted 6 lines
CPU on-line and interrupts disabled. However, after commit
f96972f2d(kernel/sys.c: calldisable_nonboot_cpus()inkernel_restart()),syscore_shutdown()is called beforedisable_nonboot_cpus(), so break the rules. We have a MIPS machine with a 8259A PIC, and there is an external timer (HPET) linked at 8259A. Since 8259A has been shutdown too early (bysyscore_shutdown()),disable_nonboot_cpus()runswithout
Quoted 9 lines
Quoted 8 lines
timer interrupt, so it hangs and reboot fails. This patch call
syscore_shutdown()a little later (afterdisable_nonboot_cpus()) to avoid reboot failure, this is the same way as poweroff does.BTW, add
disable_nonboot_cpus()inkernel_halt()for consistency.Signed-off-by Huacai Chen <[email protected]>Cc <[email protected]>Quoted 8 lines
Quoted 1 line
While I agree with the changes, I'm not sure if I'm the right
maintainer,
Quoted 3 lines
as this isn't really PM code.
Andrew, should I take this?
Andrew is on vacation for a few weeks, so you might need to take this through your tree.
OK
But, it looks like we should actually disable interrupts on the remaining CPU after we've called
disable_nonboot_cpus()so that thesyscore_shutdown()
assumptions are satisfied which the patch doesn't do.
Quoted 8 lines
Quoted 3 lines
Chen (I apologize if that's not the right part of your full name to use here),
do you think that's not necessary and if so, then for what reason?Reboot and poweroff are both OK after I move
syscore_shutdown(), I also don't know whether we should disable interrupts. Since you are the author of commit40dc166c(PM / Core: Introduce structsyscore_opsfor core subsystems
PM), please tell me whysyscore_shutdown()need interrupt disabled?
Well, the syscore_ callbacks generally do things that may go wrong when an interrupt comes in while they are being done. At least that's what happens for the suspend/resume syscore_ callbacks, but I'm not really sure about the shutdown ones.
I suppose we can leave it as is for the time being. At least I'm not aware of any problems related to that.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 65 lines · On Monday, April 08, 2013 10:51:45 AM [email protected] wrote:
Quoted 50 lines
Quoted 4 lines · Greg KH
Quoted 3 lines · Rafael J. Wysocki
Quoted 2 lines · Huacai Chen
Quoted 1 line
As commit
40dc166c(PM / Core: Introduce structsyscore_opsforcore
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
subsystems PM) say,
syscore_opsoperations should be carried withone
Quoted 1 line
Quoted 1 line
CPU on-line and interrupts disabled. However, after commit
f96972f2dQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
(
kernel/sys.c: calldisable_nonboot_cpus()inkernel_restart()),syscore_shutdown()is called beforedisable_nonboot_cpus(), sobreak
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
the rules. We have a MIPS machine with a 8259A PIC, and there is
an
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
external timer (HPET) linked at 8259A. Since 8259A has been
shutdown
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
too early (by
syscore_shutdown()),disable_nonboot_cpus()runswithout
Quoted 2 lines
Quoted 2 lines
timer interrupt, so it hangs and reboot fails. This patch call
syscore_shutdown()a little later (afterdisable_nonboot_cpus())to
Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
avoid reboot failure, this is the same way as poweroff does.
BTW, add
disable_nonboot_cpus()inkernel_halt()for consistency.Signed-off-by Huacai Chen <[email protected]>Cc <[email protected]>While I agree with the changes, I'm not sure if I'm the right
maintainer,
Quoted 2 lines
as this isn't really PM code.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Andrew, should I take this?
Andrew is on vacation for a few weeks, so you might need to take this through your tree.
OK
But, it looks like we should actually disable interrupts on the
remaining
Quoted 5 lines
CPU after we've called
disable_nonboot_cpus()so that thesyscore_shutdown()
assumptions are satisfied which the patch doesn't do.Chen (I apologize if that's not the right part of your full name to
use
Quoted 2 lines
here),
do you think that's not necessary and if so, then for what reason?Quoted 6 lines
Reboot and poweroff are both OK after I move
syscore_shutdown(), I also don't
know whether we should disable interrupts. Since you are the author of commit40dc166c(PM / Core: Introduce structsyscore_opsfor core subsystems
PM), please tell me whysyscore_shutdown()need interrupt disabled?Well, the
syscore_callbacks generally do things that may go wrong when an interrupt comes in while they are being done. At least that's what happens
for the suspend/resumesyscore_callbacks, but I'm not really sure about the
shutdown ones.
Quoted 3 lines
I suppose we can leave it as is for the time being. At least I'm not aware of
any problems related to that.
OK, linux-3.0, 3.2 and 3.4 -stable branch also need this patch because they also have merged the commit f96972f2d (kernel/sys.c: call disable_nonboot_cpus() in kernel_restart())
Quoted 9 lines
Thanks,
Rafael--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.