From: guoren@kernel.org To: palmer@rivosinc.com, conor.Dooley@microchip.com, guoren@kernel.org, heiko@sntech.de Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, crash-utility@redhat.com, Guo Ren <guoren@linux.alibaba.com>, Xianting Tian <xianting.tian@linux.alibaba.com>, Nick Kossifidis <mick@ics.forth.gr> Subject: [PATCH -next V6 1/2] riscv: kexec: EOI active and mask all interrupts in kexec crash path Date: Fri, 9 Dec 2022 02:55:12 -0500 [thread overview] Message-ID: <20221209075513.532249-2-guoren@kernel.org> (raw) In-Reply-To: <20221209075513.532249-1-guoren@kernel.org> From: Guo Ren <guoren@linux.alibaba.com> If a crash happens on cpu3 and all interrupts are binding on cpu0, the bad irq routing will cause the crash kernel can't receive any irq. Because the crash kernel won't clean up PLIC harts' enable register. This patch is similar to 'commit 9141a003a491 ("ARM: 7316/1: kexec: EOI active and mask all interrupts in kexec crash path")'; arm64 and PowerPC also have a similar mechanism. Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Signed-off-by: Guo Ren <guoren@kernel.org> Reviewed-by: Xianting Tian <xianting.tian@linux.alibaba.com> Cc: Nick Kossifidis <mick@ics.forth.gr> Cc: Palmer Dabbelt <palmer@rivosinc.com> --- arch/riscv/kernel/machine_kexec.c | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) 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"); } -- 2.36.1
WARNING: multiple messages have this Message-ID (diff)
From: guoren@kernel.org To: palmer@rivosinc.com, conor.Dooley@microchip.com, guoren@kernel.org, heiko@sntech.de Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, crash-utility@redhat.com, Guo Ren <guoren@linux.alibaba.com>, Xianting Tian <xianting.tian@linux.alibaba.com>, Nick Kossifidis <mick@ics.forth.gr> Subject: [PATCH -next V6 1/2] riscv: kexec: EOI active and mask all interrupts in kexec crash path Date: Fri, 9 Dec 2022 02:55:12 -0500 [thread overview] Message-ID: <20221209075513.532249-2-guoren@kernel.org> (raw) In-Reply-To: <20221209075513.532249-1-guoren@kernel.org> From: Guo Ren <guoren@linux.alibaba.com> If a crash happens on cpu3 and all interrupts are binding on cpu0, the bad irq routing will cause the crash kernel can't receive any irq. Because the crash kernel won't clean up PLIC harts' enable register. This patch is similar to 'commit 9141a003a491 ("ARM: 7316/1: kexec: EOI active and mask all interrupts in kexec crash path")'; arm64 and PowerPC also have a similar mechanism. Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Signed-off-by: Guo Ren <guoren@kernel.org> Reviewed-by: Xianting Tian <xianting.tian@linux.alibaba.com> Cc: Nick Kossifidis <mick@ics.forth.gr> Cc: Palmer Dabbelt <palmer@rivosinc.com> --- arch/riscv/kernel/machine_kexec.c | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) 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"); } -- 2.36.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2022-12-09 7:55 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-09 7:55 [PATCH -next V6 0/2] riscv: kexec: Fxiup crash_save percpu and guoren 2022-12-09 7:55 ` guoren 2022-12-09 7:55 ` guoren [this message] 2022-12-09 7:55 ` [PATCH -next V6 1/2] riscv: kexec: EOI active and mask all interrupts in kexec crash path guoren 2022-12-09 7:55 ` [PATCH -next V6 2/2] riscv: kexec: Make crash save multi harts' context guoren 2022-12-09 7:55 ` guoren 2022-12-16 19:37 ` [PATCH -next V6 0/2] riscv: kexec: Fxiup crash_save percpu and patchwork-bot+linux-riscv 2022-12-16 19:37 ` patchwork-bot+linux-riscv
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221209075513.532249-2-guoren@kernel.org \ --to=guoren@kernel.org \ --cc=conor.Dooley@microchip.com \ --cc=crash-utility@redhat.com \ --cc=guoren@linux.alibaba.com \ --cc=heiko@sntech.de \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-riscv@lists.infradead.org \ --cc=mick@ics.forth.gr \ --cc=palmer@rivosinc.com \ --cc=xianting.tian@linux.alibaba.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.