Skip to content

accel/ane: serve H16 shared-memory requests only after their notification - #863

Merged
RyanTheTide merged 9 commits into
aurora-wipfrom
ane/h16-start-stall
Nov 2, 2026
Merged

RyanTheTide merged 9 commits into
aurora-wipfrom
ane/h16-start-stall

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

The H16 ANE on the M4 Pro sometimes stalled while it started, which put it in quarantine until the next reboot. It happened in about 1 in 7-9 cold restarts after s2idle and about 5 in 20 boots. A quarantined ANE then refused system sleep, so the J616s had to keep its sleep mask. The stall hit after a random SHAREDMALLOC reply (the 2nd, 3rd or 4th), or after the last one and before startup ack 4.

Cause: our polled host answered a SHAREDMALLOC request as soon as its body showed up in the ch5 ring. A request header is 0, the same as an empty slot, so a visible body doesn't mean the firmware has finished posting it. Answering inside that window loses the firmware's wakeup. macOS reads the pending IRQ word, acks exactly that value, issues a barrier, and only then drains the rings that word indicates. The window opened when the H16 waits moved to 20-50 us poll steps and a 30 us busy poll; the first stall in the saved logs is on fleet14l.

Changes:

  • Serve SHAREDMALLOC only for the notified batch, captured after the ack and before any reply. Coalesced notifications are still served. Polling, deadlines, validation and reply ordering are unchanged. There is no retry and no restart.
  • Complete the irq_ack write before ring reads on H17 too (H16 already did this).
  • On a startup timeout, record every ch5 slot, the IO slot, the IRQ state and scratch, read-only.
  • Count the polls that saw a request body before its notification, and log that count at the end of every start ("startup SHAREDMALLOC allocations/early polls held").

Testing

  • KUnit (x86_64, KASAN/UBSAN): transport suite 200/200, boot suite 200/200, both at 4fb4d88. The new tests include delayed notification, an unnotified request injected during allocation, coalescing, wraparound, and the timeout evidence.
  • J616s (M4 Pro), 7.3.0-aurora-fleet14o with these modules:
    • 40 s2idle cycles with MobileNet held, then 5 boots: 45 cold starts, 0 quarantines.
    • The same handle gave identical outputs after every resume, and a fresh LOAD matched.
    • Resume median 13-14 ms, max 17.
    • The early-poll count was nonzero on 5 of the 40 resumes and on 2 of the 5 boots. That 1 in 8 matches the old failure rate, and each of those starts is one the old code would have answered early.
    • Before this change, the same machine and test had 3 quarantines in about 25 resumes.
    • SELinux enforcing. On the last boot, 0 AVCs and journalctl -p3 empty. The 40-cycle boot logged one AVC and one -p3 line, both from my test harness: a first attempt to start the run script from /var/tmp through systemd-run (init_t exec of user_tmp_t). Neither came from the driver.
  • Neo (H17), same modules: MobileNet 16/16, 10/10 s2idle cycles with identical outputs, resume median 19-21 ms, -p3 empty, 0 AVCs. No regression.

Based on the t-4541 work in ane/h16-startup-ring.

🤖 Generated with Claude Code

RyanTheTide and others added 9 commits November 2, 2026 20:04
Fresh SHAREDMALLOC slots and allocation requests both have a zero header. Polling their body without the matching channel notification can answer while firmware is still publishing the request. Snapshot the notified batch after the exact IRQ acknowledgment, before sending any answer, and retain a count across service calls. This preserves coalesced requests and prevents a later request from borrowing an old notification. Keep the existing absolute deadline and reply barriers.

Add KUnit cases for delayed and unrelated notifications, batch wraparound, descriptor-selected IRQ bits and acknowledgment-before-read ordering. The boot simulator now publishes real notifications instead of relying on unconditional scanning.
…reads

Document the MMIO accessor ordering contract and give the H17 backend the full barrier already used by H16. Include the notified batch count in H16 startup timeout evidence.
The H16 host now serves the SHAREDMALLOC ring only after the firmware
raises its notification bit, as macOS does. Count the polls that found a
request body in the ring before that bit, and log the count with the
number of allocations at the end of every startup. A nonzero count marks
a start where the earlier host would have answered the request while the
firmware was still posting it, which is the window behind the
intermittent startup and resume stalls.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide merged commit 8e9a689 into aurora-wip Nov 2, 2026
notmysegv pushed a commit to notmysegv/linux that referenced this pull request Nov 4, 2026
…nto integration/aurora

Bring integration/aurora up to the aurora-wip tip 9ff2b9a. After this
merge the two branches have the same tree.

The range contains the fleet14o source c243830 (aurora-silicon#857, aurora-silicon#858, aurora-silicon#795,
aurora-silicon#859), which was promoted on all four machines on 2026-11-02 and 03, and
the merges after it: aurora-silicon#861 (apple-dcp selftest stubs for aurora-silicon#858), aurora-silicon#860
(SEP keybag in the shared xART window, the aurora-wip copy of aurora-silicon#856),
aurora-silicon#724 (J616s boot NOR, both parts), aurora-silicon#779 (ALS colour temperature ABI),
aurora-silicon#862 (J700 GD25UF16E boot NOR, the Neo bless fix), aurora-silicon#863 (J616s ANE H16
start stall), aurora-silicon#797 (T6000 DCS whole-word writes) and aurora-silicon#803 (G17 keeps
innocent clients alive across another client's recovery).

aurora-silicon#858 and aurora-silicon#860 make the same changes integration/aurora already had as
aurora-silicon#855 and aurora-silicon#856, so they merge without conflicts.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide deleted the ane/h16-start-stall branch November 7, 2026 12:06
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.

1 participant