Skip to content

drm/asahi: g17: A18 Pro: report the performance state, its frequency and busy time - #1853

Draft
DjDeveloperr wants to merge 1 commit into
integration/aurorafrom
djdev/g17p-gpu-stats
Draft

DjDeveloperr wants to merge 1 commit into
integration/aurorafrom
djdev/g17p-gpu-stats

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

On the MacBook Neo (A18 Pro, G17P), agx_stats reported only utilisation: pstate, achieved_frequency_hz and busy_ns read unsupported, and fdinfo had no frequency keys. The A18 Pro's 26A428 firmware sends the same statistics records that #1611 decodes on the M5. Until now only the M5 decoded them.

What changes

  • g17::telemetry::Protocol describes what a firmware sends beyond utilisation: its highest performance state (tags 0x19/0x1b) and its utilisation period (tag 0x13 timestamps). g17::stats::protocol() picks it from the init graph:
    • 25G83 (M4 Pro/Max): nothing beyond utilisation;
    • A18 Pro: states 1-10, 16 ms period;
    • M5: states 1-13, 8 ms period.
  • A18 Pro pstate and busy_ns use the decoder and integration already in place for the M5.
  • achieved_frequency_hz and drm-curfreq-*/drm-maxfreq-* take the state's frequency from a per-state table. On the M5 it is the board's table. On the A18 Pro it is the device tree operating points that its performance table A names.
    • The records don't name the table. But at the top state, where the GPU runs while work is in flight (the driver's full effort is a floor), a sustained FP32 FMA load finishes faster than table B's top frequency allows.
    • gpubench compute.heavy kind=alu, 2.147 GFLOP per dispatch, 1.18 ms per dispatch at depth on the J700, needs at least 1.42 GHz on its 5 cores at one FMA per lane per clock. Table B's top state is 1326 MHz; table A's is 1470 MHz.
  • Gated cores read state 0 (off), valid, at 0 Hz, in agx_stats and drm-curfreq-*, instead of a stale state. This also changes the M5: it used to read stale while gated. Power-up still starts a new epoch, stale until the next state report.
  • Tag 0x10 is no longer decoded on a firmware that reports its state in 0x19/0x1b.
  • Docs: sysfs-driver-asahi-agx-stats and asahi-usage-stats.rst.

Measured on the J700, from tracepoint captures of the default kernel (asahi_g17_report + asahi_g17_complete, 24 GPU stress traces)

  • The utilisation record arrives every 16.00 ms (median of 1269).
  • Integrating it as on the M5 gives a busy time within about 20% of the union of the commands' own execution intervals for loads busy more than half the time. Like the M5, it reads low for loads sparser than one period.
  • The 0x19 interval records are periodic samples (about 7% of wall time at any load), not busy intervals, so they don't feed busy_ns.
  • While work is in flight the state report reads 10.

Testing

  • tools/asahi/run-host-tests.py --only telemetry: 13/13. New A18 Pro decoder and reader tests; every mutation is still killed.
  • aurora.ko compile and Neo one-shot test boot (agx_stats, fdinfo, nvtop at idle and under load, kernel fault check): pending. The PR stays a draft until then.

cc @erikwb @RyanTheTide: this extends #1611's decoder to the A18 Pro, and changes the M5's gated reading from stale to state 0 (behaviour only).

🤖 Generated with Claude Code

…and busy time

The A18 Pro's 26A428 firmware sends the same statistics records as the
M5's: the performance state in effect (tag 0x1b, after an interval
record, tag 0x19) and utilisation records that carry their own
timestamps, one every 16 ms on the A18 Pro. Only the M5 decoded them, so
agx_stats on the A18 Pro reported pstate, achieved_frequency_hz and
busy_ns as unsupported, and its fdinfo had no frequency keys.

Describe what each firmware sends beyond utilisation in a Protocol
(highest state, utilisation period) chosen from the init graph: 25G83
sends neither, the A18 Pro has states 1-10 and a 16 ms period, the M5
states 1-13 and an 8 ms period. The A18 Pro's state frequencies come
from the device tree operating points its performance table A names.
The records do not name the table, but at its top state, where the GPU
runs while work is in flight, a sustained FP32 FMA load completes faster
than table B's frequency there allows. Tag 0x10 is no longer decoded on
a firmware that reports its state in tags 0x19 and 0x1b.

While the GPU cores are gated the GPU is off: report state 0, valid,
at 0 Hz in agx_stats and drm-curfreq-*, instead of a stale state, on
the A18 Pro and the M5 alike. Power-up still starts a new epoch, stale
until the firmware reports a state again.

Signed-off-by: Diljit Singh <hey@djdev.me>
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