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

            Bug ID: 222142
           Summary: ACPI EC: Samsung DMI quirk (ec_event_clearing=status)
                    causes 500 ms EC event stalls on Galaxy Book4
           Product: ACPI
           Version: 2.5
    Kernel Version: 7.2.9-2-cachyos
          Hardware: Intel
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P3
         Component: EC
          Assignee: [email protected]
          Reporter: [email protected]
        Regression: No

Hardware: Samsung Galaxy Book4 NP750XGK-KG5IT (750XGK), Intel Core 7 150U, BIOS
P11CFP.025.251116.HQ (11/16/2025)
Kernel: 7.2.9-2-cachyos (CachyOS distribution kernel; not tested on a vanilla
kernel). Code references below are to drivers/acpi/ec.c from linux-7.2.y
stable.

On a Samsung Galaxy Book4 the brightness hotkeys (EC _Q63/_Q64 -> BRTN() ->
Notify(..., 0x87/0x86) -> "Video Bus" input device) react with a noticeable
delay
of up to ~500 ms. The user reports that on Windows the same keys react
instantly.

With the default settings, key events reached userspace on a ~502 ms grid in
every
test run (see brightness-key-timing.txt), e.g.:

    +0.000s  +1.002s  +1.504s  +5.008s  +5.509s  +6.512s

Analysis
--------
ec_dmi_table contains a catch-all entry matching
DMI_SYS_VENDOR "SAMSUNG ELECTRONICS CO., LTD." (ec_clear_on_resume, bug 44161,
whose comment names Samsung 530U/535U/540U/550P/900X). Besides
EC_FLAGS_CLEAR_ON_RESUME, it also forces ec_event_clearing =
ACPI_EC_EVT_TIMING_STATUS. The default for other machines is
ACPI_EC_EVT_TIMING_QUERY.

The EC dynamic debug log (ec-debug-status-mode.txt, dyndbg
'file drivers/acpi/ec.c +pt'; the kernel log buffer only kept the last ~2.2 s)
shows:

  [518.402901] [14] ACPI: EC: EC_SC(R) = 0x28 SCI_EVT=1 BURST=0 CMD=1 IBF=0
OBF=0
  ... polled every ~2 ms with OBF=0 (the log starts mid-transaction) ...
  [518.440855] [14] ACPI: EC: controller reset, restart transaction
  [518.440984] [14] ACPI: EC: EC_SC(W) = 0x84
  [518.441177] [14] ACPI: EC: EC_SC(R) = 0x2a SCI_EVT=1 BURST=0 CMD=1 IBF=1
OBF=0
  [518.441204] [14] ACPI: EC: Command(QR_EC) submitted/blocked
  [518.442963] [14] ACPI: EC: EC_DATA(R) = 0x63
  [518.442986] [14] ACPI: EC: Query(0x63) scheduled
  [518.443009] [14] ACPI: EC: Command(QR_EC) started
  [518.443103] [14] ACPI: EC: EC_SC(W) = 0x84
  [518.444159] [107] ACPI: EC: EC_SC(R) = 0x08 SCI_EVT=0 BURST=0 CMD=1 IBF=0
OBF=0
  ... then polled with SCI_EVT=0, OBF=0 ...

5 "controller reset, restart transaction" messages appear within those ~2.2 s.

My interpretation (from the log and the code, not verified on other hardware):
with "status" timing the event is closed as soon as QR_EC enters the POLL
state.
SCI_EVT is still set right after the 0x84 write (see 518.441177), so another
QR_EC is submitted. This EC does not seem to answer a QR_EC issued while no
event
is pending (IBF=0, OBF stays 0), and in the log it also did not answer the
pending
QR_EC when an event became pending later (SCI_EVT=1, OBF=0 at 518.402901).
ec_poll()
then waits for ec_delay (500 ms), restarts the transaction (writes 0x84 again,
up to 5 times), and only then does the EC return the event. This would explain
the 500 ms grid.

Extra EC traffic (battery cache_time=0, reading BAT1 status every 20 ms) did
not
change the grid (second section of brightness-key-timing.txt).

Workaround / verification
-------------------------
  echo query > /sys/module/acpi/parameters/ec_event_clearing

After switching to "query" at runtime, key events followed the actual press
rate
(~100-200 ms apart when pressing quickly, no 500 ms quantization) and the user
reports the hotkeys feel instant (third section of brightness-key-timing.txt).
4 "controller reset" messages were still logged during that 12 s test (dyndbg
limited to that message); I have not analysed what caused them.

Not tested: passing acpi.ec_event_clearing=query on the kernel command line.
>From reading the code, the DMI quirk runs later (dmi_check_system() in
acpi_ec_ecdt_probe()) and would override it, which is why the runtime parameter
was used.

Also not tested: suspend/resume with ec_event_clearing=query. The original
reason
for the Samsung quirk was events accumulated during sleep.

Possible fixes
--------------
 - restrict the Samsung quirk to the models it was written for, or
 - keep EC_FLAGS_CLEAR_ON_RESUME for Samsung but don't override
   ec_event_clearing on newer models, and/or
 - let an explicit acpi.ec_event_clearing= on the command line take precedence
   over the DMI quirk.

Attachments
-----------
 - ec-debug-status-mode.txt     EC dynamic debug with the default (status)
timing
 - brightness-key-timing.txt    libinput timestamps: status / status + EC
traffic / query
 - system-info.txt              DMI, EC parameters, EC boot messages
 - dsdt.dat                     raw DSDT

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

_______________________________________________
acpi-bugzilla mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/acpi-bugzilla

Reply via email to