ACPI / EC: Clear stale EC events on Samsung systems
A number of Samsung notebooks (530Uxx/535Uxx/540Uxx/550Pxx/900Xxx/etc)
continue to log events during sleep (lid open/close, AC plug/unplug,
battery level change), which accumulate in the EC until a buffer fills.
After the buffer is full (tests suggest it holds 8 events), GPEs stop
being triggered for new events. This state persists on wake or even on
power cycle, and prevents new events from being registered until the EC
is manually polled.
This is the root cause of a number of bugs, including AC not being
detected properly, lid close not triggering suspend, and low ambient
light not triggering the keyboard backlight. The bug also seemed to be
responsible for performance issues on at least one user's machine.
Juan Manuel Cabo found the cause of bug and the workaround of polling
the EC manually on wake.
The loop which clears the stale events is based on an earlier patch by
Lan Tianyu (see referenced attachment).
- Adds a function acpi_ec_clear() which polls the EC for stale _Q
events at most ACPI_EC_CLEAR_MAX (currently 100) times. A warning is
logged if this limit is reached.
- Adds a flag EC_FLAGS_CLEAR_ON_RESUME which is set to 1 if the DMI
system vendor is Samsung. This check could be replaced by several
more specific DMI vendor/product pairs, but it's likely that the bug
affects more Samsung products than just the five series mentioned
above. Further, it should not be harmful to run acpi_ec_clear() on
systems without the bug; it will return immediately after finding no
- Runs acpi_ec_clear() on initialisation (boot), from acpi_ec_add()
- Runs acpi_ec_clear() on wake, from acpi_ec_unblock_transactions()
Suggested-by: Juan Manuel Cabo <firstname.lastname@example.org>
Signed-off-by: Kieran Clancy <email@example.com>
Reviewed-by: Lan Tianyu <firstname.lastname@example.org>
Reviewed-by: Dennis Jansen <email@example.com>
Tested-by: Kieran Clancy <firstname.lastname@example.org>
Tested-by: Juan Manuel Cabo <email@example.com>
Tested-by: Dennis Jansen <firstname.lastname@example.org>
Tested-by: Maurizio D'Addona <email@example.com>
Tested-by: San Zamoyski <firstname.lastname@example.org>
Cc: All applicable <email@example.com>
Signed-off-by: Rafael J. Wysocki <firstname.lastname@example.org>
1 file changed