Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp453650rwd; Tue, 16 May 2023 03:31:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4WKtfxx0NvhjxTCjAqHS7qVYAGkNc8iwx1CJYexDakdV5E/+doggTYNu1YAv4PDvWjSyXV X-Received: by 2002:a17:902:690b:b0:1ac:a6b0:1c87 with SMTP id j11-20020a170902690b00b001aca6b01c87mr24287760plk.48.1684233082215; Tue, 16 May 2023 03:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684233082; cv=none; d=google.com; s=arc-20160816; b=CnZ8FXNd7LFuF1nnnB0rrJm5lSHfOUhKHHEjvMkAiEhdG3qSwle+4P9nI0xC96kkPl QqgJlifzC0W4R5+tfzxEg/CQIXNbrV4ivj6Ia8QWPezbdipNWyj3jljxn8PlsACMSnv7 NVV34CFHcAA0mQVl3W8uDxPcAToliIdz1Ua20kizqviYmmZInDdpaLSF6FCmqZ1+viAK 26vl9oVUTVehvTk0SKWyXSjcuHN2AfvK4jj+2OQl31wrd0eBtQbniVkyE+SVD99hEcF6 uGUVXl26+dy9BzMi3SuBKgsqX6R88o9nfsPcNw75T3Mzak5oIfrcO8xTpxQ9u12IhU0b Id8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=VqPgwAW90cOeVazXe+kEfEHoMbM4x7CLjfL19TxDKts=; b=XNcEW4qBtzPJhK6X1uTLfwFcapnhrxFwa+2RR9WLtRjx157K2lEYw8B3+xcZdQkMmp N0t4PUbV+WOKOF1KBLa7wJZbektSlEhg1bIOmppEm116YPJIFB05sgusDlR5P6GvdIG9 bBZCcxcchvWkN5ZXdFCtAs1ztEamF9gwIo0PeTYfQK7ziviDPw3CCeqkB6Sf7vtsSq22 6Al5pbMUvWxw+bf0znmzF2n55YqYeYNiui8B6iIBHs9yR24Uw2jXW0Zis+GCec9a/Mga rkOPt4kuKUX1ngGpte2G0v3645Eq7RJSoiFDnMDXHfRcUSl9KihZCxz/NXDZFdILzO+z qpLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=e6YZtoBL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=UYL2P00W; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g2-20020a170902934200b001a511254836si8663050plp.89.2023.05.16.03.31.07; Tue, 16 May 2023 03:31:22 -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=@linutronix.de header.s=2020 header.b=e6YZtoBL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=UYL2P00W; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232055AbjEPKWz (ORCPT + 99 others); Tue, 16 May 2023 06:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232129AbjEPKWl (ORCPT ); Tue, 16 May 2023 06:22:41 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2F044217 for ; Tue, 16 May 2023 03:22:39 -0700 (PDT) Date: Tue, 16 May 2023 10:22:37 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684232558; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VqPgwAW90cOeVazXe+kEfEHoMbM4x7CLjfL19TxDKts=; b=e6YZtoBLwwLoMDtBJ+I57c+6jmytCiQb7O3U9SW9VEnt9GqnRq121/aLznIuXcVQ8+s8jj mTD4WFFWc8eIWrarGRELzvRhUAxfWLnlzAcPq+wdQynUvx1QTMjPsZ3CqBaLa0zd9S4O+g ymw9Mns2jK6jKNi+JRqsz2lJ0BefVtbzaPuo0ADB/BKQSoMxXgesdCpKDiW5VHVWOHI3F5 9ee+tB59BheZ2qWeclXOHs2L5JQBUJG0AVNy9EWAOQrw3YjJnXdgZ8hbzML/rEejQCGzt7 0spOs2YTI+nOgp1YXr0lC4SfvHvv9LXaW30IFg90kjmpetdhg7yaKoi2QKR51g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684232558; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VqPgwAW90cOeVazXe+kEfEHoMbM4x7CLjfL19TxDKts=; b=UYL2P00Ws3gLiAFnLWwgZ8eh7h4SNuFM9JXXT2U9mwJSAmbT4nuQNjtmHZBnOMSLBaO4pb Ayz85hGDpltTpVAg== From: "irqchip-bot for Douglas Anderson" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-kernel@vger.kernel.org Subject: [irqchip: irq/irqchip-fixes] irqchip/gic-v3: Disable pseudo NMIs on Mediatek devices w/ firmware issues Cc: Julius Werner , Douglas Anderson , Marc Zyngier , tglx@linutronix.de In-Reply-To: <20230515131353.v2.2.I88dc0a0eb1d9d537de61604cd8994ecc55c0cac1@changeid> References: <20230515131353.v2.2.I88dc0a0eb1d9d537de61604cd8994ecc55c0cac1@changeid> MIME-Version: 1.0 Message-ID: <168423255773.404.14848290278499554700.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 The following commit has been merged into the irq/irqchip-fixes branch of irqchip: Commit-ID: 44bd78dd2b8897f59b7e3963f088caadb7e4f047 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/44bd78dd2b8897f59b7e3963f088caadb7e4f047 Author: Douglas Anderson AuthorDate: Mon, 15 May 2023 13:13:51 -07:00 Committer: Marc Zyngier CommitterDate: Tue, 16 May 2023 10:43:24 +01:00 irqchip/gic-v3: Disable pseudo NMIs on Mediatek devices w/ firmware issues 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,broken-save-restore-fw" 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". Reviewed-by: Julius Werner Signed-off-by: Douglas Anderson Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20230515131353.v2.2.I88dc0a0eb1d9d537de61604cd8994ecc55c0cac1@changeid --- 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 a610821..de47b51 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 27e3d4e..3db4592 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 6fcee22..a605aa7 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; @@ -1793,6 +1803,11 @@ static const struct gic_quirk gic_quirks[] = { .init = gic_enable_quirk_msm8996, }, { + .desc = "GICv3: Mediatek Chromebook GICR save problem", + .property = "mediatek,broken-save-restore-fw", + .init = gic_enable_quirk_mtk_gicr, + }, + { .desc = "GICv3: HIP06 erratum 161010803", .iidr = 0x0204043b, .mask = 0xffffffff, @@ -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;