From patchwork Mon Oct 2 16:45:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13406468 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 0E80EE748FA for ; Mon, 2 Oct 2023 16:46:51 +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: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:In-Reply-To:References: List-Owner; bh=8LHEFtN1T8gGYPT8Fs+AUsYD2ewgod2xqlnBf/7rLkQ=; b=PY2nrGrm4Uqmjp l3pL2BmyKtirsjhnWqtUo3RQP/t0tb5dKoTSAdvVxWBEWVRE/RqQEqlxyGvK7zxCO/XYeTsYSzs2N SS8t+iwFYvMeNOKAEmOC2WWPPOUCwMiFJEu1+9QDaLSK+P/v4ihstj/XuBGXIEGBBo4OBOiOGASwv 1F7iBp54Ua5gZCu/YJzhvLaRNBW/evtLdnJBL7esiFk99sW/J16l7zuZBLPIjahPZr+5xhDP9KELL f9NXX2Bbu0WGnxurU56COwuRC68ES0mcbNrDzvXG8S3Wo8KsOR8f8r/5IGiV0afrF8Bsae8ckbBa9 GQcKyQENnH2p7JZAwpXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qnM3n-00D5pv-2Z; Mon, 02 Oct 2023 16:46:19 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qnM3k-00D5oP-33 for linux-arm-kernel@lists.infradead.org; Mon, 02 Oct 2023 16:46:18 +0000 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5855333fbadso4649234a12.1 for ; Mon, 02 Oct 2023 09:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696265174; x=1696869974; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=aLqyuV3WHU1tmRucfRRbNKiUdX9Z1rFjqb2ZE34s0NQ=; b=LmydDOfccyzV4UKYJ25i9M2VDuhe+09T+xeIXp/8XoIApm8sHqjT5sOQfQ0ZeFFz+r BMIC3T348OD4E/EH1aIpyiHQ0o2OyVW3Gz7vV3jkSZ383rdzi5ANG3Tu/Ng77IhemgBT lBD29KKsMuRiffO6sPuMV2IosLEACI+aYuwS0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696265174; x=1696869974; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aLqyuV3WHU1tmRucfRRbNKiUdX9Z1rFjqb2ZE34s0NQ=; b=sX0bzOMno60TN3amgRheZjniTPhiNuDCpgW8RdstGlHEvFSIus3KK/LMefOuHU4IE8 QFPFRONg6l+9u/wfK5gwdBTRpsNuAzlvXJHTPCYwa7MKHtcV7ihA2nMwUekMfQVgAhNY PtPvmMgyy21NB24qHAsvAyhWpcGOQ+QXwpIqmz0jkkaq+XEiZlNO9Ei9Qr2SgqVhhutP ecFuICFB9vXHHqOdSluCTp1X0uGbWsjPJSBz47tBhfvUDPGEY4gUibywOtZA66D+G2kz 3mWYySKorahgj/5IbhlG+Ct+XI3Zubc0c3dJ0OdPlAhbTwew23jDJjXP2JnZtWtPvV8S ccFQ== X-Gm-Message-State: AOJu0YwY6V/198FOTTJe3FR+e4AIA4EdWVYX1XqKAJuxrefiR5GZwlo3 yCQG3nSGRgJ2lfjvmLOZwyf1dg== X-Google-Smtp-Source: AGHT+IFuyESTg1qXH/EpmpZCYlorecz5cuQHSkF+/6rKpci8edHI/LtYiWRbzzYyGr4lSooBLvepRg== X-Received: by 2002:a05:6a20:a110:b0:13d:1d14:6693 with SMTP id q16-20020a056a20a11000b0013d1d146693mr12076717pzk.45.1696265173921; Mon, 02 Oct 2023 09:46:13 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:bb:b2b6:1831:5edd]) by smtp.gmail.com with ESMTPSA id n3-20020a170902d2c300b001c737950e4dsm8455904plc.2.2023.10.02.09.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:46:13 -0700 (PDT) From: Douglas Anderson To: Catalin Marinas , Will Deacon , Mark Rutland , Marc Zyngier Cc: Stephen Boyd , Valentin Schneider , Chen-Yu Tsai , Douglas Anderson , AngeloGioacchino Del Regno , D Scott Phillips , Josh Poimboeuf , Matthias Brugger , Misono Tomohiro , Peter Zijlstra , Sumit Garg , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 1/2] arm64: smp: Fix pseudo NMI issues w/ broken Mediatek FW Date: Mon, 2 Oct 2023 09:45:29 -0700 Message-ID: <20231002094526.1.Ie8f760213053e3d11592f892b30912dbac6b8b48@changeid> X-Mailer: git-send-email 2.42.0.582.g8ccd20d70d-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231002_094616_980428_D992FBFB X-CRM114-Status: GOOD ( 17.75 ) 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 Some mediatek devices have the property "mediatek,broken-save-restore-fw" in their GIC. This means that, although the hardware supports pseudo-NMI, the firmware has a bug that blocks enabling it. When we're in this state, system_uses_irq_prio_masking() will return true but we'll fail to actually enable the IRQ in the GIC. Let's make the code handle this. We'll detect that we failed to request an IPI as NMI and fallback to requesting it normally. Though we expect that either all of our requests will fail or all will succeed, it's just as cheap to keep a per-IPI bitmap and that keeps us robust. Fixes: 331a1b3a836c ("arm64: smp: Add arch support for backtrace using pseudo-NMI") Reported-by: Chen-Yu Tsai Closes: https://issuetracker.google.com/issues/197061987#comment68 Signed-off-by: Douglas Anderson Reported-by: Chen-Yu Tsai Signed-off-by: Mark Rutland Reviewed-by: Douglas Anderson Tested-by: Douglas Anderson Reviewed-by: Marc Zyngier Tested-by: Chen-Yu Tsai --- arch/arm64/kernel/smp.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 814d9aa93b21..0a6002243a8c 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -87,6 +87,7 @@ enum ipi_msg_type { static int ipi_irq_base __ro_after_init; static int nr_ipi __ro_after_init = NR_IPI; static struct irq_desc *ipi_desc[MAX_IPI] __ro_after_init; +DECLARE_BITMAP(ipi_is_nmi, MAX_IPI); static void ipi_setup(int cpu); @@ -986,7 +987,7 @@ static void ipi_setup(int cpu) return; for (i = 0; i < nr_ipi; i++) { - if (ipi_should_be_nmi(i)) { + if (test_bit(i, ipi_is_nmi)) { prepare_percpu_nmi(ipi_irq_base + i); enable_percpu_nmi(ipi_irq_base + i, 0); } else { @@ -1004,7 +1005,7 @@ static void ipi_teardown(int cpu) return; for (i = 0; i < nr_ipi; i++) { - if (ipi_should_be_nmi(i)) { + if (test_bit(i, ipi_is_nmi)) { disable_percpu_nmi(ipi_irq_base + i); teardown_percpu_nmi(ipi_irq_base + i); } else { @@ -1022,17 +1023,21 @@ void __init set_smp_ipi_range(int ipi_base, int n) nr_ipi = min(n, MAX_IPI); for (i = 0; i < nr_ipi; i++) { - int err; + int err = -EINVAL; if (ipi_should_be_nmi(i)) { err = request_percpu_nmi(ipi_base + i, ipi_handler, "IPI", &cpu_number); - WARN(err, "Could not request IPI %d as NMI, err=%d\n", - i, err); - } else { + if (err) + pr_info_once("NMI unavailable; fallback to IRQ\n"); + else + set_bit(i, ipi_is_nmi); + } + + if (err) { err = request_percpu_irq(ipi_base + i, ipi_handler, "IPI", &cpu_number); - WARN(err, "Could not request IPI %d as IRQ, err=%d\n", + WARN(err, "Could not request IPI %d, err=%d\n", i, err); } From patchwork Mon Oct 2 16:45:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13406467 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 B339AE748F8 for ; Mon, 2 Oct 2023 16:46:49 +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=NoA1QLwRLJBQcAh2z9zEQBYziAm/LhenRxYWev2XR8o=; b=jBSC6FlxH4z8Sg AyLJ5IOK6a2k695Esdr+NkAOZFOI+XiaVl3MO7CN/wU3XAvxQI4plmcrmb1RbwDBECewmADnIX/Md tPUgXR1atr6X6mgwxxtuOPZUqY2M+IS+Q/CNMuR1av3/wUk/4mwTk8vlAW7mO9J54v+bX/dxrRQRp gDkhzZAOfmn7ZULev+4fllWxCbrVxzEycLeyrmAcy5bGKEZPy3u35qGY0lCe2hILrwZIKq9VP88Pm z1vHStR+lNzY8eRWnxFAVdAMpx9pidoi4XOcICkS5VqDJaBMe4Wt9anzpXSHKJo9R4UUrD90Zg6yq I4VSTnSZf5xOlNvy8f9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qnM3p-00D5qj-0m; Mon, 02 Oct 2023 16:46:21 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qnM3l-00D5oX-1i for linux-arm-kernel@lists.infradead.org; Mon, 02 Oct 2023 16:46:20 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-690bccb0d8aso13428423b3a.0 for ; Mon, 02 Oct 2023 09:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696265176; x=1696869976; darn=lists.infradead.org; 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=+OYydoz0zgcPlyOphP3bRXT7u9ruoeqId11POu4ytwI=; b=Qrjf7NHo7Q1AhV5YkomElOmt+OFncStr5TEN7KVilUhy4LUN/1dkl8fz/8EP0fDlkg aaaIzOSmdc0ERo4muAbGzLalmIlzYzTgL8zHl5YkZtgQuGPz01HjKlCfb/5h5tSTZB4C Ok9PeSWRWOowUJGz1G3OGjalhrsoUUpGmMpO0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696265176; x=1696869976; 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=+OYydoz0zgcPlyOphP3bRXT7u9ruoeqId11POu4ytwI=; b=fwIZ9CffIXq9wE6L2u1bmxUpL2d9hks5EcJ7jtdBBElRhkPqir/ExnaEl8S4RU1qft PImMHIDt0yxIXFycJX0Pq4HbJgvXQfCTYKjYEp3UJtoX6/3oWyGMQJ+7BeXS3NU0gTqH CBpbDzjp8YNbEhLMy3dt4LkrHT1sljWPNIzuXdcTFKZF+CrEDQdrgWiADlq49+iNfU8a SM0nO4UXijieWqJGz9ISVhihH5lWsXzpAC3klcn7Id/KxRbW/sELsGvmxtVNbX1MhJTA LWoKGYPtpayd3ZUm+IiJAJAUaEIhbs5ov8jekCjY/8M36V+9OVFVmWjsJzflOlsWUQ9b i1rw== X-Gm-Message-State: AOJu0YxE+Vz0K/AR5vguvCLfn9geG55Ck1QcvqEQdFQXlC6tW84cUpTE kylUsCO49/ZBkyp94ZmoS1I1Ew== X-Google-Smtp-Source: AGHT+IHLivOZAOPYQoFyzGuRgSJcfrcRS4DH8AgOzW7A69owybG54PttqaXKEA5bmpeD5DDV61nKAQ== X-Received: by 2002:a05:6a21:47cb:b0:163:e1a1:5a16 with SMTP id as11-20020a056a2147cb00b00163e1a15a16mr4527290pzc.31.1696265175774; Mon, 02 Oct 2023 09:46:15 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:bb:b2b6:1831:5edd]) by smtp.gmail.com with ESMTPSA id n3-20020a170902d2c300b001c737950e4dsm8455904plc.2.2023.10.02.09.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:46:15 -0700 (PDT) From: Douglas Anderson To: Catalin Marinas , Will Deacon , Mark Rutland , Marc Zyngier Cc: Stephen Boyd , Valentin Schneider , Chen-Yu Tsai , Douglas Anderson , D Scott Phillips , Josh Poimboeuf , Peter Zijlstra , Sumit Garg , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] arm64: smp: Don't directly call arch_smp_send_reschedule() for wakeup Date: Mon, 2 Oct 2023 09:45:30 -0700 Message-ID: <20231002094526.2.I2e6d22fc42ccbf6b26465a28a10e36e05ccf3075@changeid> X-Mailer: git-send-email 2.42.0.582.g8ccd20d70d-goog In-Reply-To: <20231002094526.1.Ie8f760213053e3d11592f892b30912dbac6b8b48@changeid> References: <20231002094526.1.Ie8f760213053e3d11592f892b30912dbac6b8b48@changeid> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231002_094617_567665_FE41FC10 X-CRM114-Status: GOOD ( 17.81 ) 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 In commit 2b2d0a7a96ab ("arm64: smp: Remove dedicated wakeup IPI") we started using a scheduler IPI to avoid a dedicated reschedule. When we did this, we used arch_smp_send_reschedule() directly rather than calling smp_send_reschedule(). The only difference is that calling arch_smp_send_reschedule() directly avoids tracing. Presumably we _don't_ want to avoid tracing here, so switch to smp_send_reschedule(). Fixes: 2b2d0a7a96ab ("arm64: smp: Remove dedicated wakeup IPI") Signed-off-by: Douglas Anderson Acked-by: Mark Rutland --- I don't 100% know if this is correct and I don't have any hardware that uses the "ACPI parking protocol", but I think it's right. My main incentive for this is that it makes it easier to backport pseudo-NMI to kernels that don't have arch_smp_send_reschedule(), but I think it's also more correct. If for some reason we truly did want to avoid tracing here, please shout and we can drop this patch. arch/arm64/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 0a6002243a8c..b530d8ef9c1d 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -1063,7 +1063,7 @@ void arch_send_wakeup_ipi(unsigned int cpu) * We use a scheduler IPI to wake the CPU as this avoids the need for a * dedicated IPI and we can safely handle spurious scheduler IPIs. */ - arch_smp_send_reschedule(cpu); + smp_send_reschedule(cpu); } #endif