CVSROOT: /cvs Module name: src Changes by: j...@cvs.openbsd.org 2020/06/10 16:26:40
Modified files: sys/dev/acpi : acpi.c acpiac.c acpibat.c acpisbs.c Log message: Give userland a consistent battery and A/C state after resume Previously we refreshed the state of acpiac(4) and acpibat(4)/acpisbs(4) by queueing fake ACPI events to be processed by the acpi thread. acpibat(4) using ACPIDEV_POLL meant that its status could be refreshed first, resulting in an APM_POWER_CHANGE event sent to userland before the state of acpiac(4) was up to date. Because of this, apmd(8) could see A/C unplugged when it was in fact plugged, possibly leading to a wrong decision. Instead of using fake ACPI events, refresh the status of acpiac(4) and acpibat(4)/acpisbs(4) right away at DVACT_WAKEUP time. To reuse the existing refresh code of those drivers, make their ACPI *_notify() handlers responsible for sending APM_POWER_CHANGE events instead. Also queue an APM_POWER_CHANGE event right after resume to retain existing behavior. This fixes the consistency of data shown to userland, and makes those drivers less special. Initially discussed last year (!) with mpi@ at Miod's place. Feedback and ok jcs@, deraadt@ agrees with the use of DVACT_WAKEUP here.