From: daniel.thompson@linaro.org (Daniel Thompson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4.7-rc3 v23 4/4] ARM: Allow IPI_CPU_BACKTRACE to exploit FIQ
Date: Thu, 30 Jun 2016 15:57:44 +0100 [thread overview]
Message-ID: <1467298664-24039-5-git-send-email-daniel.thompson@linaro.org> (raw)
In-Reply-To: <1467298664-24039-1-git-send-email-daniel.thompson@linaro.org>
The GIC (v1 & v2) driver allows its implementation of handle_arch_irq()
to be called from the FIQ handler but currently the ARM code is not
able to exploit this.
Extend handle_fiq_as_nmi() to call handle_arch_irq(). This will affect
all interrupt controllers, including ones that do not support FIQ. This
is OK because a spurious FIQ is normally fatal. Handling a spurious FIQ
like a normal interrupt does risk deadlock but does give us a chance
of surviving long enough to get an error message out.
We also extend the SMP code to indicate to irq drivers which IPIs they
should seek to implement using FIQ.
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
---
arch/arm/include/asm/smp.h | 9 +++++++++
arch/arm/kernel/smp.c | 6 ++++++
arch/arm/kernel/traps.c | 11 ++++++++++-
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
index 3d6dc8b460e4..daf869cff02e 100644
--- a/arch/arm/include/asm/smp.h
+++ b/arch/arm/include/asm/smp.h
@@ -18,6 +18,15 @@
# error "<asm/smp.h> included in non-SMP build"
#endif
+/*
+ * Identify which IPIs are safe for the irqchip to handle using FIQ.
+ *
+ * This information is advisory. The interrupt controller may not be capable
+ * of routing these IPIs to FIQ and the kernel will continue to work if they
+ * are routed to IRQ as normal.
+ */
+#define SMP_IPI_FIQ_MASK 0x80
+
#define raw_smp_processor_id() (current_thread_info()->cpu)
struct seq_file;
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index df90bc59bfce..c054db0a7ac0 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -644,6 +644,11 @@ void handle_IPI(int ipinr, struct pt_regs *regs)
break;
case IPI_CPU_BACKTRACE:
+ if (in_nmi()) {
+ nmi_cpu_backtrace(regs);
+ break;
+ }
+
printk_nmi_enter();
irq_enter();
nmi_cpu_backtrace(regs);
@@ -757,6 +762,7 @@ static void raise_nmi(cpumask_t *mask)
if (cpumask_test_cpu(smp_processor_id(), mask) && irqs_disabled())
nmi_cpu_backtrace(NULL);
+ BUILD_BUG_ON(SMP_IPI_FIQ_MASK != BIT(IPI_CPU_BACKTRACE));
smp_cross_call(mask, IPI_CPU_BACKTRACE);
}
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index bc698383e822..8f6173cd0a54 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -479,7 +479,16 @@ asmlinkage void __exception_irq_entry handle_fiq_as_nmi(struct pt_regs *regs)
nmi_enter();
- /* nop. FIQ handlers for special arch/arm features can be added here. */
+ /*
+ * Either the interrupt controller supports FIQ, meaning it will
+ * do the right thing with this call, or we will end up treating a
+ * spurious FIQ (which is normally fatal) as though it were an IRQ
+ * which, although it risks deadlock, still gives us a sporting
+ * chance of surviving long enough to log errors.
+ */
+#ifdef CONFIG_MULTI_IRQ_HANDLER
+ handle_arch_irq(regs);
+#endif
nmi_exit();
--
2.5.5
next prev parent reply other threads:[~2016-06-30 14:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-06 13:13 [PATCH 4.2-rc1 v21 0/6] irq/arm: Implement arch_trigger_all_cpu_backtrace Daniel Thompson
2015-07-06 13:13 ` [PATCH 4.2-rc1 v21 1/6] irqchip: gic: Optimize locking in gic_raise_softirq Daniel Thompson
2015-07-06 13:13 ` [PATCH 4.2-rc1 v21 2/6] irqchip: gic: Make gic_raise_softirq FIQ-safe Daniel Thompson
2015-07-06 13:13 ` [PATCH 4.2-rc1 v21 3/6] irqchip: gic: Introduce plumbing for IPI FIQ Daniel Thompson
2015-07-07 10:05 ` Holger Schurig
2015-07-06 13:13 ` [PATCH 4.2-rc1 v21 4/6] printk: Simple implementation for NMI backtracing Daniel Thompson
2015-07-06 13:13 ` [PATCH 4.2-rc1 v21 5/6] x86/nmi: Use common printk functions Daniel Thompson
2015-07-06 13:13 ` [PATCH 4.2-rc1 v21 6/6] ARM: Add support for on-demand backtrace of other CPUs Daniel Thompson
2016-06-30 14:57 ` [PATCH 4.7-rc3 v23 0/4] irq/arm: Use FIQ for NMI backtrace (when possible) Daniel Thompson
2016-06-30 14:57 ` [PATCH 4.7-rc3 v23 1/4] irqchip: gic: Optimize locking in gic_raise_softirq Daniel Thompson
2016-06-30 14:57 ` [PATCH 4.7-rc3 v23 2/4] irqchip: gic: Make gic_raise_softirq FIQ-safe Daniel Thompson
2016-06-30 14:57 ` [PATCH 4.7-rc3 v23 3/4] irqchip: gic: Introduce plumbing for IPI FIQ Daniel Thompson
2016-06-30 14:57 ` Daniel Thompson [this message]
2016-08-11 11:55 ` [PATCH 4.8-rc1 v23 0/4] irq/arm: Use FIQ for NMI backtrace (when possible) Daniel Thompson
2016-08-11 11:55 ` [PATCH 4.8-rc1 v23 1/4] irqchip: gic: Optimize locking in gic_raise_softirq Daniel Thompson
2016-08-11 11:55 ` [PATCH 4.8-rc1 v23 2/4] irqchip: gic: Make gic_raise_softirq FIQ-safe Daniel Thompson
2016-08-11 11:55 ` [PATCH 4.8-rc1 v23 3/4] irqchip: gic: Introduce plumbing for IPI FIQ Daniel Thompson
2016-08-11 11:55 ` [PATCH 4.8-rc1 v23 4/4] ARM: Allow IPI_CPU_BACKTRACE to exploit FIQ Daniel Thompson
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=1467298664-24039-5-git-send-email-daniel.thompson@linaro.org \
--to=daniel.thompson@linaro.org \
--cc=linux-arm-kernel@lists.infradead.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).