Skip to content

drm/imagination: apple: A7 compute hangs: two compute records, rewritten after retirement - #30

Merged
henrikklee merged 4 commits into
OrchardLinux:mainfrom
ricktav:a7/compute-records
Dec 1, 2026
Merged

henrikklee merged 4 commits into
OrchardLinux:mainfrom
ricktav:a7/compute-records

Conversation

@ricktav

@ricktav ricktav commented Nov 29, 2026

Copy link
Copy Markdown

Draft, to let others know: the A7 desktop's GPU hangs are understood and fixed in testing. Not ready to merge.

The hang

About every 10-60 minutes of desktop use on the iPad Air (J71), more often under memory pressure (a browser starting), one compute job was never taken by the firmware. It always looked the same:

hang: compute: submitted N, stamps N-2 N-1, work ring (N-1)/N
geometry/fragment idle, firmware posted no fault, Fender state 0x1

The 5 s timeout then reset the GPU; Quickshell lost its device and the screen went black.

Cause

The two stamp words are the mirror stamp and the finish stamp. In all 9 hangs over 6 boots, job N-1 had written its finish stamp but never its mirror stamp: the firmware never finished retiring it. It keeps using a record after the finish stamp (it reads the mirror's address and value and runs the microsequence to its end op), as with 3D records, where two alternating records already fixed a SoC freeze. The t7000 compute path waited only for the finish stamp and then rewrote its single record and microsequence in place, so a back-to-back compute job could land in that window.

The first patch (re-kick) tested the "lost doorbell" theory: on the device it rang every 50 ms for 5 s and the firmware still never took the entry. It stays as a diagnostic.

Fix (second patch)

  • Two compute records alternate; the second goes in the unused root page behind the compute channel (root 0x19000-0x19500, below the TA channel at 0x20000).
  • A record is rewritten only once the job that last used it shows its mirror stamp too (1 s timeout, then an error naming that case). Fences still signal on the finish stamp.
  • a7_cu_records (1|2) and a7_cu_mirror_wait (0|1) switch it at runtime (1/0 = the old behaviour); debugfs apple_jobs and the hang report count how often the previous job was still retiring at a submit.

Testing (J71, installed Omarchy)

  • Module built against the installed 7.3.0-rc1-orchard-apple-4k kernel tree with clang-19 (not through orchard build yet), installed, rebooted.
  • 6 Epiphany starts on the GPU under swap pressure plus 161 large-copy runs (A7 copies are compute jobs) in parallel: no hang, no re-kick, no "no mirror stamp" error. Before: a hang every few hundred to few thousand compute jobs.
  • Open: a long desktop soak, and the A8 (the same t7000 path; untested there).

Also found: rmmod powervr oopses in remove_nodes (devres) on the A7; not addressed here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFMaVcR5gEPcdDR8wQfiDP

ricktav and others added 2 commits November 29, 2026 21:22
The firmware takes a work-ring entry at once. For an entry still
untaken 50 ms after its doorbell (and after the last such ring), ring
the doorbell again from the completion check, log it (rate-limited)
and count it in the debugfs doorbell line as rekicks.

This is a diagnostic: in the A7 compute hangs (job never taken, work
ring N-1/N) it rang for 5 s without the firmware taking the entry, so
those were not lost doorbells (see the next patch). Ringing for an
entry the firmware took already adds no work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFMaVcR5gEPcdDR8wQfiDP
Assisted-by: LLM
…tirement

The firmware keeps using a record after its finish stamp: it reads the
mirror stamp's address and value from it and runs the microsequence to
its end op, as it does for 3D records (two alternating 3D records fixed
a SoC freeze there). The compute path waited only for the finish stamp
and then rewrote its one record and microsequence in place.

On the A7 a compute job every few thousand was then never taken: the
job before it showed its finish stamp but never its mirror stamp
("stamps N-2 N-1", work ring N-1/N), the other engines idle, no fault,
until the 5 s timeout reset the GPU. Nine such hangs over six boots
were identical; ringing the doorbell again every 50 ms for 5 s did not
move the work ring, so the doorbell was not lost.

Alternate two compute records (the second in the unused root page
behind the compute channel), and rewrite a record only once the job
that last used it shows its mirror stamp too, as the A9 path waits for
both stamps and Apple's kext reuses a record only after its stamps
retire. Fences still signal on the finish stamp.

a7_cu_records (1|2) and a7_cu_mirror_wait (0|1) switch it at runtime;
debugfs apple_jobs and the hang report count how often the previous job
was still retiring at a submit, and the longest mirror wait.

On the J71: 6 browser starts on the GPU under swap plus 161 large-copy
runs in parallel, no hang (before: one every few thousand compute jobs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFMaVcR5gEPcdDR8wQfiDP
Assisted-by: LLM
ricktav and others added 2 commits December 1, 2026 11:39
Drop the re-ring of a work-ring entry left untaken 50 ms after its
doorbell. It was a diagnostic for the A7 compute hang, which the two
alternating compute records fix: the entry was not lost, the job before
it had not finished retiring. On the J71 it went on firing with an
elapsed time that cannot be right ("untaken 768614336404 ms"), so it
added noise and no fix.

Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFMaVcR5gEPcdDR8wQfiDP
Two compute records, each rewritten only once its last job shows its
mirror stamp, are the behaviour the A7 needs, not a choice: with one
record, or without the wait, a compute job every few thousand is never
taken. Drop the a7_cu_records and a7_cu_mirror_wait module parameters
that switched between them during bring-up; the debugfs counters stay.

Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFMaVcR5gEPcdDR8wQfiDP
@ricktav

ricktav commented Dec 1, 2026 •

Copy link
Copy Markdown
Author

Ready for review. Two follow-up commits clean up the bring-up leftovers:

  • Ring no second doorbell for an untaken entry removes the re-ring diagnostic. The two alternating compute records are the fix: the entry was never lost, the job before it had not finished retiring.
  • Always alternate two A7/A8 compute records drops the a7_cu_records and a7_cu_mirror_wait module parameters (AGENTS.md: no module parameters for hardware behaviour). Two records with the mirror-stamp wait, the defaults, are now the fixed behaviour. The debugfs counters stay.

Built with orchard build --platform apple-4k --kernel-tree on this branch. The J71 has run the desktop since 29 Nov on a module with these defaults plus the re-ring; this exact build has not been booted on hardware yet.

The silent J71 freezes seen during browser soaks are not caused by this driver: they reproduce with headless Firefox and the powervr module not loaded (details in OrchardLinux/orchard#351).

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFMaVcR5gEPcdDR8wQfiDP

@ricktav
ricktav marked this pull request as ready for review December 1, 2026 10:46
henrikklee pushed a commit to OrchardLinux/orchard that referenced this pull request Dec 1, 2026
Bring the A7 GPU bring-up page up to date: the GPU desktop of
OrchardLinux/mesa#25 (Omarchy, Web and Firefox on the GPU, and the
driver fixes found on the way), the compute-record fix of
OrchardLinux/linux#30, what a J71 did under browser load (silent freezes
confounded by a near-empty battery on a 500 mA host port, recoverable 3D
lockups, about 220 MB of GPU memory that no eviction can free on the A7),
what exists outside Orchard, and the open work.

Assisted-by: LLM
@henrikklee
henrikklee merged commit 1b1a759 into OrchardLinux:main Dec 1, 2026
4 checks passed
@henrikklee

Copy link
Copy Markdown

Merged, thank you! Two alternating compute records, each reused only after its mirror stamp, is a solid root-cause fix for the A7 compute hangs. It ships with the next orchard release. @brkosebay, the A8 runs the same t7000 compute path, so you'll see this on the A8 too.

henrikklee added a commit that referenced this pull request Dec 1, 2026
drm/imagination: apple: A7 compute hangs: two compute records, rewritten after retirement
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