Bug 217406 - very slow keyboard typing without IRQ override with new AMD Ryzen CPUs
Summary: very slow keyboard typing without IRQ override with new AMD Ryzen CPUs
Status: ASSIGNED
Alias: None
Product: ACPI
Classification: Unclassified
Component: Config-Interrupts (show other bugs)
Hardware: AMD Linux
: P3 normal
Assignee: Mario Limonciello (AMD)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-05 14:36 UTC by evilsnoo
Modified: 2023-08-09 19:32 UTC (History)
4 users (show)

See Also:
Kernel Version: 5.19.10 to 6.3.0
Subsystem:
Regression: Yes
Bisected commit-id: 37c81d9f1d1b1458894454efcb857f6a769b6bc4


Attachments
patch to reenable IRQ override for recent AMD cpus (397 bytes, patch)
2023-05-05 14:36 UTC, evilsnoo
Details | Diff
dmesg for 6.3.2 kernel without the IRQ override (85.15 KB, text/plain)
2023-05-13 16:15 UTC, evilsnoo
Details
acpidump for 6.3.2 kernel without the IRQ override (1.51 MB, text/plain)
2023-05-13 16:16 UTC, evilsnoo
Details
dmesg for 6.3.2 kernel with the IRQ override (85.56 KB, text/plain)
2023-05-13 16:17 UTC, evilsnoo
Details
acpidump for 6.3.2 kernel with the IRQ override (1.51 MB, text/plain)
2023-05-13 16:17 UTC, evilsnoo
Details
dmesg for 6.3.2 kernel with Mario's patch (84.81 KB, text/plain)
2023-05-13 17:24 UTC, evilsnoo
Details
acpidump for 6.3.2 kernel with Mario's patch (1.51 MB, text/plain)
2023-05-13 17:25 UTC, evilsnoo
Details

Description evilsnoo 2023-05-05 14:36:38 UTC
Created attachment 304222 [details]
patch to reenable IRQ override for recent AMD cpus

I have an HP Pavilion Aero 13 laptop that comes with an AMD Ryzen 7735U CPU and an up-to-date BIOS. Using any kernel version that is strictly greater than 5.19.9 on it is causing the typing with the integrated keyboard to be extremely slow.

"Slow" is subjective but let's say that once you hit a key you have to wait a few seconds for it to be displayed. Everything else is very responsive, `top` doesn't show any abnormally high CPU usage, and the issue is really with the keyboard.

After some bisecting I found that 5.19.9 doesn't have this issue, but any version greater than or equal to 5.19.10 has it. Looking at the changelog of the 5.19.10 I noticed the 37c81d9f1d1b1458894454efcb857f6a769b6bc4 which disables IRQ overriding for AMD Ryzen CPUs.

I then wrote the following patch (see attached) which basically reverts that change (the culprit is really just the `#ifdef` below) and now after applying that patch with any kernel version up to the 6.3.0 my keyboard is responsive again.
Comment 1 Mario Limonciello (AMD) 2023-05-10 15:26:05 UTC
Can you please test the patch attached to https://bugzilla.kernel.org/show_bug.cgi?id=217394 to see if this helps?
Comment 2 Mario Limonciello (AMD) 2023-05-10 18:48:35 UTC
Also, can you please include an acpidump and dmesg for your system?
Comment 3 evilsnoo 2023-05-13 16:14:40 UTC
Hi Mario,

Apologies for the late answer. I'm including here the outputs of dmesg and acpidump for the kernel version 6.3.2 with and without the IRQ override patch that I had attached.

I haven't yet tested your patch, I'll recompile the kernel today with yours and will let you know when it's done.

Thanks!
Comment 4 evilsnoo 2023-05-13 16:15:44 UTC
Created attachment 304257 [details]
dmesg for 6.3.2 kernel without the IRQ override
Comment 5 evilsnoo 2023-05-13 16:16:24 UTC
Created attachment 304258 [details]
acpidump for 6.3.2 kernel without the IRQ override
Comment 6 evilsnoo 2023-05-13 16:17:01 UTC
Created attachment 304259 [details]
dmesg for 6.3.2 kernel with the IRQ override
Comment 7 evilsnoo 2023-05-13 16:17:33 UTC
Created attachment 304260 [details]
acpidump for 6.3.2 kernel with the IRQ override
Comment 8 evilsnoo 2023-05-13 17:23:33 UTC
@Mario: Applying your patch (and nothing else) on the 6.3.2 kernel also yields a responsive keyboard and solves the issue just like with my revert. Going to keep this kernel build as I suppose your patch is obviously the cleaner solution. I'll attach the dmesg and acpidump outputs for the 6.3.2 with your patch applied.
Comment 9 evilsnoo 2023-05-13 17:24:29 UTC
Created attachment 304261 [details]
dmesg for 6.3.2 kernel with Mario's patch
Comment 10 evilsnoo 2023-05-13 17:25:00 UTC
Created attachment 304262 [details]
acpidump for 6.3.2 kernel with Mario's patch
Comment 11 Mario Limonciello (AMD) 2023-05-16 01:17:14 UTC
I've submitted https://lore.kernel.org/linux-acpi/20230515213822.1277-1-mario.limonciello@amd.com/T/#u for discussion on this issue.
Comment 12 Hans de Goede 2023-08-09 19:32:29 UTC
Unfortunately the dropping of:

```
#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
```

As done in commit a9c4a912b7dc ("ACPI: resource: Remove "Zen" specific match and
quirks") is causing keyboard problems for quite a lot of AMD based laptop users using other models, see e.g. :

https://bugzilla.redhat.com/show_bug.cgi?id=2228891
https://bugzilla.redhat.com/show_bug.cgi?id=2229165
https://bugzilla.redhat.com/show_bug.cgi?id=2229317
https://bugzilla.kernel.org/show_bug.cgi?id=217718
https://bugzilla.kernel.org/show_bug.cgi?id=217726
https://bugzilla.kernel.org/show_bug.cgi?id=217731

So I have submitted a revert upstream:
https://lore.kernel.org/linux-acpi/20230808103335.95339-1-hdegoede@redhat.com/

I did add an extra patch on top:
https://lore.kernel.org/linux-acpi/20230808103335.95339-4-hdegoede@redhat.com/

which should keep the behavior of a9c4a912b7dc for any laptop with a line like this in dmesg:

[    0.021867] ACPI: INT_SRC_OVR (bus 0 bus_irq 1 global_irq 1 low edge)

Note the "bus_irq 1" is important here. There will also be other INT_SRC_OVR messages with a different bus_irq!

If possible please give this patch-series a try:
https://lore.kernel.org/linux-acpi/20230808103335.95339-1-hdegoede@redhat.com/

With this series there should still be a line like:

[    0.410670] ACPI: IRQ 1 override to edge, low(!)

in dmesg for laptops which need the override (based on the INT_SRC_OVR bus_irq 1),
so this patch-series should not cause a regression on the laptop from the original reporter of this bug.

Note You need to log in before you can comment on or make changes to this bug.