Repository navigation
iio: aop_als: arm the CT817 again after system sleep - #2528
Conversation
On the J700 (T8140) the light sensor stops reporting at the first system sleep of a boot and never starts again. Every read of in_illuminance_input after that wake returns the last sample from before the sleep, usually taken as the panel went dark, for the rest of the boot. Measured 2026-11-19 on integration/aurora 1473d15 and on the 7.3.0-41 RPM alike: 26 boots, 72 deep sleeps, on both the DRAM-kept and the deep path. Before the first sleep, five reads over 5 s gave 20.55 20.55 20.55 19.36 20.55 lx. After the first and second wakes the same boot read 1.453372 five times each, with the room and the backlight unchanged. Each boot froze on its own value, between 0.000000 and 6.628011 lx. The firmware stops the sensor's reports for system sleep; the lid angle driver's comment notes the same. The CT817 starts reporting only on a zero to non-zero transition of its report interval, which enable_als() writes once, at probe. Register a PM notifier, as aop_las does. At PM_POST_SUSPEND it writes the interval to zero and then repeats the probe's CT817 arming: verbosity, batch and raw interval, then the interval. Only the CT817 gets the hook; the other parts are unchanged. Tested on the J700 with 1473d15 plus this patch, built as a test kit: 2 boots, 6 DRAM-kept deep sleeps. After every wake the sensor reported again and followed the light. It read 18.23-18.61 lx with the panel on, and fell to 5.17-6.37 lx, still varying from read to read, when the lock screen dimmed the backlight to 121. The sleeps, GPU, Wi-Fi, BT and the AOP mics behaved as on the tip, and the patch logged no warning. Signed-off-by: Diljit Singh <[email protected]>
|
No blockers. I checked the hook's lifetime and teardown. The notifier block is the first field of a pinned
HW row: on J815 (T8142, CT817) with the same kit, 3 deep sleeps; after each wake Assisted-by: LLM (Claude:Opus 5.5) |
|
|
satchlj
left a comment
There was a problem hiding this comment.
Gemini 4 Neon on @satchlj's behalf
Verdict at ebc0f1bd6a73
Approve. The PmHook lifetime, pinned #[repr(C)] layout, teardown ordering, and CT817-scoped PM_POST_SUSPEND re-arm sequence are sound.
Blockers
None.
Checked
- 1 changed file (
drivers/iio/common/aop_sensors/aop_als.rs) audited in full. - Rust safety & lifecycle:
PmHookis#[repr(C)]withnbas its first field insidePin<KBox<PmHook>>.unregister()usesregistered.xchg(false, Relaxed)before callingunregister_pm_notifier()(which synchronizes against any running callback) and is invoked in bothunbind()andDrop. Struct field ordering (pmbeforelistenerbefore_iio) ensures the notifier cannot outlive the AOP listener. BothCONFIG_PM_SLEEPand!CONFIG_PM_SLEEPbuilds are cleanly handled. - Hardware scoping: Only CT817 (
offset == LUX_OFFSET_CT817) registers the hook and replaysALS_PROP_INTERVAL = 0followed byarm_ct817()onPM_POST_SUSPEND; other ALS sensors remain unchanged. - CI & trailers:
host-testsSUCCESS,MERGEABLE; commit has cleanSigned-off-by:with zero AI trailers; J700 (T8140)2 boots / 6 deep sleepsverification is documented in the commit message. - Non-blocking note: Coordinate with draft
#2713(suspend-time stop / VD6286) and clean up the PR description footer before merge as previously noted. - Untested scope: Static code audit only (userspace-only review environment; no kernel build or boot performed here).
Evidence
- Audited
drivers/iio/common/aop_sensors/aop_als.rsdiff (+161/-12) atebc0f1bd6a73. - CI at head
ebc0f1bd6a73:host-testsSUCCESS.
|
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. |
|
ebc0f1b Neo (J700, T8140) + J615 (T8122) + J616s (T6040) (batched 0-diff merge onto main) PASS: aop-sensors-als bound cleanly with 0 als errors across 2/2 rtc0 s2idle on Neo (16.07 lx pre/post-sleep, Borealis VK 1.4.363 + GL 4.6 OK) and 2/2 rtc0 s2idle on J615 (live changing lux pre 16.49-16.66 lx & post 14.90-15.05 lx); Enforcing, 0 failed, 0 AVC on Neo/J616s, 0 new kernel errors; fleet defaults restored. |
The light sensor reports on its own every 200 ms, and every report is an AOP mailbox interrupt. unbind() only dropped the listener, so the sensor went on reporting to nobody: on the J700 (T8140, CT817) the AOP mailbox kept taking 5 interrupts a second after the driver was unbound, the same rate as with the driver bound. Write the interval to zero at unbind, before the listener goes, as the motion driver already stops its sensor at unbind. A failure is logged and unbind goes on; the AOP transport refuses calls once it is closing. The CT817 arms only on a zero to non-zero transition of its interval. Probe assumed the interval was zero, which holds at a cold boot but not after a previous instance of the driver (or a kexec) left the sensor running. Make the zero write the first step of arm_ct817(), so probe and the wake path share one sequence; the wake path already wrote zero first, so its behaviour does not change. This takes over the unbind part of aurora-silicon#2713 by Kyle Arrington, who handed the branch over. Its suspend and resume part is left out: aurora-silicon#2528 now arms the CT817 again after a sleep, and whether reports still wake the CPU in suspend-to-idle needs its own measurement. Link: aurora-silicon#2713 Signed-off-by: Ryan Murray <[email protected]>
Problem
On the MacBook Neo (J700, T8140), the ambient light sensor stops at the first system sleep of every boot and never reports again until reboot. After that wake,
in_illuminance_inputkeeps returning the last sample taken before the sleep, usually from the moment the panel went dark. iio-sensor-proxy, and anything that follows ambient light, then sees a constant for the rest of the boot. No error is logged.Evidence (Neo J700, installed aura 1.0.0b13-g5dcf62d0, no dock)
20.55 20.55 20.55 19.36 20.55lx. After wake 1 and wake 2:1.453372×5 each, with the backlight (402) and the room unchanged.aop_las.rsalready notes this ("after the light sensor already stopped its reports for sleep").enable_als()writes that transition once, at probe, and the driver has no PM handling.Fix
A PM notifier, built the same way as aop_las's (#2223). At
PM_POST_SUSPENDit writes the interval to 0 and then repeats the probe's CT817 arming: verbosity, batch interval, raw interval, interval.offset == LUX_OFFSET_CT817); VD6286 and CT720 are unchanged.dev_warn..rustfmt.toml. Builds without warnings with LLVM 19 / Rust 1.85.Tested (Neo J700)
Test kit
7.3.0.nts1473a= 1473d15 + this patch (same diff), Ryzen build, config-neo-41 lineage. One-shot boots on the installed aura, each followed by a byte-exact undo.15.26×5. After wake 218.61 18.61 18.23 18.61 18.61, after wake 318.61×5, panel on.16.46 15.26 15.26 15.26 15.26. After wake 118.23×5 (panel on). After wake 2, with the lock screen dimming the backlight to 121,5.17 6.37 5.17 5.17 6.37. After wake 35.55×5.reports not armed againwarning, no AOP crash, no BAD lines.Not merging; for review.
🤖 Generated with Claude Code