Skip to content

drm/asahi: g17: M5: drop the unreachable EAGAIN retry of a host-port submission - #2437

Merged
DjDeveloperr merged 3 commits into
mainfrom
hack/asahi-retry-a
Nov 24, 2026
Merged

DjDeveloperr merged 3 commits into
mainfrom
hack/asahi-retry-a

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Firmware::submit_m5_render_pair() (drivers/gpu/drm/asahi/g17/mod.rs:915-944 at 0abc2f3) wrote an M5 render pair's records, then the transaction through the M5 host command port, and on EAGAIN dropped the pair view, took the registration power hold and tried once more. Firmware::submit_m5_work() (mod.rs:903-913) had the same retry for one transaction. Both came with 9b1f778 ("drm/asahi: g17: M5: install M5 queues and submit through the host command port").

The retry cannot run. G17Resources::submit_m5_work() (regs.rs:662) returns Ok on a J813 forms boot, ENODEV once the register mapping is revoked, and otherwise only the result of try_write64(), which fails with EINVAL for an offset outside the mapping. It has never had a powered-state check: the host command port needs no core power. The power hold the retry would have taken is also a no-op on M5, because the V26A428_M5 variant sets registration_power_hold to false (its firmware powers the cores for work by its own policy). Firmware::submit_m5_work() has no caller.

Change

The pair is written and submitted once, and any error propagates exactly as the old non-EAGAIN arm did. The uncalled single-transaction wrapper is removed. The doc comment now says why no retry exists.

Only M5 (T6050/J775D and the other M5 parts on the 26A428 M5 variant) reaches this function, through runtime/render.rs:724 when init.is_m5(). The removed branch was unreachable there, so behaviour on every SoC stays the same.

Testing

  • Combined tree with the companion G15 change (bd796f07), release config, ARCH=arm64 LLVM=1: make prepare and make drivers/gpu/drm/asahi/ build. The module's 13 remaining rustc warnings are existing dead_code warnings elsewhere in g17/g16/mmu/regs; none is in the touched code.
  • There is no KUnit for this path. The asahi KUnit suites were not run because the change removes only unreachable code.

Still to run

  • None of the Neo (T8140), J616s (T6040), M1 Pro or M2 reaches this function: it runs only on M5 (init.is_m5()). On the Neo and J616s, a regression smoke is enough: vkmark --winsys headless and glmark2-es2-drm --off-screen should pass N/N as on the base, with 0 device losses.
  • M5 (J775D), when one is available: vkmark --winsys headless and the deqp-vk dEQP-VK.api.* subset should match the base pass count, with 0 device losses.

Thanks to Diljit Singh (DjDeveloperr), who wrote the M5 host-port submission.

Hardware rows (combined test kernel, 2026-11-20)

This change was booted in a combined test kernel: integration/aurora 0abc2f3 plus the open gate-sweep drafts plus this and the related drafts (7.3.0-aurora-hk2/pwr1/hk3). It ran once on each lab Mac (M1 Pro J316s, M2 J413, J616s, Neo J700) and was compared against the production kernel on the same Mac, using the same silent row script:

  • kernel errors, failed units and SELinux denials;
  • microphone capture byte counts;
  • camera frame counts;
  • USB speeds;
  • panel brightness steps;
  • every retry/refusal message these drafts touch;
  • 2 s2idle cycles on M1 Pro, M2 and J616s.

M1 Pro, M2 and J616s matched production on every row, apart from the new counters and lines the drafts add. The Neo row found the old-DTB display regression that #2358's follow-up commit fixes.

This PR: Only M5 reaches this code; boot-clean regression rows only. GPU device-loss lines: 0 on all four Macs.

…submission

Firmware::submit_m5_render_pair() wrote a render pair's records, then the
transaction through the M5 host command port, and on EAGAIN dropped the
pair view, took the registration power hold and tried once more.
Firmware::submit_m5_work() had the same retry for a single transaction.
Both were added with the M5 host-port submission.

G17Resources::submit_m5_work() cannot return EAGAIN: it returns Ok on a
J813 forms boot, ENODEV once the register mapping is revoked, and
otherwise only the result of try_write64(), which fails with EINVAL for
an offset outside the mapping. The host command port needs no core
power ("Core activity is not a prerequisite"), so no powered-state check
exists that could refuse the transaction. The retry branch has never
run, and the hold it would have taken is a no-op on M5 anyway: the
V26A428_M5 variant has registration_power_hold false, since its firmware
powers the cores for work by its own policy. Firmware::submit_m5_work()
has no caller.

Write the pair and submit once; any error propagates as before. Remove
the uncalled single-transaction wrapper. Behaviour is unchanged on every
SoC: the removed branch was unreachable.

Fixes: 9b1f778 ("drm/asahi: g17: M5: install M5 queues and submit through the host command port")
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers.

I checked the claim that EAGAIN cannot happen. On this head, G17Resources::submit_m5_work() (regs.rs:662) returns Ok on a J813 forms boot, ENODEV from try_access(), or the result of try_write64(), which only fails a bounds check. It has no powered-state test. The register-port reader m5_fault_registers() (:707) does have one. acquire_registration_power() returns early when registration_power_hold is false (mod.rs:885), and the M5 variant sets it false (fw/variant.rs:213). The order is unchanged: pair view, prepare, commit accounting, port write, inner publish. An error after commit_accounting() propagates as the old non-EAGAIN arm did. acquire_registration_power() keeps its caller at runtime/render.rs:686, so no dead-code warning appears. mod.rs and regs.rs have not changed on integration/aurora since the base, and the PR merges cleanly.

  1. drm/asahi: remove the items rustc reports as never used (-96) #2433 deletes the same Firmware::submit_m5_work. The two merge cleanly together (checked with git merge-tree), but only one PR should carry that hunk. Land this one first and drop it from drm/asahi: remove the items rustc reports as never used (-96) #2433.

Only host-tests ran on this head; rust-build did not run. The local make drivers/gpu/drm/asahi/ covers this change.

HW row: M5 (J775D), when available: vkmark headless and dEQP-VK.api.* match the base pass count, with 0 device losses, 0 AVC, 0 failed units and no new GPU errors. This is not required for merge, since the removed branch was unreachable.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Re-check at 3c53d3e against current integration/aurora. The EAGAIN branch is still unreachable: G17Resources::submit_m5_work() (regs.rs:662) is unchanged since the base and has no EAGAIN source, and the submit order is the same. One correction to my earlier comment: g17/mod.rs and regs.rs did change on integration/aurora since the base, but nothing touches this function, and the branch still merges cleanly.

One wording nit:

  • g17/mod.rs:903-906: "The host command port needs no core power" reads as a general rule, but submit_m5_work_held() (regs.rs:677) now holds core gating off across the host-port transaction for every M5 compute kick, because an unheld advance could land at the idle edge and be missed. That path does not affect this removal, since render pairs write the port before ringing. Still, please scope the sentence to the render pair, e.g. "A render pair's host-port transaction is written before the doorbell and needs no gating hold". The transaction can also fail the try_write64() bounds check (EINVAL), not only once the mapping is gone.

Assisted-by: LLM (Claude:Opus 5.5)

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

Formal §1–§6 pre-PR review at verified live head 3c53d3e2095c8f8b831e5db9f93367d565af369c against live integration/aurora (70a00e583b03, not superseded).

Verified Clean

  • Unreachability & ordering (§1–§3): Confirmed against live drivers/gpu/drm/asahi/regs.rs:662-675 (G17Resources::submit_m5_work() returns Ok(()), ENODEV, or EINVAL from try_write64(), never EAGAIN), g17/fw/variant.rs:222-227 (V26A428_M5.registration_power_hold == false), and g17/mod.rs:905-944 (Firmware::submit_m5_work() has no callers; submit_m5_render_pair() preserves pair view -> prepare -> commit_accounting() -> host-port write -> publish_inner() -> publish/next order; acquire_registration_power() retains its caller at g17/runtime/render.rs:686).
  • Attribution (§4): Single commit 3c53d3e2095c carries human author/committer and human Signed-off-by: only (zero AI commit trailers); PR body discloses assistance.

Blockers Before APPROVE

  1. Inaccurate doc comment vs live integration/aurora (drivers/gpu/drm/asahi/g17/mod.rs:903-906):
    • "The host command port needs no core power, and its transaction fails only once the register mapping is gone; the error propagates." contradicts live regs.rs:681-701 (submit_m5_work_held(), used by g17/runtime.rs:1611 for M5 compute kicks, holds G17_GATING_HOLD across the host-port transaction) and omits EINVAL from try_write64() offset bounds checks.
    • Please scope the statement to render-pair host-port submission (submit_m5_work()) and note both ENODEV and EINVAL error propagation.
  2. §5 / §6 Exact-head build & M5 verification evidence:
    • Only host-tests ran on 3c53d3e2095c (2026-11-19 on stale base 0abc2f385e54), which does not compile drivers/gpu/drm/asahi/g17/mod.rs with rustc; the local build reported in the PR body was on an unmerged combined tree.
    • Zero M5 hardware run has been recorded (M5 is the only SoC executing submit_m5_render_pair() via init.is_m5()); the 2026-11-20 combined-kernel boot covered only non-M5 Macs and omitted numeric §5 regression counts.
    • Please rebase onto live integration/aurora, verify an exact-head drivers/gpu/drm/asahi/ Rust build cleanly, and post an exact-head M5 smoke + regression triad (0 SELinux denials [or N/A], 0 failed units, 0 new kernel errors).

Non-Blocking Note

  • Open PR #2433 (f4db4c48daf1) also deletes Firmware::submit_m5_work() in drivers/gpu/drm/asahi/g17/mod.rs; coordinate so only one PR carries that hunk.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at b83fb5ea: not ready yet

Check Detail
CI at head running running: host-tests
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head no no line with the head SHA b83fb5ea, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:gpu

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

@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 24, 2026 19:45

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

Verdict: FINISH, then merge at e88b21d5cb21: the code is ready; it needs only a row at this head.

Blockers: none in the code. Missing row: none for the code. The host-port submission can't return EAGAIN: try_write64() fails only with ENODEV or EINVAL. So this only removes an unreachable retry, with no runtime change. I updated the branch to main so rust-build compiles g17/mod.rs in CI; it merges once that's green.

Checked: no Apple material, no gates. One path removed in drivers/gpu/drm/asahi/g17/mod.rs, and the local make drivers/gpu/drm/asahi/ build passes. This replaces my earlier review.

Evidence

Nit: the new comment at g17/mod.rs:903-906 says the host port "needs no core power". submit_m5_work_held() (regs.rs:681-701) holds G17_GATING_HOLD for compute kicks, and the error can be ENODEV or EINVAL. Scope it to the render-pair submit_m5_work() path.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 19:45

Superseded by the review at e88b21d

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

Clean forward-merge of main for the #3089 M3 host-test fix; code diff unchanged and prior approval stands.

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 24, 2026
@DjDeveloperr
DjDeveloperr merged commit 4f63cd7 into main Nov 24, 2026
3 of 4 checks passed
@DjDeveloperr
DjDeveloperr deleted the hack/asahi-retry-a branch November 24, 2026 20:31
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) needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants