Patch "riscv: kexec: Fixup irq controller broken in kexec crash path" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    riscv: kexec: Fixup irq controller broken in kexec crash path

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     riscv-kexec-fixup-irq-controller-broken-in-kexec-cra.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d939a47576f17848db80adf2307553fe5a982a6c
Author: Guo Ren <guoren@xxxxxxxxxx>
Date:   Thu Oct 20 10:16:02 2022 -0400

    riscv: kexec: Fixup irq controller broken in kexec crash path
    
    [ Upstream commit b17d19a5314a37f7197afd1a0200affd21a7227d ]
    
    If a crash happens on cpu3 and all interrupts are binding on cpu0, the
    bad irq routing will cause a crash kernel which can't receive any irq.
    Because crash kernel won't clean up all harts' PLIC enable bits in
    enable registers. This patch is similar to 9141a003a491 ("ARM: 7316/1:
    kexec: EOI active and mask all interrupts in kexec crash path") and
    78fd584cdec0 ("arm64: kdump: implement machine_crash_shutdown()"), and
    PowerPC also has the same mechanism.
    
    Fixes: fba8a8674f68 ("RISC-V: Add kexec support")
    Signed-off-by: Guo Ren <guoren@xxxxxxxxxxxxxxxxx>
    Signed-off-by: Guo Ren <guoren@xxxxxxxxxx>
    Reviewed-by: Xianting Tian <xianting.tian@xxxxxxxxxxxxxxxxx>
    Cc: Nick Kossifidis <mick@xxxxxxxxxxxx>
    Cc: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221020141603.2856206-2-guoren@xxxxxxxxxx
    Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/riscv/kernel/machine_kexec.c b/arch/riscv/kernel/machine_kexec.c
index ee79e6839b86..db41c676e5a2 100644
--- a/arch/riscv/kernel/machine_kexec.c
+++ b/arch/riscv/kernel/machine_kexec.c
@@ -15,6 +15,8 @@
 #include <linux/compiler.h>	/* For unreachable() */
 #include <linux/cpu.h>		/* For cpu_down() */
 #include <linux/reboot.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
 
 /*
  * kexec_image_info - Print received image details
@@ -154,6 +156,37 @@ void crash_smp_send_stop(void)
 	cpus_stopped = 1;
 }
 
+static void machine_kexec_mask_interrupts(void)
+{
+	unsigned int i;
+	struct irq_desc *desc;
+
+	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)
+			chip->irq_eoi(&desc->irq_data);
+
+		if (chip->irq_mask)
+			chip->irq_mask(&desc->irq_data);
+
+		if (chip->irq_disable && !irqd_irq_disabled(&desc->irq_data))
+			chip->irq_disable(&desc->irq_data);
+	}
+}
+
 /*
  * machine_crash_shutdown - Prepare to kexec after a kernel crash
  *
@@ -169,6 +202,8 @@ machine_crash_shutdown(struct pt_regs *regs)
 	crash_smp_send_stop();
 
 	crash_save_cpu(regs, smp_processor_id());
+	machine_kexec_mask_interrupts();
+
 	pr_info("Starting crashdump kernel...\n");
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux