Skip to content

drm/asahi: g17: Log an unsupported firmware build only when none matches - #2585

Open
term-guy wants to merge 2 commits into
aurora-silicon:mainfrom
term-guy:g17-quiet-fw-identify
Open

term-guy wants to merge 2 commits into
aurora-silicon:mainfrom
term-guy:g17-quiet-fw-identify

Conversation

@term-guy

@term-guy term-guy commented Nov 20, 2026 •

Copy link
Copy Markdown

Problem

firmware_variant() tries each identified build in turn. Each try measured the loaded TEXT again, and a build that did not match logged unsupported GPU firmware build, supported: <that build> and GPU firmware image not admitted: EINVAL, even when the next build matched. With no apple,firmware-version on the GPU node (the installed aura doesn't write one on T8142), an M5 on macOS 27.2 logs those three errors for 26A428 before it admits 26B123. Raised on linux#2093.

Change

  • Measure the TEXT once, and try each build with Measured::find, which leaves the copy as it was.
  • Only when no build matches, log the measured identity and every supported build, then the existing Unsupported GPU firmware image line.
  • A matched build still logs GPU firmware build: ....
  • The TEXT is copied and hashed once per probe, not once per candidate build.

Testing

Mac17,2 J704 on the macOS 27.2 (26B123) stub, with #2093 (f41fdbe) underneath, five boots. Before, the probe logged:

aurora 582600000.gpu: unsupported GPU firmware build: TEXT 0x9c000 DATA 0x184000 entropy ... sha256 f957e359...
aurora 582600000.gpu: supported: 26A428 for T8142 G17G, primary then secondary
aurora 582600000.gpu: GPU firmware image not admitted: EINVAL
aurora 582600000.gpu: GPU firmware build: 26B123 for T8142 G17G, primary then secondary
aurora 582600000.gpu: GPU firmware: 27.2 (26B123), G17G

With this change:

aurora 582600000.gpu: GPU firmware build: 26B123 for T8142 G17G, primary then secondary
aurora 582600000.gpu: GPU firmware: 27.2 (26B123), G17G

Both roles acknowledged their InitData, and KDE ran on the GPU. The no-match path was checked by reading the code only.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

Looks right. Measured::find() goes through digest_at(), which puts back the entropy bytes it zeroes (or hashes a separate copy when there are boot-filled ranges), so one measurement can be reused for every candidate.

Two small things:

  • A failure to find the fw-text/fw-data regions now returns from measure_text(dev)? (g17/mod.rs:1896) without a log line. Only EAGAIN is logged (:1945). Before, the same failure printed "GPU firmware image not admitted" and the probe ended in the "Unsupported GPU firmware image" line. A dev_err for the other errors in measure_text() would keep a mismatched DT or loader visible.
  • The no-match "supported:" list (:1924) walks every build's images. Builds that share an image with different core-layout configs, which firmware_variant() allows, print that image twice. Cosmetic.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

host-tests fails in g17-firmware-selection-tests.py: the test compiles the firmware-selection code from drivers/gpu/drm/asahi/g17/mod.rs against its own stub Build type, which still has a single image field. This PR's code now uses build.images (main.rs lines 64 and 89 of the generated harness), so rustc stops with E0609 no field images on type &Build and one E0599. Updating the harness's Build stub in tools/asahi/g17-firmware-selection-tests.py to the new images shape, in this PR, should make the suite build again. Locally: python3 -I tools/asahi/run-host-tests.py --only g17-firmware-selection.

Assisted-by: LLM (Claude:Opus 5.5)

@term-guy

Copy link
Copy Markdown
Author

Thanks, all three in 974032a:

  • host-tests: the harness's Build stub now has images, with a stub measure_text() and a Measured whose find() records each image it is tried against, so the existing checks on the candidate order still hold. The stub dev_info!/dev_err! now build their messages, so the new log lines are type-checked too. python3 -I tools/asahi/run-host-tests.py --only g17-firmware-selection: ok.
  • silent measure_text() errors: every error other than EAGAIN (a missing or bad fw-text/fw-data region) now logs GPU firmware image not measured (fw-text/fw-data): <err>.
  • duplicate "supported:" lines: an image shared by several builds is listed once.

drivers/gpu/drm/asahi/ builds with no new warnings (LLVM, Rust).

AI-assisted (Assisted-by: LLM).

@RyanTheTide

Copy link
Copy Markdown

Re-review of 974032a: Blockers: 1.

From our last comments:

  1. Resolved: a measure_text() error other than EAGAIN is now logged (drivers/gpu/drm/asahi/g17/mod.rs:1956-1962).
  2. Resolved: the "supported:" list skips an image already printed (mod.rs:1925-1929). The core::ptr::eq check removes a duplicate only when builds point at the same FirmwareBuild static, which is how a shared image is meant to be listed.
  3. Resolved: the Build stub in tools/asahi/g17-firmware-selection-tests.py now has images, plus a Measured stub that records each image it is tried against, so the candidate-order checks still run.

New:

  1. Both commits (876c53c and 974032a) carry an Assisted-by: LLM trailer. Please reword them so the human Signed-off-by is the only trailer. A note that an LLM helped belongs on the PR body's last line, as Assisted-by: LLM (<vendor>:<model>). The body currently ends with "AI-assisted, tested by me on the hardware."

HW row: J704 (macOS 27.2 stub, 26B123) booted on 974032a with no apple,firmware-version on the GPU node: only the GPU firmware build: / GPU firmware: lines, no not measured or unsupported lines, GPU in use by the desktop, 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

Merge-train adversarial review (MERGETRAIN-LINUX2) at 974032a: 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

#2585 drm/asahi: g17: Log an unsupported firmware build only when none matches @974032a4

VERDICT: NO BLOCKERS

Checked on the merge (drivers/gpu/drm/asahi/g17/mod.rs merged :1882-1966, fwid.rs):

  • Measured::find() goes through digest_at() (fwid.rs:100-140). That restores the zeroed
    entropy bytes in place, or hashes a separate copy when boot_filled is non-empty, so reusing
    one measurement across candidates is sound.
  • fwid::identify() stays in use by g16/boot.rs:491, so there is no dead code.
  • measured.identity() gets every build's images to choose the boot-filled normalization, as
    before.
  • core::ptr::eq deduplicates only images that share the same static, which is the intent.
  • Host test tools/asahi/g17-firmware-selection-tests.py passes on the merge ("PASS G17
    selection ...").
  • No gate, param or Apple-internal name is added.

Nits:

  1. mod.rs merged :1896 Self::measure_text(dev)?: a measurement failure now aborts the probe
    with that error (EAGAIN/ENOMEM/EINVAL), where before it was ENODEV after "Unsupported GPU
    firmware image". It also drops the implicit re-measure: before, a transient EAGAIN (TEXT
    changed between the two copies) on the first candidate was retried by the next candidate's
    measurement. It is logged now (:1945-1962), so this is acceptable, but say it in the commit
    message.
  2. mod.rs merged :1902: "GPU firmware build: " is logged for each build whose image
    matches, before the core-layout check. A shared image whose first build's config does not
    admit the cores (T6041 25G83 style) logs the same line twice. That is cosmetic.
  3. Commit hygiene: both 876c53c and 974032a carry an Assisted-by: LLM trailer. They are
    already pushed, so per our rule they stay (NIT, not a blocker).

Missing rows:

  • J704 (T8142, 27.2/26B123) on 974032a itself. The five-boot row in the body predates the
    follow-up commit. It should show only the GPU firmware build:/GPU firmware: lines, the
    desktop on the GPU, and 0 new kernel errors.
  • Other Firmware::Identified configs that now take the single-measurement path: T6040 (J616s,
    hw/t6040.rs:69), T6041 (M4 Max, two builds sharing an image), T6050 (hw/t6050.rs). T8140 Neo
    (hw/t8140.rs:61) is Fixed and returns early. At least one boot on J616s, with no "not
    measured"/"unsupported" lines; ideally also an M4 Max to exercise the shared-image dedup.
  • The no-match path (wrong or absent firmware) was checked only by reading the code and the
    host stub. One boot with a deliberately unlisted build, or a KUnit case, would cover the new
    error output.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-PR checklist review at 974032a49058: 1 blocker (§4 attribution), plus §5 evidence gap on the live head.

Code and Safety Audit (§1–§3, §6)

  • Clean functionally. Verified against drivers/gpu/drm/asahi/fwid.rs (digest_at() restores in-place zeroed entropy bytes and uses a separate KVVec copy when boot_filled is non-empty, and returns None before mutating on record-validation failure), so reusing a single Measured across candidate builds is sound.
  • fwid::identify() remains used by drivers/gpu/drm/asahi/g16/boot.rs:491 and is cfg_attr-guarded against dead-code warnings.
  • measure_text() logs both EAGAIN and other fw-text/fw-data errors, and tools/asahi/g17-firmware-selection-tests.py matches the new Build::images / Measured shape and type-checks the dev_info!/dev_err! format strings.
  • CI: host-tests is green.

Blockers

  1. §4 commit trailers: Both commits (876c53cc5d70, 974032a49058) include an Assisted-by: LLM trailer in the commit message. Per §4 of the pre-PR checklist, commits must carry human author/committer identity and human Signed-off-by: only, with zero Assisted-by: or AI trailers in commit messages (disclosure stays in the PR body only).

Non-blocking Nits

  • drivers/gpu/drm/asahi/g17/mod.rs:1927: core::ptr::eq(seen, image) relies on const-promoted slices from BUILD_25G83/BUILD_26B123 (hw/t6041.rs:75-196) sharing an address across uses, which Rust does not guarantee for const (unlike static). Comparing (seen.name, seen.text_sha256) (or promoting shared image arrays to static) would make deduplication guaranteed.
  • drivers/gpu/drm/asahi/g17/mod.rs:1902: GPU firmware build: {} is logged before the core_layout.cores check, so a shared image whose first matching build doesn't admit the probed core layout logs that line twice; logging it at :1916 alongside GPU firmware: {} would avoid the duplicate.
  • drivers/gpu/drm/asahi/g17/mod.rs:1896: Self::measure_text(dev)? now propagates measurement errors (EAGAIN/EINVAL/ENOMEM) directly instead of continuing and returning ENODEV (and no longer re-measures on a transient EAGAIN). This is reasonable and logged; worth mentioning in the commit message when dropping the commit trailers.

§5 Evidence Needed on Live Head

  • Re-prove on J704 (macOS 27.2 / 26B123, no apple,firmware-version) at the updated head (the 5-boot row predates 974032a4) showing only GPU firmware build: / GPU firmware:, desktop on GPU, and the regression row (0 SELinux denials, 0 failed units, 0 new kernel errors).
  • Ideally also one boot on another Firmware::Identified Mac (T6040/T6041/T6050) taking the single-measurement path.

Assisted-by: LLM (Gemini 4 Neon)

firmware_variant() tries the identified builds in turn, the one the boot
loader's apple,firmware-version names first. Each try measured the
loaded TEXT again and, when it was not that build, logged
"unsupported GPU firmware build", the build it was not, and "GPU
firmware image not admitted: EINVAL", even when a later build then
matched. Without apple,firmware-version (the installed aura does not
write it on T8142), an M5 on macOS 27.2 logs three such errors for the
26A428 build before it admits 26B123.

Measure the TEXT once and try each build against that measurement
(Measured::find, which leaves the copy as it found it). Only when no
build matches, log the measured identity and every supported build,
before the existing "Unsupported GPU firmware image" line. A matched
build still logs "GPU firmware build: ...". The TEXT is now copied and
hashed once per probe rather than once per candidate build.

Signed-off-by: termg <hello@termg.com>
…hared measurement

Follow-ups to "Log an unsupported firmware build only when none matches":

- measure_text() logged only EAGAIN. A missing fw-text or fw-data region
  (a DT or boot loader mismatch) now returned from the probe silently,
  where before it printed "GPU firmware image not admitted". Log every
  other error too.
- A measurement error (EAGAIN, ENOMEM, EINVAL) now ends the probe with
  that error, where before each candidate build measured again and the
  probe ended with ENODEV after "Unsupported GPU firmware image". So a
  transient EAGAIN (TEXT changed between the two copies) is no longer
  retried by the next candidate; it is logged instead.
- "GPU firmware build: <image>" is logged once, for the build that is
  taken, next to "GPU firmware: <build>". It was logged for every build
  whose image matched, so an image shared by a build whose configuration
  does not admit the probed cores logged it twice.
- The "supported:" list walked every build's images, so an image shared
  by builds that differ only in their core layout (as T6041 25G83 is)
  was listed once per build. List each image once, comparing name and
  TEXT digest: the address of a const-promoted entry is not guaranteed
  to be shared.
- g17-firmware-selection-tests.py compiles firmware_variant() against
  stub types, and its Build stub still had a single `image` with an
  identify_image() stub, so the host test stopped building (E0609 "no
  field images"). Model the new shape instead: Build::images, a stub
  measure_text() and a Measured whose find() records each image it is
  tried against, so the existing checks on the order of the candidates
  still hold. The stub dev_info!/dev_err! now build their messages, so
  the log lines are type-checked as well.

Signed-off-by: termg <hello@termg.com>
@term-guy

Copy link
Copy Markdown
Author

Updated (45f2380, 313c264):

  • Both commits carry only my Signed-off-by; the disclosure is the last line of the description.
  • supported: deduplication now compares (name, text_sha256) instead of core::ptr::eq, so it no longer depends on const promotion sharing an address. The host stub's FirmwareBuild gained text_sha256 for this.
  • GPU firmware build: <image> is logged once, for the build that is taken, next to GPU firmware: <build>. A shared image whose first build doesn't admit the cores no longer logs it twice.
  • The second commit's message now says that a measurement error (EAGAIN/ENOMEM/EINVAL) ends the probe with that error rather than ENODEV, and that a transient EAGAIN is no longer retried by the next candidate. It is logged instead.

tools/asahi/g17-firmware-selection-tests.py passes. drivers/gpu/drm/asahi/ builds with no new warnings (same 32 as before, all pre-existing).

J704 (macOS 27.2 / 26B123 stub, no apple,firmware-version): the installed 7.3.0 kernel booted with its aurora.ko replaced by one built from that tree plus these two commits (the kernel image is unchanged). The probe logs only

aurora 582600000.gpu: GPU firmware build: 26B123 for T8142 G17G, primary then secondary
aurora 582600000.gpu: GPU firmware: 27.2 (26B123), G17G

The same boot with the module without this PR logs unsupported GPU firmware build: ..., supported: 26A428 ... and GPU firmware image not admitted: EINVAL first. Those three lines are gone. KWin (KDE login) runs on renderD128, with no GPU faults or recoveries. 0 SELinux denials (enforcing), 0 failed units, 0 new kernel errors: the remaining kernel error lines are the same set as the normal boot without this PR.

I have no T6040/T6041/T6050 Mac, so the other Firmware::Identified rows need someone who has one.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

Re-checked at 313c264 (range-diff against 974032a). The Assisted-by: LLM trailers are gone, so both commits carry only your Signed-off-by. The code changes since the merge-train review close its nits:

  • "GPU firmware build: " is now printed once, for the build that is taken (g17/mod.rs: identified carries (build, image)), not for every build whose image matched.
  • The "supported:" de-duplication compares name and TEXT digest instead of core::ptr::eq, which is right: two static arrays holding equal const entries are not guaranteed to share an address. The host-test stub gained text_sha256 to match.
  • The commit message now says that a measurement error ends the probe with that error and that a transient EAGAIN is logged rather than retried by the next candidate. I'm fine with that behaviour now that it is stated.

No code concerns from my side. What is left is a fresh run at this head, since the log path changed: the host test (run-host-tests.py --only g17-firmware-selection, CI is still queued) and one J704 boot showing exactly one "GPU firmware build:" line and no "unsupported"/"not measured" lines. With that, this is approved from my side.

Assisted-by: LLM (Claude:Opus 5.5)

@term-guy

Copy link
Copy Markdown
Author

Both are in now. CI host-tests passed at 313c264 (run 45083862624, which includes g17-firmware-selection). The J704 boot at this head is in my comment just above yours: the probe logs exactly one GPU firmware build: 26B123 for T8142 G17G, primary then secondary and GPU firmware: 27.2 (26B123), G17G, with no "unsupported" or "not measured" lines.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 313c264: host-tests green incl. g17-firmware-selection; J704 boot logs one 'GPU firmware build:' line, no unsupported/not-measured lines.

@term-guy

Copy link
Copy Markdown
Author

@DjDeveloperr could you re-review at 313c264eb802? The §4 blocker from your review at 974032a4 is fixed: both commits carry only my Signed-off-by. The §5 row at this head is in #2585 (comment): J704 on the 26B123 stub with no apple,firmware-version, only GPU firmware build: and GPU firmware: logged, KWin on the GPU, 0 SELinux denials, 0 failed units, 0 new kernel errors. CI host-tests passed. Ryan approved at this head. I have no T6040/T6041/T6050 Mac for the other Firmware::Identified row.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 313c264eb802 against the pre-PR checklist (§1–§6) and live integration/aurora (70a00e583b03): 0 blockers — approved.

Verified

  • §1–§3 (Correctness, safety, no model gating): Clean. firmware_variant() measures loaded TEXT once via Self::measure_text(dev)? and reuses Measured across candidate builds via Measured::find() (verified fwid.rs:100-140 restores in-place zeroed entropy bytes and hashes a separate copy when boot_filled is non-empty). GPU firmware build: is logged once on the selected (build, image) pair; the no-match supported: list deduplicates by (name, text_sha256) rather than pointer identity; measure_text() logs both EAGAIN and other fw-text/fw-data errors; and tools/asahi/g17-firmware-selection-tests.py matches Build::images / Measured and type-checks the log format strings. Not superseded on integration/aurora.
  • §4 (Attribution & clean-room): Resolved. Both commits (45f238024b4c, 313c264eb802) carry human author/committer and human Signed-off-by: only, with zero AI trailers in commits; disclosure is in the PR body.
  • §5 (Evidence): Exact-head J704 boot (macOS 27.2 / 26B123 stub, no apple,firmware-version) confirms only GPU firmware build: / GPU firmware: are logged, KWin runs on renderD128 without GPU faults, and 0 SELinux denials, 0 failed units, 0 new kernel errors; other Firmware::Identified platforms (T6040/T6041/T6050) are noted for owners who have that hardware.
  • §6 (Naming & live CI): Clean. Live CI host-tests is green (run/45083862624).

Assisted-by: LLM (Gemini 4 Neon)

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) needs-template PR body lacks Tested or Risk (bot) ready-to-merge Meets the merge policy: merge it (bot) labels Nov 24, 2026
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-template PR body lacks Tested or Risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants