From patchwork Wed Apr 19 22:56:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13217649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EA789C6FD18 for ; Wed, 19 Apr 2023 23:01:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NpknggINO2NO9MuwpziyDWH5m/fdVL/5ctEmBErlmU0=; b=xQqqzQD6MbBqjW qfFZTlwAd0Kl/J5e5Uu70XFmoil/4O0wD6COI4PLeIjcBqYzvSv5MxTVVH40l8RagV7PXQfhGqUXG KBIsdQF3GBEk8FaSzJI8HwmJGxTdjts+Y/XwchbHDyufa9fqPPtkZAheVb5NhvhAxoiwamO4WapAP sFdEJ/yUAAcKDjCH/ttHUpKrjRAEyzqt4Qzam/shVZkTnvxyTPo4TpBjy0Wg+0rGJH/0F1giOdy8+ u4axmjxMC4FBQbtPPVuvZ3+xNkBeuXucz6Du5UVn0L0HriMgz2Cp0JBHfiHP7s66Ogxplo48oknwN m/DKVExctKVpggiEFviA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppGmX-006a14-1L; Wed, 19 Apr 2023 23:00:09 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGly-006Zby-2i for linux-arm-kernel@bombadil.infradead.org; Wed, 19 Apr 2023 22:59:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=E4z5GDt+xM87DteGPLwbziaQRjegx46K8N8SblpggcI=; b=ck/2DslXzb9Gnk80gxUs+X81sP yuPXLqbNHQapClg7mkqzjRgvZlnuBvG6iSru4rLKagQwGcLcB6gph/1rjISTlzqFJSbOTcELb8YUW mh8g+mh9z30QTpAtugwEMwVGKOE5t3SzCw1RERDXa4msR6QHH1VrOdReKw8Rm5p5GxWeryvUlQFbh 5dr5zGewnsghuK+jEdxsv5GOBiIz4hRWyQdluArOj2khKveOTxDLjsXz5zPvvxV1pS7QosF0mGW08 VMYt33qMqF7P8gQ+oWZvrIBwVOLaJchhL5uifDVq2E0tgtUFo4BkzWXEDS+AaCKLqn5A4TXawijQy 5d6Dz+DQ==; Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGjw-0022GJ-23 for linux-arm-kernel@lists.infradead.org; Wed, 19 Apr 2023 22:59:32 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-24799a2ee83so199702a91.3 for ; Wed, 19 Apr 2023 15:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681945044; x=1684537044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E4z5GDt+xM87DteGPLwbziaQRjegx46K8N8SblpggcI=; b=lc6v/s63EfbX00zVBBvJow9kK2OWQHb1m041wnlXgjL4xvvZO/7aM1krXhOpZ+8FaO S7q+1SLxn3DdIZc+V5hfAlV4WjCb55HFzJDRyln3Irp6M3XCvR3EpDqv602NSOH5HNEg AHLZ0H0gG03A78NxoByf2kyaW6GKVrkQRI+dQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681945044; x=1684537044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E4z5GDt+xM87DteGPLwbziaQRjegx46K8N8SblpggcI=; b=liJiJjAnM46luaR/px6R18r+FoSaGYpXHMeMb9l522iq+3zSNnptYAEFQ+lcUMGoP6 TVXlRq5oi2VIeJeoRfjJmTQyDGWouOgBAY7bqJjeI/+p0gmnx9H4C92KLpCUilePpAkI GeSRoN5guYHVFONKnrxIP+jEbpVcEQkFGfWEhGBIjy9fKQgiJzZwxpVYO95qEVtqUZGz ujcRoVNO4vU6qs8Kb9EOEJin4idB5krSe8ZaGERT5AfnKMCvQCJyObA/9vlpAHCz9Agw js/JC5cgoiRkbphAiMQpyPowzAhVHPaKdCqYw6p60EYG5LKlDCDAPYzZHR29vJThT0lK bQsg== X-Gm-Message-State: AAQBX9d1UHI05vQdKA2rsh8mFfLML1lALkiH9WDPC1UVkUUzrEJ2noqV hk1TZ5VA6h5DRMr19U9/fQMNhg== X-Google-Smtp-Source: AKy350aIOHfPbowBDglSQr5Ur+c9Q9vdVJvKvaRSc+zSrfA52Pfz++ZHTr6h2HiJKmK6NXRBfzJ5NQ== X-Received: by 2002:a17:90a:5a82:b0:23f:83de:7e4a with SMTP id n2-20020a17090a5a8200b0023f83de7e4amr4268789pji.7.1681945044116; Wed, 19 Apr 2023 15:57:24 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8b1:fa03:670e:b784]) by smtp.gmail.com with ESMTPSA id h15-20020a17090aea8f00b00246ea338c96sm1847101pjz.53.2023.04.19.15.57.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:57:23 -0700 (PDT) From: Douglas Anderson To: Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier , Mark Rutland Cc: ito-yuichi@fujitsu.com, kgdb-bugreport@lists.sourceforge.net, Chen-Yu Tsai , Masayoshi Mizuma , Peter Zijlstra , Ard Biesheuvel , "Rafael J . Wysocki" , linux-arm-kernel@lists.infradead.org, Stephen Boyd , Lecopzer Chen , Thomas Gleixner , linux-perf-users@vger.kernel.org, Douglas Anderson , Masayoshi Mizuma , linux-kernel@vger.kernel.org Subject: [PATCH v8 10/10] arm64: ipi_nmi: Fallback to a regular IPI if NMI isn't enabled Date: Wed, 19 Apr 2023 15:56:04 -0700 Message-ID: <20230419155341.v8.10.Ic3659997d6243139d0522fc3afcdfd88d7a5f030@changeid> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230419225604.21204-1-dianders@chromium.org> References: <20230419225604.21204-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_235929_123148_339BD72C X-CRM114-Status: GOOD ( 20.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The current ipi_nmi implementation relies on the arm64 pseudo-NMI support. This needs to be enabled in both the kernel config with CONFIG_ARM64_PSEUDO_NMI and on the kernel command line with "irqchip.gicv3_pseudo_nmi=1". Let's add a fallback of using a regular IPI if the NMI isn't enabled. The fallback mechanism of using a regular IPI matches what arm32 does all the time since there is no NMI there. The reason for doing this is to make the trigger_all_cpu_backtrace() class of functions work. While those functions all return a bool indicating that the caller should try a fallback upon failure, an inspection of the callers shows that nearly nobody implements a fallback. It's better to at least provide something here. Signed-off-by: Douglas Anderson --- I dunno what people think of this patch. If it's great, we could actually drop some of the patches out of this series since some of them are to account for the fact that we might not be able to register an "ipi_nmi". If it's awful, it could simply be dropped. Changes in v8: - "Fallback to a regular IPI if NMI isn't enabled" new for v8 arch/arm64/kernel/ipi_nmi.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/ipi_nmi.c b/arch/arm64/kernel/ipi_nmi.c index 2adaaf1519e5..02868752845c 100644 --- a/arch/arm64/kernel/ipi_nmi.c +++ b/arch/arm64/kernel/ipi_nmi.c @@ -16,6 +16,7 @@ static struct irq_desc *ipi_nmi_desc __read_mostly; static int ipi_nmi_id __read_mostly; +static bool is_nmi; bool arm64_supports_nmi(void) { @@ -62,8 +63,12 @@ void dynamic_ipi_setup(void) if (!ipi_nmi_desc) return; - if (!prepare_percpu_nmi(ipi_nmi_id)) - enable_percpu_nmi(ipi_nmi_id, IRQ_TYPE_NONE); + if (is_nmi) { + if (!prepare_percpu_nmi(ipi_nmi_id)) + enable_percpu_nmi(ipi_nmi_id, IRQ_TYPE_NONE); + } else { + enable_percpu_irq(ipi_nmi_id, IRQ_TYPE_NONE); + } } void dynamic_ipi_teardown(void) @@ -71,14 +76,28 @@ void dynamic_ipi_teardown(void) if (!ipi_nmi_desc) return; - disable_percpu_nmi(ipi_nmi_id); - teardown_percpu_nmi(ipi_nmi_id); + if (is_nmi) { + disable_percpu_nmi(ipi_nmi_id); + teardown_percpu_nmi(ipi_nmi_id); + } else { + disable_percpu_irq(ipi_nmi_id); + } } void __init set_smp_dynamic_ipi(int ipi) { + int err; + if (!request_percpu_nmi(ipi, ipi_nmi_handler, "IPI", &cpu_number)) { - ipi_nmi_desc = irq_to_desc(ipi); - ipi_nmi_id = ipi; + is_nmi = true; + } else { + err = request_percpu_irq(ipi, ipi_nmi_handler, "IPI", &cpu_number); + if (WARN_ON(err)) + return; + + irq_set_status_flags(ipi, IRQ_HIDDEN); } + + ipi_nmi_desc = irq_to_desc(ipi); + ipi_nmi_id = ipi; }