From patchwork Thu Sep 24 04:42:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuichi Ito X-Patchwork-Id: 11796097 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 A9E3092C for ; Thu, 24 Sep 2020 04:45:24 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 74EDE235F7 for ; Thu, 24 Sep 2020 04:45:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="R7GXKTeG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74EDE235F7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=EezmVhUpDuAzQDQkC3v3Fcvnre/RFGuDS8spWpAZ2iU=; b=R7GXKTeG58yleo+yqHjXtbhjZ nxhF4s+ZJ7BDgv5Qm0vkgFJtZJqMrDCfWvOjwMsgY87uaGseYjkS1c1uuXfkXHL5QZxlPTuOsRtsK VmaTN2Sr16tNuI2wIn+tlywuhrYj1ilUth60G9jI02abkSCE+ujJzPtudUI3GB9y2XM5HuIIstBG6 OI2bejEMNF75g0YcPVIAfAQsNkaYecpsCVXxhlUnhW2uZgDQHQrNuz1WHtMvvgszJ0V/K6miNk2CX /WDKfCpDZeRTheEDMVzWcfkIg2Qh9zujRN56+OKkmtpyHtKzFyiqVzSrM+5Phe3rKmx+6PkXr5CEk fpNj7qg+g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLJ6u-0001dL-7F; Thu, 24 Sep 2020 04:44:00 +0000 Received: from mgwym03.jp.fujitsu.com ([211.128.242.42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLJ6m-0001aQ-TG for linux-arm-kernel@lists.infradead.org; Thu, 24 Sep 2020 04:43:53 +0000 Received: from yt-mxoi1.gw.nic.fujitsu.com (unknown [192.168.229.67]) by mgwym03.jp.fujitsu.com with smtp id 2792_5ff7_ce30488a_8c12_4b64_a8f1_da032634e244; Thu, 24 Sep 2020 13:43:44 +0900 Received: from pumpkin.openstacklocal (pumpkin.fct.css.fujitsu.com [10.130.70.189]) by yt-mxoi1.gw.nic.fujitsu.com (Postfix) with ESMTP id E8FFCAC0111 for ; Thu, 24 Sep 2020 13:43:43 +0900 (JST) Received: by pumpkin.openstacklocal (Postfix, from userid 1016) id 5C1B31C014; Thu, 24 Sep 2020 13:42:45 +0900 (JST) From: Yuichi Ito To: maz@kernel.org, sumit.garg@linaro.org, tglx@linutronix.de, jason@lakedaemon.net, catalin.marinas@arm.com, will@kernel.org Subject: [PATCH 1/2] irqchip/gic-v3: Enable support for SGIs to act as NMIs Date: Thu, 24 Sep 2020 13:42:35 +0900 Message-Id: <20200924044236.1245808-2-ito-yuichi@fujitsu.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200924044236.1245808-1-ito-yuichi@fujitsu.com> References: <20200924044236.1245808-1-ito-yuichi@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200924_004353_277156_58DD0220 X-CRM114-Status: GOOD ( 11.99 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [211.128.242.42 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 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: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Sumit Garg 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 262bc7377abd..2eda18d1df59 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); @@ -1708,6 +1718,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(); @@ -1719,8 +1730,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 Thu Sep 24 04:42:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuichi Ito X-Patchwork-Id: 11796101 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 D196A59D for ; Thu, 24 Sep 2020 04:45:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 9A45A235F7 for ; Thu, 24 Sep 2020 04:45:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="zXJ9y2Pb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A45A235F7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=eP+tyRq01SAV9O6lqwGqylcr5vnOTCHNSUlTo9e+sCU=; b=zXJ9y2PbRpw+WOXCuicdy7ZQ9 ZdHc2xKt9U5OnJQt5k9Ia8et5rubLrSyTnajpwZBTG2v6Gm6OUXXjrp5sNGTbBcPzXDMHTZJ5Ep5k g8x8OrO9KEowCWLEVcviIIfBq+t7ni2ktPkw5qNPhjfs3WtQk+B8Y8VyPJUtauXv9Z2L4JI+2XyoE wZWwCnKvARoWUiBSrkAn5iQQZ/ISvJa1L9Dsa0s1rElukAK5/oB13Q+qMipJUAFR1RA1wJn7GY9mx boZJ5VV4kQRQ6rN3yIQRsofBiKC1cFMup3GTBsqFN2KnEmV5r0sdQzwno193MHTxrLb2eZle2zWDM vO3ifOQgQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLJ6p-0001cF-7P; Thu, 24 Sep 2020 04:43:55 +0000 Received: from mgwym01.jp.fujitsu.com ([211.128.242.40]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLJ6l-0001aY-Ny for linux-arm-kernel@lists.infradead.org; Thu, 24 Sep 2020 04:43:52 +0000 Received: from yt-mxoi1.gw.nic.fujitsu.com (unknown [192.168.229.67]) by mgwym01.jp.fujitsu.com with smtp id 4e06_085c_bddbc018_71cc_4244_8c0c_1360d51a9d6c; Thu, 24 Sep 2020 13:43:48 +0900 Received: from pumpkin.openstacklocal (pumpkin.fct.css.fujitsu.com [10.130.70.189]) by yt-mxoi1.gw.nic.fujitsu.com (Postfix) with ESMTP id 7E5F2AC0111 for ; Thu, 24 Sep 2020 13:43:47 +0900 (JST) Received: by pumpkin.openstacklocal (Postfix, from userid 1016) id E4F1A1C014; Thu, 24 Sep 2020 13:42:48 +0900 (JST) From: Yuichi Ito To: maz@kernel.org, sumit.garg@linaro.org, tglx@linutronix.de, jason@lakedaemon.net, catalin.marinas@arm.com, will@kernel.org Subject: [PATCH 2/2] Register IPI_CPU_CRASH_STOP IPI as pseudo-NMI Date: Thu, 24 Sep 2020 13:42:36 +0900 Message-Id: <20200924044236.1245808-3-ito-yuichi@fujitsu.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200924044236.1245808-1-ito-yuichi@fujitsu.com> References: <20200924044236.1245808-1-ito-yuichi@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200924_004352_129163_7B5EE4DF X-CRM114-Status: GOOD ( 13.68 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [211.128.242.40 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 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: Yuichi Ito , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Register IPI_CPU_CRASH_STOP IPI as pseudo-NMI. For systems that do not support pseudo-NMI, register as a normal IRQ. Signed-off-by: Yuichi Ito --- arch/arm64/kernel/smp.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index b6bde2675ccc..d929dd7221ff 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -79,6 +79,8 @@ enum ipi_msg_type { static int ipi_irq_base __read_mostly; static int nr_ipi __read_mostly = NR_IPI; static struct irq_desc *ipi_desc[NR_IPI] __read_mostly; +static int ipi_crash_stop = -1; +static int ipi_crash_stop_enable_nmi; static void ipi_setup(int cpu); static void ipi_teardown(int cpu); @@ -954,8 +956,16 @@ static void ipi_setup(int cpu) if (WARN_ON_ONCE(!ipi_irq_base)) return; - for (i = 0; i < nr_ipi; i++) - enable_percpu_irq(ipi_irq_base + i, 0); + for (i = 0; i < nr_ipi; i++) { + if (ipi_irq_base + i == ipi_crash_stop) { + if (!prepare_percpu_nmi(ipi_irq_base + i)) { + enable_percpu_nmi(ipi_irq_base + i, 0); + ipi_crash_stop_enable_nmi = 1; + } else + pr_crit("CPU%u: IPI_CPU_CRASH_STOP cannot be enabled NMI.\n", cpu); + } else + enable_percpu_irq(ipi_irq_base + i, 0); + } } static void ipi_teardown(int cpu) @@ -965,23 +975,37 @@ static void ipi_teardown(int cpu) if (WARN_ON_ONCE(!ipi_irq_base)) return; - for (i = 0; i < nr_ipi; i++) - disable_percpu_irq(ipi_irq_base + i); + for (i = 0; i < nr_ipi; i++) { + if (ipi_irq_base + i == ipi_crash_stop) { + if (ipi_crash_stop_enable_nmi) { + disable_percpu_nmi(ipi_irq_base + i); + teardown_percpu_nmi(ipi_irq_base + i); + } + } else + disable_percpu_irq(ipi_irq_base + i); + } } void __init set_smp_ipi_range(int ipi_base, int n) { - int i; + int i, ret; WARN_ON(n < NR_IPI); nr_ipi = min(n, NR_IPI); + ret = request_percpu_nmi(ipi_base + IPI_CPU_CRASH_STOP, + ipi_handler, "IPI", &cpu_number); + if (!ret) + ipi_crash_stop = ipi_base + IPI_CPU_CRASH_STOP; + for (i = 0; i < nr_ipi; i++) { int err; - err = request_percpu_irq(ipi_base + i, ipi_handler, - "IPI", &cpu_number); - WARN_ON(err); + if (ipi_base + i != ipi_crash_stop) { + err = request_percpu_irq(ipi_base + i, ipi_handler, + "IPI", &cpu_number); + WARN_ON(err); + } ipi_desc[i] = irq_to_desc(ipi_base + i); irq_set_status_flags(ipi_base + i, IRQ_HIDDEN);