Skip to content

iio: aop_devmotion: reuse the report client across direct reads - #3624

Merged
RyanTheTide merged 3 commits into
mainfrom
fix/aop-devmotion-idle-window
Nov 29, 2026
Merged

RyanTheTide merged 3 commits into
mainfrom
fix/aop-devmotion-idle-window

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What: Keep the fused-orientation report client open across consecutive direct reads and close it when the reads go idle. Back off failed opens and park the client across system sleep and restore.

Tested: J316s M1 Pro and J615 M3 Air at f9b23f9863698a: three buffered scans per machine before and after same-boot s2idle, direct quaternion reads and child rebind passed. J615’s final idle callback arrived 1.995 seconds after the read burst. Arm64 driver built and all eight device-motion host cases passed.

Risk: two-way door · Macs that expose the AOP fused-motion service.

Not yet: The J316s observer did not retain the final idle callback timestamp. Hosted checks are pending.

Details

Report publication and client transitions share the stream lock so idle close invalidates the old sample after in-flight publication completes. The existing client-transition guard retains the DMA mapping and refuses new starts after an unconfirmed transition. The PM notifier is registered before exposing the IIO device and pending work is joined during teardown. This carries the device-motion portion of #2927. The accelerometer and gyroscope calibration change remains in that PR.

Evidence

Keep the report client open across short gaps between direct reads. Back off after a failed open, let buffered operation take over the client, and join idle work before suspend or teardown. Register the PM notifier before publishing the IIO device so probe failure cannot leave work behind.

Retain the existing refusal to restart after an unconfirmed fast-path transition. Add host coverage for ownership transitions, backoff and an unconfirmed close.

Signed-off-by: Ryan Murray <[email protected]>

@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 70db3668.

Blockers: Serialize poll publication with idle stop and restart. A poll callback can pass the active check and copy the old client's report, then pause. Idle stop closes the old client and clears the cached sample without joining that callback or synchronizing with its ring-lock critical section. The callback can then publish the old report after the clear. The next direct read opens a new client and sees a valid sample, so it can skip waiting for that client's first report. Please add a regression covering this interleaving and keep the requested hardware validation.

Checked: Idle cancellation runs outside the stream mutex, and teardown disables requeue before dropping the queued work reference. Buffer takeover clears the direct hold. Failed opens or closes that may leave firmware using the ring still retain the mapping and refuse new starts.

Evidence

The interleaving follows WorkItem::run(), poll(), stop() and read_now() in aop_devmotion.rs. The idle callback adds a routine asynchronous stop to the direct-read lifecycle.

Hold the stream lock through report publication and use the same
active state for direct reads and the poll worker. This makes idle
stop wait for a report in flight before invalidating the old sample.
Cover the old-client poll and subsequent restart with the host test.

Signed-off-by: Ryan Murray <[email protected]>

@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 a22f8414 after hosted checks and hardware validation.

Blockers: Complete hosted CI and the two-family rows for direct reads, idle close, buffer takeover, suspend and driver removal.

Checked: The poll worker now holds the stream mutex through publication and requeue. Stop and restart share that mutex, and direct reads already hold it around inline polling. Teardown joins delayed work after releasing the mutex. The new fixture checks the worker's lock scope, exercises an idle stop and restart, and confirms the sample remains invalid until the new client reports.

Evidence

Reviewed the two-file fix. The owner reported the arm64 build and all eight host cases passing, with the new regression rejecting removal of the worker lock. The comment above opened still describes the removed atomic active flag and can be cleaned up.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

@aurora-silicon/core @aurora-silicon/omarchy-mac @aurora-silicon/aurora-maintainers review requested for f9b23f9863698a. The device-motion client stays open for consecutive direct reads and parks on idle and suspend. All eight host cases pass, including the regression for serialization of polling with idle close. Exact hardware rows on the J316s and J615 are pending.

@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 f9b23f98 after hosted checks and hardware validation.

Blockers: The two-family lifecycle rows and hosted checks remain.

Checked: The delta from the approved head changes only two comments. They now describe the firmware open state and the mutex that serializes transitions with report publication. The race fix and regression are unchanged.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J316s M1 Pro at f9b23f9863698aa2005cd34af44f7d53514e581e, signed kernel 7.3.0-aurora-devmotion-idle, loaded module build ID 9fddc8e176a78649c07f2ad6bce4b992ad2115b0.

  • Direct quaternion reads and 3/3 buffered scans before and after one 15-second rtc1 s2idle. Suspend success counter advanced 0 → 1 with the same boot ID. Child unbind/rebind with idle work pending succeeded and a direct quaternion read returned afterward.
  • The workqueue trace saw zero idle callbacks during the 12-read burst and two afterward. The observer rejected the count because it expected exactly one. The driver can rearm at the original deadline when a later read extends it. This run did not retain the final worker timestamp.
  • NVMe root mounted and Wi-Fi gateway ping 3/3. SELinux Enforcing, zero failed units and no scoped AOP faults, kernel panics or AVC denials. Saved Edge, original boot configuration and Stage 2, GRUB success 1 and empty next entry verified after restore. No playback.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

f9b23f9 J615 (M3 MacBook Air 15", T8122) PASS: guarded kernel-only one-shot 7.3.0-aurora-devmotion-idle (saved Stage 2 and default cmdline unchanged, aop_devmotion build ID 9fddc8e176a78649c07f2ad6bce4b992ad2115b0, signed): before-sleep direct quaternion + 12-read burst (burst_worker_runs=0, idle_worker_runs=2, last_idle_delay_s=1.995) + post-idle reopen + 3/3 buffered frames + direct reread ok; 15s RTC s2idle (rtc0, 0->1, same boot c1e07586) ok; after-sleep direct + 3/3 buffered + direct reread + unbind/rebind while idle timer armed ok; 0 failed units, Enforcing, 0 AVC, 0 AOP/devmotion errors; restored saved 7.3.0-aurora-edge.

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 29, 2026 14:44
@RyanTheTide
RyanTheTide requested review from a team and DjDeveloperr as code owners November 29, 2026 14:44
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (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) labels Nov 29, 2026
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Merge readiness at f9b23f98: not ready yet

Check Detail
CI at head no failing: host-tests, apple-build, host-tests, pr-text / pr-text, pr-text / pr-text, pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at f9b23f98
Conflicts ok none
PR text ok Risk: two-way · Macs that expose the AOP fused-motion service.

Areas: area:gpu

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

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging under the 6-point rule (Ryan 09:29, permanent), at f9b23f98. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J316s+J615. (5) There's no blocking review. (6) Dj was pinged here 411 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit dce22e6 into main Nov 29, 2026
14 of 51 checks passed
@RyanTheTide
RyanTheTide deleted the fix/aop-devmotion-idle-window branch November 29, 2026 20:33
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) 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.

1 participant