Skip to content

iio: aop_als: stop the reports for a system sleep and on unbind - #1876

Closed
gig3m wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
gig3m:j813/aop-als-sleep
Closed

gig3m wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
gig3m:j813/aop-als-sleep

Conversation

@gig3m

@gig3m gig3m commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

The ALS reports on its own at the interval the driver sets at probe (200 ms), and each report is an AOP mailbox interrupt. Nothing set the interval back to zero, so:

  • after an unbind the sensor kept reporting to nobody
  • in suspend-to-idle it woke a CPU five times a second

This sets the interval to zero on unbind and in .suspend, and back in .resume.

Draft, because I can test one machine and this driver serves several. Feedback wanted on:

  • the CT817 (T8140). It starts on the zero to non-zero transition and wants its batch and raw interval written first. Resume writes only the interval. Is that enough there?
  • a real sleep. aop.rs stops the endpoints in suspend_late for a firmware sleep; this runs before that, in .suspend. I could only test s2idle.
  • whether macOS stops the ALS for a sleep the same way. I have no trace of it.

Tested on J813 (Mac17,3, 27.0 stub, VD6286), integration/aurora 5d112b1 merged with #1532:

  • awake, AOP mailbox interrupts per 10 s: bound 60, unbound 10 (59 before this change), rebound 60
  • s2idle test suspends, 20 trials: 1.15 to 1.2 interrupts per second in the sleep, 5.9 to 6.0 before
  • the channel reads again after every resume and rebind
  • one lid-close sleep, 181 s on battery: 1.02 interrupts per second in the sleep (it was 3.6 on an earlier kernel), the channel reads again after it, no warning
  • no measurable power change in s2idle here (1.90 W against 1.93 W, 20 s trials): the cores only clock-gate. It should count once T8142 has a real sleep.

Not tested: any other Mac, a failed interval write on resume (it now warns).

Assisted-by: Claude Fable 5.2

The sensor reports on its own at the interval the driver sets at probe,
and each report is an AOP mailbox interrupt. Nothing set the interval back
to zero: the sensor kept reporting after the driver was unbound, and
through suspend-to-idle, where it woke a CPU five times a second.

Set the interval to zero on unbind and on system suspend, and back on
resume.

Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
DjDeveloperr pushed a commit that referenced this pull request Nov 19, 2026
The firmware streams the lid angle at its own interval whether anyone
reads it or not, and the AOP mailbox interrupt stays enabled in suspend-
to-idle, so every report ends the CPUs' idle period. On the J815
(MacBook Air 15-inch, M5), a 4 h lid-closed s2idle left the freeze loop
14478 times, once every 0.999 s, matched by 14413 AOP mailbox interrupts
and 14551 RTKit receive works. The device-motion service already stops
its reports for sleep, and the light sensor's equivalent is #1876; the
lid angle is the AOP stream left running.

Read the interval the firmware runs at when the system sleeps, set it to
0, and write it back when the system wakes, from a PM notifier as
aop_devmotion does. A service that refuses the read is left alone. Lid
open and close reach the kernel from the SMC, not from this sensor, so a
sleeping system still wakes on the lid.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 2.

  1. drivers/iio/common/aop_sensors/aop_als.rs:254: resume restores only ALS_PROP_INTERVAL. The driver's own comment (aop_als.rs:28-36, :124-126) says the CT817 starts on the zero to non-zero interval transition only after its batch and raw properties have been written. Suspend (:244) now drives that transition on every sleep, and nothing re-arms the CT817 afterwards. If the AOP does not keep those two properties across a sleep, the T8140 ALS stops reporting after the first suspend, on a Mac this was not tested on. The fix needs no firmware load in resume: store offset in IIOAopAlsDriver, and for LUX_OFFSET_CT817 have resume replay the probe's property sequence (verbosity, batch, raw, then interval). Unbind (:356) followed by a rebind already goes through that sequence in probe, so only resume is exposed.
  2. Commit d5ee128 carries Assisted-by: Claude Fable 5.2 as a trailer. Commits should carry only the human author and their Signed-off-by. Drop it, push the result as a new branch and open a new PR (no force push). Put the credit as the PR body's last line in the form Assisted-by: LLM (Anthropic:Claude Fable 5.2).

Checked and fine: the ALS device is a child of the AOP device (registered with parent: in drivers/soc/apple/aop.rs:1387), so its .suspend runs before the AOP's suspend_late and its .resume after the AOP's resume has restarted the endpoints. Unbind zeroes the interval before the listener goes. The drvdata cast follows the same pattern as aop.rs aop_from_dev. No CI ran on this branch.

HW row: Neo J700 (T8140, CT817) and J813 (VD6286), on this head and the current stub firmware, default bootargs. On each: 10 s2idle and 3 firmware (deep) sleeps; after every resume in_illuminance_raw changes when the lid sensor is covered and then uncovered; AOP mailbox IRQ rate during the sleep is lower than before the change; an unbind/rebind cycle; 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@gig3m

gig3m commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Replaced by #2713, on current integration/aurora with only the human Signed-off-by in the commit. Resume now replays the probe's CT817 sequence (verbosity, batch, raw, then the interval), with the offset stored in IIOAopAlsDriver; the other parts still get only the interval. I have no T8140, so the CT817 path hasn't run. Closing this one.

Assisted-by: LLM (Claude:Opus 5.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants