Skip to content

iio: aop_temp, aop_las: run board temperature and lid angle reports on demand with idle stop - #3409

Open
erikwb wants to merge 6 commits into
mainfrom
fix/aop-temp-las-ondemand
Open

erikwb wants to merge 6 commits into
mainfrom
fix/aop-temp-las-ondemand

Conversation

@erikwb

@erikwb erikwb commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What: Stop continuous 1 Hz AOP fake-HID reports from aop_temp and aop_las at idle and start them on demand for direct sysfs reads (and kfifo buffer enable on aop_temp), with a 5 s idle-stop grace window, failure backoff, stop-retry recovery, and pre-probe interval restore attempts on aop_las unbind/rollback.
Tested: J716c (M5 Max, T6050, firmware 27.2, AC, default command line) at c8cde22e54ca, merged with main 429e7e15f122 in a one-shot trial kernel: aop_las in_angl_raw cold 801 ms (warm 0 ms), aop_temp in_temp_input cold 987 ms (warm 1 ms); both read cold again after >= 7 s idle (987 ms and 991 ms, so the 5 s idle stop ran); modprobe -r and modprobe of both modules clean (cold 803 ms / 987 ms after reload); reads after 2x pm_test=devices and 1x pm_test=platform suspend return (613 to 698 ms and 986 to 1011 ms cold, 1 ms warm); 0 AOP errors in dmesg; 1 failed unit (aurora-peripherals.service) as on the default boot, 0 LSM denials, 0 GPU/MMU faults. aop_las.rs is unchanged from b803dcae16de, aop_temp.rs is updated for wake reconciliation. Host and build checks at c8cde22e54ca pass: aop-temp.py (6/6), aop-las.py (8/8), aop-als.py (5/5), aop-motion.py (10/10), aop-devmotion.py (8/8), run-host-tests.py --only aop (13/13), rustfmt, checkpatch --strict (0 errors), arm64 Clang + Rust 1.99 build of drivers/iio/common/aop_sensors/, and full j716c kernel build with CONFIG_IIO_AOP_SENSOR_TEMP=m. Earlier-head hardware rows (J616C at b803dcae16de, J713 / J316s / J716c / J700 / J313 at cf2c1f844ddb and c7d67b009c22, where aop_las.rs is byte-identical to c8cde22e54ca) and b803dcae16de KUnit asahi (510/514 passed, 4 skipped) are in Evidence.
Risk: two-way door · M1–M5 Macs with AOP lid-angle or board-temperature sensors (aop_temp services that refuse PROP_INTERVAL = 0, and aop_las services that refuse PROP_INTERVAL = 0 or report a pre-probe interval > 2 s, retain the passive cached path).
Not yet: aop_las / aop_temp across a real s2idle or rtcwake -m mem on J716c (only pm_test=devices and pm_test=platform ran earlier because the RTC alarm cannot wake J716c unattended); on-device exercise of the on-demand path on J313 (M1; no aop_las or aop_temp device binds on T8103); on-device runs on M2/M3 AOP models (host tests exercise both on-demand and passive fallback paths); and hosted CI run at c8cde22e54ca (replacing the b803dcae16de run where 12 KUnit suites in 46516573857 were cancelled at the 4 h limit).

Details

Both aop_temp and aop_las previously left 1 Hz AOP fake-HID reports streaming continuously from probe until unbind or system sleep, waking the AP twice a second on an idle desktop even with no consumers.

Following the on-demand idle-stop pattern in aop_motion:

  • aop_temp (fff2d23562f4, c8cde22e54ca):
    • Calibrates once per AOP boot (and conservatively again after pm_suspend_via_firmware() sleep, hibernation, or restore) and stops reports at probe after verifying calibration, start, and stop. Retains continuous mode if the service refuses PROP_INTERVAL = 0 and unwinds transient errors.
    • Tracks service run state as Stopped, Running, or Unknown so any unacknowledged start or stop reasserts the target interval on the next transition and arms a 5 s stop retry whenever an idle on-demand stream is left Unknown or Running (including after unpark).
    • Preserves RunState::Unknown on pm_suspend_via_firmware(), hibernation, and restore wakes in Stream::set_parked_with (c8cde22e54ca), matching aop_las, so an unacknowledged suspend stop (including pm_test=devices runs that never enter firmware sleep) or AOP restart reconciles PROP_INTERVAL = 0 while idle and arms the 5 s retry if that write fails.
    • Invalidates cached samples before starting reports from Stopped or Unknown on direct reads, buffer enable, and sleep resume.
    • Wires iio_buffer_setup_ops (postenable / predisable) to the kfifo buffer, gating iio_push_to_buffers() under a spinlock that drains in-flight pushes in predisable before IIO detaches the buffer list while keeping direct-read sample caching active.
    • Tracks in-flight direct_readers so concurrent reads wait for the first report and buffer transitions cannot stop a stream under an active direct read; holds reports warm for 5 s via DelayedWork and backs off after failed starts.
    • Frees the IIO device via devres registered before the kfifo buffer and tears down IIO, PM, delayed work, and listener in Drop as well as unbind so probe rollback after iio.register() cannot leak work.
    • Adds host regression test tools/testing/selftests/drivers/apple/aop-temp.py (extended with MockTempIo wake-reconciliation tests in c8cde22e54ca) and registers it in tools/asahi/run-host-tests.py.
  • aop_las (a54b081f186f, cf2c1f844ddb):
    • Records the pre-probe PROP_INTERVAL when readable, clearable, and <= 2 s; stops reports at probe and starts them on demand for in_angl_raw reads with direct_readers tracking, RunState::{Stopped, Running, Unknown}, interval + 500 ms cold wait, 5 s warm hold, failure backoff, and 5 s stop-retry recovery.
    • Reconciles ambiguous probe stop timeouts and attempts to restore the saved interval on unbind or probe rollback (clearing the saved interval only after an acknowledged write, so a second teardown pass can retry a failed restore) so a subsequent rebind normally observes the pre-probe interval instead of 0. When readback and the fallback restore both fail (cf2c1f844ddb), keeps on-demand mode active in RunState::Unknown with interval_us set and an armed idle stop retry rather than entering passive ENODATA.
    • Clears the interval again on wake while idle after pm_suspend_via_firmware() sleep, hibernation, or restore in case an AOP restart resumed default streaming; the suspend/resume path attempts to restore the stream state and only logs a warning (reports not switched for sleep) if a firmware write fails, so restoration is attempted, not guaranteed.
    • Extends tools/testing/selftests/drivers/apple/aop-las.py with MockAop tests over Stream::{probe_with, sync_with, shutdown_with} and updates Documentation/iio/aop-sensors.rst.
  • Forward merges (c7d67b009c22, b803dcae16de):
    • c7d67b009c22 merges main (18058ea228e2, including #3473) into fix/aop-temp-las-ondemand.
    • b803dcae16de merges origin/main (dbfbced70b31) into fix/aop-temp-las-ondemand, keeping one entry each for aop-als, aop-devmotion, aop-las, aop-motion, and aop-temp in tools/asahi/run-host-tests.py and tools/testing/selftests/drivers/apple/Makefile.
  • Revert: git revert -m 1 <merge-sha> on main (or revert fff2d23562f4, a54b081f186f, cf2c1f844ddb, c8cde22e54ca) and reinstall aop_las/aop_temp modules; restores prior continuous 1 Hz streaming with no persistent on-disk, DT, or firmware state (aop_las restores its pre-probe PROP_INTERVAL on unbind).
Evidence
  • Commits:
    • fff2d23562f4 iio: aop_temp: run board temperature reports on demand with idle stop
    • a54b081f186f iio: aop_las: stop lid angle reports at idle and start on demand
    • cf2c1f844ddb iio: aop_las: keep ambiguous probe stop-restore failure recoverable
    • c7d67b009c22 Merge branch 'main' into fix/aop-temp-las-ondemand
    • b803dcae16de Merge remote-tracking branch 'origin/main' into fix/aop-temp-las-ondemand
    • c8cde22e54ca iio: aop_temp: preserve Unknown state across firmware-sleep wake
  • Byte-identity:
    • drivers/iio/common/aop_sensors/aop_las.rs: git blob 4c30d05939d1c43a6ed2b80149325fbf75d37698 (unchanged across cf2c1f844ddb -> c7d67b009c22 -> b803dcae16de -> c8cde22e54ca)
    • tools/testing/selftests/drivers/apple/aop-las.py: git blob aefccb4a325f22cf47f3de0a6c9d08b6ef19c37e (unchanged across cf2c1f844ddb -> c7d67b009c22 -> b803dcae16de -> c8cde22e54ca)
    • Documentation/iio/aop-sensors.rst: git blob bed42b2674f3d76e3ff2789712df891f8c5fb4f6 (unchanged from b803dcae16de to c8cde22e54ca)
    • drivers/iio/common/aop_sensors/aop_temp.rs: git blob e2d74b4b98d69163fb2eb0ed68c5ac1ab267edc5 (updated at c8cde22e54ca from f24bd055d7f0cf1687e802a1fce79a3ada2f1b55)
    • tools/testing/selftests/drivers/apple/aop-temp.py: git blob fbbb590fa3ed7830bdbba13ac3bfd244e16a922f (updated at c8cde22e54ca from b9aabc02121df6f484d2f94b7f18db4b2e204016)
  • Host tests, build & style at c8cde22e54ca:
    • python3 tools/testing/selftests/drivers/apple/aop-temp.py — 6/6 passed
    • python3 tools/testing/selftests/drivers/apple/aop-las.py — 8/8 passed
    • python3 tools/testing/selftests/drivers/apple/aop-als.py — 5/5 passed
    • python3 tools/testing/selftests/drivers/apple/aop-motion.py — 10/10 passed
    • python3 tools/testing/selftests/drivers/apple/aop-devmotion.py — 8/8 passed
    • python3 tools/asahi/run-host-tests.py --only aop — 13/13 passed
    • rustfmt --edition 2021 --check drivers/iio/common/aop_sensors/aop_temp.rs drivers/iio/common/aop_sensors/aop_las.rs — clean
    • make O=_build ARCH=arm64 LLVM=1 drivers/iio/common/aop_sensors/ (defconfig + asahi.config, Rust 1.99.0) — clean (aop_las.o, aop_als.o, aop_motion.o, aop_devmotion.o, aop_temp.o)
    • Full j716c kernel build with CONFIG_IIO_AOP_SENSOR_TEMP=m (Image.gz, dtbs, modules.tar.zst, aop_las.ko, aop_temp.ko, kfifo_buf.ko) — clean
    • scripts/checkpatch.pl --strict --git dbfbced70b31..HEAD — 0 errors (0 errors/warnings/checks on c8cde22e54ca; 1 standard MAINTAINERS warning on fff2d23562f4 for adding aop-temp.py)
    • git merge-tree --write-tree origin/main HEAD (a171afd2123f) — conflict-free (d50b67331ff0)
  • J716c at c8cde22e54ca (16-inch M5 Max, T6050, firmware 27.2, AC 100%, default command line, default Stage 2): one-shot trial kernel, Linux 7.3.0, config = the J716c board config with CONFIG_IIO_AOP_SENSOR_TEMP=m (CONFIG_IIO_BUFFER=y, CONFIG_IIO_KFIFO_BUF=m), main 429e7e15f122 with c8cde22e54ca and the open PR heads 6c38b2268568, fc59c510f4e2, 27ffbe1aa92a, 0e6b27f5a2a8 and df01a6cd9b2e merged (no file overlap with this PR except tools/asahi/run-host-tests.py, merged without conflict).
    • IIO devices: aop-sensors-las (in_angl_raw), aop-sensors-als, aop-sensors-als-temp (in_temp_input, in_temp_sampling_frequency, kfifo buffer); AOP mailbox (290608000.mailbox-recv) 1.0 Hz (10 IRQs / 10 s) idle, 2.0 Hz (6 / 3 s) right after the reads, 1.0 Hz 7 to 17 s after the last read and again after the idle stop (the rate on this Mac only moves inside the warm-hold window).
    • Cold aop_las read 801 ms (second boot of the module 803 ms), warm 0 to 1 ms, cold again 987 ms after >= 7 s idle; cold aop_temp read 1010 ms / 987 ms, warm 1 ms, cold again 991 ms after >= 7 s idle.
    • modprobe -r aop_temp aop_las then modprobe aop_las and modprobe aop_temp: both back, reads 85 (803 ms) and 23468 (987 ms).
    • pm_test=devices (x2) and pm_test=platform (x1) suspend cycles (no real s2idle: the RTC alarm cannot wake J716c): aop_las 613 / 698 / 661 ms cold, aop_temp 994 / 986 / 1011 ms cold then 1 ms warm, so each wake reconciled the stopped stream; dmesg shows 0 AOP/IIO errors or warnings after them.
    • Smoke (same boot): eDP-1 3456x2234@120, Apple MTP keyboard / trackpad and lid devices enumerated, wlan0 0% loss over 3 pings, Borealis Apple M5 Max (G17C B1) with vkcube --c 240 --wsi wayland clean, 1 failed unit (aurora-peripherals.service, also failed on the default boot), 0 LSM denials (no SELinux or AppArmor loaded), 0 GPU fault / MMU fault / DeviceLost / Oops / WARN lines.
  • Earlier-head checks at b803dcae16de (prior to c8cde22e54ca):
    • M4 Max (J616C / T6041) (report) in a combined battery batch atop main (fe9af4b604784, with PR head b803dcae16de, alongside #3359 and #3335): clean boot, 0 failed units, 0 AOP sensor/IIO errors in dmesg, settled battery idle 3.52–3.59 W (disp_bl=100, kbd_bl=64).
    • ./tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/gpu/drm/asahi/.kunitconfig — 510 passed, 4 skipped of 514 (at b803dcae16de).
    • Hosted CI at b803dcae16de: apple-build (run 46516573857), host-tests (run 46516573781), pr-text (run 46516574426), and KUnit ane-boot, ane-pm, dcp-fabric, dcp-topology passed; 12 KUnit suites in 46516573857 were cancelled at the 4 h timeout.
  • Earlier-head J716c batched trial runs at c7d67b009c22 (3545ebecb76f): J716c (16-inch M5 Max, T6050, firmware 27.2, AC, default command line) in a one-shot batched trial kernel (origin/main b897ccb4e71c plus 18 open PR heads, commit 3545ebecb76f; driver blobs matched b803dcae16de before c8cde22e54ca), with one-shot Stage 2 SHA-256 b7d99286395ddd7dadccc6d9593f4bd55391d9e787af97c18b45f58688d9885d and DTB t6050-j716c.dtb SHA-256 d2f0db7a5026ae9cc4e1cff61dca38b4d1b363d47e5bad696ef65c7d715517e0 (default Stage 2 21edee972e1ff1718c6f41c32b91ee151afdc58cbb69f16f2f6a4d8d4c722170 and default kernel untouched). Real s2idle and rtcwake -m mem were not run on either boot (the RTC alarm cannot wake J716c unattended).
    • Boot 1 (default config + CONFIG_ARM_APPLE_SOC_CPUFREQ=m + CONFIG_SENSORS_MACSMC_HWMON=m; config had no aop_temp and no IIO buffer support):
      • Kernel Image.gz SHA-256 d56efde4c7232208bd29d5c4e5890319e0050595dd4f4b1c3844df6656a08312, modules.tar.zst SHA-256 9d5782bcf02ea60a225278c9319431f902b495f6beb485d79d127c0fb2fccc92.
      • Sensor check (aop_las, aop_als loaded): in_angl_raw 91, cold read 453 ms, warm 0-1 ms, same after 4 s idle (the 4 s read falls inside the 5 s warm-hold window and does NOT verify the 5 s idle stop).
      • Boot 1 smoke snapshot: display eDP-1 3456x2234@120 enabled; input Apple MTP keyboard, trackpad and SMC lid devices enumerated; networking wlan0 connected, 0% loss over 3 pings; permitted audio sink AppleJ716 + AppleJ716HPAI present with speakerguardd v2 active; GPU Borealis Apple M5 Max (G17C B1), renderD128, vkcube --c 180 --wsi wayland clean. 1 failed system unit (aurora-peripherals.service, same as baseline warm reboots; 0 new failed units), 0 failed user units, 0 LSM denials, 0 Oops/BUG/fault lines; initial boot smoke snapshot err+ 40 lines against 55 on the default boot, none that the default boot lacks.
    • Boot 2 (same commit 3545ebecb76f, adding CONFIG_IIO_BUFFER=y, CONFIG_IIO_AOP_SENSOR_TEMP=m, and resulting CONFIG_IIO_KFIFO_BUF=m):
      • Kernel Image.gz SHA-256 0379bd3eb63c74b8e429dd9a67dcd85b0f300d9725a2cf6495e2609be3f9c926, modules.tar.zst SHA-256 ee6ff86cf22623f64f8ee79d516bb4ad84b24638535c84b1e1b2788e07323987.
      • Sensor check (aop_las, aop_als, aop_temp, kfifo_buf): iio:device2 aop-sensors-als-temp, in_temp_sampling_frequency 1, in_temp_input cold read 935 ms, warm 1 ms, values 24460 -> 24468 -> 24453 mdegC (4 s read; does NOT verify the 5 s idle stop) and 24445 / 24437 / 24429 after 2x pm_test=devices and 1x pm_test=platform, aop_las unchanged at 91; modprobe -r aop_temp and modprobe aop_temp clean; 0 AOP errors in dmesg.
      • Boot 2 smoke snapshot: same 5-item smoke pass, 1 failed system unit (aurora-peripherals.service, same as baseline warm reboots; 0 new failed units), 0 failed user units, 0 LSM denials, 0 Oops/BUG/fault lines; initial boot smoke snapshot err+ 42 lines against 55 on the default boot.
  • Live hardware at cf2c1f844ddb (driver blobs byte-identical in b803dcae16de; default cmdline, default Stage 2, Linux 7.3.0):
    • J713 (M4 MacBook Air, T8132, firmware 27.2), candidate b3dbf237542b over main 9e38a276dcb4: idle 390608000.mailbox-recv 6.00 Hz (60 IRQs / 10 s); on-demand aop_las (las.4.auto) read las=100 and aop_temp (als-temp.5.auto) read temp=23828 raised it to 7.00 Hz (21 IRQs / 3 s); 6.00 Hz again after the 5 s idle stop; clean unbind/rebind of both, post-rebind read las=100, temp=23828, 6.00 Hz; read after 3x s2idle (rtcwake -d /dev/rtc1 -m freeze -s 5) las=100, temp=24273, 6.00 Hz; 0 AOP errors.
    • J316s (M1 Pro, T6000) fleet89 combined-module run (report): carried #3409 cf2c1f844ddb LAS (4c30d059) and temp (f24bd055) blobs alongside #3473's ALS blob; stock las=107, temp=19.500 °C; on-demand las=107 (0.35 s first read), temp=19.437 °C (0.71 s first read); combined AOP IRQs 28->6 per 6 s at idle (for the combined batch); SPI keyboard/trackpad and ALSA registered, gateway 3/3, hardware EGL 32/32, SELinux Enforcing, 0 failed units.
    • J316s (M1 Pro, T6000) guarded Nightly boot (report): based on 94ea195b6eb5, carrying #3473 ALS (b11717dde674) + #3409 LAS/temp (cf2c1f844ddb) blobs; returned lux, las=107, and temp=19.312 °C; SPI keyboard and trackpad and ALSA endpoints registered, gateway 3/3, hardware EGL 32/32, SELinux Enforcing, 0 failed units, kernel errors, or AVCs.
    • J716c (16-inch M5 Max, T6050), candidate c3da8eed6f72 over main 9af21b007425, AC 100%: 290608000.mailbox-recv 1.0 Hz idle (10/10 s), 1.0 Hz active, 1.0 Hz after the 5 s idle stop, 1.0 Hz after suspend (the rate did not change between windows on this Mac); cold aop_las read 178 ms, warm 1 ms, cold aop_temp read 972 ms; after aop_las unbind and rebind the read returned 95 in 1000 ms; after pm_test=devices suspend 1 and 2 reads returned 95 in 598 ms and 511 ms; modprobe -r aop_temp and modprobe aop_temp clean; 0 new dmesg lines.
    • J700 (MacBook Neo), fleet89 645f7cd3: live-loaded aop_las (4c30d059) and aop_temp (f24bd055) from cf2c1f844ddb; inserted/removed cleanly, 0 IIO devices created, CT817 ALS unaffected, 0 failed units.
    • J313 (M1 MacBook Air, T8103), candidate ac44bee46ee4: no aop_las or aop_temp device binds on T8103, so neither driver ran; 0 regressions.
  • Earlier-head hardware verification on J713 (M4 MacBook Air, T8132, firmware 27.2, at a54b081f186f, default cmdline):
    • Idle AOP mailbox (390608000.mailbox-recv): 60 IRQs / 10 s (6.0 Hz), cold in_angl_raw=100 (23 ms), in_temp_input=23546 (989 ms), warm 1 ms, active 7.0 Hz, post-5 s idle-stop 6.0 Hz, unbind/rebind clean (100, 23515), 0 failed units, 0 new kernel warnings/errors.

The AOP temperature driver starts 1 Hz fake-HID reports at probe and
keeps them streaming until system sleep or unbind, waking the
application processor once a second even when nothing reads
in_temp_input or enables its kfifo buffer.

Follow the on-demand idle-stop pattern used by aop_motion:

- Calibrate once per AOP boot (and conservatively again after firmware
  suspend, hibernation, or restore) and stop reports at probe after
  verifying calibration, start, and stop. Retain continuous mode if
  the firmware refuses PROP_INTERVAL = 0, and unwind transient errors.
- Track firmware run state as Stopped, Running, or Unknown so any
  unacknowledged start or stop reasserts the target interval on the
  next transition and arms a 5 s stop retry whenever an idle on-demand
  stream is left Unknown or Running (including after unpark).
- Invalidate cached samples before starting reports from Stopped or
  Unknown on direct reads, buffer enable, and sleep resume.
- Wire iio_buffer_setup_ops (postenable / predisable) to the kfifo
  buffer, gating iio_push_to_buffers() under a spinlock that drains
  in-flight pushes in predisable before IIO detaches the buffer list
  while keeping direct-read sample caching active.
- Track in-flight direct_readers so concurrent reads wait for the
  first report and buffer transitions cannot stop a stream under an
  active direct read; hold reports warm for 5 s via DelayedWork and
  back off after failed starts.
- Free the IIO device via devres registered before the kfifo buffer,
  and tear down IIO, PM, delayed work, and listener in Drop as well as
  unbind so probe rollback after iio.register() cannot leak work.
- Add a host regression test (aop-temp.py) and register it in
  run-host-tests.py.

Signed-off-by: Erik Bourget <[email protected]>
The AOP lid angle firmware streams reports at its default interval
(~1 Hz) from boot whether anyone reads in_angl_raw or not, generating
continuous AOP mailbox interrupts on an idle desktop.

When the service supports reading and clearing PROP_INTERVAL at probe
and reports within 2 s, record its interval, stop reports immediately,
and start them on demand for in_angl_raw reads (tracking in-flight
direct_readers, RunState::{Stopped, Running, Unknown}, waiting
interval + 500 ms for a cold sample, holding for a 5 s idle window,
backing off after failed starts, and arming a 5 s stop retry whenever
an unacknowledged start or stop leaves an idle stream potentially
running). Reconcile ambiguous probe stop timeouts and unconditionally
restore the pre-probe interval on unbind or probe rollback (clearing
the saved interval only after an acknowledged write) so a subsequent
rebind never inherits 0. On firmware suspend, hibernation, or restore,
clear the interval again on wake while idle in case an AOP restart
resumed default streaming. Services whose interval cannot be read or
cleared, or exceeds 2 s, keep the passive cached-read and sleep-hook
path.

Extend aop-las.py to cover the on-demand stream state machine and
update Documentation/iio/aop-sensors.rst.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb requested review from a team and DjDeveloperr as code owners November 27, 2026 16:48

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at a54b081f186f

Blockers: LAS probe can enter the passive path with no reports. If firmware applies the zero interval but the reply is lost, the subsequent read can also fail, and restoration can fail or time out. The code records Unknown and the saved interval but leaves interval_us unset. Direct reads then use the passive cache and never attempt a restart, and the saved interval is only retried during teardown. Keep this state recoverable during normal operation or unwind probe with a defined recovery path. Add a mock covering applied stop, failed readback and a failed first restore, followed by a successful read or recovery.

Checked: Followed the LAS probe reconciliation, direct-read selection and teardown. The posted J713 row qualifies normal transitions. Actual wake and an affected peer remain pending.

Evidence

The restoration-failure branch sets only restore_interval and run_state. read_now selects its passive path from interval_us, and shutdown is the remaining consumer of restore_interval in that state.

When the probe stop write times out, readback fails, and the fallback
restore of the pre-probe interval also fails, firmware may have already
applied interval 0. Leaving interval_us unset put read_now() on the
passive cache path, where it never restarted reports and only teardown
retried restoring restore_interval.

Extract Stream::{probe_with, sync_with, shutdown_with} over an
IntervalIo trait, set interval_us = Some(interval) alongside
restore_interval and RunState::Unknown when both readback and restore
fail, and arm the idle stop retry so either the next direct read
restarts reports or the idle timer reconciles the stopped state.

Extend aop-las.py with a mock IntervalIo test covering an applied stop
with a lost reply, failed readback, and failed/refused first restore
followed by direct-read and idle-retry recovery.

Signed-off-by: Erik Bourget <[email protected]>
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m2 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at c8cde22e: not ready yet

Check Detail
CI at head no failing: host-tests
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes no requested by DjDeveloperr
Hardware row at head ok in the PR body at c8cde22e
Conflicts ok none
PR text ok Risk: two-way · M1–M5 Macs with AOP lid-angle or board-temperature sensors (aoptemp services that refuse PROPINTERVAL = 0, and aoplas services that refuse PROPINTERVAL = 0 or report a pre-probe interval > 2 s, retain the passive cached path).

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@erikwb

erikwb commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in cf2c1f844ddb.

When Stream::probe_with hits a timed-out stop write, failed readback, and a failed or refused fallback restore, it now preserves interval_us = Some(interval) alongside restore_interval = Some(interval), marks run_state = RunState::Unknown, and arms the 5 s idle stop retry instead of falling back to the passive cache. From that state, a direct read calls Stream::sync_with (SyncAction::Start(interval)) to restart reports rather than returning ENODATA, and an idle system reconciles SyncAction::Stop on the retry timer.

tools/testing/selftests/drivers/apple/aop-las.py now extracts Stream::{probe_with, sync_with, shutdown_with} over IntervalIo and tests both recovery paths against a MockAop where stop applies 0 with a timed-out reply, readback fails, and the first restore times out or is refused (8/8 tests passing).

@github-actions github-actions Bot added blast:m1 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) and removed blast:m2 Macs affected, from Merge risk (bot) labels Nov 27, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at cf2c1f84

Blockers:

  1. Missing exact-head cf2c1f84 hardware verification row confirming on-demand aop_temp and aop_las sysfs reads, 5 s idle-stop, and clean unbind/restore on a live Mac (body currently lists host checks only at cf2c1f84).
  2. Re-run the cancelled pr-text and readiness CI checks to green (19/19 build/host/KUnit checks already pass).

Checked:

  • cf2c1f844ddb cleanly resolves the prior aop_las passive-fallback blocker: on an ambiguous probe stop-restore failure (timed-out stop write, failed readback, and failed/refused restore), Stream::probe_with now preserves interval_us = Some(interval) and restore_interval = Some(interval), marks RunState::Unknown, and arms the 5 s idle-stop retry so direct reads stay recoverable.
  • Checked for Apple material, tool attribution, private serials, and board gating: clean; MERGEABLE on main.
Evidence
  • Head: cf2c1f844ddb (base: main, mergeable: MERGEABLE, +1906/-147 across 7 files).

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LAS recovery path now retains the original interval after an ambiguous stop, failed readback and failed restore. Unknown remains recoverable on direct read and the idle stop is retried. The author reports both failure branches covered by the transport tests. The PR body now records the exact-source J713 integrated row, including the idle IRQ return, both sensor reads and unbind/rebind. Keep hosted CI and the combined candidate regression with the ALS change as landing gates.

@RyanTheTide

RyanTheTide commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

J700 MacBook Neo normal boot, fleet89 645f7cd3: built and live-loaded the exact #3409 aop_las (4c30d059) and aop_temp (f24bd055) source blobs from cf2c1f844ddb. Both inserted and removed cleanly. This Neo exposes only the CT817 ALS service. The two drivers created no IIO device and the separately tested CT817 continued to return samples. Saved module set, saved boot, empty next entry, Enforcing and zero failed units were verified after restore. This is the no-service control for the author’s J713 and J716c feature rows.

code-owner ping @aurora-silicon/core @aurora-silicon/omarchy-mac @aurora-silicon/aurora-maintainers Please review for merge alongside the targeted J713/J716c rows.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Independent affected-family row on J316s M1 Pro, fleet89, with the exact cf2c1f844ddb lid and temperature driver blobs. Stock lid angle was 107 and board temperature was 19.500 °C. On demand, lid angle was 107 (0.35 s first read) and board temperature was 19.437 °C (0.71 s first read). The candidate also carried the separately tested #3473 ALS blob, so the 28→6 AOP IRQs per 6 s at idle are for the combined batch.

SPI keyboard/trackpad and ALSA cards registered, headless DRM status was consistent with the saved boot, gateway was 3/3 and hardware EGL passed 32/32. Stock module set and the saved GRUB state were restored, Enforcing and 0 failed units. This complements the J713 and J716c integrated rows.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Integrated J316s regression, in one guarded Nightly kernel boot based on 94ea195b6eb5. The installed modules used the exact #3473 ALS blob from b11717dde674 and the exact #3409 lid/temperature blobs from cf2c1f844ddb. Each module probed during normal boot, with its installed hash matching the staged overlay. CT817 functionality and deep wake were tested separately on J700.

J316s returned lux, lid angle 107 and board temperature 19.312 °C. SPI keyboard and trackpad and ALSA endpoints registered. DRM stayed in the usual headless state. Gateway ping passed 3/3, hardware EGL passed 32/32, SELinux was Enforcing, and there were zero failed units, kernel errors or AVCs. Restored and byte-compared the saved fleet89 receipt, including the default entry, command line and boot-stage hash. Removed the trial entry, modules and dead-man.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@erikwb Could you forward-merge current aurora-silicon/linux:main into this branch by 00:36 AEDT on November 30? The train merged #3473 at f3bcc901bd23. GitHub now reports #3409 as conflicting at cf2c1f844ddb.

The conflict is limited to the registrations in tools/asahi/run-host-tests.py and tools/testing/selftests/drivers/apple/Makefile. Keep one entry each for the ALS, LAS, motion and temperature harnesses. The combined registration passed 28/28 host checks on the buildbox. The J316s combined boot test and the J700 absent-service control can carry forward if the changed driver blobs stay byte-identical. The new head will need fresh CI and review.

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 28, 2026
@erikwb

erikwb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

@RyanTheTide Forward-merged aurora-silicon/linux:main (18058ea228e2, including #3473 f3bcc901bd23) into fix/aop-temp-las-ondemand at c7d67b009c22. Fresh hosted CI and review remain pending on c7d67b009c22.

The merge conflicts were limited to tools/asahi/run-host-tests.py and tools/testing/selftests/drivers/apple/Makefile, keeping one entry each for aop-als.py, aop-las.py, aop-motion.py, and aop-temp.py. All PR driver, documentation, and selftest blobs remain byte-identical to cf2c1f844ddb:

  • drivers/iio/common/aop_sensors/aop_las.rs: git blob 4c30d05939d1c43a6ed2b80149325fbf75d37698
  • drivers/iio/common/aop_sensors/aop_temp.rs: git blob f24bd055d7f0cf1687e802a1fce79a3ada2f1b55
  • Documentation/iio/aop-sensors.rst: git blob 61356a4bb6a98cec8fb1f9d0f8dbdfe8ae6a97bb
  • tools/testing/selftests/drivers/apple/aop-las.py: git blob aefccb4a325f22cf47f3de0a6c9d08b6ef19c37e
  • tools/testing/selftests/drivers/apple/aop-temp.py: git blob b9aabc02121df6f484d2f94b7f18db4b2e204016

Between the merge base (fcb124279183) and origin/main (18058ea228e2), rust/kernel/workqueue.rs only adds Queue::new_ordered_highpri_reclaim, which neither aop_las nor aop_temp uses, so the existing J713, J316s (fleet89 combined and Nightly), J716c (c3da8eed6f72), J700, and J313 hardware rows from cf2c1f844ddb carry forward unchanged.

Host verification at c7d67b009c22:

  • python3 tools/testing/selftests/drivers/apple/aop-las.py: 8/8 passed
  • python3 tools/testing/selftests/drivers/apple/aop-temp.py: 5/5 passed
  • python3 tools/testing/selftests/drivers/apple/aop-als.py: 5/5 passed
  • python3 tools/testing/selftests/drivers/apple/aop-motion.py: 10/10 passed
  • python3 tools/asahi/run-host-tests.py --only aop: 12/12 passed (including registration check)
  • rustfmt --edition 2021 --check drivers/iio/common/aop_sensors/aop_las.rs drivers/iio/common/aop_sensors/aop_temp.rs: clean
  • make O=_build ARCH=arm64 LLVM=1 drivers/iio/common/aop_sensors/ (defconfig + asahi.config, Rust 1.99.0): clean
  • scripts/checkpatch.pl --strict --git origin/main..HEAD: 0 errors, 1 standard MAINTAINERS notice for new aop-temp.py

J716c batched trial verification at c7d67b009c22 (3545ebecb76f, Stage 2 SHA-256 b7d99286395ddd7dadccc6d9593f4bd55391d9e787af97c18b45f58688d9885d):

  • Boot 1 (kernel SHA-256 d56efde4c7232208bd29d5c4e5890319e0050595dd4f4b1c3844df6656a08312, modules SHA-256 9d5782bcf02ea60a225278c9319431f902b495f6beb485d79d127c0fb2fccc92; default config has no aop_temp / no IIO buffer support): aop_las and aop_als loaded, in_angl_raw 91, cold read 453 ms, warm 0-1 ms, same after 4 s idle (note: the 4 s read falls inside the 5 s warm-hold window and does NOT verify the 5 s idle stop). Smoke snapshot: 1 baseline failed system unit (aurora-peripherals.service, same as baseline warm reboots), 40 err+ lines on initial boot smoke snapshot (later checks recorded additional messages).
  • Boot 2 (same commit, kernel SHA-256 0379bd3eb63c74b8e429dd9a67dcd85b0f300d9725a2cf6495e2609be3f9c926, modules SHA-256 ee6ff86cf22623f64f8ee79d516bb4ad84b24638535c84b1e1b2788e07323987, adding CONFIG_IIO_BUFFER=y, CONFIG_IIO_AOP_SENSOR_TEMP=m, and resulting CONFIG_IIO_KFIFO_BUF=m): iio:device2 aop-sensors-als-temp, in_temp_sampling_frequency 1, in_temp_input cold read 935 ms, warm 1 ms, values 24460 -> 24468 -> 24453 mdegC (4 s read; does NOT verify the 5 s idle stop) and 24445 / 24437 / 24429 after 2x pm_test=devices and 1x pm_test=platform, aop_las unchanged at 91; modprobe -r aop_temp and modprobe aop_temp clean; 0 AOP error lines in dmesg. Smoke snapshot: 1 baseline failed system unit (aurora-peripherals.service, same as baseline warm reboots), 42 err+ lines on initial boot smoke snapshot (later checks recorded additional messages).
  • Real J716c s2idle and rtcwake -m mem were not run (the RTC alarm cannot wake J716c unattended).

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at c7d67b009c22

Blockers: Keep hosted CI and the recorded integrated regression gates.

Checked: All runtime driver blobs and the specific sensor fixtures are byte-identical to the reviewed head. The changed files are test registration. The current receipt reports 12/12 AOP host harness cases passed.

Evidence

Compared the current head, prior review and current PR receipts.

@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Nov 29, 2026
@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 29, 2026
…mand

Conflicts:
	tools/asahi/run-host-tests.py
	tools/testing/selftests/drivers/apple/Makefile

Both sides added AOP harness registrations; keep one entry each for
aop-als, aop-devmotion, aop-las, aop-motion and aop-temp.

Signed-off-by: Erik Bourget <[email protected]>
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Nov 30, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold for current-head hosted CI. I compared the LAS and temperature driver and targeted selftest blob IDs against c7d67b0 and all four match. The host and kselftest registries retain both tests alongside the newly inherited device-motion entry. The prior hardware evidence carries for the exercised paths, with J716c idle-stop and real suspend still unverified.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor

Tested on M4 Max (J616C / T6041) in a combined battery batch atop main (fe9af4b604784, with PR head b803dcae16de2, alongside #3359 and #3335):

  • Clean boot, 0 failed units, 0 AOP sensor/IIO errors in dmesg.
  • Settled battery idle: 3.52–3.59 W (disp_bl=100, kbd_bl=64).

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Dec 1, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at b803dcae16de

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: Code reviewed in the earlier App review at this head (6120965091).

Follow-ups (not blocking): current-head hosted CI; J716c idle-stop and real suspend row

When pm_suspend_via_firmware() is true on wake (including pm_test=devices
runs when deep suspend is selected, which never enter firmware sleep),
Control::set_parked() previously reset s.run_state to RunState::Stopped.
If the suspend stop failed and left RunState::Unknown, an idle stream
then appeared stopped on wake without sending PROP_INTERVAL = 0 or
arming an idle stop retry, allowing reports to keep streaming.

Extract TempIo and Stream::{arm_stop_retry, sync_with, set_parked_with}
and mark RunState::Unknown alongside calibrated = false on reset_cal
wakes, matching aop_las. Idle wakes then reconcile by issuing
stop_reports() (and arming the 5 s retry if that write fails), while
active buffers and continuous-mode fallback recalibrate and start
reports.

Extend aop-temp.py with a MockTempIo harness covering unacknowledged
suspend stops across deep-suspend and s2idle wakes, idle-retry
recovery, and firmware-sleep recalibration.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb

erikwb commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Updated aop_temp in c8cde22e54ca (iio: aop_temp: preserve Unknown state across firmware-sleep wake) and refreshed the PR description for the new head.

Changes in c8cde22e54ca:

  • Extracted TempIo and Stream::{arm_stop_retry, sync_with, set_parked_with} in drivers/iio/common/aop_sensors/aop_temp.rs.
  • Stream::set_parked_with() now sets RunState::Unknown alongside calibrated = false on reset_cal wakes (pm_suspend_via_firmware(), hibernation, and restore), matching aop_las, so an unacknowledged suspend stop (including pm_test=devices runs that never enter firmware sleep) or an AOP restart reconciles PROP_INTERVAL = 0 while idle and arms the 5 s retry if that write fails instead of assuming RunState::Stopped.
  • Extended tools/testing/selftests/drivers/apple/aop-temp.py with a MockTempIo harness covering unacknowledged suspend stops across deep-suspend and s2idle wakes, idle-retry recovery, and firmware-sleep recalibration.

drivers/iio/common/aop_sensors/aop_las.rs (blob 4c30d059), tools/testing/selftests/drivers/apple/aop-las.py (blob aefccb4a), and Documentation/iio/aop-sensors.rst (blob bed42b26) are unchanged from b803dcae16de. git merge-tree --write-tree against origin/main (a171afd2123f) is conflict-free (d50b67331ff0).

Verification at c8cde22e54ca:

  • Host tests, style, and builds pass: aop-temp.py (6/6), aop-las.py (8/8), aop-als.py (5/5), aop-motion.py (10/10), aop-devmotion.py (8/8), run-host-tests.py --only aop (13/13), rustfmt --edition 2021 --check, checkpatch.pl --strict --git dbfbced70b31..HEAD (0 errors on c8cde22e54ca; 1 standard MAINTAINERS warning on fff2d23562f4), arm64 Clang + Rust 1.99 build of drivers/iio/common/aop_sensors/, and full j716c kernel build with CONFIG_IIO_AOP_SENSOR_TEMP=m.
  • J716c (M5 Max) at c8cde22e54ca in a one-shot trial kernel on main 429e7e15f122: cold reads aop_las 801 ms / aop_temp 987 ms, warm 0 to 1 ms, cold again after >= 7 s idle (idle stop ran), modprobe -r / modprobe clean, reads after 2x pm_test=devices and 1x pm_test=platform suspend cycles return, 0 AOP errors in dmesg.
  • Hosted CI re-run at c8cde22e54ca is pending.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Dec 1, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drivers/iio/common/aop_sensors/aop_temp.rs:445–451 fails probe if the new optional interval-zero test times out, even when the retry immediately succeeds and leaves the stream in the same confirmed Stopped state as the success branch. Calibration and starting reports already succeeded, so this input used to produce a working temperature device. Please enter on-demand mode after a successful stop retry and cover that sequence with a regression test.

@github-actions github-actions Bot added changes-requested A reviewer requested changes (bot) ci-failing A check failed at the PR head (bot) labels Dec 1, 2026

This branch has not been deployed

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

Labels

area:gpu Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) changes-requested A reviewer requested changes (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants