Skip to contentSkip to conversation

New: lg-laptop: Spurious ACK and dropped keystrokes due to unprotected i8042 port access

Bug 221238 [email protected] 1 participant 11 messages Mar 15 – Mar 25 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=221238

Bug ID: 221238
Summary: lg-laptop: Spurious ACK and dropped keystrokes due to
unprotected i8042 port access
Product: Drivers
Version: 2.5
Hardware: Intel
OS: Linux
Status: NEW
Severity: normal
Priority: P3
Component: Platform_x86
Assignee: [email protected]
Reporter: [email protected]
Regression: No

The lg-laptop driver (drivers/platform/x86/lg-laptop.c) communicates with the LG embedded controller using raw inb()/outb() on i8042 ports 0x60/0x64, completely bypassing the kernel's i8042 driver and its locking (i8042_mutex / i8042_lock). This causes a race condition between lg-laptop EC transactions and the atkbd driver's interrupt handling, resulting in:

1. atkbd serio0: Spurious ACK on isa0060/serio0. Some program might be trying
to access hardware directly.
2. Intermittent key drops — keys (particularly on the left side of the
keyboard matrix: s, w, left Ctrl) stop responding for several seconds.
3. Occasional phantom or misinterpreted scancodes.

The problem has worsened significantly since battery_hook_register() was added to the driver (commit 822933b1b29), which causes periodic EC access in the background on every battery status poll — independent of any user Fn-key interaction.

Steps to reproduce:

1. Boot any LG Gram laptop (tested on 16Z90Q-G.AD76F, 2022 model) with the
lg_laptop module loaded.
2. Use the keyboard normally for 10-30 minutes.
3. Observe dmesg | grep "Spurious ACK" — messages accumulate over time.
4. Keys intermittently stop registering input.

Frequency:

- Kernel 6.8.0-101 (with battery_hook_register): ~28 spurious ACKs/day,
frequent key drops
- Kernel 5.15.0-171 (without battery hook): ~7 spurious ACKs/day, less
frequent key drops
- Blacklisting lg_laptop: 0 spurious ACKs, no key drops (confirms the driver
as the cause)

Hardware:

- LG Gram 16Z90Q-G.AD76F (2022)
- Built-in PS/2 keyboard: AT Translated Set 2 keyboard (i8042,
isa0060/serio0)

Affected kernel versions:

- 5.15.0-171-generic (Ubuntu/Mint)
- 6.8.0-101-generic (Ubuntu HWE)
- Likely all versions since driver inclusion (4.14+), worsened after battery
hook addition

Proposed fix:

Wrap the raw port I/O sequences in lg-laptop.c with i8042_lock_chip() / i8042_unlock_chip() to serialize access with the kernel's i8042 interrupt handler:

  #include <linux/i8042.h>

static int lg_ec_read(unsigned char addr, unsigned char *val)

  {
      int ret;

      ret = i8042_lock_chip();
      if (ret)
          return ret;

      /* existing inb/outb sequence */

      i8042_unlock_chip();
      return 0;

}

This is the same approach used by other drivers that need direct EC port access. All functionality is preserved.

Current workaround:

echo "blacklist lg_laptop" | sudo tee
/etc/modprobe.d/blacklist-lg-laptop.conf

This eliminates the issue but disables keyboard backlight, fan mode, battery care, and Fn-key hotkey support.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#1 lore raw

[Bug 221238] lg-laptop: Spurious ACK and dropped keystrokes due to unprotected i8042 port access

https://bugzilla.kernel.org/show_bug.cgi?id=221238

Alfonso GARCIA FREY ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------

                 CC|                            |[email protected]
                   |                            |rnel.org
Signature · 5 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are on the CC list for the bug.
You are watching the assignee of the bug.
#2 lore raw

[Bug 221238] lg-laptop: Spurious ACK and dropped keystrokes caused by ACPI method calls conflicting with i8042 driver

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=221238

Alfonso GARCIA FREY ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------

            Summary|lg-laptop: Spurious ACK and |lg-laptop: Spurious ACK and
                   |dropped keystrokes due to   |dropped keystrokes caused
                   |unprotected i8042 port      |by ACPI method calls
                   |access                      |conflicting with i8042
                   |                            |driver
Signature · 5 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are on the CC list for the bug.
You are watching the assignee of the bug.
#3 lore raw

[Bug 221238] lg-laptop: Spurious ACK and dropped keystrokes caused by ACPI method calls conflicting with i8042 driver

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=221238

--- Comment #1 from Alfonso GARCIA FREY ([email protected]) --- Correction to the original description after creating a local test patch:

The original report incorrectly states the driver uses "raw inb()/outb() calls" and references a battery_hook_register() function. Neither is accurate. The actual situation:

The lg-laptop driver calls ACPI methods WMAB, WMBB, and GGOV via acpi_evaluate_object(). These firmware-defined methods internally access the EC through I/O ports shared with the i8042 keyboard controller, without coordination with the kernel's i8042 driver. This causes the race condition between ACPI method execution and atkbd interrupt handling, producing the spurious ACKs and key drops.

The proposed fix remains the same — wrap acpi_evaluate_object() calls with i8042_lock_chip() / i8042_unlock_chip() — but the reason is to serialize ACPI method execution (which internally touches i8042 ports) with the i8042 interrupt handler, not to protect direct port I/O in the driver itself.

Signature · 5 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are on the CC list for the bug.
You are watching the assignee of the bug.
#4 lore raw

[Bug 221238] lg-laptop: Spurious ACK and dropped keystrokes caused by ACPI method calls conflicting with i8042 driver

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=221238

Armin Wolf ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]

--- Comment #2 from Armin Wolf ([email protected]) --- Can you share the output of "acpidump" on your machine?

Signature · 5 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are on the CC list for the bug.
You are watching the assignee of the bug.
#5 lore raw

[Bug 221238] lg-laptop: Spurious ACK and dropped keystrokes caused by ACPI method calls conflicting with i8042 driver

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=221238

--- Comment #3 from Alfonso GARCIA FREY ([email protected]) --- Created attachment 309669
--> https://bugzilla.kernel.org/attachment.cgi?id=309669&action=edit
acpidump

acpidump

Signature · 5 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are on the CC list for the bug.
You are watching the assignee of the bug.
#6 lore raw

[Bug 221238] lg-laptop: Spurious ACK and dropped keystrokes caused by ACPI method calls conflicting with i8042 driver

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=221238

--- Comment #4 from Armin Wolf ([email protected]) ---
The ACPI bytecode indeed creates a operation region for the atkbd IO ports, but said operation region is unused. So this cannot be the cause of your issues.

Can you check if the battery limit exposed by the driver actually works and returns the correct values previously written to it?

Signature · 5 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are on the CC list for the bug.
You are watching the assignee of the bug.
#7 lore raw

[Bug 221238] lg-laptop: Spurious ACK and dropped keystrokes caused by ACPI method calls conflicting with i8042 driver

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=221238

--- Comment #5 from Alfonso GARCIA FREY ([email protected]) --- Tested battery_care_limit on kernel 5.15.0-171 with the stock lg-laptop module:

  # cat /sys/devices/platform/lg-laptop/battery_care_limit
  100
  # echo 80 > /sys/devices/platform/lg-laptop/battery_care_limit
  # cat /sys/devices/platform/lg-laptop/battery_care_limit
  80
  # echo 100 > /sys/devices/platform/lg-laptop/battery_care_limit
  # cat /sys/devices/platform/lg-laptop/battery_care_limit
  100

It looks like it works correctly for both values (80 and 100).

I also acknowledge that my original report incorrectly stated the driver uses "raw inb()/outb()" — it actually uses acpi_evaluate_object() for WMAB/WMBB/GGOV. The reference to battery_hook_register() is also incorrect for 5.15. Apologies for the inaccuracies.

The spurious ACK messages and key drops do still occur with the stock module loaded and stop when the module is blacklisted (17 spurious ACKs per boot on 5.15, 114 on 6.8).

Signature · 5 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are on the CC list for the bug.
You are watching the assignee of the bug.
#8 lore raw

[Bug 221238] lg-laptop: Spurious ACK and dropped keystrokes caused by ACPI method calls conflicting with i8042 driver

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=221238

--- Comment #6 from Armin Wolf ([email protected]) ---
Can you check if the spurious ACKs still happen with a recent kernel version?

Signature · 5 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are on the CC list for the bug.
You are watching the assignee of the bug.
#9 lore raw

[Bug 221238] lg-laptop: Spurious ACK and dropped keystrokes caused by ACPI method calls conflicting with i8042 driver

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=221238

--- Comment #7 from Alfonso GARCIA FREY ([email protected]) --- Tested with kernel 6.8.0-106. The spurious ACKs still occur — in fact they are significantly worse:

- Kernel 5.15.0-171: ~17 spurious ACKs per boot
- Kernel 6.8.0-106: ~114 spurious ACKs per boot

Signature · 5 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are on the CC list for the bug.
You are watching the assignee of the bug.
#10 lore raw

[Bug 221238] lg-laptop: Spurious ACK and dropped keystrokes caused by ACPI method calls conflicting with i8042 driver

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=221238

--- Comment #8 from Armin Wolf ([email protected]) --- Can you test this with kernel 6.19?

Signature · 5 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are on the CC list for the bug.
You are watching the assignee of the bug.