Skip to contentSkip to conversation

ACPI: EC: Samsung DMI quirk (ec_clear_on_resume) costs 2.5 s per resume and stalls s2idle on Galaxy Book4

BUG Jamil Khan 1 participant 1 message Nov 17 ACPI

lore
Share & tools
lore

Jamil Khan

author
#0 lore raw

Hi,

The DMI quirk in drivers/acpi/ec.c that matches every machine with

DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")

and calls ec_clear_on_resume() (added for Samsung Series 5/9, bugzilla 44161) misbehaves on a current Samsung model. It sets EC_FLAGS_CLEAR_ON_RESUME and ec_event_clearing = ACPI_EC_EVT_TIMING_STATUS.

Machine: Samsung Galaxy Book4, product 750XGK, board NP750XGK-LG2IN, BIOS P11CFP.025.251116.HQ, Intel Core 5 120U (Raptor Lake-U), s2idle only. Kernel 7.2.15.

On this machine the EC does not answer QR_EC when no event is pending. The transaction is restarted five times and then fails, so every such query costs 5 * ec_delay = 2.5 s. Two visible effects:

1. Resume. acpi_ec_clear() always issues at least one query with nothing pending. The acpi-ec resume callback takes 2.5 s on every resume:

device_pm_callback: acpi-ec PNP0C09:00 [resume] 2510 ms
ACPI: EC: 0 stale EC events cleared

"PM: resume of devices complete after 2509 msecs" on every cycle; nothing else is above 0.3 s.

2. s2idle on AC. Shortly after entering s2idle the EC reports fan changes (Query 0x56 -> Notify(FAN1, 0x80)) in a burst. With the STATUS timing the driver submits more queries than there are events. With pm_debug_messages and dyndbg on ec.c:

       13430.605 PM: Triggering wakeup from IRQ 9
       13430.606 ACPI: EC: ACPI EC GPE dispatched
       13430.607 ACPI: EC: Query(0x56) started / stopped
       ...  (8 real queries in 3.5 s, on a 500 ms cadence)
       13434.111 ACPI: EC: Query(0x56) stopped
       13449.109 ACPI: EC: ACPI EC work flushed

function_graph shows acpi_s2idle_wake() -> acpi_ec_dispatch_gpe() -> __acpi_ec_flush_work() blocked for 18.5 s, and the workqueue trace shows one acpi_ec_event_handler run of 18.503 s: 6 unanswered queries of 2.5 s each after the real ones. The system only goes back to sleep after that. On battery there are no fan events and the stall does not happen.

Awake, with a CPU load to generate fan events, per ec_event_clearing mode (function tracer on acpi_ec_*):

status (set by the quirk): 19 queries submitted for 11 real events, event handler busy for the whole run query (driver default) : 14 submitted for 11 real events
event : 5 submitted for 5 real events, no transaction restarts

As far as I can see the EC driver only ever issues QR_EC here: a kprobe on acpi_ec_space_handler saw no calls across a full suspend/resume cycle, so EC RAM is not accessed through it.

Workaround in use, set at runtime because the quirk overrides the command line:

echo query > /sys/module/acpi/parameters/ec_event_clearing
echo 50 > /sys/module/acpi/parameters/ec_delay

Result on AC through a real suspend: 0.4 s awake in total for EC events instead of 18.5 s, and the acpi-ec resume callback takes 261 ms instead of 2510 ms. Events (lid, Fn keys, AC) still arrive. ec_delay only shortens the unanswered query in acpi_ec_clear(); it does not remove it.

Questions:

- Should the Samsung match be narrowed (the original report was for Series 5/9), or should newer models such as the Galaxy Book4 family be excluded?
- Independently of the quirk, is there a better way to handle an EC that does not answer QR_EC when nothing is pending than waiting 5 * ec_delay?

I can test patches on this machine and provide full traces (ftrace, dmesg with ec.c dyndbg, acpidump).

Thanks,
Jamil Khan <[email protected]>