Bug 217718 - IRQ override revert breaks keyboard on Lenovo Yoga 7 14ARB7
Summary: IRQ override revert breaks keyboard on Lenovo Yoga 7 14ARB7
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-07-27 16:36 UTC by August Wikerfors
Modified: 2023-12-09 19:03 UTC (History)
13 users (show)

See Also:
Kernel Version:
Subsystem:
Regression: Yes
Bisected commit-id: a9c4a912b7dc7ff922d4b9261160c001558f9755


Attachments
dmidecode (18.00 KB, text/plain)
2023-07-27 16:36 UTC, August Wikerfors
Details
acpidump (DSDT and SSDT tables) (1.07 MB, text/plain)
2023-07-27 17:14 UTC, August Wikerfors
Details
potential patch (v1) (1.67 KB, application/mbox)
2023-07-27 17:47 UTC, Mario Limonciello (AMD)
Details
/sys/firmware/acpi/tables/APIC (312 bytes, application/octet-stream)
2023-07-27 19:53 UTC, August Wikerfors
Details
dmesg (94.45 KB, text/plain)
2023-07-27 20:14 UTC, August Wikerfors
Details
possible patch (1.67 KB, patch)
2023-07-28 01:26 UTC, Mario Limonciello (AMD)
Details | Diff
dmesg with v0.2 (94.53 KB, text/plain)
2023-07-28 13:52 UTC, August Wikerfors
Details
irq whitelist for lenovo laptops (1.91 KB, patch)
2023-08-05 14:07 UTC, r1nlx0
Details | Diff
patches for some Lenovo laptops (2.35 KB, patch)
2023-08-06 12:15 UTC, r1nlx0
Details | Diff

Description August Wikerfors 2023-07-27 16:36:30 UTC
Created attachment 304710 [details]
dmidecode

(cross-posting from https://lore.kernel.org/all/596b9c4a-fb83-a8ab-3a44-6052d83fa546@augustwikerfors.se/ with dmidecode)

Since v6.5-rc1 the keyboard on this laptop no longer works. This problem also existed before v6.0-rc1 commit 9946e39fe8d0 ("ACPI: resource: skip IRQ override on AMD Zen platforms"), so I suspected the cause to be a9c4a912b7dc ("ACPI: resource: Remove "Zen" specific match and quirks") which reverted that commit. Reverting a9c4a912b7dc confirmed this theory.

My specs are:
Laptop model: Lenovo Yoga 7 14ARB7
BIOS: K5CN40WWT66 (latest beta from [1])
CPU: AMD Ryzen 5 6600U
Kernel config: [2]
Distribution: Arch Linux

The issue has been confirmed by at least one other user with this laptop: [3]

[1] https://forums.lenovo.com/t5/Lenovo-Yoga-Series-Laptops/Yoga-7-14ARB7-keyboard-lag-when-on-certain-websites-or-when-Vantage-is-opened/m-p/5174991?page=28#5974742
[2] https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/raw/d4a56a1e994201b6c607199922aa22e4337b56c9/config
[3] https://github.com/tomsom/yoga-linux/issues/47
Comment 1 August Wikerfors 2023-07-27 17:14:58 UTC
Created attachment 304712 [details]
acpidump (DSDT and SSDT tables)
Comment 2 Mario Limonciello (AMD) 2023-07-27 17:47:07 UTC
Created attachment 304713 [details]
potential patch (v1)

Here is a patch that I think should help, can you please confirm?
Comment 3 August Wikerfors 2023-07-27 19:35:50 UTC
(In reply to Mario Limonciello (AMD) from comment #2)
> Created attachment 304713 [details]
> potential patch (v1)
> 
> Here is a patch that I think should help, can you please confirm?

Unfortunately it doesn't fix the problem.
Comment 4 Mario Limonciello (AMD) 2023-07-27 19:40:14 UTC
Can you please attach your MADT (/sys/firmware/acpi/tables/APIC) and a dmesg with the current patch applied?
Comment 5 August Wikerfors 2023-07-27 19:53:21 UTC
Created attachment 304716 [details]
/sys/firmware/acpi/tables/APIC

Here is the APIC, will get a dmesg soon
Comment 6 Mario Limonciello (AMD) 2023-07-27 20:12:09 UTC
No interrupt source overrides in your MADT for IRQ 1.  Need to see your dmesg.

> [0C4h 0196   1]                Subtable Type : 02 [Interrupt Source Override]
> [0C5h 0197   1]                       Length : 0A
> [0C6h 0198   1]                          Bus : 00
> [0C7h 0199   1]                       Source : 00
> [0C8h 0200   4]                    Interrupt : 00000002
> [0CCh 0204   2]        Flags (decoded below) : 0000
>                                     Polarity : 0
>                                 Trigger Mode : 0
> 
> [0CEh 0206   1]                Subtable Type : 02 [Interrupt Source Override]
> [0CFh 0207   1]                       Length : 0A
> [0D0h 0208   1]                          Bus : 00
> [0D1h 0209   1]                       Source : 09
> [0D2h 0210   4]                    Interrupt : 00000009
> [0D6h 0214   2]        Flags (decoded below) : 000F
>                                     Polarity : 3
>                                 Trigger Mode : 3
>
Comment 7 August Wikerfors 2023-07-27 20:14:45 UTC
Created attachment 304717 [details]
dmesg

Here is the dmesg
Comment 8 Mario Limonciello (AMD) 2023-07-28 01:26:28 UTC
Created attachment 304719 [details]
possible patch

> [    0.332929] ACPI: IRQ 1 override to edge, high(!)

OK I believe it's because it wasn't matching because I had level but your DSDT had edge.  I've modified it, can you try again?
Comment 9 August Wikerfors 2023-07-28 13:52:18 UTC
Created attachment 304723 [details]
dmesg with v0.2

Unfortunately that doesn't work either. I've attached the new dmesg.
Comment 10 August Wikerfors 2023-07-28 14:27:19 UTC
I added this in acpi_dev_get_irqresource

> pr_warn("triggering = %hhd, polarity = %hhd, shareable = %hhd", triggering,
> polarity, shareable);

and it printed

> triggering = 1, polarity = 1, shareable = 1

so I think the shareable field should be 1 instead of 0. I'll compile that and check
Comment 11 August Wikerfors 2023-07-28 14:43:12 UTC
This works:

> { lenovo_laptop, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, false}
Comment 12 Mario Limonciello (AMD) 2023-07-28 18:59:45 UTC
Thanks!
Submitted https://lore.kernel.org/linux-acpi/20230728183921.17230-1-mario.limonciello@amd.com/T/#u
Comment 13 XiaoYan Li 2023-07-30 07:50:47 UTC
This revert also affects ASUS laptops, namely the Zenbook S 13 OLED UM5302TA.
I can no longer use the built-in keyboard after upgrading the kernel.
Comment 14 August Wikerfors 2023-07-30 13:00:32 UTC
(In reply to XiaoYan Li from comment #13)
> This revert also affects ASUS laptops, namely the Zenbook S 13 OLED UM5302TA.
> I can no longer use the built-in keyboard after upgrading the kernel.

See https://bugzilla.kernel.org/show_bug.cgi?id=217726
Comment 15 r1nlx0 2023-08-04 03:59:06 UTC
Hi it seems this also affects another Lenovo notebook for me it's `Yoga Slim 7 proX 14ARH7`. For the dmidecode 

> Manufacturer: LENOVO
> Product Name: 82TL
> Version: Yoga Slim 7 proX 14ARH7

Thank you
Comment 16 r1nlx0 2023-08-04 14:45:07 UTC
Ok, it seems the patches from this thread doesn't apply to all Lenovo Notebook, since after I try to apply it in my current notebook, it doesn't work (the keyboard still doesn't work). I'll try to add this line & retry to rebuild it again. 

> pr_warn("triggering = %hhd, polarity = %hhd, shareable = %hhd", triggering,
> polarity, shareable);
Comment 17 Ni 2023-08-05 07:17:34 UTC
While you guys at it, please add my laptop too, see: https://bbs.archlinux.org/viewtopic.php?pid=2045467#p2045467. Or should I open a new bug report specifically for my model?

Also, now that I mentioned the post, there are many other laptops (and people) out there also effected by this problem. Not really sure a whitelist is a good solution.

Also also, Mario Limonciello is here too? AMD should really give you a raise or something, you guys are the only reason that I'm keeping myself from bad mouthing AMD at every possible chances.
Comment 18 r1nlx0 2023-08-05 08:28:48 UTC
(In reply to r1nlx0 from comment #15)
> Hi it seems this also affects another Lenovo notebook for me it's `Yoga Slim
> 7 proX 14ARH7`. For the dmidecode 
> 
> > Manufacturer: LENOVO
> > Product Name: 82TL
> > Version: Yoga Slim 7 proX 14ARH7
> 
> Thank you

Hmm, it seems I should use `dmidecode -s baseboard-product-name` rather than `dmidecode -s system-product-name` for identifying `DMI_BOARD_NAME`, thus I'll try to build the patches with 

> +     {
> +             .ident = "Yoga Slim 7 proX 14ARH7",
> +             .matches = {
> +                     DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
> +                     DMI_MATCH(DMI_BOARD_NAME, "LNVNB161216"),
> +             },
> +     },
Comment 19 mitchie 2023-08-05 08:37:14 UTC
can confirm the same issue affects my Lenovo IdeaPad 5 Pro:
> Manufacturer: LENOVO
> Product Name: 82SN
> Version: IdeaPad 5 Pro 16ARH7

the keyboard worked fine up to and including Archlinux's `linux-6.4.6`, stopped working after upgrading to `6.4.7`, and now `6.4.8` is available and the issue is still present.

also, this thread focuses a lot on Lenovo Yoga, and aforementioned #217726 focuses on some ASUS laptops, but it seems that the issue is the same and more laptop models are affected.
Comment 20 r1nlx0 2023-08-05 14:07:05 UTC
Created attachment 304782 [details]
irq whitelist for lenovo laptops

Hi Mario, would you mind to add this patches to the upstream ? This patches adds the whitelist for `Yoga Slim 7 proX 14ARH7`. It's tested in my notebook and it works. Thank you.
Comment 21 August Wikerfors 2023-08-05 21:31:53 UTC
(In reply to r1nlx0 from comment #20)
> Created attachment 304782 [details]
> irq whitelist for lenovo laptops
> 
> Hi Mario, would you mind to add this patches to the upstream ? This patches
> adds the whitelist for `Yoga Slim 7 proX 14ARH7`. It's tested in my notebook
> and it works. Thank you.

Lenovo has used the board name "LNVNB161216" on lots of models, even Intel ones, going back to at least 2017: https://lore.kernel.org/all/?q=LNVNB161216

So it seems risky to match on that. Can you try the product name instead:

> DMI_MATCH(DMI_PRODUCT_NAME, "82TL"),
Comment 22 r1nlx0 2023-08-06 05:34:53 UTC
Thank you August, I'll try to rebuild it again based on your recommendation.
Comment 23 r1nlx0 2023-08-06 12:15:35 UTC
Created attachment 304787 [details]
patches for some Lenovo laptops

Hi August, Mario & mitchie, 

Here, I attach new patches that includes : 
- Lenovo Yoga 7 14ARB7
- Yoga Slim 7 proX 14ARH7
- IdeaPad 5 Pro 16ARH7

NOTE: I only tests the patches for `Yoga Slim 7 proX 14ARH7` and it works too. Thank you for the helps & guidances in here.
Comment 24 Mario Limonciello (AMD) 2023-08-07 04:41:46 UTC
Can you guys please see if this works?

diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index 1dd8d5aebf678..b74d7d8cc8630 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -19,7 +19,7 @@
 #include <linux/dmi.h>
 
 #ifdef CONFIG_X86
-#define valid_IRQ(i) (((i) != 0) && ((i) != 2))
+#define valid_IRQ(i) ((i) > 2)
 static inline bool acpi_iospace_resource_valid(struct resource *res)
 {
        /* On X86 IO space is limited to the [0 - 64K] IO port range */
Comment 25 r1nlx0 2023-08-07 08:44:51 UTC
Hi Mario, I'm sorry since I don't have knowledge in kernel development, did the patches that you propose has other non-local side-effects ? (if i skims, it will calls `irqresource_disabled`, in impacted Lenovo, I assume irq 1 probably always pointing to i8042, thus > 2 condition). 

Thank you
Comment 26 Potekhin Dmitry 2023-08-07 09:01:59 UTC
Hi, guys,
Not sure if its right place, but it seems, that this issue affects Redmi Book Pro 15 2022 as well
Here is dmidecode

> System Information
>       Manufacturer: TIMI
>       Product Name: Redmi Book Pro 15 2022
>       Version:  
>       SKU Number: TM2113-39463
>       Family: Mi Laptop
> 
> Base Board Information
>       Manufacturer: TIMI
>       Product Name: TM2113
>       Version: V24H2
Comment 27 Mario Limonciello (AMD) 2023-08-07 17:16:02 UTC
The patch in comment 24 worked for some of my stuff, but not everything.  It will not be the way we solve it.
Comment 28 Paul Spedding 2023-08-21 13:16:37 UTC
Also affects Lenovo Ideapad Slim 3, with AMD 7520U CPU, model 82XQ

No touchpad, no keyboard except FN keys. Not sure weather to create a new thread.

A bunch of our new laptops for our new starting staff are paperweights at the moment.
They work with a USB keyboard and mouse but doing so removes the point of a laptop being portable.

I've tried Kernel 6.1.46 and upgraded to 6.4.11 and neither worked.
Comment 29 Mario Limonciello (AMD) 2023-08-21 15:06:52 UTC
Can you still reproduce it on 6.5-rc7?  If so, open up a new issue and gather all the details.  If you can't, then we probably need to backport more patches to the stable trees for this issue.
Comment 30 Felipe Morales Carbonell 2023-08-21 17:27:01 UTC
Can confirm it is fixed in 6.5.0-rc7 for the Yoga Slim 7 proX 14ARH7.
Comment 31 Potekhin Dmitry 2023-08-23 23:15:39 UTC
Can confirm it is fixed in 6.5.0-rc7 for the Redmi Book Pro 15 2022 as well. Thanks to everyone involved!
Comment 32 fry86297 2023-08-24 02:52:37 UTC
I am using Asus Zenbook S13 OLED. I could see the keyboard problem on 6.4.8 kernels but I don't see the keyboard problem on 6.1.38 and 6.5.0-rc7.

Thanks for fixing the problem.
Comment 33 fiat.vendo 2023-12-09 19:03:50 UTC
Hello, everyone. The keyboard on the following laptop is also affected:

> System Information
>       Manufacturer: Eluktronics Inc.
>       Product Name: RP-15
>       Version: Standard
>       SKU Number: RP-15 G2
>       Family: RP Family

> Base Board Information
>       Manufacturer: Eluktronics
>       Product Name: RP-15
>       Version: Standard

Currently running Kernel 6.5.6-300.fc39.x86_64

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