Bug 2302253 - ACPI: EC: LG gram laptop brightness keys stop working with kernel >= 6.9.7
Summary: ACPI: EC: LG gram laptop brightness keys stop working with kernel >= 6.9.7
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 40
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-08-01 14:19 UTC by Hans de Goede
Modified: 2024-09-02 17:03 UTC (History)
17 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-08-22 09:26:23 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
acpidump LG Gram laptop (3.63 MB, application/octet-stream)
2024-08-01 14:24 UTC, Hans de Goede
no flags Details
dmesg output LG Gram laptop (92.25 KB, text/plain)
2024-08-01 16:57 UTC, Iñaki Ucar
no flags Details
dmesg output with working kernel (91.31 KB, text/plain)
2024-08-01 18:40 UTC, Iñaki Ucar
no flags Details
dmesg for working patch (96.40 KB, text/plain)
2024-08-12 22:16 UTC, Iñaki Ucar
no flags Details

Description Hans de Goede 2024-08-01 14:19:02 UTC
Moving this to bugzilla from its original discussion here:
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/V2KWAGZIAX4TOWPCH6A6FSIT66PR3KMZ/

The problem is that with kernel >= 6.9.7 the brightness hotkeys on a LG gram laptop's keyboard no longer generate KEY_BRIGHTNESSDOWN / KEY_BRIGHTNESSUP on the ACPI "video bus" /dev/input/event# input device.

This problem started with 6.9.7 (6.9.6 is fine) which has the 2 commits related to "EC: Install address space handler at the namespace root" from 6.10 backported:

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/acpi?h=v6.9.7&id=2b2b0ac1533d790690d6d28899f01a2924d54d4d
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/acpi?h=v6.9.7&id=9750135f2f326879889ed60ccd68b96572dfa6ee

Iñaki Ucar, the reporter of this has tested a 6.9.9 kernel with these 2 reverted and has confirmed that that fixes the brightness key presses, but now there is a problem with an IRQ storm on the ACPI IRQ (IRQ 9) when connected to thunderbolt.


Reproducible: Always

Comment 1 Hans de Goede 2024-08-01 14:24:31 UTC
Created attachment 2043228 [details]
acpidump LG Gram laptop

Comment 2 Hans de Goede 2024-08-01 14:26:34 UTC
Iñaki, can you please reboot your laptop into a *not* working kernel and then immediately after boot run:

sudo dmesg > dmesg.txt

and attach the generated dmesg.txt file here ?

Having the kernel logs will help in debugging this.

Also as mentioned in the possibly related bug 2298938, please give this test kernel build which contains a possible fix for bug 2298938 a try:

https://koji.fedoraproject.org/koji/taskinfo?taskID=121344486

Here are instructions for installing a kernel directly from koji (Fedora's buildsystem): https://fedorapeople.org/~jwrdegoede/kernel-test-instructions.txt

Comment 3 Iñaki Ucar 2024-08-01 15:04:46 UTC
I tried that kernel but it doesn't help. Same issues. :(
I saved the output from dmesg. Any part that I should supress from the output to post it here?

Comment 4 Hans de Goede 2024-08-01 15:06:05 UTC
(In reply to Iñaki Ucar from comment #3)
> I tried that kernel but it doesn't help. Same issues. :(

Thank you for giving it a try.

> I saved the output from dmesg. Any part that I should supress from the
> output to post it here?

Not really, generally speaking there should not be any privacy sensitive info in dmesg output.

Comment 5 Iñaki Ucar 2024-08-01 16:57:47 UTC
Created attachment 2043237 [details]
dmesg output LG Gram laptop

Comment 6 Hans de Goede 2024-08-01 18:26:56 UTC
(In reply to Iñaki Ucar from comment #5)
> Created attachment 2043237 [details]
> dmesg output LG Gram laptop

Thank you. I'm seeing some possible related errors but I'm not sure. Can you also collect a dmesg with a working (e.g. 6.9.6) kernel so that I can see if that shows the same errors or not ?

Comment 7 Iñaki Ucar 2024-08-01 18:40:09 UTC
Created attachment 2043238 [details]
dmesg output with working kernel

Comment 8 Hans de Goede 2024-08-05 11:29:09 UTC
OK, now we are getting somewhere. Here is an email which I just send to the kernel list about this:

Ok, so the bugzilla now has 2 different dmesg outputs:

1. 6.9.6, this kernel works without problems

2. 6.9.12 with the following patch you suggested on top:

--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1788,7 +1788,7 @@ void __init acpi_ec_dsdt_probe(void)
 	 * At this point, the GPE is not fully initialized, so do not to
 	 * handle the events.
 	 */
-	ret = acpi_ec_setup(ec, NULL, true);
+	ret = acpi_ec_setup(ec, NULL, false);
 	if (ret) {
 		acpi_ec_free(ec);
 		return;

Unfortunately this does not help. dmesg shows some EC _REG errors, which
are now (with the above diff applied) shown just before the
"Boot DSDT EC initialization complete" message, which shows that _REG now
runs from acpi_ec_add() rather then before:

[    1.007566] ACPI BIOS Error (bug): Could not resolve symbol [\_TZ.FN00._OFF], AE_NOT_FOUND (20230628/psargs-330)
[    1.007576] ACPI Error: Aborting method \_SB.PC00.LPCB.H_EC.EREG due to previous error (AE_NOT_FOUND) (20230628/psparse-52
[    1.007580] ACPI Error: Aborting method \_SB.PC00.LPCB.H_EC._REG due to previous error (AE_NOT_FOUND) (20230628/psparse-52
[    1.007639] ACPI: EC: interrupt unblocked
[    1.007640] ACPI: EC: event unblocked
[    1.007675] ACPI: EC: EC_CMD/EC_SC=0x66, EC_DATA=0x62
[    1.007676] ACPI: EC: GPE=0x6e
[    1.007677] ACPI: \_SB_.PC00.LPCB.LGEC: Boot DSDT EC initialization complete
[    1.007679] ACPI: \_SB_.PC00.LPCB.LGEC: EC: Used to handle transactions and events

Note that the errors are from calling _REG on \_SB.PC00.LPCB.H_EC, where as the actual
EC (and the only acpi_device on which _REG would get called for the EC Opregion before) is:
\_SB_.PC00.LPCB.LGEC.

Looking at the DSDT it seems that the H_EC is not used and is leftover from a copy/paste
from some reference design DSDT. Its _REG however does write to the EC before hitting the error
and I think that that write may be causing the issue...

The H_EC device does have an _STA method and looking closer the troublesome EREG method is
also called from _INI. So I guess that _STA is returning 0 causing _INI to not run and
that is the reason why we are not seeing the same EREG errors with kernel 6.9.6 where _REG is
only called for the EC opregion on \_SB_.PC00.LPCB.LGEC and not for the entire ACPI device
hierarchy as is done with >= 6.9.7 .

Maybe we should only call _REG for the EC opregion on present devices (and devices without
a _STA)?

Also note that both LGEC and H_EC use the same cmd + data ports.

I'll go and ask the reporter to retreive the status of both LGEC and H_EC and then see
from there.

Comment 9 Hans de Goede 2024-08-05 11:34:12 UTC
As I mentioned in the email it would be useful to know what the _STA (status / present) method of the H_EC device returns.

Can you please from a terminal run:

cat /sys/bus/acpi/devices/PNP0C09\:00/path
cat /sys/bus/acpi/devices/PNP0C09\:00/status
cat /sys/bus/acpi/devices/PNP0C09\:01/path
cat /sys/bus/acpi/devices/PNP0C09\:01/status

and let me know the output of all 4 commands, please also copy and paste the actual commands from the terminal into your next comment here in bugzilla so that I can easily match up the output to each command.

Comment 10 Iñaki Ucar 2024-08-05 12:06:16 UTC
Here it is, with kernel 6.9.6:

$ cat /sys/bus/acpi/devices/PNP0C09\:00/path
\_SB_.PC00.LPCB.H_EC
$ cat /sys/bus/acpi/devices/PNP0C09\:00/status
0
$ cat /sys/bus/acpi/devices/PNP0C09\:01/path
\_SB_.PC00.LPCB.LGEC
$ cat /sys/bus/acpi/devices/PNP0C09\:01/status
15

Comment 11 Hans de Goede 2024-08-05 12:41:12 UTC
(In reply to Iñaki Ucar from comment #10)
> Here it is, with kernel 6.9.6:
> 
> $ cat /sys/bus/acpi/devices/PNP0C09\:00/path
> \_SB_.PC00.LPCB.H_EC
> $ cat /sys/bus/acpi/devices/PNP0C09\:00/status
> 0
> $ cat /sys/bus/acpi/devices/PNP0C09\:01/path
> \_SB_.PC00.LPCB.LGEC
> $ cat /sys/bus/acpi/devices/PNP0C09\:01/status
> 15

Great thank you, so this confirms that the _STA method for the extra \_SB_.PC00.LPCB.H_EC EC device which seems to be causing the issues returns 0 / not present.

So before the recent EC handling changes only _REG of \_SB_.PC00.LPCB.LGEC was run, but now the other _REG runs too and that seems to be causing the issue.

I'm not 100% sure how to best fix this and Rafael the upstream ACPI is taking a break this week. I'll get back to you when we have a possible fix to test. In the mean time you can stick with 6.9.6 as you are already doing.

Comment 12 Iñaki Ucar 2024-08-07 10:02:31 UTC
It was expected, but for completeness, I just tried 6.10.3 (in updates-testing) and same issues.

Comment 13 Hans de Goede 2024-08-12 11:24:04 UTC
Rafael, the upstream kernel ACPI maintainer has made a branch with a proposed fix this issue (1) available:

https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/log/?h=acpi-ec-fixes

I have started a test Fedora 40 6.10.4 kernel build with the patches from the acpi-ec-fixes branch added:
https://koji.fedoraproject.org/koji/taskinfo?taskID=121834209

This kernel is still building at the moment (should be done in a couple of hours), please give this kernel a try once it is done building and let us know if this resolves the brightness key-press issue.

Here are instructions for installing a kernel directly from koji (Fedora's buildsystem): https://fedorapeople.org/~jwrdegoede/kernel-test-instructions.txt



1) A fix for what we believe is the root cause of this issue, the calling of _REG on the non active second EC device in the ACPI table.

Comment 14 Hans de Goede 2024-08-12 12:22:13 UTC
The latest test-kernel with the upstream fix for this is done building and is ready for testing now.

Comment 15 Iñaki Ucar 2024-08-12 22:16:14 UTC
Created attachment 2044019 [details]
dmesg for working patch

Comment 16 Iñaki Ucar 2024-08-12 22:18:01 UTC
There are still some ACPI errors in the dmesg output, but this solved the issues I had!

Comment 17 Hans de Goede 2024-08-13 10:07:23 UTC
> There are still some ACPI errors in the dmesg output, but this solved the issues I had!

Thank you for testing. I've let Rafael know that his patches solve the problem so that he can move ahead with adding these to the upstream kernel.

I checked and those ACPI errors were already there with 6.9.6, these refer to a LG custom OpRegion which Linux does not implement and these are harmless. Another kernel contributor has actually been working on supporting this OpRegion, so at sometime in the future these errors will hopefully be gone too:

https://lore.kernel.org/platform-driver-x86/20240813022903.20567-1-W_Armin@gmx.de/

Comment 18 Iñaki Ucar 2024-08-21 15:21:53 UTC
Do you happen to know when will this patch land in F40? Version 6.10.6 now is in testing, and it seems to solve the execheap denials that are so annoying.

Comment 19 Hans de Goede 2024-08-22 09:26:23 UTC
(In reply to Iñaki Ucar from comment #18)
> Do you happen to know when will this patch land in F40? Version 6.10.6 now
> is in testing, and it seems to solve the execheap denials that are so
> annoying.

The patches fixing this are in the 6.10.y queue now:

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/log/?h=queue/6.10

(look for "ACPI: EC: Evaluate _REG outside the EC scope more carefully")

So they should show up in 6.10.7

So just a bit of patience and then Fedora will have them.

Comment 20 Iñaki Ucar 2024-08-29 15:09:42 UTC
BTW, not sure if it is related, and please let me know if I should open a new issue for this... but I noticed that I see the IRQ storm (ACPI IRQ 9) again with the Thunderbolt hub connected. Not sure how to debug this either.

Comment 21 Iñaki Ucar 2024-09-02 15:26:20 UTC
It definitely has something to do with this, because I see:

$ cat /sys/firmware/acpi/interrupts/gpe{_all,6E}
 2919465
 2918394  EN     enabled      unmasked

And if I disable gpe6E, the brightness buttons do not work anymore.

Comment 22 Iñaki Ucar 2024-09-02 17:03:52 UTC
Never mind, it seems there's already a bug upstream (https://bugzilla.kernel.org/show_bug.cgi?id=217076). I'll continue the discussion there.


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