Skip to contentSkip to conversation

Add a workaround for Framework 13 spurious IRQ1

PATCH In review Mario Limonciello 4 participants 12 messages Dec 12, 2023 – Dec 18, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Add a workaround for Framework 13 spurious IRQ1

The 13" Framework laptop EC emits a spurious keyboard interrupt on every resume from hardware sleep. When a user closes the lid on an already suspended system this causes the system to wake up.

This series adjusts the previous Cezanne quirk (which has a much different root cause) to be able to apply to other systems too. The Framework 13" system is added to the list it will apply to.

Mario Limonciello (4):
platform/x86/amd/pmc: Move platform defines to header platform/x86/amd/pmc: Only run IRQ1 firmware version check on Cezanne platform/x86/amd/pmc: Move keyboard wakeup disablement detection to
pmc-quirks
platform/x86/amd/pmc: Disable keyboard wakeup on AMD Framework 13

 drivers/platform/x86/amd/pmc/pmc-quirks.c | 20 ++++++++++++++
 drivers/platform/x86/amd/pmc/pmc.c        | 33 +++++++++--------------
 drivers/platform/x86/amd/pmc/pmc.h        | 12 +++++++++
 3 files changed, 45 insertions(+), 20 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/4 platform/x86/amd/pmc: Move platform defines to header

The platform defines will be used by the quirks in the future, so move them to the common header to allow use by both source files.

---
 drivers/platform/x86/amd/pmc/pmc.c | 10 ----------
 drivers/platform/x86/amd/pmc/pmc.h | 11 +++++++++++
 2 files changed, 11 insertions(+), 10 deletions(-)
drivers/platform/x86/amd/pmc/pmc.c +0 -10
index c3104714b480..666cc6e98267 100644
@@ -91,16 +91,6 @@
 #define SMU_MSG_LOG_RESET		0x07
 #define SMU_MSG_LOG_DUMP_DATA		0x08
 #define SMU_MSG_GET_SUP_CONSTRAINTS	0x09
-/* List of supported CPU ids */
-#define AMD_CPU_ID_RV			0x15D0
-#define AMD_CPU_ID_RN			0x1630
-#define AMD_CPU_ID_PCO			AMD_CPU_ID_RV
-#define AMD_CPU_ID_CZN			AMD_CPU_ID_RN
-#define AMD_CPU_ID_YC			0x14B5
-#define AMD_CPU_ID_CB			0x14D8
-#define AMD_CPU_ID_PS			0x14E8
-#define AMD_CPU_ID_SP			0x14A4
-#define PCI_DEVICE_ID_AMD_1AH_M20H_ROOT 0x1507
 
 #define PMC_MSG_DELAY_MIN_US		50
 #define RESPONSE_REGISTER_LOOP_MAX	20000
drivers/platform/x86/amd/pmc/pmc.h +11 -0
index c27bd6a5642f..a85c235247d3 100644
@@ -41,4 +41,15 @@ struct amd_pmc_dev {
 void amd_pmc_process_restore_quirks(struct amd_pmc_dev *dev);
 void amd_pmc_quirks_init(struct amd_pmc_dev *dev);
 
+/* List of supported CPU ids */
+#define AMD_CPU_ID_RV			0x15D0
+#define AMD_CPU_ID_RN			0x1630
+#define AMD_CPU_ID_PCO			AMD_CPU_ID_RV
+#define AMD_CPU_ID_CZN			AMD_CPU_ID_RN
+#define AMD_CPU_ID_YC			0x14B5
+#define AMD_CPU_ID_CB			0x14D8
+#define AMD_CPU_ID_PS			0x14E8
+#define AMD_CPU_ID_SP			0x14A4
+#define PCI_DEVICE_ID_AMD_1AH_M20H_ROOT 0x1507
+
 #endif /* PMC_H */
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/4 platform/x86/amd/pmc: Only run IRQ1 firmware version check on Cezanne

In reply to Mario Limonciello

amd_pmc_wa_czn_irq1() only runs on Cezanne platforms currently but may be extended to other platforms in the future. Rename the function and only check platform firmware version when it's called for a Cezanne based platform.

---
 drivers/platform/x86/amd/pmc/pmc.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/platform/x86/amd/pmc/pmc.c +12 -9
index 666cc6e98267..824673a8673e 100644
@@ -756,19 +756,22 @@ static int amd_pmc_get_os_hint(struct amd_pmc_dev *dev)
 	return -EINVAL;
 }
 
-static int amd_pmc_czn_wa_irq1(struct amd_pmc_dev *pdev)
+static int amd_pmc_wa_irq1(struct amd_pmc_dev *pdev)
 {
 	struct device *d;
 	int rc;
 
-	if (!pdev->major) {
-		rc = amd_pmc_get_smu_version(pdev);
-		if (rc)
-			return rc;
-	}
+	/* cezanne platform firmware has a fix in 64.66.0 */
+	if (pdev->cpu_id == AMD_CPU_ID_CZN) {
+		if (!pdev->major) {
+			rc = amd_pmc_get_smu_version(pdev);
+			if (rc)
+				return rc;
+		}
 
-	if (pdev->major > 64 || (pdev->major == 64 && pdev->minor > 65))
-		return 0;
+		if (pdev->major > 64 || (pdev->major == 64 && pdev->minor > 65))
+			return 0;
+	}
 
 	d = bus_find_device_by_name(&serio_bus, NULL, "serio0");
 	if (!d)
@@ -928,7 +931,7 @@ static int amd_pmc_suspend_handler(struct device *dev)
 	struct amd_pmc_dev *pdev = dev_get_drvdata(dev);
 
 	if (pdev->cpu_id == AMD_CPU_ID_CZN && !disable_workarounds) {
-		int rc = amd_pmc_czn_wa_irq1(pdev);
+		int rc = amd_pmc_wa_irq1(pdev);
 
 		if (rc) {
 			dev_err(pdev->dev, "failed to adjust keyboard wakeup: %d\n", rc);
Signature · 1 line
2.34.1
maintainer
#3 lore raw

Re: [PATCH 2/4] platform/x86/amd/pmc: Only run IRQ1 firmware version check on Cezanne

Quoted 47 lines · Mario Limonciello

amd_pmc_wa_czn_irq1() only runs on Cezanne platforms currently but may be extended to other platforms in the future. Rename the function and only check platform firmware version when it's called for a Cezanne based platform.

---
 drivers/platform/x86/amd/pmc/pmc.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/platform/x86/amd/pmc/pmc.c +11 -8
index 666cc6e98267..824673a8673e 100644
@@ -756,19 +756,22 @@ static int amd_pmc_get_os_hint(struct amd_pmc_dev *dev)
 	return -EINVAL;
 }
 
-static int amd_pmc_czn_wa_irq1(struct amd_pmc_dev *pdev)
+static int amd_pmc_wa_irq1(struct amd_pmc_dev *pdev)
 {
 	struct device *d;
 	int rc;
 
-	if (!pdev->major) {
-		rc = amd_pmc_get_smu_version(pdev);
-		if (rc)
-			return rc;
-	}
+	/* cezanne platform firmware has a fix in 64.66.0 */
+	if (pdev->cpu_id == AMD_CPU_ID_CZN) {
+		if (!pdev->major) {
+			rc = amd_pmc_get_smu_version(pdev);
+			if (rc)
+				return rc;
+		}
 
-	if (pdev->major > 64 || (pdev->major == 64 && pdev->minor > 65))
-		return 0;
+		if (pdev->major > 64 || (pdev->major == 64 && pdev->minor > 65))
+			return 0;
+	}
 
 	d = bus_find_device_by_name(&serio_bus, NULL, "serio0");
 	if (!d)

drivers/platform/x86/amd/pmc/pmc.c static int amd_pmc_suspend_handler(struct device *dev) · line 937

Quoted 8 lines
drivers/platform/x86/amd/pmc/pmc.c +1 -1
@@ -928,7 +931,7 @@ static int amd_pmc_suspend_handler(struct device *dev)
 	struct amd_pmc_dev *pdev = dev_get_drvdata(dev);
 
 	if (pdev->cpu_id == AMD_CPU_ID_CZN && !disable_workarounds) {
-		int rc = amd_pmc_czn_wa_irq1(pdev);
+		int rc = amd_pmc_wa_irq1(pdev);
 
 		if (rc) {
 			dev_err(pdev->dev, "failed to adjust keyboard wakeup: %d\n", rc);

Hi Mario,

This doesn't look necessary for the fix in this series, right?

I'd prefer to leave it to next and only take 1,3-4 to fixes.

Signature · 1 line
 i.
maintainer
#4 lore raw

Re: [PATCH 2/4] platform/x86/amd/pmc: Only run IRQ1 firmware version check on Cezanne

Quoted 60 lines · Ilpo Järvinen
Quoted 47 lines · Mario Limonciello

amd_pmc_wa_czn_irq1() only runs on Cezanne platforms currently but may be extended to other platforms in the future. Rename the function and only check platform firmware version when it's called for a Cezanne based platform.

---
 drivers/platform/x86/amd/pmc/pmc.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/platform/x86/amd/pmc/pmc.c +11 -8
index 666cc6e98267..824673a8673e 100644
@@ -756,19 +756,22 @@ static int amd_pmc_get_os_hint(struct amd_pmc_dev *dev)
 	return -EINVAL;
 }
 
-static int amd_pmc_czn_wa_irq1(struct amd_pmc_dev *pdev)
+static int amd_pmc_wa_irq1(struct amd_pmc_dev *pdev)
 {
 	struct device *d;
 	int rc;
 
-	if (!pdev->major) {
-		rc = amd_pmc_get_smu_version(pdev);
-		if (rc)
-			return rc;
-	}
+	/* cezanne platform firmware has a fix in 64.66.0 */
+	if (pdev->cpu_id == AMD_CPU_ID_CZN) {
+		if (!pdev->major) {
+			rc = amd_pmc_get_smu_version(pdev);
+			if (rc)
+				return rc;
+		}
 
-	if (pdev->major > 64 || (pdev->major == 64 && pdev->minor > 65))
-		return 0;
+		if (pdev->major > 64 || (pdev->major == 64 && pdev->minor > 65))
+			return 0;
+	}
 
 	d = bus_find_device_by_name(&serio_bus, NULL, "serio0");
 	if (!d)

drivers/platform/x86/amd/pmc/pmc.c static int amd_pmc_suspend_handler(struct device *dev) · line 937

Quoted 8 lines
drivers/platform/x86/amd/pmc/pmc.c +1 -1
@@ -928,7 +931,7 @@ static int amd_pmc_suspend_handler(struct device *dev)
 	struct amd_pmc_dev *pdev = dev_get_drvdata(dev);
 
 	if (pdev->cpu_id == AMD_CPU_ID_CZN && !disable_workarounds) {
-		int rc = amd_pmc_czn_wa_irq1(pdev);
+		int rc = amd_pmc_wa_irq1(pdev);
 
 		if (rc) {
 			dev_err(pdev->dev, "failed to adjust keyboard wakeup: %d\n", rc);

Hi Mario,

Quoted 3 lines

This doesn't look necessary for the fix in this series, right?

I'd prefer to leave it to next and only take 1,3-4 to fixes.

Nevermind, I was just blind. :-/

Signature · 1 line
 i.
#5 lore raw

PATCH 3/4 platform/x86/amd/pmc: Move keyboard wakeup disablement detection to pmc-quirks

In reply to Mario Limonciello

Other platforms may need to disable keyboard wakeup besides Cezanne, so move the detection into amd_pmc_quirks_init() where it may be applied to multiple platforms.

---
 drivers/platform/x86/amd/pmc/pmc-quirks.c | 3 +++
 drivers/platform/x86/amd/pmc/pmc.c        | 2 +-
 drivers/platform/x86/amd/pmc/pmc.h        | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/platform/x86/amd/pmc/pmc-quirks.c +3 -0
index 6bbffb081053..c32046dfa960 100644
@@ -235,6 +235,9 @@ void amd_pmc_quirks_init(struct amd_pmc_dev *dev)
 {
 	const struct dmi_system_id *dmi_id;
 
+	if (dev->cpu_id == AMD_CPU_ID_CZN)
+		dev->disable_8042_wakeup = true;
+
 	dmi_id = dmi_first_match(fwbug_list);
 	if (!dmi_id)
 		return;
drivers/platform/x86/amd/pmc/pmc.c +1 -1
index 824673a8673e..864c8cc2f8a3 100644
@@ -930,7 +930,7 @@ static int amd_pmc_suspend_handler(struct device *dev)
 {
 	struct amd_pmc_dev *pdev = dev_get_drvdata(dev);
 
-	if (pdev->cpu_id == AMD_CPU_ID_CZN && !disable_workarounds) {
+	if (pdev->disable_8042_wakeup && !disable_workarounds) {
 		int rc = amd_pmc_wa_irq1(pdev);
 
 		if (rc) {
drivers/platform/x86/amd/pmc/pmc.h +1 -0
index a85c235247d3..b4794f118739 100644
@@ -36,6 +36,7 @@ struct amd_pmc_dev {
 	struct mutex lock; /* generic mutex lock */
 	struct dentry *dbgfs_dir;
 	struct quirk_entry *quirks;
+	bool disable_8042_wakeup;
 };
 
 void amd_pmc_process_restore_quirks(struct amd_pmc_dev *dev);
Signature · 1 line
2.34.1
#6 lore raw

PATCH 4/4 platform/x86/amd/pmc: Disable keyboard wakeup on AMD Framework 13

In reply to Mario Limonciello

The Laptop 13 (AMD Ryzen 7040Series) BIOS 03.03 has a workaround included in the EC firmware that will cause the EC to emit a "spurious" keypress during the resume from s0i3 [1].

This series of keypress events can be observed in the kernel log on resume.

```
atkbd serio0: Unknown key pressed (translated set 2, code 0x6b on isa0060/serio0).
atkbd serio0: Use 'setkeycodes 6b <keycode>' to make it known.
atkbd serio0: Unknown key released (translated set 2, code 0x6b on isa0060/serio0).
atkbd serio0: Use 'setkeycodes 6b <keycode>' to make it known.
```

In some user flows this is harmless, but if a user has specifically suspended the laptop and then closed the lid it will cause the laptop to wakeup. The laptop wakes up because the ACPI SCI triggers when the lid is closed and when the kernel sees that IRQ1 is "also" active. The kernel can't distinguish from a real keyboard keypress and wakes the system.

Add the model into the list of quirks to disable keyboard wakeup source. This is intentionally only matching the production BIOS version in hopes that a newer EC firmware included in a newer BIOS can avoid this behavior.

---
 drivers/platform/x86/amd/pmc/pmc-quirks.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/platform/x86/amd/pmc/pmc-quirks.c +17 -0
index c32046dfa960..b456370166b6 100644
@@ -16,12 +16,17 @@
 
 struct quirk_entry {
 	u32 s2idle_bug_mmio;
+	bool spurious_8042;
 };
 
 static struct quirk_entry quirk_s2idle_bug = {
 	.s2idle_bug_mmio = 0xfed80380,
 };
 
+static struct quirk_entry quirk_spurious_8042 = {
+	.spurious_8042 = true,
+};
+
 static const struct dmi_system_id fwbug_list[] = {
 	{
 		.ident = "L14 Gen2 AMD",
@@ -193,6 +198,16 @@ static const struct dmi_system_id fwbug_list[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "HP Laptop 15s-eq2xxx"),
 		}
 	},
+	/* https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128 */
+	{
+		.ident = "Framework Laptop 13 (Phoenix)",
+		.driver_data = &quirk_spurious_8042,
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Framework"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Laptop 13 (AMD Ryzen 7040Series)"),
+			DMI_MATCH(DMI_BIOS_VERSION, "03.03"),
+		}
+	},
 	{}
 };
 
@@ -245,4 +260,6 @@ void amd_pmc_quirks_init(struct amd_pmc_dev *dev)
 	if (dev->quirks->s2idle_bug_mmio)
 		pr_info("Using s2idle quirk to avoid %s platform firmware bug\n",
 			dmi_id->ident);
+	if (dev->quirks->spurious_8042)
+		dev->disable_8042_wakeup = true;
 }
Signature · 1 line
2.34.1
Reviewed-by Tested-by on the v1 series
#7 lore raw
In reply to Mario Limonciello
Quoted 15 lines · Mario Limonciello

The 13" Framework laptop EC emits a spurious keyboard interrupt on every resume from hardware sleep. When a user closes the lid on an already suspended system this causes the system to wake up.

This series adjusts the previous Cezanne quirk (which has a much different root cause) to be able to apply to other systems too. The Framework 13" system is added to the list it will apply to.

Mario Limonciello (4):
platform/x86/amd/pmc: Move platform defines to header platform/x86/amd/pmc: Only run IRQ1 firmware version check on Cezanne platform/x86/amd/pmc: Move keyboard wakeup disablement detection to
pmc-quirks
platform/x86/amd/pmc: Disable keyboard wakeup on AMD Framework 13

Quoted 4 lines
 drivers/platform/x86/amd/pmc/pmc-quirks.c | 20 ++++++++++++++
 drivers/platform/x86/amd/pmc/pmc.c        | 33 +++++++++--------------
 drivers/platform/x86/amd/pmc/pmc.h        | 12 +++++++++
 3 files changed, 45 insertions(+), 20 deletions(-)

For the full series:

The device now only wakes up when opening the lid.

Thanks,
Thomas

Reviewed-by
#8 lore raw

Hi All,

Quoted 21 lines · Thomas Weißschuh
Quoted 15 lines · Mario Limonciello

The 13" Framework laptop EC emits a spurious keyboard interrupt on every resume from hardware sleep. When a user closes the lid on an already suspended system this causes the system to wake up.

This series adjusts the previous Cezanne quirk (which has a much different root cause) to be able to apply to other systems too. The Framework 13" system is added to the list it will apply to.

Mario Limonciello (4):
platform/x86/amd/pmc: Move platform defines to header platform/x86/amd/pmc: Only run IRQ1 firmware version check on Cezanne platform/x86/amd/pmc: Move keyboard wakeup disablement detection to
pmc-quirks
platform/x86/amd/pmc: Disable keyboard wakeup on AMD Framework 13

Quoted 4 lines
 drivers/platform/x86/amd/pmc/pmc-quirks.c | 20 ++++++++++++++
 drivers/platform/x86/amd/pmc/pmc.c        | 33 +++++++++--------------
 drivers/platform/x86/amd/pmc/pmc.h        | 12 +++++++++
 3 files changed, 45 insertions(+), 20 deletions(-)
Quoted 6 lines

For the full series:

The device now only wakes up when opening the lid.

Thomas, thank you for the review and testing.

The series looks good to me too:

Ilpo, do you plan on sending out one more fixes pull-req for 6.7 and if yes, can you add this series to that; or shall I merge this into for-next so that it gets included in 6.8-rc1 ?

Regards,

Hans

maintainer
#9 lore raw
Quoted 31 lines · Hans de Goede
Quoted 21 lines · Thomas Weißschuh
Quoted 15 lines · Mario Limonciello

The 13" Framework laptop EC emits a spurious keyboard interrupt on every resume from hardware sleep. When a user closes the lid on an already suspended system this causes the system to wake up.

This series adjusts the previous Cezanne quirk (which has a much different root cause) to be able to apply to other systems too. The Framework 13" system is added to the list it will apply to.

Mario Limonciello (4):
platform/x86/amd/pmc: Move platform defines to header platform/x86/amd/pmc: Only run IRQ1 firmware version check on Cezanne platform/x86/amd/pmc: Move keyboard wakeup disablement detection to
pmc-quirks
platform/x86/amd/pmc: Disable keyboard wakeup on AMD Framework 13

Quoted 4 lines
 drivers/platform/x86/amd/pmc/pmc-quirks.c | 20 ++++++++++++++
 drivers/platform/x86/amd/pmc/pmc.c        | 33 +++++++++--------------
 drivers/platform/x86/amd/pmc/pmc.h        | 12 +++++++++
 3 files changed, 45 insertions(+), 20 deletions(-)
Quoted 6 lines

For the full series:

The device now only wakes up when opening the lid.

Thomas, thank you for the review and testing.

Quoted 7 lines

The series looks good to me too:

Ilpo, do you plan on sending out one more fixes pull-req for 6.7 and if yes, can you add this series to that; or shall I merge this into for-next so that it gets included in 6.8-rc1 ?

I was thinking not to but that was because I for some reason had missed this series in the pending queue over the entire last week.

So I'll make make more pr taking this series, the thinkpad fan thing and 1/2 intel pmc fix, 2/2 intel pmc is for material that is in next only. Hopefully LKP cooperates slightly better this week than it has been over the last month :-).

Signature · 1 line
 i.
#10 lore raw

Hi,

Quoted 40 lines · Ilpo Järvinen
Quoted 31 lines · Hans de Goede
Quoted 21 lines · Thomas Weißschuh
Quoted 15 lines · Mario Limonciello

The 13" Framework laptop EC emits a spurious keyboard interrupt on every resume from hardware sleep. When a user closes the lid on an already suspended system this causes the system to wake up.

This series adjusts the previous Cezanne quirk (which has a much different root cause) to be able to apply to other systems too. The Framework 13" system is added to the list it will apply to.

Mario Limonciello (4):
platform/x86/amd/pmc: Move platform defines to header platform/x86/amd/pmc: Only run IRQ1 firmware version check on Cezanne platform/x86/amd/pmc: Move keyboard wakeup disablement detection to
pmc-quirks
platform/x86/amd/pmc: Disable keyboard wakeup on AMD Framework 13

Quoted 4 lines
 drivers/platform/x86/amd/pmc/pmc-quirks.c | 20 ++++++++++++++
 drivers/platform/x86/amd/pmc/pmc.c        | 33 +++++++++--------------
 drivers/platform/x86/amd/pmc/pmc.h        | 12 +++++++++
 3 files changed, 45 insertions(+), 20 deletions(-)
Quoted 6 lines

For the full series:

The device now only wakes up when opening the lid.

Thomas, thank you for the review and testing.

Quoted 7 lines

The series looks good to me too:

Ilpo, do you plan on sending out one more fixes pull-req for 6.7 and if yes, can you add this series to that; or shall I merge this into for-next so that it gets included in 6.8-rc1 ?

Quoted 5 lines

I was thinking not to but that was because I for some reason had missed this series in the pending queue over the entire last week.

So I'll make make more pr taking this series, the thinkpad fan thing and 1/2 intel pmc fix, 2/2 intel pmc is for material that is in next only.

Great, thank you. I'll pick up the 2/2 pmc fix.

Regards,

Hans

maintainer
#11 lore raw
In reply to Mario Limonciello
Quoted 9 lines · Mario Limonciello

The 13" Framework laptop EC emits a spurious keyboard interrupt on every resume from hardware sleep. When a user closes the lid on an already suspended system this causes the system to wake up.

This series adjusts the previous Cezanne quirk (which has a much different root cause) to be able to apply to other systems too. The Framework 13" system is added to the list it will apply to.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo branch. Note it will show up in the public platform-drivers-x86/review-ilpo branch only once I've pushed my local branch there, which might take a while.

The list of commits applied:
[1/4] platform/x86/amd/pmc: Move platform defines to header

      commit: 85980669a863514dd47761efd6c1bc4677a2ae08
[2/4] platform/x86/amd/pmc: Only run IRQ1 firmware version check on Cezanne
      commit: 2d53c0ab61e62302d7b62d660fe76de2bff6bf45
[3/4] platform/x86/amd/pmc: Move keyboard wakeup disablement detection to pmc-quirks
      commit: b614a4bd73efeddc2b20d9e6deb6c2710373802b
[4/4] platform/x86/amd/pmc: Disable keyboard wakeup on AMD Framework 13
      commit: a55bdad5dfd1efd4ed9ffe518897a21ca8e4e193

--
i.