public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 -fixes] riscv: kexec: Avoid deadlock in kexec crash path
@ 2024-06-26  2:33 Song Shuai
  2024-06-26  6:32 ` [V2,-fixes] " takakura
  2024-07-04 13:10 ` [PATCH V2 -fixes] " patchwork-bot+linux-riscv
  0 siblings, 2 replies; 3+ messages in thread
From: Song Shuai @ 2024-06-26  2:33 UTC (permalink / raw)
  To: takakura, alex, paul.walmsley, palmer
  Cc: aou, bhe, songshuaishuai, akpm, guoren, xianting.tian,
	linux-riscv, linux-kernel

If the kexec crash code is called in the interrupt context, the
machine_kexec_mask_interrupts() function will trigger a deadlock while
trying to acquire the irqdesc spinlock and then deactivate irqchip in
irq_set_irqchip_state() function.

Unlike arm64, riscv only requires irq_eoi handler to complete EOI and
keeping irq_set_irqchip_state() will only leave this possible deadlock
without any use. So we simply remove it.

Link: https://lore.kernel.org/linux-riscv/20231208111015.173237-1-songshuaishuai@tinylab.org/
Fixes: b17d19a5314a ("riscv: kexec: Fixup irq controller broken in kexec crash path")
Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
---
Changes since V1:
https://lore.kernel.org/linux-riscv/20231208111015.173237-1-songshuaishuai@tinylab.org/
- update the commit log as @Ryo elaborated 
- rebase on Linux 6.10-rc3

---
 arch/riscv/kernel/machine_kexec.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/arch/riscv/kernel/machine_kexec.c b/arch/riscv/kernel/machine_kexec.c
index ed9cad20c039..3c830a6f7ef4 100644
--- a/arch/riscv/kernel/machine_kexec.c
+++ b/arch/riscv/kernel/machine_kexec.c
@@ -121,20 +121,12 @@ static void machine_kexec_mask_interrupts(void)
 
 	for_each_irq_desc(i, desc) {
 		struct irq_chip *chip;
-		int ret;
 
 		chip = irq_desc_get_chip(desc);
 		if (!chip)
 			continue;
 
-		/*
-		 * First try to remove the active state. If this
-		 * fails, try to EOI the interrupt.
-		 */
-		ret = irq_set_irqchip_state(i, IRQCHIP_STATE_ACTIVE, false);
-
-		if (ret && irqd_irq_inprogress(&desc->irq_data) &&
-		    chip->irq_eoi)
+		if (chip->irq_eoi && irqd_irq_inprogress(&desc->irq_data))
 			chip->irq_eoi(&desc->irq_data);
 
 		if (chip->irq_mask)
-- 
2.39.2


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

* Re: [V2,-fixes] riscv: kexec: Avoid deadlock in kexec crash path
  2024-06-26  2:33 [PATCH V2 -fixes] riscv: kexec: Avoid deadlock in kexec crash path Song Shuai
@ 2024-06-26  6:32 ` takakura
  2024-07-04 13:10 ` [PATCH V2 -fixes] " patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: takakura @ 2024-06-26  6:32 UTC (permalink / raw)
  To: songshuaishuai, alex, paul.walmsley, palmer
  Cc: aou, bhe, guoren, xianting.tian, akpm, takakura, linux-riscv,
	linux-kernel

On Wed, 26 June 2024, Song Shuai wrote:
>If the kexec crash code is called in the interrupt context, the
>machine_kexec_mask_interrupts() function will trigger a deadlock while
>trying to acquire the irqdesc spinlock and then deactivate irqchip in
>irq_set_irqchip_state() function.
>
>Unlike arm64, riscv only requires irq_eoi handler to complete EOI and
>keeping irq_set_irqchip_state() will only leave this possible deadlock
>without any use. So we simply remove it.
>
>Link: https://lore.kernel.org/linux-riscv/20231208111015.173237-1-songshuaishuai@tinylab.org/
>Fixes: b17d19a5314a ("riscv: kexec: Fixup irq controller broken in kexec crash path")
>Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
>---
>Changes since V1:
>https://lore.kernel.org/linux-riscv/20231208111015.173237-1-songshuaishuai@tinylab.org/
>- update the commit log as @Ryo elaborated 
>- rebase on Linux 6.10-rc3

Reviewed-by: Ryo Takakura <takakura@valinux.co.jp>

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

* Re: [PATCH V2 -fixes] riscv: kexec: Avoid deadlock in kexec crash path
  2024-06-26  2:33 [PATCH V2 -fixes] riscv: kexec: Avoid deadlock in kexec crash path Song Shuai
  2024-06-26  6:32 ` [V2,-fixes] " takakura
@ 2024-07-04 13:10 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-07-04 13:10 UTC (permalink / raw)
  To: Song Shuai
  Cc: linux-riscv, takakura, alex, paul.walmsley, palmer, aou, bhe,
	akpm, guoren, xianting.tian, linux-kernel

Hello:

This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Wed, 26 Jun 2024 10:33:16 +0800 you wrote:
> If the kexec crash code is called in the interrupt context, the
> machine_kexec_mask_interrupts() function will trigger a deadlock while
> trying to acquire the irqdesc spinlock and then deactivate irqchip in
> irq_set_irqchip_state() function.
> 
> Unlike arm64, riscv only requires irq_eoi handler to complete EOI and
> keeping irq_set_irqchip_state() will only leave this possible deadlock
> without any use. So we simply remove it.
> 
> [...]

Here is the summary with links:
  - [V2,-fixes] riscv: kexec: Avoid deadlock in kexec crash path
    https://git.kernel.org/riscv/c/c562ba719df5

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-07-04 13:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-26  2:33 [PATCH V2 -fixes] riscv: kexec: Avoid deadlock in kexec crash path Song Shuai
2024-06-26  6:32 ` [V2,-fixes] " takakura
2024-07-04 13:10 ` [PATCH V2 -fixes] " patchwork-bot+linux-riscv

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