* [PATCH] powerpc/powernv: Make opal_event_shutdown() callable from IRQ context
@ 2017-09-29 3:58 Michael Ellerman
2017-09-29 5:24 ` Balbir Singh
2017-10-08 8:43 ` Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Michael Ellerman @ 2017-09-29 3:58 UTC (permalink / raw)
To: linuxppc-dev; +Cc: anton, rlippert
In opal_event_shutdown() we free all the IRQs hanging off the
opal_event_irqchip. However it's not safe to do so if we're called
from IRQ context, because free_irq() wants to synchronise versus IRQ
context. This can lead to warnings and a stuck system.
For example from sysrq-b:
Trying to free IRQ 17 from IRQ context!
------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at kernel/irq/manage.c:1461 __free_irq+0x398/0x8d0
...
NIP __free_irq+0x398/0x8d0
LR __free_irq+0x394/0x8d0
Call Trace:
__free_irq+0x394/0x8d0 (unreliable)
free_irq+0xa4/0x140
opal_event_shutdown+0x128/0x180
opal_shutdown+0x1c/0xb0
pnv_shutdown+0x20/0x40
machine_restart+0x38/0x90
emergency_restart+0x28/0x40
sysrq_handle_reboot+0x24/0x40
__handle_sysrq+0x198/0x590
hvc_poll+0x48c/0x8c0
hvc_handle_interrupt+0x1c/0x50
__handle_irq_event_percpu+0xe8/0x6e0
handle_irq_event_percpu+0x34/0xe0
handle_irq_event+0xc4/0x210
handle_level_irq+0x250/0x770
generic_handle_irq+0x5c/0xa0
opal_handle_events+0x11c/0x240
opal_interrupt+0x38/0x50
__handle_irq_event_percpu+0xe8/0x6e0
handle_irq_event_percpu+0x34/0xe0
handle_irq_event+0xc4/0x210
handle_fasteoi_irq+0x174/0xa10
generic_handle_irq+0x5c/0xa0
__do_irq+0xbc/0x4e0
call_do_irq+0x14/0x24
do_IRQ+0x18c/0x540
hardware_interrupt_common+0x158/0x180
We can avoid that by using disable_irq_nosync() rather than
free_irq(). Although it doesn't fully free the IRQ, it should be
sufficient when we're shutting down, particularly in an emergency.
Add an in_interrupt() check and use free_irq() when we're shutting
down normally. It's probably OK to use disable_irq_nosync() in that
case too, but for now it's safer to leave that behaviour as-is.
Fixes: 9f0fd0499d30 ("powerpc/powernv: Add a virtual irqchip for opal events")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/platforms/powernv/opal-irqchip.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powernv/opal-irqchip.c b/arch/powerpc/platforms/powernv/opal-irqchip.c
index ecdcba9d1220..9d1b8c0aaf93 100644
--- a/arch/powerpc/platforms/powernv/opal-irqchip.c
+++ b/arch/powerpc/platforms/powernv/opal-irqchip.c
@@ -174,8 +174,14 @@ void opal_event_shutdown(void)
/* First free interrupts, which will also mask them */
for (i = 0; i < opal_irq_count; i++) {
- if (opal_irqs[i])
+ if (!opal_irqs[i])
+ continue;
+
+ if (in_interrupt())
+ disable_irq_nosync(opal_irqs[i]);
+ else
free_irq(opal_irqs[i], NULL);
+
opal_irqs[i] = 0;
}
}
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/powernv: Make opal_event_shutdown() callable from IRQ context
2017-09-29 3:58 [PATCH] powerpc/powernv: Make opal_event_shutdown() callable from IRQ context Michael Ellerman
@ 2017-09-29 5:24 ` Balbir Singh
2017-10-08 8:43 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Balbir Singh @ 2017-09-29 5:24 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, rlippert, anton
On Fri, 29 Sep 2017 13:58:02 +1000
Michael Ellerman <mpe@ellerman.id.au> wrote:
> In opal_event_shutdown() we free all the IRQs hanging off the
> opal_event_irqchip. However it's not safe to do so if we're called
> from IRQ context, because free_irq() wants to synchronise versus IRQ
> context. This can lead to warnings and a stuck system.
>
> For example from sysrq-b:
>
> Trying to free IRQ 17 from IRQ context!
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 0 at kernel/irq/manage.c:1461 __free_irq+0x398/0x8d0
> ...
> NIP __free_irq+0x398/0x8d0
> LR __free_irq+0x394/0x8d0
> Call Trace:
> __free_irq+0x394/0x8d0 (unreliable)
> free_irq+0xa4/0x140
> opal_event_shutdown+0x128/0x180
> opal_shutdown+0x1c/0xb0
> pnv_shutdown+0x20/0x40
> machine_restart+0x38/0x90
> emergency_restart+0x28/0x40
> sysrq_handle_reboot+0x24/0x40
> __handle_sysrq+0x198/0x590
> hvc_poll+0x48c/0x8c0
> hvc_handle_interrupt+0x1c/0x50
> __handle_irq_event_percpu+0xe8/0x6e0
> handle_irq_event_percpu+0x34/0xe0
> handle_irq_event+0xc4/0x210
> handle_level_irq+0x250/0x770
> generic_handle_irq+0x5c/0xa0
> opal_handle_events+0x11c/0x240
> opal_interrupt+0x38/0x50
> __handle_irq_event_percpu+0xe8/0x6e0
> handle_irq_event_percpu+0x34/0xe0
> handle_irq_event+0xc4/0x210
> handle_fasteoi_irq+0x174/0xa10
> generic_handle_irq+0x5c/0xa0
> __do_irq+0xbc/0x4e0
> call_do_irq+0x14/0x24
> do_IRQ+0x18c/0x540
> hardware_interrupt_common+0x158/0x180
>
> We can avoid that by using disable_irq_nosync() rather than
> free_irq(). Although it doesn't fully free the IRQ, it should be
> sufficient when we're shutting down, particularly in an emergency.
>
> Add an in_interrupt() check and use free_irq() when we're shutting
> down normally. It's probably OK to use disable_irq_nosync() in that
> case too, but for now it's safer to leave that behaviour as-is.
>
> Fixes: 9f0fd0499d30 ("powerpc/powernv: Add a virtual irqchip for opal events")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
Acked-by: Balbir Singh <bsingharora@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: powerpc/powernv: Make opal_event_shutdown() callable from IRQ context
2017-09-29 3:58 [PATCH] powerpc/powernv: Make opal_event_shutdown() callable from IRQ context Michael Ellerman
2017-09-29 5:24 ` Balbir Singh
@ 2017-10-08 8:43 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2017-10-08 8:43 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev; +Cc: rlippert, anton
On Fri, 2017-09-29 at 03:58:02 UTC, Michael Ellerman wrote:
> In opal_event_shutdown() we free all the IRQs hanging off the
> opal_event_irqchip. However it's not safe to do so if we're called
> from IRQ context, because free_irq() wants to synchronise versus IRQ
> context. This can lead to warnings and a stuck system.
>
> For example from sysrq-b:
>
> Trying to free IRQ 17 from IRQ context!
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 0 at kernel/irq/manage.c:1461 __free_irq+0x398/0x8d0
> ...
> NIP __free_irq+0x398/0x8d0
> LR __free_irq+0x394/0x8d0
> Call Trace:
> __free_irq+0x394/0x8d0 (unreliable)
> free_irq+0xa4/0x140
> opal_event_shutdown+0x128/0x180
> opal_shutdown+0x1c/0xb0
> pnv_shutdown+0x20/0x40
> machine_restart+0x38/0x90
> emergency_restart+0x28/0x40
> sysrq_handle_reboot+0x24/0x40
> __handle_sysrq+0x198/0x590
> hvc_poll+0x48c/0x8c0
> hvc_handle_interrupt+0x1c/0x50
> __handle_irq_event_percpu+0xe8/0x6e0
> handle_irq_event_percpu+0x34/0xe0
> handle_irq_event+0xc4/0x210
> handle_level_irq+0x250/0x770
> generic_handle_irq+0x5c/0xa0
> opal_handle_events+0x11c/0x240
> opal_interrupt+0x38/0x50
> __handle_irq_event_percpu+0xe8/0x6e0
> handle_irq_event_percpu+0x34/0xe0
> handle_irq_event+0xc4/0x210
> handle_fasteoi_irq+0x174/0xa10
> generic_handle_irq+0x5c/0xa0
> __do_irq+0xbc/0x4e0
> call_do_irq+0x14/0x24
> do_IRQ+0x18c/0x540
> hardware_interrupt_common+0x158/0x180
>
> We can avoid that by using disable_irq_nosync() rather than
> free_irq(). Although it doesn't fully free the IRQ, it should be
> sufficient when we're shutting down, particularly in an emergency.
>
> Add an in_interrupt() check and use free_irq() when we're shutting
> down normally. It's probably OK to use disable_irq_nosync() in that
> case too, but for now it's safer to leave that behaviour as-is.
>
> Fixes: 9f0fd0499d30 ("powerpc/powernv: Add a virtual irqchip for opal events")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Acked-by: Balbir Singh <bsingharora@gmail.com>
Applied to powerpc next.
https://git.kernel.org/powerpc/c/c6baa077b784c3b37391a8c11f433e
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-08 8:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-29 3:58 [PATCH] powerpc/powernv: Make opal_event_shutdown() callable from IRQ context Michael Ellerman
2017-09-29 5:24 ` Balbir Singh
2017-10-08 8:43 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).