Repository navigation
iio: aop_als: stop the reports for system sleep - #3404
Conversation
The light sensor reports on its own every 200 ms, and each report is an AOP mailbox interrupt. Nothing stopped them for a system sleep, so in suspend-to-idle they went on waking a CPU for readings nobody takes. On a J413 (M2 Air, VD6286, suspend-to-idle by default) the AOP mailbox took 84 interrupts during a 21 s rtc sleep with the light sensor armed, and 26 with it stopped: the light sensor was about 2.7 of the 4 wakeups a second the AOP caused while the Mac slept. The lid angle driver already stops its reports for the sleep. Extend the PM notifier that re-arms the CT817 to every part: at PM_SUSPEND_PREPARE write the interval to zero, and at PM_POST_SUSPEND start the reports again. The CT817 keeps the whole arming sequence after every sleep, because its firmware stops the reports for system sleep even when the host did not. The other parts get their interval back, and only if it was stopped. A failure to stop is logged and never refuses the sleep. Link: #2713 Signed-off-by: Ryan Murray <[email protected]>
There was a problem hiding this comment.
The J413 interrupt counts and J700 wake reports cover the normal path, and unbind unregisters the notifier before removing the listener. The stop failure path can leave a non-CT817 sensor permanently silent. PM_SUSPEND_PREPARE sets stopped only on a successful reply, so if the interval-zero command reaches the AOP but its reply is lost or times out, PM_POST_SUSPEND skips restoration on VD6286/CT720. This also applies when suspend aborts after the prepare callback. Please restore the driver's active interval after every attempted stop, including uncertain completion, or establish that all errors guarantee the command was never applied. Cover a failed reply followed by post-suspend. Keep the existing CT817 re-arm sequence.
PM_SUSPEND_PREPARE marked the reports as stopped only when the AOP answered the interval-zero command. A command that reached the AOP but whose reply was lost or timed out may still have been applied, and then PM_POST_SUSPEND did not restore a VD6286 or CT720, which stayed silent until the driver was bound again. Record the attempt before the command goes out and restore the active interval after every attempted stop, whatever the reply. Writing the active interval to a sensor that kept reporting changes nothing; the CT817 keeps its full arming sequence after every sleep. Link: #3404 (review) Signed-off-by: Ryan Murray <[email protected]>
|
Fixed in
Logs: J413 |
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Setting stop_attempted before the write addresses uncertain completion while preserving unconditional CT817 re-arm. I ran the exact notifier body against a mocked AOP that applies interval zero and returns ETIMEDOUT. Two consecutive prepare/post pairs restored the active interval and cleared the marker each time. The reported J413 and J700 rows exercise the normal paths on this head. Code approved. Keep held for hosted CI and record the CT720 coverage limit from the existing test report.
|
Merged as |
What:
iio_aop_alsnow stops the light sensor's reports for system sleep and starts them again after it, asaop_lasalready does for the lid angle. In suspend-to-idle the reports kept arriving as AOP mailbox interrupts (about 2.7 a second on a J413) and woke a CPU for readings nobody takes. This is the suspend part of #2713, on top of #3393 (merged).Tested: at
116a2c10(rows below re-run at this head; first run atdb323325), built as a module against the fleet89 tree and loaded on the running fleet89 kernel, stock module first, then this one. Counts are AOP mailbox interrupts during one 20 s rtc sleep.db323325: 84/81 vs 28/28). A test-only build where the stop fails (ETIMEDOUT) still had reports back at 46/10 s after each wake. Reports came back after every wake (46-47 per 10 s, same as before the sleep).Risk: two-way · Macs with an AOP light sensor. Every part now gets a PM notifier. The CT817 wake path behaves as before (#2528); VD6286/CT720 parts gain a stop before the sleep and a restart after it.
Not yet: the power saved per hour of s2idle hasn't been measured; only the interrupt counts above. No CT720 Mac in the lab; the VD6286 takes the same code path (one interval write each way). Not yet run on a cold boot of a kernel built from this head. Lux read 0 in the dark lab rooms, so these rows don't show light-following.
Details
PM_SUSPEND_PREPARE: record the attempt, then write interval 0. A failure is logged and never refuses the sleep.PM_POST_SUSPEND: the CT817 gets the whole arming sequence after every sleep, because its firmware stops the reports for system sleep even when the host didn't (iio: aop_als: arm the CT817 again after system sleep #2528). The other parts getALS_INTERVAL_USback after every attempted stop, including one whose reply was lost (review item; fixed in116a2c10).Evidence
J413, 20 s
rtcwake -d rtc1 -m freeze, AOP mailbox24a408000(also carries the other AOP sensors):Earlier the same night, with the ALS stopped by unbind instead: 26 interrupts per 21 s sleep. With it armed: 84.
J700, 20 s
rtcwake -m memx2 +-m freeze, AOP mailbox310608000:No new kernel warnings in either run.
Build:
aop_als.ocompiles against main2d96d922with no warnings (fleet config, clang/LLD 22.1.6, rustc 1.97.1, bindgen 0.73.2). The test module was built against fleet89645f7cd3with an identical config and symbol table.rustfmt --checkis clean;checkpatchreports 0 errors and 0 warnings.Revert:
git revert -m 1 <merge>; ALS reports run through system sleep again, and the CT817 is re-armed after wake as before.