From patchwork Tue Dec 8 13:14:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 11958571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 507A0C433FE for ; Tue, 8 Dec 2020 13:16:14 +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 0153A23AA7 for ; Tue, 8 Dec 2020 13:16:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0153A23AA7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.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:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id: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:In-Reply-To:References:List-Owner; bh=trj/imf4aNlb89lBIszpxlupKafzj0P1+/dIXw9WpMc=; b=2W+KTDB5bahZyiY65HRBsSso/F pJli1xFH6mvURe+fvTR/E+Z4fMeQYso1ahFGGvZDgoqfbGRLrnnc1FtfnzBrOKXte5Xehhni/CVls QQ/LMpyvGV84lSLWvDDAN1JAtuFUpNbqBth4owr9WYjztJNWZI85x867py/6nriWLx0AkA+MQaD4b eeu+qPFjhSac7xWJ7RyHhudMDUNVbDI5fn0gvLH2RUzUfuRWEnJfdzUx8Bdh633IJWdUA8/fkJDYm ad6NIqZ1Q+VsPN/8dJFwGuadMiEZ27lwV9wbG83LsHejdIBm7RGp6N639Fz2q/Zg9xPMlYkCsQiNj skIorjxA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmcpP-0001eS-3f; Tue, 08 Dec 2020 13:14:51 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmcpM-0001dt-4J for linux-arm-kernel@lists.infradead.org; Tue, 08 Dec 2020 13:14:49 +0000 Received: by mail-pl1-x644.google.com with SMTP id s2so6952618plr.9 for ; Tue, 08 Dec 2020 05:14:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=0dZtJmjM9NKd3YlN8B/M+0PpX5LNel6ZowNdlfmscLc=; b=PQCbPFmYwA0MGOJhTGZ/wKmez59ur2yY0YNBnjV+Yttp5fHbdWyK7VplamS4TH/QJa Lq6y9MS+THxc9J5YUvYylPAUdeestuAmG4WBQgoyKD2Na4d5p2tQtIehI9K/OaZEtVcA Tqfb0pPQWtwmdPRpJyTuSUytampd32b7+kaDsdoEt8rZFpbQLfq9o9UHh169z1bEmEoC JqOo3AKiqYDFggZhZbB9309ewv610gWbGPBxLlJtj7vSybigQbrzEL0nvnqK82qQzEte qKdLUalUA3fI6HvUG4eWbX7JzCsCRvD7n1KaRdG4AV03zjSLfT/oV5k3XxOoKt/2HuW+ wIKQ== 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; bh=0dZtJmjM9NKd3YlN8B/M+0PpX5LNel6ZowNdlfmscLc=; b=Hcrd7TNoHYCUSztTH77g7tII7mMyv9y/oSBA8OYzBsbURLSdj5J/yGwq7/w935XyGJ zYyn02NR0yVRkDXAKuvreh0ZRCZyV7gCUT15QloP5VTglmCT8nGAT2Oh6SK43S1gcwY7 HfgteyCW7Bs/Aq9MS9GkFnYMRnd75Ei8YyEyhnajFiLFAPzzwyO817HD0ySjlulAq7eY Pdm1SZwJiDma+d/a738vhQ5NbbbC0x6/TxIeg7ftLbkk+5hhHQXMtlbmGs2EY6aDME/f nR20IbEXVOnmnDVmDBCM69Ptvofu+tclNPqfMO/EtXyx8vLZs32MIFNbml5+EBYZJjrF lffg== X-Gm-Message-State: AOAM530gW7XMjBB2GdWjJiBpz2CN8PhmcawuKIDvG+3uDXKnQNe2aTmR Z74Vibe39sBo2cbL4nwR97sEihN16Aqh X-Google-Smtp-Source: ABdhPJxme/nDW+wIsFYqVmoBDhJHR3KEG5GyvAegnybvsU0bBZrrOY9Ac1dNLASD3m1CRHpGSzQyMQ== X-Received: by 2002:a17:902:5581:b029:da:a547:b6a6 with SMTP id g1-20020a1709025581b02900daa547b6a6mr20906262pli.78.1607433285432; Tue, 08 Dec 2020 05:14:45 -0800 (PST) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id u12sm1625486pfn.88.2020.12.08.05.14.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Dec 2020 05:14:44 -0800 (PST) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64/irq: use NMI to send stop IPI Date: Tue, 8 Dec 2020 21:14:30 +0800 Message-Id: <1607433270-9807-1-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201208_081448_367133_5C09DA0A X-CRM114-Status: GOOD ( 18.41 ) 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: Mark Rutland , Julien Thierry , Catalin Marinas , Pingfan Liu , Marc Zyngier , Will Deacon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Like other arches, both 'kexec -l' and 'kexec -p' expect to use NMI to interrupt other cpus in order to capture cpus tightly to a known state. So for both of the cases, try to use NMI IPI if irqchip supports NMI. Signed-off-by: Pingfan Liu Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: Marc Zyngier Cc: Julien Thierry To: linux-arm-kernel@lists.infradead.org --- arch/arm64/kernel/smp.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 18e9727..ff61e2c 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -884,6 +884,31 @@ static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs) } /* + * Overlapped with the counterpart in do_handle_IPI(), only just for nmi purpose + */ +static irqreturn_t nmi_ipi_handler(int irq, void *data) +{ + unsigned int cpu = smp_processor_id(); + int ipinr = irq - ipi_irq_base; + + switch (ipinr) { + case IPI_CPU_STOP: + local_cpu_stop(); + unreachable(); + break; + + case IPI_CPU_CRASH_STOP: + if (IS_ENABLED(CONFIG_KEXEC_CORE)) { + ipi_cpu_crash_stop(cpu, get_irq_regs()); + + unreachable(); + } + break; + } + return IRQ_NONE; +} + +/* * Main handler for inter-processor interrupts */ static void do_handle_IPI(int ipinr) @@ -902,10 +927,12 @@ static void do_handle_IPI(int ipinr) generic_smp_call_function_interrupt(); break; + /* If NMI IPI is not supported */ case IPI_CPU_STOP: local_cpu_stop(); break; + /* If NMI IPI is not supported */ case IPI_CPU_CRASH_STOP: if (IS_ENABLED(CONFIG_KEXEC_CORE)) { ipi_cpu_crash_stop(cpu, get_irq_regs()); @@ -989,6 +1016,14 @@ void __init set_smp_ipi_range(int ipi_base, int n) for (i = 0; i < nr_ipi; i++) { int err; + if (i == IPI_CPU_CRASH_STOP || i == IPI_CPU_STOP) { + err = request_percpu_nmi(ipi_base + i, nmi_ipi_handler, + "NMI-IPI", &cpu_number); + if (!err) + continue; + + pr_warn("Fail to request nmi for NMI-IPI\n"); + } err = request_percpu_irq(ipi_base + i, ipi_handler, "IPI", &cpu_number); WARN_ON(err); @@ -1038,6 +1073,7 @@ void smp_send_stop(void) if (system_state <= SYSTEM_RUNNING) pr_crit("SMP: stopping secondary CPUs\n"); + /* NMI is expected, but it is subject to the irq line's ability */ smp_cross_call(&mask, IPI_CPU_STOP); } @@ -1084,6 +1120,7 @@ void crash_smp_send_stop(void) atomic_set(&waiting_for_crash_ipi, num_other_online_cpus()); pr_crit("SMP: stopping secondary CPUs\n"); + /* NMI is expected, but it is subject to the irq line's ability */ smp_cross_call(&mask, IPI_CPU_CRASH_STOP); /* Wait up to one second for other CPUs to stop */