Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp9438075rwr; Thu, 11 May 2023 15:10:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5v8BXiKqnHY+hVXlr1xEuZwnw5LxKn7TZhSjh+8avr8X9qvNwlXY3faxPpWR+fnV9VLIQ8 X-Received: by 2002:a17:90a:e56:b0:246:97d2:dc27 with SMTP id p22-20020a17090a0e5600b0024697d2dc27mr23661197pja.42.1683843030463; Thu, 11 May 2023 15:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683843030; cv=none; d=google.com; s=arc-20160816; b=xSr7+2aeSfk0mKSSVAGmOwERvQhxj6+KU3Y9bIa6TSzJr7+u9A98C7ipvCVd97IyF8 GQRKDVepWDl+1sAHImSM+sMPpHZxUgxpByyywh0Vea6s/rQ7aK4Fw8bemS8YcBpnlph2 V/uVpqGdWsIYlvI+EzUlb0FvHGrlvo2ceH6ZeXLLzX3q1VIMKl23b3NtyScwjDu9k2k6 WifTyZxYVkZwDipvTy/HIxXFMHLUlACZbDyLu2p3lew3BzHSR98tLMMpgEhoj7S+f6Qk ik8oHbf5D0gLhlFUUKY56g1Te6gWLg3PW78gsBkBqcYg/4joTMdcqLivVTrfMzcBYJDD JW7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7GXLLz1cb9WjUR21vBHXCkRjhHYZlPAU9fn/3rFZSY4=; b=x1sf8GM+uHEWAuYB85C/mt74k378xHx/WnEpkLEp7uYqeT9pgR40vdGRuOEbgtiGqk 3pqnPDqS3E8/09YZIFmAEW1HbU6GDckL5ygv51g7Sg4Fn2bN96loiV879ZEaWy2rteOE I+av5WaES3GA6fOGa4XEKmmRJhTrh1qLQXKYGTch/gHvzrvZzBaNOPdLo6eV96JTSiem fnjkEYRm/dTwshrnndxl8b0nNsXc+Fd+nnItYpMa6HVe0EnH42RCDqtXQz7LJY8w4Xsn 2dzdsnHNh1Sf5ZugHGoeoiQLDCPAHMpyLdSINsTM+ZGzOctXPr+bMhiW4tB6Q4UcJwrX leQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DExkZbfi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rj2-20020a17090b3e8200b002503ba697e9si16570894pjb.131.2023.05.11.15.10.15; Thu, 11 May 2023 15:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DExkZbfi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238949AbjEKWHb (ORCPT + 99 others); Thu, 11 May 2023 18:07:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239033AbjEKWHY (ORCPT ); Thu, 11 May 2023 18:07:24 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67763729E for ; Thu, 11 May 2023 15:07:22 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-24df6bbf765so8016734a91.0 for ; Thu, 11 May 2023 15:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683842842; x=1686434842; 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=7GXLLz1cb9WjUR21vBHXCkRjhHYZlPAU9fn/3rFZSY4=; b=DExkZbfiK7dYHdPhxBr1koLSFcgH+8Qe2mzgYfxjWSP/l0Qrezi1bLqTam26KdtwOY 39sMwKChIzmpXPLMiTALhfSPVRkRfcYA+JkOOmLwzXXWNweNCgMnDBwgihE9jkZ+CdoO a5jxyKCc+96tFL1pYbjuJVvHn82u64k8LtHmI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683842842; x=1686434842; 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=7GXLLz1cb9WjUR21vBHXCkRjhHYZlPAU9fn/3rFZSY4=; b=MhwhSUE7Tn2f6q9/NZpSPYxOC/Koq309S3tkuJxS6p+5jI5LYnIiufB1uCXbpHR1ky YonlPxr4OPB08zHpjZYhX+J5vtrQgkofEOBRv3avkpg0BdKAHqgpcoa5hxe6JGAB1HBe 2GsNg/qBpIoyQfx2k/knv/k2ecZcDqXuPJIaMPTK+KgOGAuS7aKuGU0oBlvYI/C7qVmS VXuJXZylXg+J9aJEWQ04OoxaxdKj3P5hK1kq7kN5lQlIdgFL2AGnt4eNIbs1mBZoHCRv JUQ84X+o7FBm6ixg/fbQvddLLCfPV7L9C+DmYlUbB5Wz6tGW9mD14+xIyW2jebJP3EHK gaKA== X-Gm-Message-State: AC+VfDyEzHGZuL1klVOPPmWMQo+l/cvHJZSl1MpIGHaAJV32RYP21pNs 8FGfnpATNsodnIMWOERMxk+YKA== X-Received: by 2002:a17:90b:28b:b0:246:9ef5:3c45 with SMTP id az11-20020a17090b028b00b002469ef53c45mr23147850pjb.13.1683842841770; Thu, 11 May 2023 15:07:21 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:b96a:d776:ee3:e572]) by smtp.gmail.com with ESMTPSA id h24-20020a17090a9c1800b00247735d1463sm17589457pjp.39.2023.05.11.15.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 15:07:21 -0700 (PDT) From: Douglas Anderson To: Marc Zyngier , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Matthias Brugger Cc: devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, wenst@chromium.org, Eddie Huang , Allen-KH Cheng , Ben Ho , Weiyi Lu , AngeloGioacchino Del Regno , linux-arm-kernel@lists.infradead.org, Tinghan Shen , jwerner@chromium.org, Hsin-Hsiung Wang , yidilin@chromium.org, Seiya Wang , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [PATCH 2/6] irqchip/gic-v3: Disable pseudo NMIs on Mediatek devices w/ firmware issues Date: Thu, 11 May 2023 15:05:36 -0700 Message-ID: <20230511150539.2.I88dc0a0eb1d9d537de61604cd8994ecc55c0cac1@changeid> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog In-Reply-To: <20230511150539.6.Ia0b6ebbaa351e3cd67e201355b9ae67783c7d718@changeid> References: <20230511150539.6.Ia0b6ebbaa351e3cd67e201355b9ae67783c7d718@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some Chromebooks with Mediatek SoCs have a problem where the firmware doesn't properly save/restore certain GICR registers. Newer Chromebooks should fix this issue and we may be able to do firmware updates for old Chromebooks. At the moment, the only known issue with these Chromebooks is that we can't enable "pseudo NMIs" since the priority register can be lost. Enabling "pseudo NMIs" on Chromebooks with the problematic firmware causes crashes and freezes. Let's detect devices with this problem and then disable "pseudo NMIs" on them. We'll detect the problem by looking for the presence of the "mediatek,gicr-save-quirk" property in the GIC device tree node. Any devices with fixed firmware will not have this property. Our detection plan works because we never bake a Chromebook's device tree into firmware. Instead, device trees are always bundled with the kernel. We'll update the device trees of all affected Chromebooks and then we'll never enable "pseudo NMI" on a kernel that is bundled with old device trees. When a firmware update is shipped that fixes this issue it will know to patch the device tree to remove the property. In order to make this work, the quick detection mechanism of the GICv3 code is extended to be able to look for properties in addition to looking at "compatible". Signed-off-by: Douglas Anderson --- drivers/irqchip/irq-gic-common.c | 8 ++++++-- drivers/irqchip/irq-gic-common.h | 1 + drivers/irqchip/irq-gic-v3.c | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-common.c b/drivers/irqchip/irq-gic-common.c index a610821c8ff2..de47b51cdadb 100644 --- a/drivers/irqchip/irq-gic-common.c +++ b/drivers/irqchip/irq-gic-common.c @@ -16,7 +16,11 @@ void gic_enable_of_quirks(const struct device_node *np, const struct gic_quirk *quirks, void *data) { for (; quirks->desc; quirks++) { - if (!of_device_is_compatible(np, quirks->compatible)) + if (quirks->compatible && + !of_device_is_compatible(np, quirks->compatible)) + continue; + if (quirks->property && + !of_property_read_bool(np, quirks->property)) continue; if (quirks->init(data)) pr_info("GIC: enabling workaround for %s\n", @@ -28,7 +32,7 @@ void gic_enable_quirks(u32 iidr, const struct gic_quirk *quirks, void *data) { for (; quirks->desc; quirks++) { - if (quirks->compatible) + if (quirks->compatible || quirks->property) continue; if (quirks->iidr != (quirks->mask & iidr)) continue; diff --git a/drivers/irqchip/irq-gic-common.h b/drivers/irqchip/irq-gic-common.h index 27e3d4ed4f32..3db4592cda1c 100644 --- a/drivers/irqchip/irq-gic-common.h +++ b/drivers/irqchip/irq-gic-common.h @@ -13,6 +13,7 @@ struct gic_quirk { const char *desc; const char *compatible; + const char *property; bool (*init)(void *data); u32 iidr; u32 mask; diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 6fcee221f201..161cc8957e8b 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -39,6 +39,7 @@ #define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0) #define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) +#define FLAGS_WORKAROUND_MTK_GICR_SAVE (1ULL << 2) #define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1) @@ -1720,6 +1721,15 @@ static bool gic_enable_quirk_msm8996(void *data) return true; } +static bool gic_enable_quirk_mtk_gicr(void *data) +{ + struct gic_chip_data *d = data; + + d->flags |= FLAGS_WORKAROUND_MTK_GICR_SAVE; + + return true; +} + static bool gic_enable_quirk_cavium_38539(void *data) { struct gic_chip_data *d = data; @@ -1792,6 +1802,11 @@ static const struct gic_quirk gic_quirks[] = { .compatible = "qcom,msm8996-gic-v3", .init = gic_enable_quirk_msm8996, }, + { + .desc = "GICv3: Mediatek Chromebook GICR save problem", + .property = "mediatek,gicr-save-quirk", + .init = gic_enable_quirk_mtk_gicr, + }, { .desc = "GICv3: HIP06 erratum 161010803", .iidr = 0x0204043b, @@ -1834,6 +1849,11 @@ static void gic_enable_nmi_support(void) if (!gic_prio_masking_enabled()) return; + if (gic_data.flags & FLAGS_WORKAROUND_MTK_GICR_SAVE) { + pr_warn("Skipping NMI enable due to firmware issues\n"); + return; + } + ppi_nmi_refs = kcalloc(gic_data.ppi_nr, sizeof(*ppi_nmi_refs), GFP_KERNEL); if (!ppi_nmi_refs) return; -- 2.40.1.606.ga4b1b128d6-goog