Skip to content

drm/asahi: g17p: take the firmware DATA base from the bound GPU - #2659

Merged
RyanTheTide merged 2 commits into
integration/aurorafrom
g17p/diag-bound-data-base
Nov 23, 2026
Merged

RyanTheTide merged 2 commits into
integration/aurorafrom
g17p/diag-bound-data-base

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem. g17p_diag_knobs and g17p_fw_peek are module parameters, so they exist on every Mac that loads aurora.ko. Reading them translates G17P firmware DATA addresses with a hard-coded physical base, the J700's GFX data segment, and maps that page whatever GPU is bound. On a non-G17P Mac the read oopses in diag_get (#2627). On another G17P SoC it would read unrelated memory.

Change. The bound G17P GPU publishes the base at probe and withdraws it at unbind. The base comes only from the GPU's fw-data reserved-memory region, and only if that region holds the whole 0x134000-byte GFX DATA segment. t8140.dtsi declares /reserved-memory/gpu-fw-data and the loader fills it from the ADT gfx-data/gfx1-data segments (aura#204). There is no fixed-address fallback and no chip check; the second commit removes the J700 fallback the first commit had.

g17p_gfx_link_to_physical() now returns Option and is None when nothing is published or the address is outside the DATA segment. In that case no caller touches memory:

  • g17p_diag_knobs still prints the knob value, then <word> none (no G17P fw-data region) for each firmware word;
  • g17p_fw_peek prints error: no G17P fw-data region;
  • the e2e power samples and the accounting-clock read stop with an error.

Testing.

  • J700 / MacBook Neo (G17P), head 449130b: one-shot boot of our fleet kernel (integration/aurora 92fd860 + open PR heads) with this PR's aurora.ko in the initramfs, on the production Stage 2, which predates aura#204 and leaves gpu-fw-data disabled. All four words read none (no G17P fw-data region), the peek prints error: no G17P fw-data region, there are 0 oops/BUG lines, and the GPU rows (gpubench, multi-pass, IRQ rate) match the base module.
  • J700, first commit 3a9590a, fallback path: three identical g17p_diag_knobs reads, g17p_fw_peek dumped the DATA rows, knob round trip OK, 0 oops, dEQP-VK api.smoke 8/8.
  • M1 Pro (G13X), 3a9590a: four none words and the peek error, 0 oops, and the GPU initialised normally.
  • Head: checkpatch.pl --strict 0/0/0, no new compiler warnings, tools/asahi/run-host-tests.py --only g17 90/90.

Still to run. The J700 on a Stage 2 that carries aura#204, so that the region is filled and the diagnostics publish from it. An M1 Pro re-run at 449130b.

Notes for review
  • Only GpuVariant::P publishes. In this tree that's T8140 alone; T6040 is S and T6041 is C. An M4 Pro therefore never gets J700-laid-out addresses.
  • g17p_fw_data_start() rejects the disabled placeholder (reg = <0 0 0 0> gives start 0), an unaligned start and a short region.
  • With no region, arming the e2e trace with option bit 2 returns an error instead of mapping a constant.
  • Fixes: names b2e300a, which added the constant, diag_get's firmware reads and peek_get.
  • Neo rows: the arm-C rows in our A18 Pro run for linux#2213 (same boots, separate aurora.ko).

Assisted-by: LLM (Claude:Opus 5.5)

The g17p_diag_knobs and g17p_fw_peek module parameters, and the e2e
power samples, translate fixed G17P firmware DATA LINK addresses with
g17p_gfx_link_to_physical(), which adds a hard-coded physical base: the
start of the J700 (MacBook Neo, T8140) GFX data segment. The parameters
exist on every Mac that loads aurora.ko, so reading them maps and reads
that address whatever GPU is bound. On an M2 (G14) reading
g17p_diag_knobs oopses in diag_get+0x208, and any other SoC whose
firmware data lives elsewhere would read unrelated memory.

Publish the base from the bound GPU instead. When a G17P GPU probes,
take the start of its fw-data reserved-memory region, which the loader
fills with the data segments of both firmware roles, GFX (ADT sgx
gfx-data) first, if the region is page aligned and holds the whole
0x134000-byte GFX DATA segment. A J700 boot whose device tree has no
fw-data region falls back to the address its loader is known to use,
which is the old constant, so the diagnostics keep working there.
Withdraw the base on unbind.
g17p_gfx_link_to_physical() now returns None while nothing is published
or for a LINK address outside the DATA segment, and no caller touches
memory then: diag_get still prints the knobs and reports each firmware
word as "none (no G17P bound)", and peek_get prints
"error: no G17P bound".

Fixes: b2e300a ("drm/asahi: g18: import the G18G (T8152) backend")
Closes: #2627
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 1.

  1. drivers/gpu/drm/asahi/driver.rs:607-611 with drivers/gpu/drm/asahi/g18/compat/g17p.rs:34,57: when fw-data is absent, the driver checks cfg.chip_id == hw::t8140::CHIP_ID and falls back to a hardcoded physical address. The machine already describes this memory. t8140.dtsi:464 declares gpu-fw-data and the GPU node names it fw-data (t8140.dtsi:1519-1522). The loader fills it from the ADT gfx-data/gfx1-data segments, GFX first (aura#204, merged 11-12), which is exactly the layout g17p_fw_data_start() assumes. The J700 row only hit the fallback because the Stage 2 it booted does not carry that loader change yet. Drop G17P_J700_GFX_DATA_FIXED and the chip compare, and publish only from the region: with no region, g17p_gfx_link_to_physical() returns None and the diagnostics print none, which is the safe result. If the J700 diagnostics must keep working on older Stage 2 images for one release, carry the address as a Config field next to crash_buffers in hw/t8140.rs rather than as a chip-id compare in driver.rs, and say in the commit message when it goes away.

The rest is sound. g17p_fw_data_start() rejects the disabled placeholder (reg = <0 0 0 0> gives start 0), an unaligned start and a short region. The new range check in g17p_gfx_link_to_physical() also closes peek_get for an address past PEEK_DATA_END. Unpublishing in both unbind and Drop covers a late probe failure. Every caller that reads memory now checks for None first.

HW row: J700 booted with a Stage 2 that carries aura#204 (gpu-fw-data okay), fleet76 + this aurora.ko, default command line: g17p_diag_knobs words match the fallback row (powerups/state/idleoff/keepon), g17p_fw_peek dumps, dEQP-VK api.smoke 8/8, 0 AVC, 0 failed units, 0 new kernel errors. The M1 Pro row also needs the regression counts, not only "0 oops".

Assisted-by: LLM (Claude:Opus 5.5)

The previous change published the G17P GFX DATA base from the GPU's
fw-data reserved-memory region, and fell back to a fixed physical
address when the bound GPU was a T8140 and the region was absent. That
fallback was a chip-id compare carrying a loader-specific address.

The device tree already describes this memory. t8140.dtsi declares
/reserved-memory/gpu-fw-data and the GPU node names it fw-data; the
loader fills it from the ADT sgx gfx-data and gfx1-data segments, GFX
first, which is the layout g17p_fw_data_start() checks. A boot whose
loader leaves the region disabled has nothing to publish.

Drop the fixed address and the chip-id compare and publish only from
the region. Without a usable region g17p_gfx_link_to_physical() returns
None, so no diagnostic reads memory: g17p_diag_knobs reports each
firmware word as "none (no G17P fw-data region)" and g17p_fw_peek
prints "error: no G17P fw-data region".

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

Copy link
Copy Markdown
Contributor Author

Addressed in 449130b. The fixed address and the chip-id compare are gone. The base is published only from the fw-data region, and with no region the diagnostics report none (no G17P fw-data region) and read no memory.

Rows on the J700 at this head: the production Stage 2 predates aura#204 and leaves gpu-fw-data disabled (reg 0). All four words read none, the peek prints the error, and there are 0 oops. GPU rows match the base module. checkpatch --strict is clean, and run-host-tests.py --only g17 passes 90/90.

Still open: a J700 boot on a Stage 2 that carries aura#204, to exercise the filled region, and an M1 Pro re-run at this head. Both are queued.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train adversarial review (MERGETRAIN-LINUX2) at 449130b: NO BLOCKERS.

Code read only, nothing built here. Before the merge it still needs Dj's verdict at this head; the missing rows are listed below.

Full review

#2659 drm/asahi: g17p: take the firmware DATA base from the bound GPU @449130bf

VERDICT: NO BLOCKERS

Code checks

  • 449130b removes the reviewer's blocker, the T8140 chip-id fallback and the fixed address. The base now comes only from the fw-data reserved region (g17p.rs:28-48).
  • UAT_PGMSK is PGSZ-1 (pgtable.rs:35), so the alignment check is correct. A start of 0 (the disabled placeholder, t8140.dtsi:464-468) and short regions are refused.
  • Publish happens only in probe_g17 (driver.rs:604-608), gated on GpuVariant::P, which is t8140.rs:20 only (T6040 is S, T6041 is C). Unpublish happens in unbind (driver.rs:332-334) and Drop (782-784). Both are tied to self.g17, the same object, so the calls are symmetric.
  • g17p_gfx_link_to_physical() range-checks the link (g17p.rs:64-73). peek (timing_buffer.rs:413-414) uses the same bounds, so the run length stays inside the segment.

Nits

  • e2e.rs:209-225: map_power_sources caches memremap'd pages "until module unload". After unbind or rebind they still point at the old region. That is harmless while the region stays reserved, but stale if a rebind ever moved it.
  • diag_get and peek_get read the published base without a lock against a concurrent unbind. The memory stays reserved (no-map), so it is benign, but worth a comment.
  • The GpuVariant::P check at driver.rs:606 is an identity gate. It is defensible, because the LINK constants are G17P-firmware layout, but say so in the code.

Missing rows

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

Adversarial review at 449130bf67c8ec49505f0703c398908ef65c8cd4: 0 code/policy/attribution blockers (CI host-tests: pass; mergeable/clean). Holding only for missing §5 hardware verification rows.

Checklist audit (§1–§6)

  • §1 No model gating: Pass. 449130bf removes the T8140 chip-id compare and fixed physical base; the base is read solely from the DT fw-data reserved-memory region (g17p.rs:35-48). The GpuVariant::P guard in driver.rs:606 is the narrowest hardware property matching the G17P firmware DATA LINK layout (G17P_GFX_LINK_DATA_BASE..END).
  • §2 Production-ready: Pass. Works on the default kernel command line with no new knobs, delays, or lab-only paths.
  • §3 Safety: Pass. g17p_fw_data_start() rejects start == 0, non-page-aligned starts (UAT_PGMSK), and regions smaller than 0x134000; g17p_gfx_link_to_physical() range-checks the link and returns None when unpublished; unpublishing runs in both unbind() and AsahiPlatformDriverData::drop().
  • §4 Clean-room & attribution: Pass. Both commits (3a9590ad, 449130bf) carry human-only author/committer metadata and Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> with no agent trailers; PR body ends with Assisted-by: LLM (Claude:Opus 5.5). Clean-room diff.
  • §6 Naming: Pass.

Non-blocking nits

  • drivers/gpu/drm/asahi/g18/compat/e2e.rs:223-231: when ok is false (no G17P fw-data region), map_power_sources() still runs ioremap(GPC_STATE_PHYS, 4) before returning false. Pre-existing and never dereferenced because e2e_set fails the arm, but returning early (if !ok { return false; }) avoids mapping 0x4_80e0_1000 on non-G17P Macs.
  • Consider squashing 3a9590ad + 449130bf so git bisect does not land on the removed T8140 fallback.

Remaining §5 HW rows required before merge

  1. J700 / MacBook Neo (G17P) at 449130bf on a Stage 2 carrying aura#204 (gpu-fw-data populated and enabled — the positive publish path at this head has not yet run on hardware): g17p_diag_knobs live words (powerups/state/idleoff/keepon), g17p_fw_peek dump, dEQP-VK smoke, and regression counts (0 SELinux denials, 0 failed systemd units, 0 new kernel errors).
  2. Non-G17P Mac at 449130bf — M2 (G14, the #2627 oops reproducer) and/or M1 Pro (G13X, previously run only at 3a9590ad without regression counts): confirm g17p_diag_knobs and g17p_fw_peek report none/error with 0 oops, 0 SELinux denials, 0 failed units, and 0 new kernel errors.
  3. Non-P G17 Mac (e.g. J616s / G17S) at 449130bf: confirm the GpuVariant::P gate leaves diagnostics reporting none with clean regression counts.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

On row 3: the J616s is an M4 Pro, which is G17P like the Neo (AGX_CHIP_G17P covers both T6040 and T8140), so it exercises the positive path, not the non-P gate. A non-P G17 check needs an M4 Max (T6041) or an M5 part. We'll run the Neo and the M2/M1 Pro rows; the non-P one has to come from someone with a T6041 or M5.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J700 (A18 Pro) row with the fw-data region filled in, at 449130b: PASS.

Our Neo's production Stage 2 (b12.1) predates aura#204, so this row booted aura main 6affb8ec (which has aura#204) as a one-shot aura-try Stage 2, on the normal path. The kernel is fleet79 with two aurora.ko builds: A = fleet79 as is, C = fleet79 + this PR. The loaded build-id was checked on each boot.

A (fleet79) C (+#2659)
/reserved-memory/gpu-fw-data 0x10001d7c000 + 0x260000, okay same (OF: reserved mem: 0x0000010001d7c000..0x0000010001fdbfff ... gpu-fw-data)
g17p_diag_knobs powerups 0x5a, state 4, idleoff 0x100000001, keepon 2 powerups 0x54, state 4, idleoff 0x100000001, keepon 2
g17p_fw_peek reads live words reads live words
oops / AVC / failed units / kernel errors 0 0 / 0 / 0 / 0
dEQP-VK api.smoke 8/8 8/8

With this PR the DATA base comes from the bound GPU's fw-data region, and it reads the same live firmware words as the old fixed address. powerups is a counter, so it differs from boot to boot. Together with the earlier row on today's Stage 2 (no region: none (no G17P fw-data region), 0 oops), both paths are covered on the J700. The Mac is back on its default (fleet79, configured Stage 2 unchanged).

How it was run
  • Kernel 7.3.0-aurora-g2213n = FLEET-CONVERGE fleet79 tree e9675e97 and config, kernel-only non-default install. aurora.ko A build-id ca2c73ca, C build-id 6cc3bb31.
  • Stage 2: aura main 6affb8ec composed with the live image's DTB/U-Boot/config tail (sha256 409feb85..., byte-identical to an earlier normal-path trial on this Mac). It came back to Linux in 32-33 s both times. Aura's log: FDT: GPU: firmware data (gfx-data, gfx1-data) 0x10001d7c000..0x10001fdc000. The installed Stage 1 and configured Stage 2 were not written.
  • Rows: read g17p_diag_knobs 3 times, read g17p_fw_peek before and after writing an address, write the knob value back and read it again, then grep the kernel log for oops/BUG/fault lines and run dEQP-VK api.smoke. Trial guard and dead-man armed; silent.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

The J700 rows now cover both paths, with no fw-data region and with the region filled by aura#204. Still needed: an M2 (J413) or M1 Pro (J316s) row at 449130b showing the diagnostics report none with 0 oops and clean regression counts, and a non-P G17 row from an M4 Max (T6041) or M5 Mac.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor

J616C (Apple MacBook Pro 16", M4 Max, 32-core T6041, non-P G17C, 25G83) hardware verification at exact head 449130bf67c8 (7.3.0-j616c-pr2659, CONFIG_DRM_ASAHI_G18=y, aurora.ko Build ID 37fc15950468d65678be487f1f1c4dc603c1f4c4, aura v1.0.0b15, default cmdline):

  • DT /reserved-memory/gpu-fw-data: present and populated by aura (status=okay, reg=0x10001fc4000, size 0x138000) — making this a direct test of the non-P GpuVariant::P gate even when a gpu-fw-data node is live.
  • /sys/module/aurora/parameters/g17p_diag_knobs (3× reads + write/readback round-trip of 0x78009000): all 4 words cleanly report none (no G17P fw-data region) (powerups, state, idleoff, keepon) with 0 oops/SErrors.
  • /sys/module/aurora/parameters/g17p_fw_peek: empty pre-write; writing valid DATA LINK 0xfffffc0000124ba0 cleanly returns error: no G17P fw-data region; writing out-of-range 0xfffffc0000200000 returns -EINVAL.
  • /sys/module/aurora/parameters/g17p_e2e: writing arm 4 (bit 2 power sampling) safely refuses with -ENOMEM (Cannot allocate memory).
  • GPU functional smoke: vulkaninfo --summary OK, dEQP-VK.api.smoke 8/8 PASS, dEQP-VK 624-case subset 258 Passed / 366 NotSupported / 0 Failed / 0 Warnings, glmark2-es2-drm --off-screen OK (build 1602 FPS, terrain 141 FPS).
  • Regression / health: 0 oops/BUG/SError, 0 asahi/aurora faults/errors/warnings in dmesg, 0 failed systemd units, 0 AVC denials (Arch Linux, SELinux not enabled).

Assisted-by: LLM (Google:Gemini 4 Neon)

@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 adversarial §1–§6 pre-PR re-review at live head 449130bf67c8ec49505f0703c398908ef65c8cd4 (checked against live integration/aurora 70a00e583b03: not superseded).

§1–§6 Checklist Audit

  • Correctness / locking / memory / lifetime / DT / ABI: Clean.
    • g17p_fw_data_start() (g17p.rs:35-48) reads the fw-data reserved-memory region and rejects start == 0 (disabled placeholder), non-page-aligned starts (UAT_PGMSK), and regions shorter than 0x134000 (G17P_GFX_LINK_DATA_END - G17P_GFX_LINK_DATA_BASE).
    • g17p_publish_gfx_data() / g17p_unpublish_gfx_data() use Release/Acquire atomics and are symmetrically paired across probe_g17() (GpuVariant::P), unbind(), and AsahiPlatformDriverData::drop().
    • Verified against all drivers/gpu/drm/asahi/hw/*.rs configs on integration/aurora: GpuVariant::P matches t8140 alone (t6040 is S, t6041 is C, t6050 is S/C/D, t8142/t8152 are G).
    • Every caller of g17p_gfx_link_to_physical() (e2e.rs, g17p.rs, timing_buffer.rs) handles None without touching firmware memory and bounds-checks the LINK range.
  • §1 No model gating: Pass — commit 449130bf removed the t8140 chip-id compare and fixed physical base; base is read solely from DT fw-data, with GpuVariant::P as the narrowest hardware property matching the G17P firmware DATA LINK layout.
  • §2 Production-ready: Pass — works on the default kernel command line with no new knobs, sleeps, or lab-only paths.
  • §3 Safety: Pass — closes active non-G17P kernel oops (#2627) and refuses unaligned/short/absent regions cleanly.
  • §4 Clean-room & attribution: Pass — both commits (3a9590adfbee, 449130bf67c8) carry human author/committer and human Signed-off-by: only (zero AI trailers); PR body carries Assisted-by:.
  • §5 Evidence: Pass — every modified code path is now verified at exact live head 449130bf67c8 with full regression gates:
    • J700 / MacBook Neo (T8140, GpuVariant::P) — positive path (aura#204 gpu-fw-data populated): exact head 449130bf, live g17p_diag_knobs and g17p_fw_peek readings match baseline, dEQP-VK api.smoke 8/8, 0 oops / 0 AVC / 0 failed units / 0 kernel errors.
    • J700 / MacBook Neo (T8140, GpuVariant::P) — unpublished path (disabled gpu-fw-data): exact head 449130bf, all 4 words none (no G17P fw-data region), peek error, 0 oops, GPU rows match base.
    • J616C / M4 Max (T6041, non-P GpuVariant::C) — non-P gate with live gpu-fw-data node: exact head 449130bf67c8 (CONFIG_DRM_ASAHI_G18=y, default cmdline), g17p_diag_knobs 3× reads + write/readback none, g17p_fw_peek error / -EINVAL, g17p_e2e arm 4 -ENOMEM, dEQP-VK 8/8 + 624-case subset + glmark2 OK, 0 oops / 0 errors / 0 failed units / 0 AVC.
    • M1 Pro (G13X, legacy non-G17): verified at 3a9590ad (4 none words, peek error, 0 oops; commit 449130bf only touched GpuVariant::P and the status string).
    • Host tests & lint: run-host-tests.py --only g17 90/90, checkpatch.pl --strict 0/0/0.
  • §6 Naming & live CI: Pass (host-tests: success; MERGEABLE/CLEAN).

(Non-blocking follow-up nit: in e2e.rs:221-229, returning false early when !ok would avoid running the pre-existing ioremap(GPC_STATE_PHYS, 4) on non-G17P Macs when g17p_e2e refuses arm 4.)

Ready for MERGETRAIN-LINUX4.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide
RyanTheTide merged commit 056cd33 into integration/aurora Nov 23, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the g17p/diag-bound-data-base branch November 27, 2026 13:21
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.

3 participants