From patchwork Thu Jun 30 14:57:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 71256 Delivered-To: patches@linaro.org Received: by 10.140.28.4 with SMTP id 4csp438070qgy; Thu, 30 Jun 2016 07:58:08 -0700 (PDT) X-Received: by 10.194.70.41 with SMTP id j9mr14213263wju.30.1467298688024; Thu, 30 Jun 2016 07:58:08 -0700 (PDT) Return-Path: Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com. [2a00:1450:400c:c09::22e]) by mx.google.com with ESMTPS id s24si1302992wma.122.2016.06.30.07.58.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jun 2016 07:58:08 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 2a00:1450:400c:c09::22e as permitted sender) client-ip=2a00:1450:400c:c09::22e; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 2a00:1450:400c:c09::22e as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-wm0-x22e.google.com with SMTP id a66so122663234wme.0 for ; Thu, 30 Jun 2016 07:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aJ7ZQFtuTCMRFpp41/lRtfv/mWLo2lgVc84E4IwuJ8s=; b=XR/sDSa9QJeK23Rr1lzxNUQWJ6gjbAaWI/B3pK426Rwsgf/uLwDDHvS7eyh5XOUdMy uoIFyT8/qv7XjXRRX1QGceVOVY/2BcVRZH//ymosQ5oTPeoZ4jyvwdvKUswByKu4qXcp 4tqv8aBB1zUYY5b0ltgQJKlZmUtW0eEQOhZDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aJ7ZQFtuTCMRFpp41/lRtfv/mWLo2lgVc84E4IwuJ8s=; b=TYcGtbVj1FoyQ8ubFmnDy+Yg925j0BWwaFS1Tvg9XcuSGEH9re9ychapJZDrN1Xijh BIEm3st152ZiYqcSLgWjmv65MdtlIFYpmfGskQ+OhLJZsQoURf2H7BWy5hTVcM89etnu 02pvfbnRP1l+xU44J/lAwQRk8UEykl56D9B+oFTN8f7fgle5hY5Ri0vlEFsI2MvuHfvY TW1g+9tyM2WMwGaOpxJCtXbWyhpZCNAib0kTB/SX4A1kYTqLc2ztiLkbumU1qqf47eTj nr4eqqBdO5/vAPdJ0f10P3ISI2abyeboxk+y50FO6XH6l1KYXYwgrBjUsOCvh3sd31Vg +Qaw== X-Gm-Message-State: ALyK8tKQ/jJNEOMcricVujBaXWJ0qLNJ2VA3g6C/mS/FGhRMk2rmjUqLlbx6cTQ/7e76cV31s/U= X-Received: by 10.194.164.98 with SMTP id yp2mr13764465wjb.85.1467298687662; Thu, 30 Jun 2016 07:58:07 -0700 (PDT) Return-Path: Received: from wychelm.lan (cpc4-aztw19-0-0-cust71.18-1.cable.virginm.net. [82.33.25.72]) by smtp.gmail.com with ESMTPSA id r130sm4222874wmf.20.2016.06.30.07.58.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jun 2016 07:58:06 -0700 (PDT) From: Daniel Thompson To: Thomas Gleixner , Jason Cooper , Russell King , Marc Zyngier Cc: Daniel Thompson , Will Deacon , Catalin Marinas , Stephen Boyd , John Stultz , Steven Rostedt , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, patches@linaro.org, linaro-kernel@lists.linaro.org, Sumit Semwal , Dirk Behme , Daniel Drake , Dmitry Pervushin , Tim Sander , Petr Mladek , Lucas Stach 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 Message-Id: <1467298664-24039-5-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1467298664-24039-1-git-send-email-daniel.thompson@linaro.org> References: <1436188438-9478-1-git-send-email-daniel.thompson@linaro.org> <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 --- 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(-) -- 2.5.5 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 " 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();