Skip to contentSkip to conversation

ACPI: resource: Fix regressions from "Remove "Zen" specific match and quirks"

PATCH Superseded Hans de Goede 2 participants 6 messages Aug 8, 2023 – Aug 9, 2023

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover ACPI: resource: Fix regressions from "Remove "Zen" specific match and quirks"

Hi All,

As discussed here in the v1 thread:
https://lore.kernel.org/linux-acpi/[email protected]/

Here is a v2 which adds a few fixes on top of the revert to avoid the revert causing regressions on AMD Zen systems where dropping the special Zen behavior was known to fix things.

As also mentioned in the thread this is intended as a short term fix for 6.4.y >= 6.4.7 and 6.5 to get all the systems which were working fine before commit a9c4a912b7dc ("ACPI: resource: Remove "Zen" specific match and quirks") to work again.

The long term plan is to see if we can read back what the BIOS has actually programmed as IRQ trigger-type / polarity into the IOAPIC.

Regards,

Hans

Hans de Goede (3):
ACPI: resource: revert "Remove "Zen" specific match and quirks"
ACPI: resource: Always use MADT override IRQ settings for GSI != 1
ACPI: resource: Honor MADT INT_SRC_OVR settings for IRQ1 on AMD Zen

 arch/x86/include/asm/acpi.h |  1 +
 arch/x86/kernel/acpi/boot.c |  4 +++
 drivers/acpi/resource.c     | 52 +++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+)
Signature · 1 line
2.41.0
#1 lore raw

PATCH v2 1/3 ACPI: resource: revert "Remove "Zen" specific match and quirks"

Commit a9c4a912b7dc ("ACPI: resource: Remove "Zen" specific match and quirks") is causing keyboard problems for quite a log of AMD based laptop users, leading to many bug reports.

Revert this change for now, until we can come up with a better fix for the PS/2 IRQ trigger-type/polarity problems on some x86 laptops.

Fixes a9c4a912b7dc ("ACPI: resource: Remove "Zen" specific match and quirks")
Cc Mario Limonciello <[email protected]>
Cc Linux regressions mailing list <[email protected]>
---
 drivers/acpi/resource.c | 60 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
drivers/acpi/resource.c +60 -0
index 1dd8d5aebf67..0800a9d77558 100644
@@ -470,6 +470,52 @@ static const struct dmi_system_id asus_laptop[] = {
 	{ }
 };
 
+static const struct dmi_system_id lenovo_laptop[] = {
+	{
+		.ident = "LENOVO IdeaPad Flex 5 14ALC7",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "82R9"),
+		},
+	},
+	{
+		.ident = "LENOVO IdeaPad Flex 5 16ALC7",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "82RA"),
+		},
+	},
+	{ }
+};
+
+static const struct dmi_system_id tongfang_gm_rg[] = {
+	{
+		.ident = "TongFang GMxRGxx/XMG CORE 15 (M22)/TUXEDO Stellaris 15 Gen4 AMD",
+		.matches = {
+			DMI_MATCH(DMI_BOARD_NAME, "GMxRGxx"),
+		},
+	},
+	{ }
+};
+
+static const struct dmi_system_id maingear_laptop[] = {
+	{
+		.ident = "MAINGEAR Vector Pro 2 15",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Micro Electronics Inc"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MG-VCP2-15A3070T"),
+		}
+	},
+	{
+		.ident = "MAINGEAR Vector Pro 2 17",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Micro Electronics Inc"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MG-VCP2-17A3070T"),
+		},
+	},
+	{ }
+};
+
 static const struct dmi_system_id lg_laptop[] = {
 	{
 		.ident = "LG Electronics 17U70P",
@@ -493,6 +539,10 @@ struct irq_override_cmp {
 static const struct irq_override_cmp override_table[] = {
 	{ medion_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
 	{ asus_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
+	{ lenovo_laptop, 6, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true },
+	{ lenovo_laptop, 10, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true },
+	{ tongfang_gm_rg, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true },
+	{ maingear_laptop, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true },
 	{ lg_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
 };
 
@@ -512,6 +562,16 @@ static bool acpi_dev_irq_override(u32 gsi, u8 triggering, u8 polarity,
 			return entry->override;
 	}
 
+#ifdef CONFIG_X86
+	/*
+	 * IRQ override isn't needed on modern AMD Zen systems and
+	 * this override breaks active low IRQs on AMD Ryzen 6000 and
+	 * newer systems. Skip it.
+	 */
+	if (boot_cpu_has(X86_FEATURE_ZEN))
+		return false;
+#endif
+
 	return true;
 }
 
Signature · 1 line
2.41.0
#2 lore raw

PATCH v2 2/3 ACPI: resource: Always use MADT override IRQ settings for GSI != 1

In reply to Hans de Goede

All the cases, were the DSDT IRQ settings should be used instead of the MADT override, are for IRQ 1 (the PS/2 kbd IRQ).

Simplify things by always honering the override for GSI != 1 (for non DMI quirked cases).

This allows removing the DMI quirks to honor the override for some non IRQ 1 IRQs on some AMD ZEN based Lenovo models.

Fixes a9c4a912b7dc ("ACPI: resource: Remove "Zen" specific match and quirks")
Cc Mario Limonciello <[email protected]>
Cc Linux regressions mailing list <[email protected]>
---
 drivers/acpi/resource.c | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)
drivers/acpi/resource.c +8 -20
index 0800a9d77558..840b938a5fb0 100644
@@ -470,24 +470,6 @@ static const struct dmi_system_id asus_laptop[] = {
 	{ }
 };
 
-static const struct dmi_system_id lenovo_laptop[] = {
-	{
-		.ident = "LENOVO IdeaPad Flex 5 14ALC7",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "82R9"),
-		},
-	},
-	{
-		.ident = "LENOVO IdeaPad Flex 5 16ALC7",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "82RA"),
-		},
-	},
-	{ }
-};
-
 static const struct dmi_system_id tongfang_gm_rg[] = {
 	{
 		.ident = "TongFang GMxRGxx/XMG CORE 15 (M22)/TUXEDO Stellaris 15 Gen4 AMD",
@@ -539,8 +521,6 @@ struct irq_override_cmp {
 static const struct irq_override_cmp override_table[] = {
 	{ medion_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
 	{ asus_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
-	{ lenovo_laptop, 6, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true },
-	{ lenovo_laptop, 10, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true },
 	{ tongfang_gm_rg, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true },
 	{ maingear_laptop, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true },
 	{ lg_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
@@ -562,6 +542,14 @@ static bool acpi_dev_irq_override(u32 gsi, u8 triggering, u8 polarity,
 			return entry->override;
 	}
 
+	/*
+	 * Always use the MADT override info, except for IRQ 1 for IRQ1
+	 * the DSDT IRQ settings should sometimes be used otherwise
+	 * PS/2 keyboards will not work.
+	 */
+	if (gsi != 1)
+		return true;
+
 #ifdef CONFIG_X86
 	/*
 	 * IRQ override isn't needed on modern AMD Zen systems and
Signature · 1 line
2.41.0
#3 lore raw

Re: [PATCH v2 2/3] ACPI: resource: Always use MADT override IRQ settings for GSI != 1

Quoted 61 lines · Hans de Goede

All the cases, were the DSDT IRQ settings should be used instead of the MADT override, are for IRQ 1 (the PS/2 kbd IRQ).

Simplify things by always honering the override for GSI != 1 (for non DMI quirked cases).

This allows removing the DMI quirks to honor the override for some non IRQ 1 IRQs on some AMD ZEN based Lenovo models.

Fixes a9c4a912b7dc ("ACPI: resource: Remove "Zen" specific match and quirks")
Cc Mario Limonciello <[email protected]>
Cc Linux regressions mailing list <[email protected]>
---
  drivers/acpi/resource.c | 28 ++++++++--------------------
  1 file changed, 8 insertions(+), 20 deletions(-)
drivers/acpi/resource.c +1 -20
index 0800a9d77558..840b938a5fb0 100644
@@ -470,24 +470,6 @@ static const struct dmi_system_id asus_laptop[] = {
  	{ }
  };
 
-static const struct dmi_system_id lenovo_laptop[] = {
-	{
-		.ident = "LENOVO IdeaPad Flex 5 14ALC7",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "82R9"),
-		},
-	},
-	{
-		.ident = "LENOVO IdeaPad Flex 5 16ALC7",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "82RA"),
-		},
-	},
-	{ }
-};
-
  static const struct dmi_system_id tongfang_gm_rg[] = {
  	{
  		.ident = "TongFang GMxRGxx/XMG CORE 15 (M22)/TUXEDO Stellaris 15 Gen4 AMD",
@@ -539,8 +521,6 @@ struct irq_override_cmp {
  static const struct irq_override_cmp override_table[] = {
  	{ medion_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
  	{ asus_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
-	{ lenovo_laptop, 6, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true },
-	{ lenovo_laptop, 10, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true },
  	{ tongfang_gm_rg, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true },
  	{ maingear_laptop, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true },
  	{ lg_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
@@ -562,6 +542,14 @@ static bool acpi_dev_irq_override(u32 gsi, u8 triggering, u8 polarity,
  			return entry->override;
  	}
 
+	/*

drivers/acpi/resource.c static bool acpi_dev_irq_override(u32 gsi, u8 triggering, u8 polarity, · line 555

Quoted 10 lines
drivers/acpi/resource.c +7 -0
+	 * Always use the MADT override info, except for IRQ 1 for IRQ1
+	 * the DSDT IRQ settings should sometimes be used otherwise
+	 * PS/2 keyboards will not work.
+	 */
+	if (gsi != 1)
+		return true;
+
  #ifdef CONFIG_X86
  	/*
  	 * IRQ override isn't needed on modern AMD Zen systems and

I don't think this will work for the Lenovo ThinkPad neo 14 because according to https://bugzilla.kernel.org/show_bug.cgi?id=217731 it needs the override to also be skipped for IRQ 12.

Regards,
August Wikerfors

#4 lore raw

Re: [PATCH v2 2/3] ACPI: resource: Always use MADT override IRQ settings for GSI != 1

Hi August,

Quoted 64 lines · August Wikerfors
Quoted 63 lines · Hans de Goede

All the cases, were the DSDT IRQ settings should be used instead of the MADT override, are for IRQ 1 (the PS/2 kbd IRQ).

Simplify things by always honering the override for GSI != 1 (for non DMI quirked cases).

This allows removing the DMI quirks to honor the override for some non IRQ 1 IRQs on some AMD ZEN based Lenovo models.

Fixes a9c4a912b7dc ("ACPI: resource: Remove "Zen" specific match and quirks")
Cc Mario Limonciello <[email protected]>
Cc Linux regressions mailing list <[email protected]>

---
  drivers/acpi/resource.c | 28 ++++++++--------------------

  1 file changed, 8 insertions(+), 20 deletions(-)
drivers/acpi/resource.c +0 -19
index 0800a9d77558..840b938a5fb0 100644
@@ -470,24 +470,6 @@ static const struct dmi_system_id asus_laptop[] = {
       { }
   };
   -static const struct dmi_system_id lenovo_laptop[] = {
-    {
-        .ident = "LENOVO IdeaPad Flex 5 14ALC7",
-        .matches = {
-            DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-            DMI_MATCH(DMI_PRODUCT_NAME, "82R9"),
-        },
-    },
-    {
-        .ident = "LENOVO IdeaPad Flex 5 16ALC7",
-        .matches = {
-            DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-            DMI_MATCH(DMI_PRODUCT_NAME, "82RA"),
-        },
-    },
-    { }
-};
-
   static const struct dmi_system_id tongfang_gm_rg[] = {
       {
           .ident = "TongFang GMxRGxx/XMG CORE 15 (M22)/TUXEDO Stellaris 15 Gen4 AMD",
@@ -539,8 +521,6 @@ struct irq_override_cmp {
   static const struct irq_override_cmp override_table[] = {
       { medion_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
       { asus_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
-    { lenovo_laptop, 6, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true },
-    { lenovo_laptop, 10, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, true },
       { tongfang_gm_rg, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true },
       { maingear_laptop, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true },
       { lg_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
@@ -562,6 +542,14 @@ static bool acpi_dev_irq_override(u32 gsi, u8 triggering, u8 polarity,
               return entry->override;
       }

  +    /*
+     * Always use the MADT override info, except for IRQ 1 for IRQ1 +     * the DSDT IRQ settings should sometimes be used otherwise +     * PS/2 keyboards will not work.
+     */

Quoted 8 lines
Quoted 6 lines

+    if (gsi != 1)
+        return true;
+
  #ifdef CONFIG_X86
      /*
       * IRQ override isn't needed on modern AMD Zen systems and

I don't think this will work for the Lenovo ThinkPad neo 14 because according to https://bugzilla.kernel.org/show_bug.cgi?id=217731 it needs the override to also be skipped for IRQ 12.

You are right, thank you for catching this. I'll submit a v3 of the series with the check changed to:

    if (gsi != 1 && gsi != 12)
        return true;

I'll update the Link: tags in the revert to add more bugreports Links including the 217731 bugzilla.

Regards,

Hans

#5 lore raw

PATCH v2 3/3 ACPI: resource: Honor MADT INT_SRC_OVR settings for IRQ1 on AMD Zen

In reply to Hans de Goede

On AMD Zen acpi_dev_irq_override() by default prefers the DSDT IRQ 1 settings over the MADT settings.

This causes the keyboard to malfunction on some laptop models (see Links), all models from the Links have an INT_SRC_OVR MADT entry for IRQ 1.

Fixes a9c4a912b7dc ("ACPI: resource: Remove "Zen" specific match and quirks")
Cc Mario Limonciello <[email protected]>
Cc Linux regressions mailing list <[email protected]>
---
 arch/x86/include/asm/acpi.h | 1 +
 arch/x86/kernel/acpi/boot.c | 4 ++++
 drivers/acpi/resource.c     | 4 ++++
 3 files changed, 9 insertions(+)
arch/x86/include/asm/acpi.h +1 -0
index 8eb74cf386db..2173b7c19adf 100644
@@ -31,6 +31,7 @@ extern int acpi_skip_timer_override;
 extern int acpi_use_timer_override;
 extern int acpi_fix_pin2_polarity;
 extern int acpi_disable_cmcff;
+extern int acpi_irq1_int_src_ovr;
 
 extern u8 acpi_sci_flags;
 extern u32 acpi_sci_override_gsi;
arch/x86/kernel/acpi/boot.c +4 -0
index 21b542a6866c..f69ffb9a35c1 100644
@@ -52,6 +52,7 @@ int acpi_lapic;
 int acpi_ioapic;
 int acpi_strict;
 int acpi_disable_cmcff;
+int acpi_irq1_int_src_ovr;
 
 /* ACPI SCI override configuration */
 u8 acpi_sci_flags __initdata;
@@ -588,6 +589,9 @@ acpi_parse_int_src_ovr(union acpi_subtable_headers * header,
 
 	acpi_table_print_madt_entry(&header->common);
 
+	if (intsrc->source_irq == 1)
+		acpi_irq1_int_src_ovr = 1;
+
 	if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
 		acpi_sci_ioapic_setup(intsrc->source_irq,
 				      intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
drivers/acpi/resource.c +4 -0
index 840b938a5fb0..8b0c641db1e8 100644
@@ -551,6 +551,10 @@ static bool acpi_dev_irq_override(u32 gsi, u8 triggering, u8 polarity,
 		return true;
 
 #ifdef CONFIG_X86
+	/* If the override comes from an INT_SRC_OVR MADT entry honor it */
+	if (acpi_irq1_int_src_ovr)
+		return true;
+
 	/*
 	 * IRQ override isn't needed on modern AMD Zen systems and
 	 * this override breaks active low IRQs on AMD Ryzen 6000 and
Signature · 1 line
2.41.0