Skip to content

Commit 44bd78d

Browse files
diandersMarc Zyngier
authored andcommitted
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 <[email protected]> Signed-off-by: Douglas Anderson <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/20230515131353.v2.2.I88dc0a0eb1d9d537de61604cd8994ecc55c0cac1@changeid
1 parent 43cd3dd commit 44bd78d

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

drivers/irqchip/irq-gic-common.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ void gic_enable_of_quirks(const struct device_node *np,
1616
const struct gic_quirk *quirks, void *data)
1717
{
1818
for (; quirks->desc; quirks++) {
19-
if (!of_device_is_compatible(np, quirks->compatible))
19+
if (quirks->compatible &&
20+
!of_device_is_compatible(np, quirks->compatible))
21+
continue;
22+
if (quirks->property &&
23+
!of_property_read_bool(np, quirks->property))
2024
continue;
2125
if (quirks->init(data))
2226
pr_info("GIC: enabling workaround for %s\n",
@@ -28,7 +32,7 @@ void gic_enable_quirks(u32 iidr, const struct gic_quirk *quirks,
2832
void *data)
2933
{
3034
for (; quirks->desc; quirks++) {
31-
if (quirks->compatible)
35+
if (quirks->compatible || quirks->property)
3236
continue;
3337
if (quirks->iidr != (quirks->mask & iidr))
3438
continue;

drivers/irqchip/irq-gic-common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
struct gic_quirk {
1414
const char *desc;
1515
const char *compatible;
16+
const char *property;
1617
bool (*init)(void *data);
1718
u32 iidr;
1819
u32 mask;

drivers/irqchip/irq-gic-v3.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)
4141
#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1)
42+
#define FLAGS_WORKAROUND_MTK_GICR_SAVE (1ULL << 2)
4243

4344
#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)
4445

@@ -1720,6 +1721,15 @@ static bool gic_enable_quirk_msm8996(void *data)
17201721
return true;
17211722
}
17221723

1724+
static bool gic_enable_quirk_mtk_gicr(void *data)
1725+
{
1726+
struct gic_chip_data *d = data;
1727+
1728+
d->flags |= FLAGS_WORKAROUND_MTK_GICR_SAVE;
1729+
1730+
return true;
1731+
}
1732+
17231733
static bool gic_enable_quirk_cavium_38539(void *data)
17241734
{
17251735
struct gic_chip_data *d = data;
@@ -1792,6 +1802,11 @@ static const struct gic_quirk gic_quirks[] = {
17921802
.compatible = "qcom,msm8996-gic-v3",
17931803
.init = gic_enable_quirk_msm8996,
17941804
},
1805+
{
1806+
.desc = "GICv3: Mediatek Chromebook GICR save problem",
1807+
.property = "mediatek,broken-save-restore-fw",
1808+
.init = gic_enable_quirk_mtk_gicr,
1809+
},
17951810
{
17961811
.desc = "GICv3: HIP06 erratum 161010803",
17971812
.iidr = 0x0204043b,
@@ -1834,6 +1849,11 @@ static void gic_enable_nmi_support(void)
18341849
if (!gic_prio_masking_enabled())
18351850
return;
18361851

1852+
if (gic_data.flags & FLAGS_WORKAROUND_MTK_GICR_SAVE) {
1853+
pr_warn("Skipping NMI enable due to firmware issues\n");
1854+
return;
1855+
}
1856+
18371857
ppi_nmi_refs = kcalloc(gic_data.ppi_nr, sizeof(*ppi_nmi_refs), GFP_KERNEL);
18381858
if (!ppi_nmi_refs)
18391859
return;

0 commit comments

Comments
 (0)