Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1581755rdb; Mon, 2 Oct 2023 14:21:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0OZ4PlOBoNFZL3lldttcKd9zh4+Liv0/CJ2m7K8lfXoh2SmL8fEsfdS6czwgwlSwv1up6 X-Received: by 2002:a05:6358:3408:b0:135:3f5c:9675 with SMTP id h8-20020a056358340800b001353f5c9675mr13999382rwd.19.1696281678863; Mon, 02 Oct 2023 14:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696281678; cv=none; d=google.com; s=arc-20160816; b=RgXppg8QrVQlS7HQq4FgVFKdeyqLR70aHHHaCap5qCHja3VmND6Zbe6fAEYolu75k8 Nm8T6+Vje9R1Vj0q7ohTEysZmVITS+yTJA3dTZmBQAQLHztmI1sSFzbGJFCn1tlJKmsH HHKEBUTW/Ok9gYS0T/Ov9tdBjRwQS3/+QN94BYbGX3MASnmHEfamt8Lzs6j+QoKYrgsP 1KwAZs2Lc9vMpe6lJWQ9EMqcm2ZLT74cusjtnVxJmo9fgUD/AI46aJ9WcDA8OXAkUMFD CFToGuCP5eZOEYlaiqLUmlvV8oH4bt28NvfE3Dj7l1/z1XjMJMHUucdauBagd5vM59Ix bulA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=w025f/6AdfhrbLNyBq/UB//v5OtoztTxmfkB6A0lQtk=; fh=Ax5vTVdZsQ0Kw1zvGbgZ/1sZDWz5nOKBb70idRRHt4o=; b=Yk37H1fjq+YokgLYn3cfCwKHpE+IzX5aA0oXcS7qFgknwHAysAsnfph18bfYUi/p+L /OOF52Uu2VEJ/TGZLriXFXNn4ajB99MafbDvI+e5gXWSK2q5VeE90meklZAYp5idJ7zq B/q3thZCPNSJnWUnrSvgV35adhTWItZHVx4SYAKS6t7EYr+nxu0u9GnD/nIeFs8XHnw9 EaprockQqCdIVjzGidCHGWCUp1NMUxwqjQR994G+jvl4N1Rhp2PyaJts0chtSCkQaEhg sti1Uex+CZyDXPESRlf36jagK74AwYV1S71f0qyx6fG67Y3cg23jsqEeHgJNv5MJltpw x5HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BY+Ph2xg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id z17-20020aa78891000000b0068fb5cec8cfsi28790294pfe.267.2023.10.02.14.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 14:21:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BY+Ph2xg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 890EE8096FED; Mon, 2 Oct 2023 12:16:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229629AbjJBTQn (ORCPT + 99 others); Mon, 2 Oct 2023 15:16:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjJBTQm (ORCPT ); Mon, 2 Oct 2023 15:16:42 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BCF2AC for ; Mon, 2 Oct 2023 12:16:39 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9a9d82d73f9so9163466b.3 for ; Mon, 02 Oct 2023 12:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696274195; x=1696878995; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=w025f/6AdfhrbLNyBq/UB//v5OtoztTxmfkB6A0lQtk=; b=BY+Ph2xgmcJS6lMgcv6xlOKb8em0H8WFes1SgQc+A5BMG3NyF0ZfssuGOcADXqeoTG KMBYcIICOwvooM6PxzaUhHHjTcylFXujXbvTUOXMCX82rVs0Aija7hNzWSVjI4l7hXr4 hobcBO6xvPH+yce3wqulE7VKQ2olZYAHurbyU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696274195; x=1696878995; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w025f/6AdfhrbLNyBq/UB//v5OtoztTxmfkB6A0lQtk=; b=kmRUgMoR2ikrqlFQk6VKDMt4vIMV8cNrOFvaT6usT6aJBPd741yoD70O8jT0kur7sA fC64rYkOJSCm7UsoBxd8PYwkvZMeFpQB5NFYDGlSfpFfVUas266Bxi1GtRf9TawTpIvs YVXFrHo8DjWDq2EuL00doLLJoHXf6+KJ5XKSLBuP7ql6WlidGSNt0Os8Bzv0P5ZLjYiL t3XLD4xl6GcNVCEtc4YwriNaUxlsIn6/HbGGWmXhGS4AGByE0tDpJehfQzZyPRDsKYbR pwYT08gssKky6BjJhtsBRtVUqRTt4KVjjNmtiJ0pz+3dRxpZIKS5PbQfRSw61e5YH651 Ntzw== X-Gm-Message-State: AOJu0Yw1w/gv0SjApCY3BwLhxsdV5/UnEU3+jNF+0nDeTAG3TmppcoDk glo01KAIXpB3p285XCjfN03eMqFEb42sWuGuva+CMDKY X-Received: by 2002:a17:906:25b:b0:9a2:185b:5375 with SMTP id 27-20020a170906025b00b009a2185b5375mr10864731ejl.18.1696274195513; Mon, 02 Oct 2023 12:16:35 -0700 (PDT) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com. [209.85.128.43]) by smtp.gmail.com with ESMTPSA id l6-20020a1709060e0600b009ae05f9eab3sm17462228eji.65.2023.10.02.12.16.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Oct 2023 12:16:35 -0700 (PDT) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4053f24c900so17035e9.1 for ; Mon, 02 Oct 2023 12:16:34 -0700 (PDT) X-Received: by 2002:a05:600c:3b07:b0:400:46db:1bf2 with SMTP id m7-20020a05600c3b0700b0040046db1bf2mr28521wms.2.1696274194181; Mon, 02 Oct 2023 12:16:34 -0700 (PDT) MIME-Version: 1.0 References: <20231002094526.1.Ie8f760213053e3d11592f892b30912dbac6b8b48@changeid> In-Reply-To: From: Doug Anderson Date: Mon, 2 Oct 2023 12:16:17 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] arm64: smp: Fix pseudo NMI issues w/ broken Mediatek FW To: Mark Rutland Cc: Catalin Marinas , Will Deacon , Marc Zyngier , Stephen Boyd , Valentin Schneider , Chen-Yu Tsai , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 02 Oct 2023 12:16:55 -0700 (PDT) Hi, On Mon, Oct 2, 2023 at 10:24=E2=80=AFAM Mark Rutland = wrote: > > On Mon, Oct 02, 2023 at 09:45:29AM -0700, Douglas Anderson wrote: > > 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 > > --- > > > > arch/arm64/kernel/smp.c | 19 ++++++++++++------- > > 1 file changed, 12 insertions(+), 7 deletions(-) > > I'm not too keen on falling back here when we have no idea why the reques= t failed. > > I'd prefer if we could check the `supports_pseudo_nmis` static key direct= ly to > account for the case of broken FW, e.g. as below. > > Mark. > > ---->8---- > From 72fdec05c64a74f21871b44c7c760bbe07cac044 Mon Sep 17 00:00:00 2001 > From: Mark Rutland > Date: Mon, 2 Oct 2023 18:00:36 +0100 > Subject: [PATCH] arm64: smp: avoid NMI IPIs with broken MediaTek FW > > Some MediaTek devices have broken firmware which corrupts some GICR > registers behind the back of the OS, and pseudo-NMIs cannot be used on > these devices. For more details see commit: > > 44bd78dd2b8897f5 ("irqchip/gic-v3: Disable pseudo NMIs on Mediatek devi= ces w/ firmware issues") > > We did not take this problem into account in commit: > > 331a1b3a836c0f38 ("arm64: smp: Add arch support for backtrace using pse= udo-NMI") > > Since that commit arm64's SMP code will try to setup some IPIs as > pseudo-NMIs, even on systems with broken FW. The GICv3 code will > (rightly) reject attempts to request interrupts as pseudo-NMIs, > resulting in boot-time failures. > > Avoid the problem by taking the broken FW into account when deciding to > request IPIs as pseudo-NMIs. The GICv3 driver maintains a static_key > named "supports_pseudo_nmis" which is false on systems with broken FW, > and we can consult this within ipi_should_be_nmi(). > > Fixes: 331a1b3a836c0f38 ("arm64: smp: Add arch support for backtrace usin= g pseudo-NMI") > Reported-by: Chen-Yu Tsai > Closes: https://issuetracker.google.com/issues/197061987#comment68 > Signed-off-by: Mark Rutland > Cc: Douglas Anderson > Cc: Marc Zyngier > --- > arch/arm64/kernel/smp.c | 5 ++++- > drivers/irqchip/irq-gic-v3.c | 2 +- > 2 files changed, 5 insertions(+), 2 deletions(-) Sure, this is OK w/ me as long as folks don't mind accessing the global here, it's OK w/ me: Reviewed-by: Douglas Anderson It seems to work for me, thus: Tested-by: Douglas Anderson > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 814d9aa93b21b..061c69160f90f 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -964,7 +964,10 @@ static void smp_cross_call(const struct cpumask *tar= get, unsigned int ipinr) > > static bool ipi_should_be_nmi(enum ipi_msg_type ipi) > { > - if (!system_uses_irq_prio_masking()) > + DECLARE_STATIC_KEY_FALSE(supports_pseudo_nmis); > + > + if (!system_uses_irq_prio_masking() || > + !static_branch_likely(&supports_pseudo_nmis)) One thought, actually, is whether we should actually change system_uses_irq_prio_masking() to return the correct value. What do you think? -Doug