Skip to content

drm/asahi: g17: T6041: report the performance state, its frequency and busy time - #2864

Merged
RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
AxxzyWasTaken:feat/t6041-pstate-telemetry
Nov 23, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
AxxzyWasTaken:feat/t6041-pstate-telemetry

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

T6041's 25G83 firmware emits the same performance state records (tag 0x19 interval end timestamps and tag 0x1b with words 1 and 3 naming states 1..10) and timestamped utilisation records (tag 0x13, 8 ms / 192,000 ticks at 24 MHz, as the existing 25G83 decoder assumes) as V26A428. Because g17::stats::protocol() previously mapped every InitGraph::V25G83 build to Protocol::NONE, agx_stats on T6041 reported pstate, achieved_frequency_hz, and busy_ns as unsupported, and DRM fdinfo omitted drm-curfreq-* and drm-maxfreq-*.

Change

  • Move the telemetry Protocol onto fw::variant::Variant::telemetry_protocol so each firmware build declares its own telemetry capabilities directly rather than deriving them from (InitGraph, m5_commands) in g17::stats::protocol().
  • Make telemetry::Protocol firmware-record-format-shaped (Protocol::NONE, Protocol::PSTATE_8MS for 8 ms / 192,000-tick utilisation with 0x19/0x1b state reports, and Protocol::PSTATE_16MS for 16 ms / 384,000-tick utilisation with 0x19/0x1b state reports) instead of per-chip constants, and derive the valid max_pstate upper bound at runtime from StateFrequencies::max_pstate() (13 on M5's 14-entry board table, 10 on A18 Pro and T6041's 11-state PERF table, 0 / fail-closed if absent), stored on Shared so initial boot and firmware recovery restarts use the same bound.
  • Enable Protocol::PSTATE_8MS on T6041's BUILD_25G83 variant while leaving T6041 26B123, T6041 25F84, and T6040 25G83 (M4 Pro) on Protocol::NONE because they have not been measured yet.
  • State frequencies continue to come from perf.states_a mapped onto the DT operating points: on T6041 both table A and table B map state 10 to OPP 15 (1578 MHz) and only differ on mid-states (5..9 on 32-core J616C; 6..9 on 40-core), so those mid-state frequencies are documented as nominal (taken from table A) until measured by a mid-state ALU benchmark.
  • Add unit and integration test coverage for T6041's 0x13/0x19/0x1b handling, runtime-derived max_pstate bounds (10 vs 13 on PSTATE_8MS and fail-closed max_pstate == 0), defensive rejection of mismatched or out-of-range states, safe fallback if a build omits 0x1b, and 8 ms busy-time integration.
  • Update Documentation/ABI/testing/sysfs-driver-asahi-agx-stats, Documentation/gpu/asahi-usage-stats.rst, and comments in drivers/gpu/drm/asahi/{stats.rs,sysfs.c}.
  • Merge-order note: Both this PR and #2863 (feat/t6041-pool-reuse) add a field in BUILD_25G83 in drivers/gpu/drm/asahi/hw/t6041.rs, so whichever lands second gets a trivial 1-line rebase.

Testing

  • scripts/checkpatch.pl --strict --git HEAD~1..HEAD: 0 errors, 0 warnings, 0 checks (886 lines checked).
  • make ARCH=arm64 LLVM=1 W=1 CONFIG_KUNIT=y drivers/gpu/drm/asahi/aurora.o: compiles cleanly with 0 warnings in any touched file (clang 22.1.8, rustc 1.99.1).
  • tools/asahi/run-host-tests.py --only g17: 90/90 passed (including g17-telemetry-tests, g17-telemetry-integration-tests, and all 11 mutation tests); CI (host-tests) green.
  • J616C (32-core T6041, 25G83) hardware verification at exact head 5af8985d15eb (7.3.0-j616c-pr2864, see #issuecomment-7094020390):
    • agx_stats: idle-gated pstate_status valid, pstate 0, achieved_frequency_hz 0; active 12 s GPU load pstate 10 (1578000000 Hz), strictly monotonic busy_ns (+10.06 s over 11.94 s, 0.843); clean idle-gate return to pstate 0 / 0 Hz with cumulative busy_ns retained.
    • DRM fdinfo: live drm-curfreq-{vertex,fragment,compute}: 1578000000 Hz and drm-maxfreq-*: 1578000000 Hz.
    • dEQP-VK 624-case subset 258/366/0, 0 GPU faults/errors/warnings, 0 failed systemd units, 0 SELinux AVC denials.

Hardware Scope & Uncovered Hardware

  • Verified hardware: Apple M4 Max J616C (32-core T6041) on 25G83.
  • Enabled but unmeasured: 40-core T6041 (J614C/J575C) on 25G83.
  • Untouched (Protocol::NONE): T6041 26B123, T6041 25F84, T6040 25G83 (M4 Pro; follow-up planned using Ryan's J616s capture).
  • No behaviour change for V26A428 (A18 Pro / M5) or T6040.

Assisted-by: LLM (Anthropic:Claude Opus 5.5, Google:Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Review at b07ff34 (non-author, draft). No blocker in the decoding; two points on the shape.

  • Moving the protocol onto Variant::telemetry_protocol removes the (InitGraph, m5_commands) derivation in stats.rs, and the existing builds keep their protocols (A18_PRO, M5, NONE). Mismatched words, state 0 and states above the maximum are rejected; the tests cover the 8 ms integration window and the gap rule.
  • Merges cleanly on the current integration/aurora tip (with drm/asahi: g17: take T6041 render pool identity at context creation #2863 one of the two needs a one-line rebase, as you note).

Points to consider:

  • Protocol::T6041 carries max_pstate: 10, i.e. "states 1 to 10 of its eleven-state performance tables". The driver already knows the state count from the DT operating points (perf_max_pstate), so the maximum could come from there for every protocol, and the protocol would only describe the record format (which tags, the utilisation period). That would also make the type firmware-shaped rather than chip-named.
  • T6040's 25G83 is the same firmware family ("The M4 Pro firmware (25G83)" in variant.rs) and stays on NONE only because it has not been captured. A firmware_reports capture from an M4 Pro would most likely let the protocol attach to the firmware build rather than to one chip; we can provide one from an M4 Pro.
  • The mid-state table A vs B question (states 5-9) decides what achieved_frequency_hz reports under load; until it is measured, the ABI doc could say those states' frequencies are nominal.

Assisted-by: LLM (Claude:Opus 5.5)

…d busy time

T6041's 25G83 firmware emits the same performance state records (tags
0x19 and 0x1b, with words 1 and 3 naming states 1..10) and timestamped
utilisation records (tag 0x13, 8 ms period = 192000 ticks at 24 MHz, as
the existing 25G83 decoder assumes) as V26A428. Because
stats::protocol() mapped all InitGraph::V25G83 builds to Protocol::NONE,
agx_stats on T6041 reported pstate, achieved_frequency_hz and busy_ns as
unsupported, and fdinfo omitted drm-curfreq-* and drm-maxfreq-*.

Move the telemetry Protocol onto fw::variant::Variant so each firmware
build declares its own telemetry capabilities directly instead of
deriving them from InitGraph and m5_commands, and make Protocol describe
only the firmware record format (Protocol::NONE, Protocol::PSTATE_8MS
for 8 ms / 192000-tick utilisation with 0x19/0x1b state reports, and
Protocol::PSTATE_16MS for 16 ms / 384000-tick utilisation with 0x19/0x1b
state reports) rather than per-chip constants. Derive the valid pstate
upper bound (max_pstate) at runtime from StateFrequencies::max_pstate()
instead of hardcoding it on Protocol, storing it on Shared so initial
boot and firmware recovery restarts share the same bound (13 on M5's
14-entry board table, 10 on A18 Pro's and T6041's 11-state PERF table,
and 0 / fail-closed if no table is present).

Enable Protocol::PSTATE_8MS on T6041's 25G83 build, while leaving T6041
26B123, T6041 25F84, and T6040 25G83 (M4 Pro) on Protocol::NONE because
they have not been measured yet. State frequencies continue to come from
perf.states_a mapped onto the device tree operating points; on T6041
both table A and table B map state 10 to OPP 15 (1578 MHz) and only
differ on mid-states (states 5..9 on 32-core J616C, 6..9 on 40-core), so
those mid-state frequencies are documented as nominal (taken from table
A) until measured by a mid-state ALU benchmark.

Add unit and integration test coverage for T6041's 0x13/0x19/0x1b
handling, runtime-derived max_pstate bounds (10 vs 13 on PSTATE_8MS and
fail-closed max_pstate == 0), defensive rejection of mismatched or
out-of-range states, safe fallback if a build omits 0x1b, and 8 ms
busy-time integration, and update the agx_stats and asahi-usage-stats
documentation.

Scope: targets J616C (32-core T6041) on 25G83; live boot-testing is
pending. Left on Protocol::NONE: T6041 26B123, T6041 25F84, T6040
25G83. Enabled but unmeasured: 40-core T6041 (J614C/J575C) on 25G83.

Signed-off-by: AxxzyWasTaken <[email protected]>
@AxxzyWasTaken
AxxzyWasTaken force-pushed the feat/t6041-pstate-telemetry branch from b07ff34 to 5af8985 Compare November 23, 2026 00:42
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Updated #2864 (rebased onto integration/aurora 6732e74f9395 -> 5af8985d15eb) to address both shape points from your review:

  1. Firmware-shaped Protocol + runtime-derived max_pstate:
    • Replaced chip-named Protocol::{M5, A18_PRO, T6041} with record-format constants Protocol::NONE, Protocol::PSTATE_8MS (192,000 ticks, used by V26A428_M5 and T6041 BUILD_25G83), and Protocol::PSTATE_16MS (384,000 ticks, used by V26A428).
    • Derived max_pstate at runtime via StateFrequencies::max_pstate() (self.states.saturating_sub(1) -> 13 from M5's 14-entry board table, 10 from A18 Pro / T6041's 11-entry PERF table rather than raw DT OPP count since T6041 maps 11 states onto 16 DT OPPs, and 0 / fail-closed if absent), stored on Shared so both initial boot and recovery restarts pass the same bound to Rings::new() / Telemetry::new().
  2. ABI & doc wording for states 5–9:
    • Updated Documentation/ABI/testing/sysfs-driver-asahi-agx-stats and Documentation/gpu/asahi-usage-stats.rst to state explicitly that T6041's mid-state frequencies (5..9 on 32-core J616C, 6..9 on 40-core) are nominal (taken from table A) until measured by a mid-state ALU benchmark.
  3. Tests & verification at 5af8985d15eb:
    • Added KUnit + integration coverage for PSTATE_8MS under both 11-state (max_pstate = 10, rejecting state 13) and 14-state (max_pstate = 13) tables plus max_pstate == 0 fail-closed.
    • tools/asahi/run-host-tests.py --only g17: 90/90 PASS; checkpatch.pl --strict: 0/0/0; aurora.o (ARCH=arm64 LLVM=1 W=1 CONFIG_KUNIT=y): 0 new warnings.

Once you have a T6040 25G83 firmware_reports capture, enabling M4 Pro is now just flipping V25G83.telemetry_protocol to Protocol::PSTATE_8MS (or PSTATE_16MS depending on cadence). Keeping in Draft pending our exact-head J616C boot row.

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

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 5af8985. Both shape points are addressed: the protocol now names the record format (PSTATE_8MS / PSTATE_16MS / NONE) and attaches to firmware builds, and max_pstate comes from the state-frequency table at runtime. A missing table gives 0, which fails closed. Keeping it on the PERF table rather than the raw DT OPP count is right given T6041's 11 states over 16 OPPs. Recovery restarts pass the same bound, the doc now calls the mid states nominal, and the new tests cover 11 and 14 states plus the fail-closed case. No code concerns from my side; the J616C row at this head is what's left.

For the M4 Pro we'll take a firmware_reports capture from our J616s (T6040, 25G83) under idle, a GPU ramp and sustained load, and post it here with the record cadence, so the build can attach to the matching protocol in a follow-up.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

T6040 (J616s, M4 Pro) 25G83 firmware_reports capture, as promised. Fleet kernel 7.3.0-aurora-fleet81, default cmdline, read-only debugfs polling every 1 ms through idle, a ramp (vkcube, glmark2 build, glmark2 terrain) and 150 s of sustained glmark2 terrain.

It is the same record format as T6041 25G83, so PSTATE_8MS fits:

  • 0x13 (utilisation, words 3/4/6 = tiler/renderer/device %): about 117 records/s under sustained load. Consecutive word-1 timestamps are 192,280 ticks apart on average (8.01 ms at 24 MHz) for 76 % of the samples. 23 % arrive late (204k to 400k ticks) and 0.1 % are longer gaps.
  • 0x19 and 0x1c: one record each per 200,000 ticks (8.333 ms), p10 to p90 = 199,864 to 200,134. At idle they come in bursts while the cores power up and down.
  • 0x1b: words 1 and 3 name the state and agree in 99.8 % of records. I saw states 2 to 10: idle reports 2, sustained load reports 10, and the ramp walks 2 -> 3 -> ... -> 6 and 8 -> 9 -> 10. I never saw state 1. The maximum of 10 is consistent with an 11-state PERF table (16 GPU OPPs in the DT, as on T6041).
  • Today agx_stats reports pstate, achieved_frequency_hz and busy_ns as unsupported on this Mac (T6040 25G83 = Protocol::NONE). Utilisation is valid. 0 firmware crashes, 0 SELinux denials.

So flipping V25G83.telemetry_protocol to Protocol::PSTATE_8MS for T6040 should be all it takes. We can run the boot row for that follow-up on the J616s when it exists (pstate / achieved_frequency_hz / busy_ns / fdinfo drm-curfreq-*).

Per-phase numbers
== sustained: 148.9 s (glmark2 terrain 1600x1000)
  0x13 records=17461 117.3/s merged_polls=0 | w1 delta p10=186995 p50=193621 p90=232070; mean in 180-204k = 192280 (8.012 ms)
       buckets: 180-188k 14.8%, 188-196k 44.2%, 196-204k 17.4%, 204-400k 23.3%, <180k 0.2%, >=400k 0.1%
  0x19 records=17854 119.9/s | w1 delta p10=199864 p50=200000 p90=200134 (8.333 ms) | w1-w3 p50=1649 ticks
  0x1b records=17824 | (w1,w3): (10,10) 17766, (2,2) 12, (4,5) 11, (9,10) 4, (8,9) 2, (8,8) 1
  0x1c records=17854 | same cadence as 0x19
== ramp: 72.9 s (vkcube 20 s, glmark2 build 20 s, terrain 30 s)
  0x13 records=2986 40.9/s | mean in 180-204k = 192757 (8.032 ms)
  0x19 records=8545 | w1 delta p50=199998
  0x1b (w1,w3): (10,10) 5929, (2,2) 1750, (3,4) 14, (4,5) 12, (5,6) 10, (2,3) 2, (4,4) 2
== idle 90 s / tail 40 s: 0x13 none; 0x19/0x1b/0x1c ~1.5-1.9/s in bursts; 0x1b (2,2) only

Method: poll /sys/kernel/debug/aurora-g17/firmware_reports every 1 ms and log each count change of a role/tag with words 0-7. A count step of more than 1 between two polls is counted as merged and excluded from the deltas. Timestamps are words 1|2 (64-bit, 24 MHz).

Assisted-by: LLM (Claude:Opus 5.5)

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Thanks for capturing T6040 (J616s, 25G83) firmware_reports — those numbers (0x13 mean 192,280 ticks / 8.01 ms, 0x19 200,000 ticks / 8.333 ms, 0x1b states 2..10 agreeing 99.8% across an 11-state PERF table over 16 OPPs) confirm it is the exact same Protocol::PSTATE_8MS format.

Keeping #2864 scoped cleanly to T6041 at 5af8985d (host-tests CI green, exact-head J616C boot kit built and queued once our J616C hardware lane is back online), and we'll follow up with the one-line V25G83.telemetry_protocol = Protocol::PSTATE_8MS flip for T6040 right after #2864 lands so you can add the J616s row there.

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

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

J616C (Apple MacBook Pro 16", M4 Max, 32-core T6041, 25G83) hardware verification at exact head 5af8985d15eb (7.3.0-j616c-pr2864, default cmdline, sddm greeter active):

agx_stats (Protocol::PSTATE_8MS, max_pstate = 10)

  • Pre-load idle: pstate_status valid, pstate 0, achieved_frequency_hz 0, busy_ns 0, utilisation_status valid, util_{tiler,renderer,device}_percent 0.
  • Active 12 s offscreen glmark2-es2-drm terrain: 117/119 active 100 ms polls reported pstate 10 and achieved_frequency_hz 1578000000 (peak snapshot: util_tiler_percent 54, util_renderer_percent 85, util_device_percent 86); busy_ns accumulated strictly monotonically (+10,064,867,523 ns over 11.94 s, 0.843 busy fraction).
  • Post-load & post-dEQP-VK return to idle: cleanly idle-gated back to pstate_status valid, pstate 0, achieved_frequency_hz 0 with cumulative busy_ns 14014472069 retained.

DRM fdinfo (live glmark2-es2-drm client fd)

drm-driver:             aurora
drm-engine-vertex:      0 ns
drm-curfreq-vertex:     1578000000 Hz
drm-maxfreq-vertex:     1578000000 Hz
drm-engine-fragment:    780763586 ns
drm-curfreq-fragment:   1578000000 Hz
drm-maxfreq-fragment:   1578000000 Hz
drm-engine-compute:     1012011905 ns
drm-curfreq-compute:    1578000000 Hz
drm-maxfreq-compute:    1578000000 Hz

firmware_reports & Regression Check

  • /sys/kernel/debug/aurora-g17/firmware_reports: active tag=0x13 (1164 / 1160 admitted), tag=0x19 (1930 / 1662), tag=0x1b (1669 / 1632, words (0xa, 0xa)), tag=0x1c (1930 / 1662).
  • dEQP-VK 624-case subset: 258 Passed / 366 NotSupported / 0 Failed / 0 Warnings; vtxalu 1M × 20: 16.296 ms.
  • Health: 0 asahi/aurora faults/errors/warnings in dmesg, 0 failed systemd units, 0 SELinux AVC denials.

Marking #2864 Ready for Review (CI host-tests green). Once this merges we will open the follow-up V25G83.telemetry_protocol = Protocol::PSTATE_8MS PR for T6040 so J616s can add its row there.

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

@AxxzyWasTaken
AxxzyWasTaken marked this pull request as ready for review November 23, 2026 07:08

@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 review at live head 5af8985d15ebcf3d53aad64a1855d7691972a6a8: 0 blockers — approving.

Checked & clean

  • §1 No model gating & architecture (g17/telemetry.rs, g17/fw/variant.rs, g17/stats.rs, g17/mod.rs, hw/t6041.rs):
    • telemetry::Protocol is cleanly firmware-record-format shaped (NONE, PSTATE_8MS, PSTATE_16MS) on Variant::telemetry_protocol, eliminating the (InitGraph, m5_commands) derivation in g17/stats.rs.
    • max_pstate is derived at runtime via StateFrequencies::max_pstate() (10 for 11-state PERF tables on A18 Pro / T6041, 13 for M5's 14-entry board table, 0 / fail-closed if absent) and stored on Shared so both initial boot and recovery restarts pass the same bound into channel::Rings::new() / Telemetry::new().
    • Keeping V25G83 on Protocol::NONE here while enabling Protocol::PSTATE_8MS on T6041 BUILD_25G83 is cleanly scoped pending the follow-up T6040 V25G83 PR with a J616s boot row.
  • §2–§3 Production quality, safety & docs:
    • Tag 0x1b rejects mismatched words[1] != words[3], 0, and > self.max_pstate (fail-closed when max_pstate == 0); 8 ms busy-time integration bounds windows at 2 * 192_000 ticks without overflow; frequencies come from DT OPPs via perf.states_a.
    • Documentation/ABI/testing/sysfs-driver-asahi-agx-stats, Documentation/gpu/asahi-usage-stats.rst, stats.rs, and sysfs.c clearly document T6041 25G83 support and explicitly note that mid-states (5..9 on 32-core, 6..9 on 40-core) are nominal until measured.
    • Unit and integration tests (g17/telemetry.rs, tools/asahi/g17-telemetry-integration-tests.py) cover PSTATE_8MS with both max_pstate = 10 and 13, fail-closed max_pstate = 0, missing 0x1b fallback, idle gating, and 8 ms busy integration.
  • §4 Attribution: Single commit 5af8985d15eb carries human author/committer (AxxzyWasTaken <[email protected]>) and human Signed-off-by: only (zero AI trailers); PR body includes Assisted-by:.
  • §5 Evidence & live CI:
    • Live CI host-tests: green (SUCCESS).
    • Exact-head J616C (32-core T6041, 25G83, 7.3.0-j616c-pr2864, default cmdline) row verifies pre-load idle (pstate 0, 0 Hz, busy_ns 0), 12 s active glmark2-es2-drm (117/119 polls at pstate 10 / 1578 MHz, monotonic busy_ns +10.065 s over 11.94 s), clean post-load idle-gating back to pstate 0 / 0 Hz with busy_ns retained, live DRM fdinfo (drm-curfreq-* & drm-maxfreq-* 1578000000 Hz), firmware_reports (0x13/0x19/0x1b/0x1c), dEQP-VK (258 Passed / 0 Failed / 0 Warnings), vtxalu, and full §5 health (0 faults/errors/warnings in dmesg, 0 failed units, 0 SELinux AVC denials).
  • §6 Naming: Clean.

Non-blocking notes

  • The PR body still mentions "Pending before leaving Draft" from before the J616C row was posted; trivial 1-line rebase interaction with #2863 in t6041.rs BUILD_25G83.

Assisted-by: LLM (Gemini 4 Neon)

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