linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sumit Garg <sumit.garg@linaro.org>
To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org,
	daniel.thompson@linaro.org
Cc: linux-arm-kernel@lists.infradead.org, tglx@linutronix.de,
	jason@lakedaemon.net, linux@armlinux.org.uk,
	tsbogend@alpha.franken.de, mpe@ellerman.id.au,
	davem@davemloft.net, mingo@redhat.com, bp@alien8.de,
	x86@kernel.org, mark.rutland@arm.com,
	julien.thierry.kdev@gmail.com, dianders@chromium.org,
	jason.wessel@windriver.com, msys.mizuma@gmail.com,
	ito-yuichi@fujitsu.com, kgdb-bugreport@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, Sumit Garg <sumit.garg@linaro.org>
Subject: [PATCH v7 7/7] arm64: kgdb: Roundup cpus using IPI as NMI
Date: Mon,  2 Nov 2020 17:14:47 +0530	[thread overview]
Message-ID: <1604317487-14543-8-git-send-email-sumit.garg@linaro.org> (raw)
In-Reply-To: <1604317487-14543-1-git-send-email-sumit.garg@linaro.org>

arm64 platforms with GICv3 or later supports pseudo NMIs which can be
leveraged to roundup CPUs which are stuck in hard lockup state with
interrupts disabled that wouldn't be possible with a normal IPI.

So instead switch to roundup CPUs using IPI turned as NMI. And in
case a particular arm64 platform doesn't supports pseudo NMIs,
it will switch back to default kgdb CPUs roundup mechanism.

Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
---
 arch/arm64/kernel/ipi_nmi.c |  5 +++++
 arch/arm64/kernel/kgdb.c    | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/arch/arm64/kernel/ipi_nmi.c b/arch/arm64/kernel/ipi_nmi.c
index 597dcf7..898d69c 100644
--- a/arch/arm64/kernel/ipi_nmi.c
+++ b/arch/arm64/kernel/ipi_nmi.c
@@ -8,6 +8,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/kgdb.h>
 #include <linux/nmi.h>
 #include <linux/smp.h>
 
@@ -45,10 +46,14 @@ bool arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self)
 static irqreturn_t ipi_nmi_handler(int irq, void *data)
 {
 	irqreturn_t ret = IRQ_NONE;
+	unsigned int cpu = smp_processor_id();
 
 	if (nmi_cpu_backtrace(get_irq_regs()))
 		ret = IRQ_HANDLED;
 
+	if (!kgdb_nmicallback(cpu, get_irq_regs()))
+		ret = IRQ_HANDLED;
+
 	return ret;
 }
 
diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c
index 1a157ca3..371b176 100644
--- a/arch/arm64/kernel/kgdb.c
+++ b/arch/arm64/kernel/kgdb.c
@@ -17,6 +17,7 @@
 
 #include <asm/debug-monitors.h>
 #include <asm/insn.h>
+#include <asm/nmi.h>
 #include <asm/traps.h>
 
 struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = {
@@ -353,3 +354,20 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
 	return aarch64_insn_write((void *)bpt->bpt_addr,
 			*(u32 *)bpt->saved_instr);
 }
+
+void kgdb_roundup_cpus(void)
+{
+	struct cpumask mask;
+
+	if (!arm64_supports_nmi()) {
+		kgdb_smp_call_nmi_hook();
+		return;
+	}
+
+	cpumask_copy(&mask, cpu_online_mask);
+	cpumask_clear_cpu(raw_smp_processor_id(), &mask);
+	if (cpumask_empty(&mask))
+		return;
+
+	arm64_send_nmi(&mask);
+}
-- 
2.7.4


  parent reply	other threads:[~2020-11-02 11:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02 11:44 [PATCH v7 0/7] arm64: Add framework to turn an IPI as NMI Sumit Garg
2020-11-02 11:44 ` [PATCH v7 1/7] arm64: Add framework to turn " Sumit Garg
2020-11-02 15:33   ` Masayoshi Mizuma
2020-11-04 12:48     ` Sumit Garg
2020-11-02 11:44 ` [PATCH v7 2/7] irqchip/gic-v3: Enable support for SGIs to act as NMIs Sumit Garg
2020-11-02 16:17   ` Masayoshi Mizuma
2020-11-18 11:54   ` ito-yuichi
2020-11-02 11:44 ` [PATCH v7 3/7] arm64: smp: Assign and setup an IPI as NMI Sumit Garg
2020-11-02 16:19   ` Masayoshi Mizuma
2020-11-02 11:44 ` [PATCH v7 4/7] nmi: backtrace: Allow runtime arch specific override Sumit Garg
2021-01-05 10:32   ` Sumit Garg
2020-11-02 11:44 ` [PATCH v7 5/7] arm64: ipi_nmi: Add support for NMI backtrace Sumit Garg
2020-11-02 16:21   ` Masayoshi Mizuma
2020-11-02 11:44 ` [PATCH v7 6/7] kgdb: Expose default CPUs roundup fallback mechanism Sumit Garg
2020-11-02 11:44 ` Sumit Garg [this message]
2021-06-25 14:54   ` [PATCH v7 7/7] arm64: kgdb: Roundup cpus using IPI as NMI Chen-Yu Tsai
2021-01-05 10:34 ` [PATCH v7 0/7] arm64: Add framework to turn an " Sumit Garg
2021-01-05 10:43   ` Marc Zyngier
2021-07-07  6:03     ` Sumit Garg
2021-06-25 14:56 ` Chen-Yu Tsai
2021-07-07  5:59   ` Sumit Garg
2022-01-12 19:31     ` Masayoshi Mizuma
2022-01-13 11:00       ` Sumit Garg

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=1604317487-14543-8-git-send-email-sumit.garg@linaro.org \
    --to=sumit.garg@linaro.org \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=daniel.thompson@linaro.org \
    --cc=davem@davemloft.net \
    --cc=dianders@chromium.org \
    --cc=ito-yuichi@fujitsu.com \
    --cc=jason.wessel@windriver.com \
    --cc=jason@lakedaemon.net \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=msys.mizuma@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=tsbogend@alpha.franken.de \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).