Skip to content

drm/asahi: validate legacy firmware compatibility before starting the ASC - #3940

Open
RyanTheTide wants to merge 3 commits into
mainfrom
fix/asahi-legacy-validate-compat-before-start-cpu
Open

RyanTheTide wants to merge 3 commits into
mainfrom
fix/asahi-legacy-validate-compat-before-start-cpu

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What: Validate (gpu_gen, gpu_variant, apple,firmware-compat) via select_legacy_gpu_manager() before touching DMA masks, MMIO, or calling Resources::start_cpu() in AsahiPlatformDriver::probe(). Fixes the Linux-side safety blocker noted on aurora-silicon/aura#649 where a ProbeConfig::Legacy GPU (such as T6020/T6021/T6022 with [27, 2, 0]) had its GFX ASC CPU started before probe returned -ENODEV.
Tested: Two Macs at exact head 7f894f60118d (7.3.0-aurora-m2fam3940, default cmdline, restored cleanly):

  • M1 Pro 16" (J316s, apple,agx-t6000, ProbeConfig::Legacy, [13, 5, 0], boot_id=76dd0f45-110c-4fab-9019-df1960b63fd7): aurora probes G13S (16 active cores, RTKit v12, /dev/dri/renderD128), 1x 12s RTC s2idle PASS (0->1), 0 oops, 0 AVCs, 0 DART/GPU faults, Enforcing.
  • M2 Air 13" (J413, apple,agx-t8112, ProbeConfig::LegacyWithG14Handoff, [27, 2, 0], boot_id=1cc6f69c-8018-425b-b758-cf82005827bf): /dev/dri/renderD128 up on 27.2 handoff, 1x 12s RTC s2idle PASS (0->1), 0 oops, 0 DART/GPU faults, Enforcing.
  • Host tests CI PASS (legacy-probe-compat-tests 3/3 incl. 2 mutations killed).
    Risk: two-way · M1 / M2 family (ProbeConfig::Legacy and ProbeConfig::LegacyWithG14Handoff: T8103, T8112, T6000/1/2, T6020/1/2); a plain revert restores the previous probe order.
    Not yet: Live J414s T6020 27.2 boot paired with aura#649 (no T6020 in our lab; covered by legacy-probe-compat-tests asserting select_legacy_gpu_manager(G14, S, &[27, 2, 0]) == None before Resources::new / init_mmio / start_cpu).

Row: 7f894f6 + J316s (M1 Pro, ProbeConfig::Legacy) + J413 (M2 Air 27.2, ProbeConfig::LegacyWithG14Handoff) + PASS

Details

In drivers/gpu/drm/asahi/driver.rs, AsahiPlatformDriver::probe() previously called dma_set_mask_and_coherent(), Resources::new(), resources.init_mmio(), Resources::start_cpu(), and DRM/binding setup before checking whether (cfg.gpu_gen, cfg.gpu_variant, compat.as_slice()) matched a supported legacy GpuManager variant.

When Aura enables a ProbeConfig::Legacy GPU node with an unsupported apple,firmware-compat tuple (for example T6020 advertising [27, 2, 0] before a G14S 27.2 kernel backend lands), probe set the GFX ASC RUN bit on the preloaded firmware and then exited with -ENODEV, leaving the coprocessor running without a driver.

This change extracts LegacyGpuManagerKind and select_legacy_gpu_manager() and runs the check right after the has_g14_handoff && [27, 2, 0] branch, returning -ENODEV with the existing "Unsupported GPU/firmware combination" message before any hardware setup. The later GpuManager*::new() dispatch matches exhaustively on LegacyGpuManagerKind, keeping the selector and constructor arms in lockstep.

Evidence
  • Exact head: 7f894f60118d291c7f4535707a731e8e9b1763d1
  • CI: pr-text SUCCESS, pr-readiness SUCCESS, Host tests SUCCESS (legacy-probe-compat-tests 3/3 incl. mutations start-cpu-before-select and accept-g14x-27-2 killed with Rust exit 101)
  • scripts/checkpatch.pl --no-signoff: 0 errors, 0 warnings
  • Hardware row 1 — M1 Pro 16" (apple,j316s, apple,t6000, apple,agx-t6000 ProbeConfig::Legacy, [13, 5, 0], Stage 2 1.0.0b18):
    • One-shot 7.3.0-aurora-m2fam3940 (boot_id=76dd0f45-110c-4fab-9019-df1960b63fd7, default cmdline, slim test config)
    • aurora 406400000.gpu: Probing... -> MMU: initialized -> Type: G13S (Active cores: 16) -> RTKit: Initializing (protocol version 12) -> [drm] Initialized aurora 1.0.0 for 406400000.gpu on minor 0
    • /dev/dri/renderD128 present; s2idle via rtc1 (12s): rc=0 success=0->1
    • oops=0, avc=0, dart_faults=0, gpu_faults=0, post_oops=0, post_gpu_faults=0, selinux=Enforcing
    • Restored saved 7.3.0-aurora-edge (boot_id=71478a8c-bcc4-4e16-bd48-ef16e640e58a), custom.cfg byte-identical, next_entry empty, boot_success=1, Enforcing, failed=0
  • Hardware row 2 — M2 Air 13" (apple,j413, apple,t8112, apple,agx-t8112 ProbeConfig::LegacyWithG14Handoff, [27, 2, 0], Stage 2 1.0.0b18-g16648d69):
    • One-shot 7.3.0-aurora-m2fam3940 (boot_id=1cc6f69c-8018-425b-b758-cf82005827bf, default cmdline, slim test config)
    • /dev/dri/renderD128 present; s2idle via rtc1 (12s): rc=0 success=0->1
    • oops=0, dart_faults=0, gpu_faults=0, post_oops=0, post_gpu_faults=0, selinux=Enforcing
    • Restored saved 7.3.0-aurora-fleet94 (boot_id=33ca8950-587b-4e71-8d21-f4830f20f1f3), next_entry empty, boot_success=1, Enforcing, failed=0

… ASC

In AsahiPlatformDriver::probe(), the legacy path currently calls
Resources::new(), init_mmio(), and Resources::start_cpu() before checking
whether (gpu_gen, gpu_variant, apple,firmware-compat) has a matching
legacy GpuManager backend.

When a bootloader enables a legacy GPU node with an unsupported firmware
compat version (such as T6020/T6021/T6022 advertising [27, 2, 0] before
a matching 27.2 backend exists), probe sets the GFX ASC RUN bit on the
preloaded firmware and then returns -ENODEV, leaving the coprocessor
running with no driver.

Extract LegacyGpuManagerKind and select_legacy_gpu_manager() and validate
the combination before touching DMA masks, MMIO, or starting the ASC CPU.
Add host tests covering manager selection, rejection of unsupported
combinations, and probe call ordering.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

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 7f894f6 (code clean; waiting on CI + exact-head hardware row)

Blockers:

  1. Wait for the queued Actions CI checks (apple-build, host-tests, KUnit plan, readiness) to complete green at 7f894f60118d.
  2. Post the exact-head hardware regression row (currently listed as queued under Not yet; a clean G13/G14 regression boot or paired J414s T6020 probe row confirming -ENODEV before start_cpu()).

Checked:

  • Audited the full diff at 7f894f60118d (drivers/gpu/drm/asahi/driver.rs, tools/asahi/legacy-probe-compat-tests.py, tools/asahi/run-host-tests.py): no code blockers found.
  • select_legacy_gpu_manager() preserves the exact 5 supported legacy (gpu_gen, gpu_variant, compat) combinations and runs immediately after the has_g14_handoff && compat == [27, 2, 0] branch, returning -ENODEV before dma_set_mask_and_coherent(), Resources::new(), init_mmio(), and regs::Resources::start_cpu().
  • Post-start_cpu() dispatch matches exhaustively over LegacyGpuManagerKind, preventing drift between the pre-check and instantiation tables.
  • tools/asahi/legacy-probe-compat-tests.py verifies both probe ordering and compat rejection (including [27, 2, 0] across G13/G14 variants) with two killed mutations registered in run-host-tests.py.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Exact-head hardware rows posted at 7f894f60118d (7.3.0-aurora-m2fam3940, default cmdline, restored cleanly):

  • M1 Pro 16" (J316s, apple,agx-t6000, ProbeConfig::Legacy, [13, 5, 0]): boot_id=76dd0f45-110c-4fab-9019-df1960b63fd7 — aurora probes G13S (16 cores, RTKit v12, /dev/dri/renderD128), 12s RTC s2idle PASS (0->1), 0 oops, 0 AVCs, 0 DART/GPU faults, Enforcing; restored to 7.3.0-aurora-edge (failed=0).
  • M2 Air 13" (J413, apple,agx-t8112, ProbeConfig::LegacyWithG14Handoff, [27, 2, 0]): boot_id=1cc6f69c-8018-425b-b758-cf82005827bf — /dev/dri/renderD128 up, 12s RTC s2idle PASS (0->1), 0 oops, 0 DART/GPU faults, Enforcing; restored to 7.3.0-aurora-fleet94 (failed=0).

Host tests CI is green at 7f894f60118d (legacy-probe-compat-tests 3/3). Waiting on queued apple-build / KUnit checks and review @satchlj.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Draft sweep 12-05: merged main @ f02bd68 (bafda83, clean) and out of draft. The 12-02 review's two blockers were CI and the exact-head rows; the J316s and J413 rows at 7f894f6 are posted above (rc=0, restored). main's changes to driver.rs since the base are next to, not in, this change: T6020 moved to ProbeConfig::LegacyWithG14Handoff (so its 27.2 tuple now goes to the handoff branch, which runs before select_legacy_gpu_manager()), probe_g14_v27_2 takes the per-chip v27_2 config, and the sleep/memacct hunks; the pre-check table and the exhaustive dispatch are unchanged and still agree. Local: legacy-probe-compat-tests PASS on the merged tree. Rust build left to CI (buildbox is in single-object mode today); a re-run of the J413/J316s rows is not needed for a clean merge, but CI must be green on this head.

@RyanTheTide
RyanTheTide marked this pull request as ready for review December 5, 2026 01:26
@RyanTheTide
RyanTheTide requested review from a team and DjDeveloperr as code owners December 5, 2026 01:26
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (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 Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

Merge readiness at bafda83e: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review no needs one approving review from Core, Omarchy Mac or Aurora Maintainers (not the author)
Requested changes ok none
Hardware row at head ok comment at bafda83e
Conflicts ok none
PR text ok Risk: two-way · M1 / M2 family (ProbeConfig::Legacy and ProbeConfig::LegacyWithG14Handoff: T8103, T8112, T6000/1/2, T6020/1/2); a plain revert restores the previous probe order.

Areas: area:gpu

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

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:m2 Macs affected, from Merge risk (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.

2 participants