From patchwork Wed May 20 11:11:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11559973 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CF53138A for ; Wed, 20 May 2020 11:12:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 54AD6207D3 for ; Wed, 20 May 2020 11:12:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DzK3+X3i"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aGADS/21" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54AD6207D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=AaMgKDz9vkn/3Azl8v/tj9v/sM1dC2MC31Jj/JiXbBQ=; b=DzK3+X3i8AJCAG/tdAdMAHiZp3 Ow0I46Wh9SNsGh3vM4oi6QVST85oyDKfjUA2mJP9yFhOn9nkSUVgBnXCGl6yAzmESFUNHTUfj6/9W 3U8Z0I66M5u8p0un+JKCr+s2OlQ4N/IXxIKUYdveBzpAGkTy1S9zY7szVEq/BrDS8DkiOnyn1D4D8 KRW4VlKRaACJw3xVtbjWINKPVSLH7hVBxkX8gp1tzjtiT1PLEB4aSFK86+XcBzQZB0U16mdYoOcdB ToBCTHyr9DVS6Nm0ybdZIhTLKAYzBtZMjpoXKmW1ATUYJ/ibtrpW/Gkuj//Z0m9t/cHcUGXHMg+OB o1BUnShg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbMed-0004OA-9b; Wed, 20 May 2020 11:12:55 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbMeZ-0004IL-3y for linux-arm-kernel@lists.infradead.org; Wed, 20 May 2020 11:12:52 +0000 Received: by mail-pj1-x1044.google.com with SMTP id cx22so1098526pjb.1 for ; Wed, 20 May 2020 04:12:50 -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=ijhEJD7IduE0U1E8AnSJDUXoqHR53bJuCE3Hju6nI0s=; b=aGADS/21PIt44tBDepA8z7JH39hjNazac7GxhdW+KNVWe0A3Hy/0c4bYlV9oSf3BvP LCgJNx3/hzoPEak3bXvFApjYrByfQNhAzTXG5QWGS0f9YWJQ/d5zIvHCql8pYNUeH5AB KwuWXI952vPjmL4r8O+gG2aHXkvWJj67H1moGsmx5H3+FDhMPIL4n8NFTGOiPj+uDX+P e7tbjJDHqLT/H61jYEE4EYXZCQLYRYrkiYnBD8YDRE0tRnAy8r/nOGBwUHcvbIPMWXDC JtFTEPl/aeX1mocEmBiGSRNvlcCmOhBfuctZV+oD7NuAApDIrmmWK7YDlqYAjPzUWdT+ BN7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ijhEJD7IduE0U1E8AnSJDUXoqHR53bJuCE3Hju6nI0s=; b=jkEH/LmyBVCdmDpB94cbaSWkwx9rDUHbq39/4h9BIrZhIk+KISD0GddcMCJ59gsXZv 5XMiFf2Xk2SCQuLA8pGOlSEpV4rib/0LTeRAsXiWMSeKfQ6wh1O6QQquHnROyimJvBoP CIpX4Qqz9rWFMhDXcf7nimHzyYfDYmkWiA4G4UeEZVf6c9CzfmZVozNRLyUOBUTpkPEj KXUndt8qR9p8uvLB5Us443RcVjxeWvu3IIDjthhZJKTiPkvRbDbc/0Y3kQA3/RpfrhMl zTnSF2h6uosm4HhvprJBaHmGj1T6xd/VeYrgUWKVlhNZhWavAdETiUJmKB3JcNc+C/Kf oTFA== X-Gm-Message-State: AOAM531D16dDnNXsEs5/wL1gtHqqQ9jR/I9A/yw1jU98VfFJFUdgxly0 gp5Fnyi2NL/zqIt8mM4ollxLMN4pi4E= X-Google-Smtp-Source: ABdhPJzNvSwUoGbq89C1ybvRuntAvjJr6uSw+V7BIYsslChvoR7r5VHqx1MN7bVP2u8IX7evwU3kkg== X-Received: by 2002:a17:90a:2325:: with SMTP id f34mr4619400pje.91.1589973169271; Wed, 20 May 2020 04:12:49 -0700 (PDT) Received: from localhost.localdomain ([117.252.68.136]) by smtp.gmail.com with ESMTPSA id q134sm2044974pfc.143.2020.05.20.04.12.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 May 2020 04:12:48 -0700 (PDT) From: Sumit Garg To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/4] arm64: smp: Introduce a new IPI as IPI_CALL_NMI_FUNC Date: Wed, 20 May 2020 16:41:52 +0530 Message-Id: <1589973115-14757-2-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589973115-14757-1-git-send-email-sumit.garg@linaro.org> References: <1589973115-14757-1-git-send-email-sumit.garg@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200520_041251_262898_4FE93F96 X-CRM114-Status: GOOD ( 13.93 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , daniel.thompson@linaro.org, jason@lakedaemon.net, catalin.marinas@arm.com, jason.wessel@windriver.com, dianders@chromium.org, linux-kernel@vger.kernel.org, maz@kernel.org, kgdb-bugreport@lists.sourceforge.net, tglx@linutronix.de, will@kernel.org, julien.thierry.kdev@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Introduce a new inter processor interrupt as IPI_CALL_NMI_FUNC that can be invoked to run special handlers in NMI context. One such handler example is kgdb_nmicallback() which is invoked in order to round up CPUs to enter kgdb context. As currently pseudo NMIs are supported on specific arm64 platforms which incorporates GICv3 or later version of interrupt controller. In case a particular platform doesn't support pseudo NMIs, IPI_CALL_NMI_FUNC will act as a normal IPI which can still be used to invoke special handlers. Signed-off-by: Sumit Garg --- arch/arm64/include/asm/hardirq.h | 2 +- arch/arm64/include/asm/smp.h | 1 + arch/arm64/kernel/smp.c | 13 ++++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/hardirq.h b/arch/arm64/include/asm/hardirq.h index 87ad961..abaa23a 100644 --- a/arch/arm64/include/asm/hardirq.h +++ b/arch/arm64/include/asm/hardirq.h @@ -13,7 +13,7 @@ #include #include -#define NR_IPI 7 +#define NR_IPI 8 typedef struct { unsigned int __softirq_pending; diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h index bec6ef0..b4602de 100644 --- a/arch/arm64/include/asm/smp.h +++ b/arch/arm64/include/asm/smp.h @@ -106,6 +106,7 @@ extern void secondary_entry(void); extern void arch_send_call_function_single_ipi(int cpu); extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); +extern void arch_send_call_nmi_func_ipi_mask(const struct cpumask *mask); #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL extern void arch_send_wakeup_ipi_mask(const struct cpumask *mask); diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index d29823a..236784e 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -81,7 +81,8 @@ enum ipi_msg_type { IPI_CPU_CRASH_STOP, IPI_TIMER, IPI_IRQ_WORK, - IPI_WAKEUP + IPI_WAKEUP, + IPI_CALL_NMI_FUNC }; #ifdef CONFIG_HOTPLUG_CPU @@ -802,6 +803,7 @@ static const char *ipi_types[NR_IPI] __tracepoint_string = { S(IPI_TIMER, "Timer broadcast interrupts"), S(IPI_IRQ_WORK, "IRQ work interrupts"), S(IPI_WAKEUP, "CPU wake-up interrupts"), + S(IPI_CALL_NMI_FUNC, "NMI function call interrupts"), }; static void smp_cross_call(const struct cpumask *target, unsigned int ipinr); @@ -855,6 +857,11 @@ void arch_irq_work_raise(void) } #endif +void arch_send_call_nmi_func_ipi_mask(const struct cpumask *mask) +{ + smp_cross_call(mask, IPI_CALL_NMI_FUNC); +} + static void local_cpu_stop(void) { set_cpu_online(smp_processor_id(), false); @@ -949,6 +956,10 @@ static void do_handle_IPI(int ipinr) break; #endif + case IPI_CALL_NMI_FUNC: + /* nop, IPI handlers for special features can be added here. */ + break; + default: pr_crit("CPU%u: Unknown IPI message 0x%x\n", cpu, ipinr); break; From patchwork Wed May 20 11:11:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11559975 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBF59138A for ; Wed, 20 May 2020 11:13:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BB3C7207D3 for ; Wed, 20 May 2020 11:13:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZQFiesNS"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pdAwNIlv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB3C7207D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=cyZ8no5PFyLpyjVlqzVtKNN7cbBIYPG9jMJBA6rerG4=; b=ZQFiesNSmUQPMIBOZxl4pFB90a DHFu1k1AbQquZQGbRX3SAX3Ap5pu4afedj4bA8yOgeBPP3vueTca5bs8FXqjmV2GTv5hZaBMWXjY2 v5VMX9MgVCRcsPz8E4P2AJwWrmyj6zdkJTYsAQeUfwbM2WB1yoaqWiqOj7ZUY71Psp9NWG/DPwln3 lx23KQ9BNdywaFqkBixzbuzq3MYBDGYOA3WmNobD8nBAgcs1lWEm4v+wYcDqpzR454PafbrjNpMJ2 fFndZuxdoiiMuauwMgrnJiSR1NDRo1PcGp31ZBf+wV2Pe2FEpz27XXpLIQHZenZNvrdY4Y5UfGJtn 2f3VL3ug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbMf4-0004iV-AT; Wed, 20 May 2020 11:13:22 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbMer-0004Zg-34 for linux-arm-kernel@lists.infradead.org; Wed, 20 May 2020 11:13:10 +0000 Received: by mail-pg1-x544.google.com with SMTP id p21so1255039pgm.13 for ; Wed, 20 May 2020 04:13:08 -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=ZG9/oyco7B79XCj6TKIn88+qkDpSNwk8w2d1UWYERo0=; b=pdAwNIlvROhiKpL/uEs/CC2blZgu9oXn0Cip5pIyL+nIKtHyciusiYEz1cZHlaoldy 11bzJLJpdW3zY2XILih4rOtUwCCavUZFMs8eYp8a69jMGrEyovcPGuyMlNMwqRw/J0Nd sVGmw/B6Cu9iE1/8flZoqNa5DmIadUAAyYBR2UqNtvdvb/mUlDMknuK2bxsAotyaHJw7 afeMaBCy/zcIeP6yN4vijo3dtNwFpDuQkl/EyXebZaW6ZH+d28yZT6+wVwxPG5azbPAK cAw/AutnoRZ7i1RjlCBe4Pt4M9KMv3aA0uWSM8hY2ouSd+5X/aDy2zXH6Lf5tYsAPZ/U HjXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZG9/oyco7B79XCj6TKIn88+qkDpSNwk8w2d1UWYERo0=; b=imaoepBcwCXGd1WhWHAcpQBCoiHJ11gi6jQGSS0w6E7xjnsK2cx5/PVmIeSYV8ThHZ XMq4JnJrnUDm9v4c8Jzt6JU2k+bLaq/khXdRPM4hP9lKJr7JsDukhx9KC00YVhpq2FoA 2yZxYQg/wx/9YUBwunzExoxy5TA/tt9zSXkIq32kIL1kCkJ6x46pJD0IQ9j0b9+1n5VL Mn+5m9YVuwstCr3euV2JPSk9+hGP+LfqClFFCWCpKoeVJJaSji0J/GHcMd3tzRvNWkhX TLoDJ6cbldhlxFeMYqBbhR/WDggRI9NAii5MgbEBmeo56pvDDEvUNFtL1ovtz0m+zg3E gSvw== X-Gm-Message-State: AOAM531D11sWev69FWblq1LRCCvu4gJxisryNkpPnpfNPVJpFrIA5ESp 0HGNFo+tRojejzGw6uRvHgshAPEp9gg= X-Google-Smtp-Source: ABdhPJyAXA8IR3qjB6XDW9mgUh5Gkt/Gfwj2utLLwP9UmxbL/P36lgEOjUZ0/LGMAYySKXzpGmJeRg== X-Received: by 2002:a62:ee02:: with SMTP id e2mr3672825pfi.161.1589973187571; Wed, 20 May 2020 04:13:07 -0700 (PDT) Received: from localhost.localdomain ([117.252.68.136]) by smtp.gmail.com with ESMTPSA id q134sm2044974pfc.143.2020.05.20.04.13.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 May 2020 04:13:06 -0700 (PDT) From: Sumit Garg To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 2/4] irqchip/gic-v3: Enable support for SGIs to act as NMIs Date: Wed, 20 May 2020 16:41:53 +0530 Message-Id: <1589973115-14757-3-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589973115-14757-1-git-send-email-sumit.garg@linaro.org> References: <1589973115-14757-1-git-send-email-sumit.garg@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200520_041309_218833_75A9CC4B X-CRM114-Status: GOOD ( 13.90 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:544 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , daniel.thompson@linaro.org, jason@lakedaemon.net, catalin.marinas@arm.com, jason.wessel@windriver.com, dianders@chromium.org, linux-kernel@vger.kernel.org, maz@kernel.org, kgdb-bugreport@lists.sourceforge.net, tglx@linutronix.de, will@kernel.org, julien.thierry.kdev@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add support to handle SGIs as regular NMIs. As SGIs or IPIs defaults to a special flow handler: handle_percpu_devid_fasteoi_ipi(), so skip NMI handler update in case of SGIs. Also, enable NMI support prior to gic_smp_init() as allocation of SGIs as IRQs/NMIs happen as part of this routine. Signed-off-by: Sumit Garg --- drivers/irqchip/irq-gic-v3.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 82095b8..ceef63b 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -477,6 +477,11 @@ static int gic_irq_nmi_setup(struct irq_data *d) if (WARN_ON(gic_irq(d) >= 8192)) return -EINVAL; + if (get_intid_range(d) == SGI_RANGE) { + gic_irq_set_prio(d, GICD_INT_NMI_PRI); + return 0; + } + /* desc lock should already be held */ if (gic_irq_in_rdist(d)) { u32 idx = gic_get_ppi_index(d); @@ -514,6 +519,11 @@ static void gic_irq_nmi_teardown(struct irq_data *d) if (WARN_ON(gic_irq(d) >= 8192)) return; + if (get_intid_range(d) == SGI_RANGE) { + gic_irq_set_prio(d, GICD_INT_DEF_PRI); + return; + } + /* desc lock should already be held */ if (gic_irq_in_rdist(d)) { u32 idx = gic_get_ppi_index(d); @@ -1675,6 +1685,7 @@ static int __init gic_init_bases(void __iomem *dist_base, gic_dist_init(); gic_cpu_init(); + gic_enable_nmi_support(); gic_smp_init(); gic_cpu_pm_init(); @@ -1686,8 +1697,6 @@ static int __init gic_init_bases(void __iomem *dist_base, gicv2m_init(handle, gic_data.domain); } - gic_enable_nmi_support(); - return 0; out_free: From patchwork Wed May 20 11:11:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11559977 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCE15138A for ; Wed, 20 May 2020 11:13:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 88DAE20823 for ; Wed, 20 May 2020 11:13:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="P92CaGXp"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qNl6HzvI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 88DAE20823 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=CgqAnAuQut0SDTIrBf3VFc9YzB6a4l0RC+EFN2yaDOU=; b=P92CaGXpMBdXlwr7uMtJQq5VO1 Q2gNtieQBJddeW0ulPbXerizO/pgA05eVEvkNBUacTOMS8Q3uUTXYyJYPAtaO5wj4qGRPMoVkWAtt UDLJFpSuAwLbcGqTA3JsPpe4P2mFZUKp1FGzSNCyC4UMjKjbBtjG62kYLaBy42Cq2ZS8SaI4Ycu2G e1CRVeybsv+f7C0zGbXGVLxonc21y6W7J4APkAM7bN5olkhiUR69TpAkeGrLhaaDdzvqM7Ih4jikl OFeF1CeFBCcKetzR38XcGYHSmNiaNHWVXLlDohJKt4rKiipbx31xg2dDn/D06wDwoJQIrrZdqDm7Z XrB+hSZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbMfO-0004yu-BA; Wed, 20 May 2020 11:13:42 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbMey-0004fW-8I for linux-arm-kernel@lists.infradead.org; Wed, 20 May 2020 11:13:20 +0000 Received: by mail-pg1-x541.google.com with SMTP id n11so1264166pgl.9 for ; Wed, 20 May 2020 04:13:15 -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=L4VlC3w2vGN2vXDu2vdOxtfNJ1ZDmhnMu1C9iDb4k5Q=; b=qNl6HzvIrP8iK8PRiHj/zvYTJ4DNHplta8G2LBd6c7zrLo9i6ACDRVaLkd6wXoXCJB +Fuka+XhWtRFpeAoF054KBR5WugZjBOv8jYQKfvLaSICPXf9AP3Zltm4vXBY+oWnEfez J1s6wj0eGeX1s/UrjZsBUIjUJKuYkd4aznXtek3r9WIw3NWoXXiMxBgc5QUGuJIdRYTu +yD1LPTQQ6D1fOc6EZ1NjUvpkAa3wEo8qscsWG+J7LF8y7qEUCk6GeYvOEmLUuJ03SAi Bin0nIdV7vyudrOoQomqHhjsrl55+SCMPftq7nhExZAGFrnf1zxw64T90Necr5seGfNb D3MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L4VlC3w2vGN2vXDu2vdOxtfNJ1ZDmhnMu1C9iDb4k5Q=; b=nRzHB++i751FG84o20/D/X4VsP35pb548S5APwDK674EV6A1UoxJ8cPoLjCUbYZcxs aXV0RziaKO4pucWsRAQQqcxTac/Wro4b0hNB5ZZkbKF1atnBpL2T0YVjfXluRf2d2+nu jnQ9Vfb8dEKaP9LGNVYBY78y2vCb8X4EqszFAKJDgu9LTxuy4+g7Gv52tL3Q+ynadfgl fc589K33GXKRK1spHi3uxJhLpHJ0Btv9rXAUf46842RdhyX9MSAZNpLDuqjVMXdc2zZC n9OGuaVkyGQv6DoCJiYB4iPqWUi7yBBAOYexydEr1Em/esx5mHnqvYj9JYYmL1JR9qCL nWyw== X-Gm-Message-State: AOAM53066S+dVRUemwzu1fw8TbEeaOB0koaOyoe2xBqcP9LW94ybccg5 VZbUXvUVl9q1umGRV9syzAdgj3b/lNE= X-Google-Smtp-Source: ABdhPJzFrj1psMvJysAYcuO/Cf5POOGdTZuwteJpZy4CrbC1e194avqYMKbaNslTxsDvhte0gChECQ== X-Received: by 2002:a63:e60b:: with SMTP id g11mr3836980pgh.120.1589973194777; Wed, 20 May 2020 04:13:14 -0700 (PDT) Received: from localhost.localdomain ([117.252.68.136]) by smtp.gmail.com with ESMTPSA id q134sm2044974pfc.143.2020.05.20.04.13.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 May 2020 04:13:13 -0700 (PDT) From: Sumit Garg To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/4] arm64: smp: Setup IPI_CALL_NMI_FUNC as a pseudo NMI Date: Wed, 20 May 2020 16:41:54 +0530 Message-Id: <1589973115-14757-4-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589973115-14757-1-git-send-email-sumit.garg@linaro.org> References: <1589973115-14757-1-git-send-email-sumit.garg@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200520_041316_481595_2760A6D5 X-CRM114-Status: GOOD ( 14.64 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:541 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , daniel.thompson@linaro.org, jason@lakedaemon.net, catalin.marinas@arm.com, jason.wessel@windriver.com, dianders@chromium.org, linux-kernel@vger.kernel.org, maz@kernel.org, kgdb-bugreport@lists.sourceforge.net, tglx@linutronix.de, will@kernel.org, julien.thierry.kdev@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Setup IPI_CALL_NMI_FUNC as a pseudo NMI using generic interrupt framework APIs. In case a plarform doesn't provide support for pseudo NMIs, switch back to IPI_CALL_NMI_FUNC being a normal interrupt. Signed-off-by: Sumit Garg --- arch/arm64/kernel/smp.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 236784e..c5e42a1 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -68,6 +68,7 @@ struct secondary_data secondary_data; int cpus_stuck_in_kernel; static int ipi_irq_base; +static int ipi_nmi = -1; static int nr_ipi = NR_IPI; static struct irq_desc *ipi_desc[NR_IPI]; @@ -986,8 +987,14 @@ static void ipi_setup(int cpu) if (ipi_irq_base) { int i; - for (i = 0; i < nr_ipi; i++) - enable_percpu_irq(ipi_irq_base + i, 0); + for (i = 0; i < nr_ipi; i++) { + if (ipi_nmi == ipi_irq_base + i) { + if (!prepare_percpu_nmi(ipi_nmi)) + enable_percpu_nmi(ipi_nmi, 0); + } else { + enable_percpu_irq(ipi_irq_base + i, 0); + } + } } } @@ -997,23 +1004,33 @@ static void ipi_teardown(int cpu) int i; for (i = 0; i < nr_ipi; i++) - disable_percpu_irq(ipi_irq_base + i); + if (ipi_nmi == ipi_irq_base + i) { + disable_percpu_nmi(ipi_nmi); + teardown_percpu_nmi(ipi_nmi); + } else { + disable_percpu_irq(ipi_irq_base + i); + } } } void __init set_smp_ipi_range(int ipi_base, int n) { - int i; + int i, err; WARN_ON(n < NR_IPI); nr_ipi = min(n, NR_IPI); - for (i = 0; i < nr_ipi; i++) { - int err; + err = request_percpu_nmi(ipi_base + IPI_CALL_NMI_FUNC, + ipi_handler, "IPI", &irq_stat); + if (!err) + ipi_nmi = ipi_base + IPI_CALL_NMI_FUNC; - err = request_percpu_irq(ipi_base + i, ipi_handler, - "IPI", &irq_stat); - WARN_ON(err); + for (i = 0; i < nr_ipi; i++) { + if (ipi_base + i != ipi_nmi) { + err = request_percpu_irq(ipi_base + i, ipi_handler, + "IPI", &irq_stat); + WARN_ON(err); + } ipi_desc[i] = irq_to_desc(ipi_base + i); irq_set_status_flags(ipi_base + i, IRQ_NO_ACCOUNTING); From patchwork Wed May 20 11:11:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11559979 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4ADA7138A for ; Wed, 20 May 2020 11:14:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0BC0B20823 for ; Wed, 20 May 2020 11:14:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="I/Y9xz6R"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="egwaEsnb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BC0B20823 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=YQTf2H/H4hjtK5qfuhqaWJbQYsJSsr6UUeSz0Tvy8Cw=; b=I/Y9xz6RDAXyKR9G+HIDvrjaL7 beUemjwHuZwcs97MwBRHAUYEACoSieCwdqHevVfr0oyQcuEfV/Wl3QWjleuVmLrw0JA4EktmHY3Ik 5hCNs1sRrEved3WUW+CsZ9mlqqy86iiK1E7cDvfwv7GSrat1j2sDxC9sPtd+cPRTIXQhKw5YEJthn 4Ig+8Sru6HHmS8qGKQjZ37NscVsYBbda2wtJljta3zX5qTVW0yGRfNpwGs2jHIpP/RnAKSdHXdH6p dHeiLd1ZqpUdCz5xCMIJzo1V78cdtsx0YVVfz+yP3x3Fizx+cAVeKqQOrxM70OvePp9/xqfAIXYB3 zoiJGXwA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbMfc-0005C4-F0; Wed, 20 May 2020 11:13:56 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbMf5-0004kH-S3 for linux-arm-kernel@lists.infradead.org; Wed, 20 May 2020 11:13:26 +0000 Received: by mail-pl1-x644.google.com with SMTP id t7so1198011plr.0 for ; Wed, 20 May 2020 04:13:23 -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=yX6L8WE/2wulIJ9zzHwHac/OpN/D9QY9ojqo7Mh/3mw=; b=egwaEsnbY6AeyS96dO0hGfkxr/9sazC/TRAuJtiKxLcMasIkKn3431qFi4aKu8PyZy zA+K2sbl6vAxNVwL9+KW7XZ6wDYR0TzfCEIX9eF4LrQXw6fMVz9bXjVDFxUoh1Awjccn ikb16VFGIwZvdaIOWKt4pgIEZT6ajVQzfP7WI2ZTnNIVJZCp5DG8DKNGNTvC4VTRynVq 5oD1hCIlADqJ8xlYek0oUenVOv++9LauUwQ9ImiMD6NjhqZAfkNSzAItZBGBgnIpAekq GXtOXwG57Y9VE31yfVzj2gBoGkiuh6+l8qxBEZcJ3Ymt5wWomn20SbsZKRngQKiep0rj icKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yX6L8WE/2wulIJ9zzHwHac/OpN/D9QY9ojqo7Mh/3mw=; b=MbwzGCRbVhGBLVYI4yfzbfSDhPNtrppHwS4xBiBFGRqICEnU2ajULzvli7OPctNtnW kfA2GiBWpToZClcjK3cehLmhA5U6VP+NntGAZdUvHrPSgbl+gW+gzo/zcqjdKHmagALy 8AWIczg+UWc6yM7DsrozpAv9xRieYCYa1edXn6J7qEkDWqNE4OlOIri0+oKW68u3euL+ 2TCLTR+G3/vbi0Mm7LSYdqNsT2acwJ3fQ+fodurEutY4H5PKJe929A9vjoKroySAb/Pp kvZlMhL4sZ/v76kBmuxIaW7qJZN/XiX5GWWsFnVUmOeKgRY8tlw4EvGWElx5NPcOleQ4 3nCA== X-Gm-Message-State: AOAM5313xXTocJtArzCWKyn2xSiV1LRglfrNbdt9I4DWMchoSE8szjsj bIU2Opw7nb+/TTBVue/qT5XYCetWZOs= X-Google-Smtp-Source: ABdhPJzUpGV1y7deDtZi57sfC8WyhNh7TcidlxseCMF5t7wpivc/pdczLuxnyS0XLzXoczy4erEZ3Q== X-Received: by 2002:a17:90b:110d:: with SMTP id gi13mr4537270pjb.131.1589973202196; Wed, 20 May 2020 04:13:22 -0700 (PDT) Received: from localhost.localdomain ([117.252.68.136]) by smtp.gmail.com with ESMTPSA id q134sm2044974pfc.143.2020.05.20.04.13.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 May 2020 04:13:21 -0700 (PDT) From: Sumit Garg To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 4/4] arm64: kgdb: Round up cpus using IPI_CALL_NMI_FUNC Date: Wed, 20 May 2020 16:41:55 +0530 Message-Id: <1589973115-14757-5-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589973115-14757-1-git-send-email-sumit.garg@linaro.org> References: <1589973115-14757-1-git-send-email-sumit.garg@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200520_041323_942547_53883807 X-CRM114-Status: GOOD ( 13.96 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:644 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , daniel.thompson@linaro.org, jason@lakedaemon.net, catalin.marinas@arm.com, jason.wessel@windriver.com, dianders@chromium.org, linux-kernel@vger.kernel.org, maz@kernel.org, kgdb-bugreport@lists.sourceforge.net, tglx@linutronix.de, will@kernel.org, julien.thierry.kdev@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org arm64 platforms with GICv3 or later supports pseudo NMIs which can be leveraged to round up CPUs which are stuck in hard lockup state with interrupts disabled that wouldn't be possible with a normal IPI. So instead switch to round up CPUs using IPI_CALL_NMI_FUNC. And in case a particular arm64 platform doesn't supports pseudo NMIs, IPI_CALL_NMI_FUNC will act as a normal IPI which maintains existing kgdb functionality. Signed-off-by: Sumit Garg --- arch/arm64/include/asm/kgdb.h | 8 ++++++++ arch/arm64/kernel/kgdb.c | 21 +++++++++++++++++++++ arch/arm64/kernel/smp.c | 3 ++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kgdb.h b/arch/arm64/include/asm/kgdb.h index 21fc85e..6f3d3af 100644 --- a/arch/arm64/include/asm/kgdb.h +++ b/arch/arm64/include/asm/kgdb.h @@ -24,6 +24,14 @@ static inline void arch_kgdb_breakpoint(void) extern void kgdb_handle_bus_error(void); extern int kgdb_fault_expected; +#ifdef CONFIG_KGDB +extern void ipi_kgdb_nmicallback(int cpu, void *regs); +#else +static inline void ipi_kgdb_nmicallback(int cpu, void *regs) +{ +} +#endif + #endif /* !__ASSEMBLY__ */ /* diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index 4311992..ee932ba 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -353,3 +354,23 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) return aarch64_insn_write((void *)bpt->bpt_addr, *(u32 *)bpt->saved_instr); } + +void ipi_kgdb_nmicallback(int cpu, void *regs) +{ + if (atomic_read(&kgdb_active) != -1) + kgdb_nmicallback(cpu, regs); +} + +#ifdef CONFIG_SMP +void kgdb_roundup_cpus(void) +{ + struct cpumask mask; + + cpumask_copy(&mask, cpu_online_mask); + cpumask_clear_cpu(raw_smp_processor_id(), &mask); + if (cpumask_empty(&mask)) + return; + + arch_send_call_nmi_func_ipi_mask(&mask); +} +#endif diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index c5e42a1..3baace7 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -958,7 +959,7 @@ static void do_handle_IPI(int ipinr) #endif case IPI_CALL_NMI_FUNC: - /* nop, IPI handlers for special features can be added here. */ + ipi_kgdb_nmicallback(cpu, get_irq_regs()); break; default: