All of lore.kernel.org
 help / color / mirror / Atom feed
From: "irqchip-bot for Douglas Anderson" <tip-bot2@linutronix.de>
To: linux-kernel@vger.kernel.org
Cc: Julius Werner <jwerner@chromium.org>,
	Douglas Anderson <dianders@chromium.org>,
	Marc Zyngier <maz@kernel.org>,
	tglx@linutronix.de
Subject: [irqchip: irq/irqchip-fixes] irqchip/gic-v3: Disable pseudo NMIs on Mediatek devices w/ firmware issues
Date: Tue, 16 May 2023 10:22:37 -0000	[thread overview]
Message-ID: <168423255773.404.14848290278499554700.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20230515131353.v2.2.I88dc0a0eb1d9d537de61604cd8994ecc55c0cac1@changeid>

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 <dianders@chromium.org>
AuthorDate:    Mon, 15 May 2023 13:13:51 -07:00
Committer:     Marc Zyngier <maz@kernel.org>
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 <jwerner@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
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;

  reply	other threads:[~2023-05-16 10:22 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-15 20:13 [PATCH v2 0/5] irqchip/gic-v3: Disable pseudo NMIs on Mediatek Chromebooks w/ bad FW Douglas Anderson
2023-05-15 20:13 ` Douglas Anderson
2023-05-15 20:13 ` [PATCH v2 1/5] dt-bindings: interrupt-controller: arm,gic-v3: Add quirk for Mediatek SoCs w/ broken FW Douglas Anderson
2023-05-15 20:13   ` Douglas Anderson
2023-05-16 10:22   ` [irqchip: irq/irqchip-fixes] " irqchip-bot for Douglas Anderson
2023-05-16 13:24   ` [PATCH v2 1/5] " AngeloGioacchino Del Regno
2023-05-16 13:24     ` AngeloGioacchino Del Regno
2023-05-15 20:13 ` [PATCH v2 2/5] irqchip/gic-v3: Disable pseudo NMIs on Mediatek devices w/ firmware issues Douglas Anderson
2023-05-15 20:13   ` Douglas Anderson
2023-05-16 10:22   ` irqchip-bot for Douglas Anderson [this message]
2023-05-16 13:23   ` AngeloGioacchino Del Regno
2023-05-16 13:23     ` AngeloGioacchino Del Regno
2023-05-16 14:19     ` Doug Anderson
2023-05-16 14:19       ` Doug Anderson
2023-05-16 14:57     ` Marc Zyngier
2023-05-16 14:57       ` Marc Zyngier
2023-05-30  8:29   ` Geert Uytterhoeven
2023-05-30  8:29     ` Geert Uytterhoeven
2023-05-30  9:46     ` Marc Zyngier
2023-05-30  9:46       ` Marc Zyngier
2023-05-30  9:58       ` Geert Uytterhoeven
2023-05-30  9:58         ` Geert Uytterhoeven
2023-05-30 16:36       ` Doug Anderson
2023-05-30 16:36         ` Doug Anderson
2023-05-15 20:13 ` [PATCH v2 3/5] arm64: dts: mediatek: mt8183: Add mediatek,broken-save-restore-fw to kukui Douglas Anderson
2023-05-15 20:13   ` Douglas Anderson
2023-05-16 13:18   ` AngeloGioacchino Del Regno
2023-05-16 13:18     ` AngeloGioacchino Del Regno
2023-05-15 20:13 ` [PATCH v2 4/5] arm64: dts: mediatek: mt8192: Add mediatek,broken-save-restore-fw to asurada Douglas Anderson
2023-05-15 20:13   ` Douglas Anderson
2023-05-16 13:18   ` AngeloGioacchino Del Regno
2023-05-16 13:18     ` AngeloGioacchino Del Regno
2023-05-15 20:13 ` [PATCH v2 5/5] arm64: dts: mediatek: mt8195: Add mediatek,broken-save-restore-fw to cherry Douglas Anderson
2023-05-15 20:13   ` Douglas Anderson
2023-05-16 13:18   ` AngeloGioacchino Del Regno
2023-05-16 13:18     ` AngeloGioacchino Del Regno
2023-05-16  9:58 ` [PATCH v2 0/5] irqchip/gic-v3: Disable pseudo NMIs on Mediatek Chromebooks w/ bad FW Marc Zyngier
2023-05-16  9:58   ` Marc Zyngier
2023-05-29 15:41   ` Matthias Brugger
2023-05-29 15:41     ` Matthias Brugger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=168423255773.404.14848290278499554700.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=dianders@chromium.org \
    --cc=jwerner@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.