Skip to content

drm/asahi: refresh G16S/G17P utilisation from pending statistics - #1096

Merged
RyanTheTide merged 4 commits into
integration/aurorafrom
gpu/telemetry-g16s-g17p
Nov 8, 2026
Merged

RyanTheTide merged 4 commits into
integration/aurorafrom
gpu/telemetry-g16s-g17p

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

G16S and G17P already share the tag-0x13 decoder, bounded averages and agx_stats formatter, but reads only inspected the cached snapshot, and every GPU power-gate invalidated it. This PR does two things:

  1. Drain both firmware statistics roles during agx_stats reads under the existing device mutex, with power observations before and after the drain, so queued samples reach the ABI without waiting for another event notification. Suspension, epoch cutoffs, copy-before-consume and quarantine admission are unchanged.
  2. Read a power-gated GPU as idle, not stale (7a1effc). The cores gate about 2 ms after the last work, so before this change a reader saw stale / unsupported whenever the GPU was idle. A gate still ends the averaging epoch; the last sample stays valid until it ages out, then the gated GPU reads as a valid 0 %. A wake is stale until its first record. Suspend, recovery, restart and quarantine stay stale.

agx_stats also gains utilisation_source, utilisation_samples and utilisation_host_ns diagnostics. Executable tests of the production reader cover both firmware graphs: queued records without event service, repeated reads, freshness expiry, valid idle zero, gated idle, suspend/resume, power epochs, recovery, crash and detach. A missing-drain mutation fails them. Per-client fdinfo engine nanoseconds stay separate: tag-0x13 percentages have no client identity and cannot become busy_ns or cycles.

Scope: utilisation only. pstate, requested_frequency_hz, achieved_frequency_hz and busy_ns stay unsupported on G16S/G17P. The stage 2 layout research found that the available evidence does not match the shipped firmware builds closely enough to read those fields safely; Documentation/gpu/asahi-usage-stats.rst lists what is still missing. No speculative firmware command or module parameter is added. The classic (M1/M2 family) statistics path is untouched: the only sysfs change is inside the qualified-stats formatter that G16S/G17P use.

Hardware results

Neo (J700, G17P), 2026-11-08 23:27-23:36. Default fleet34 kernel (without this PR) as baseline, then a one-shot test kernel 7.3.0-aurora-gputel1 = integration 009c878 (fleet33) + this branch at 7a1effc, clean merge 9d335902, fleet config. agx_stats sampled at 5 Hz, load = glmark2-es2-gbm offscreen terrain (silent, displays off):

phase gputel1 (this PR) fleet34 (without)
idle, 15 s 75/75 valid 0 % 75/75 stale, util unsupported
glmark2 terrain, 20 s valid, 45/100 at 100/100/100, the rest ramping in valid, 52/100 at 100/100/100
idle after, 15 s 75/75 valid 0 % 75/75 stale
5 x (2 s load / 3 s idle) load rises to ~100 every time; every idle 15/15 valid 0 % load ~100; every idle 15/15 stale
idle, 10 s 50/50 valid 0 % 50/50 stale
  • Enforcing, 0 AVC, 0 failed units, 0 GPU fault/recovery lines, no new kernel warnings.
  • Touch ID restored 2 enrolled, os_uuid pin on every boot entry.
  • fdinfo engine ns move only for the load client.
  • glmark2-es2-gbm build: 11824 / 11785 / 12923 vs 12547 on fleet34, within run-to-run noise.
  • The Neo is back on its fleet34 default and the test kernel is removed.

J616s (G16S), 2026-11-08 05:12. Same branch at 7a1effc, one-shot test kernel 7.3.0-aurora-gpux2: idle 20/25 valid 0 % (5 stale at the transition), load valid ~100 %, idle after 25/25 valid 0 %. fleet27 without the change: every idle sample stale (details in the comment below). The J616s was not re-run tonight. It uses the same G16S/G17P reader as the Neo, so the Neo proof covers this head; a J616s re-check on the next fleet kernel is a follow-up.

Tests

  • CI host-tests: pass.
  • Buildbox, merged tree 9d335902: tools/asahi/run-host-tests.py 196/196, apple-dcp selftests 87 ok / 0 not ok. Before the merge: g17-telemetry-tests.rs 6/6, Rust part of g17-telemetry-integration-tests.py 20/20.

Consume pending statistics from both firmware roles under the existing device mutex and epoch admission rules, without requiring another event notification. Retain the shared tag-0x13 decoder and keep device percentages separate from per-client fdinfo engine time.

Exercise the production reader with queued samples, expiry, zero samples and lifecycle boundaries; add a missing-drain negative control. Document the exact shared-power ABI facts still needed before pstate or frequency can be exported.

Assisted-by: LLM

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM

Signed-off-by: Ryan Murray <[email protected]>
The firmware gates the G16S/G17P cores a few milliseconds after the last
work completes and emits no utilisation record while they are gated. Every
power observation invalidated the readout, so agx_stats reported a stale
sample (and "unsupported" values) whenever it was read on an idle or
lightly loaded GPU, which is almost always. On the Neo, with or without
the statistics drain on reads, utilisation was valid only under sustained
glmark2 load and stale at idle and under short bursts, although the
firmware delivered and the driver admitted every tag 0x13 record.

A power gate still ends the averaging epoch, but the last sample now
stays valid until it ages out, and the gated GPU then reads as a valid
zero for every utilisation value. A wake starts a new epoch that stays
stale until its first record. Suspend, recovery, restart and quarantine
remain stale, never idle.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware run on the Neo (J700, G17P, firmware 26A428). One-shot test kernel 7.3.0-aurora-gpux1 = fleet23 (810b92c) + this branch at c977cb3 + linux#1065 + linux#1146. SELinux enforcing, 0 AVC, 0 failed units.

  • The drain on reads changes nothing observable. agx_stats with and without this branch (fleet24 stock):
    • Sustained glmark2 terrain: both kernels report utilisation_status valid, 100/100/100.
    • Idle, and short submit bursts: both report stale, with values unsupported.
  • The firmware delivers the records and the driver admits them. firmware_reports showed role 0 tag 0x13 count=567 admitted=567, e.g. tiler 80 / device 80.
  • The real gap is power gating. The cores gate about 2 ms after the last work, and observe_statistics_power() invalidated the readout on every gated observation. A reader therefore saw stale whenever the GPU was idle, which is almost always.

Pushed 7a1effc on this branch: drm/asahi: g17: read a power-gated GPU as idle, not stale.

  • A gate still ends the averaging epoch.
  • The last sample stays valid until it ages out, and the gated GPU then reads as a valid zero.
  • A wake is stale until its first record.
  • Suspend, recovery, restart and quarantine remain stale.
  • Tests:
    • new unit test a_gated_gpu_reads_idle_after_its_last_sample_ages_out;
    • the two integration cases that encoded "gate => stale" now expect idle.
  • Host results: g17-telemetry-tests.rs 6/6, the Rust part of g17-telemetry-integration-tests.py 20/20.

The hardware re-run of the idle-zero / load / idle acceptance on a gpux2 kernel follows. pstate/frequency (stage 2) is filed as Daybreak t-5591.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J616s hardware check of this PR + 7a1effc ("read a power-gated GPU as idle, not stale"), 2026-11-08 05:12 AEDT. One-shot kernel 7.3.0-aurora-gpux2, removed afterwards; same Stage 2 DTB and the same script as the fleet27 comparison. agx_stats sampled at 5 Hz:

phase gpux2 (this PR) fleet27 (without)
idle, 5 s 20/25 valid 0 %, 5 stale 25/25 stale, util unsupported
glmark2 terrain, 7 s valid; 25/35 at 100 %, ramping in 35/35 valid 100 %
idle after, 5 s 25/25 valid 0 % 25/25 stale
idle, 3 s 14/15 valid 0 % 15/15 stale

The power-gate fix closes the idle gap on the J616s (G16S). A few stale samples remain right at transitions. glmark2 build score 7248 vs 7221. Enforcing, 0 AVC, no new kernel warnings.

@RyanTheTide

RyanTheTide commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Neo (G17P) hardware proof for head 7a1effc, 2026-11-08 23:27-23:36. One-shot test kernel 7.3.0-aurora-gputel1 = integration 009c878 + this branch (clean merge 9d335902), compared against the fleet34 default without it. Sampled at 5 Hz.

  • Idle. All 275 idle samples read valid 0 % with this PR. On fleet34 all 275 read stale with util unsupported.
  • Under glmark2-es2-gbm offscreen load. Both kernels read valid and reach 100 %, including on all five 2 s load / 3 s idle transitions.
  • No regressions. 0 AVC, Enforcing, 0 GPU faults, Touch ID 2 restored, pin on every entry. glmark2 build score is within noise.
  • pstate/frequency. These stay unsupported, as intended. Stage 2 research could not qualify those fields for the shipped firmware builds.

Host tests on the merged tree: 196/196, dcp 87/0. CI host-tests: green.

G16S was proven on the J616s at 05:12 (comment above). It shares this reader, so a J616s re-check is a follow-up and does not block the merge.

Data: traces/gpu/20261108-neo-gputel1 (S500). The Neo is restored to fleet34 and the test kernel is removed. Marking ready and merging per the merge train.

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 8, 2026 12:36
@RyanTheTide
RyanTheTide merged commit 1239ef8 into integration/aurora Nov 8, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the gpu/telemetry-g16s-g17p branch November 16, 2026 05:07
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.

1 participant