Skip to content

drm/asahi: g17: count busy time across power gates, in timestamp order (#1611 follow-up) - #1879

Open
m0d16l14n1 wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
m0d16l14n1:j815/g17-m5-stats-v2
Open

m0d16l14n1 wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
m0d16l14n1:j815/g17-m5-stats-v2

Conversation

@m0d16l14n1

Copy link
Copy Markdown
Contributor

The follow-up to #1611 that @DjDeveloperr asked for in this review, reworked from the two commits I offered there (8c58f1d, 2c515ec). Two commits on integration/aurora.

The problem

On a J815 (M5) under a frame-paced load (es2gears + vkcube, 20 s), the cores power-gate about 95 times a second (power_epoch 10861), usually with one utilisation record per power epoch. busy_ns stayed 0 although the 0x13 records kept arriving:

  • busy time needed two records in one epoch, because every boundary cleared the window start (busy_ts);
  • the records queued before a boundary, and those drained while the cores read gated, never reached the decoder.

What changed from the earlier commits, by review point

  • Accounting is separate from the utilisation epoch. The decoder keeps the firmware timestamp up to which it has credited busy time (busy_mark). Power gates, suspend and restarts keep it. A record at or before the mark adds nothing, so an older queued record, a repeat, or the other role's record for the same time is never credited twice in any drain order. This also covers drm/asahi: g17: M5: report the performance state, its frequency and busy time #1611's note 3 (one baseline for both roles).
  • The first record after a gap is qualified. It closes only its own 8 ms sampling period, and that period lies after the mark, so the gap is never credited. Within two periods of the mark a record closes the window since it, as before.
  • The cut-off records go to busy time only. record_busy() takes 0x13 records that a power boundary kept out, and nothing else. The utilisation average, its delivery cadence and the performance state never see them. Suspend, a real invalidation's discard and quarantine still keep everything out.
  • The pstate rule is unchanged here. No retained "valid while gated" state and no record_timed() path into the publisher. drm/asahi: g17: A18 Pro: report the performance state, its frequency and busy time #1853 changes the gated reading separately.
  • No gpu_power_gated and no per-pstate residency. Nothing new in the common formatter, so G16S/G17P output doesn't change.
  • Docs. The ABI and asahi-usage-stats.rst now describe the mark, the one-period rule and the busy-only path. They also fix "Tick deltas are never accumulated…" (drm/asahi: g17: M5: report the performance state, its frequency and busy time #1611 note 4: it is about tag 0x10).
  • Quarantine. busy_ns reads stale once a statistics ring is quarantined (drm/asahi: g17: M5: report the performance state, its frequency and busy time #1611 note 2), instead of a frozen value that reads valid.
  • The status-label commit (the part you called separable) prints stale/unavailable for pstate and achieved_frequency_hz instead of unsupported. Where pstate is unsupported, output is byte for byte the same, which includes every non-M5 G16S/G17P firmware through qualify().

Credited windows never overlap and each ends at its own record's timestamp, so busy_ns stays bounded by elapsed time.

Testing

  • Host: tools/asahi/run-host-tests.py --only telemetry 13/13, on each commit separately.
    • New decoder cases: a gate between every record, records kept out of the epoch, interleaved roles, a clock restart.
    • New ring case: records cut off at a gate and drained while gated count; a repeat from the other role does not; suspend keeps them out; quarantine reads stale.
    • Each of these mutants fails the tests: the mark reset at an epoch boundary, a record at or before the mark credited, the gap after a gate credited in full, record_busy dropped (in the decoder or in the ring), and record_busy without the percentage check.
    • The fixture's existing quarantine mutation still fails: the admission and the read share statistics_quarantined().
  • aurora.ko builds (LLVM, Rust 1.99) with no warnings in these files.
  • Not yet run on the J815 with this change. That's why it's a draft. I'll post agx_stats and fdinfo under the same es2gears + vkcube load, plus busy_ns against the commands' own execution intervals from asahi_g17_report/asahi_g17_complete traces (as drm/asahi: g17: A18 Pro: report the performance state, its frequency and busy time #1853 did on the J700).

With #1853

These two commits conflict textually with #1853, since both rework telemetry.rs, the ABI doc and the formatter. I've rebased them onto #1853 at j815/g17-m5-stats-v2-on-1853, host tests 13/13 there. On that base the rule uses the firmware's own period, so it covers the A18 Pro's 16 ms records too. #1853's A18 Pro case then expects one 16 ms period after its >2-period gap instead of nothing. Whichever lands second, I'll switch this PR to match.

Assisted-by: Claude Opus 5.5

pstate and achieved_frequency_hz printed "unsupported" whenever
pstate_status wasn't valid. On a firmware that reports its state (M5,
A18 Pro), the state is "stale" after the cores power up, until the
firmware's next state report, and the file then read as a missing
feature. Print the status word instead. achieved_frequency_hz keeps
"unsupported" for a valid state with no frequency in the board's table.

busy_ns also gets a "stale" reading, for a total that stopped (used by
the next change); every other non-valid busy status still reads
"unsupported".

Where pstate is unsupported (25G83, and always there through
g17::stats::qualify), the status word is "unsupported", so that output
is byte for byte the same. The integration test's formatter cases follow
the new readings and check "busy_ns stale".

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
On a J815 (M5) under a frame-paced load (es2gears + vkcube, 20 s), the
cores power-gate about 95 times a second (power_epoch 10861), usually with
one utilisation record per power epoch. busy_ns stayed 0 although the
0x13 records kept arriving:

- busy time needed two records in one epoch, because every boundary
  cleared the window start (busy_ts);
- the records queued before a boundary, and those drained while the cores
  read gated, never reached the decoder.

Busy time now has its own ordering, separate from the utilisation epoch,
on every firmware whose Protocol integrates it (M5 and A18 Pro):

- The decoder keeps the firmware timestamp up to which it has credited
  busy time (busy_mark). Epoch boundaries keep it. A record at or before
  it adds nothing, so an older queued record, a repeat, or the other
  role's record for the same time is never credited twice, whatever the
  drain order.
- A later record closes the window since the mark when that is at most two
  utilisation periods, as before. After a longer gap it closes only its
  own period (8 ms on M5, 16 ms on the A18 Pro), which lies after the
  mark: the gap is never credited. Before, such a record only set the
  baseline. The first record after a gate now credits its period at its
  own device utilisation.
- Records a power boundary keeps out of the averaging epoch (cut off, or
  drained while gated) are decoded for busy time only (record_busy). The
  utilisation average, its delivery cadence and the performance state do
  not see them. Suspend, a real invalidation's discard and quarantine
  still keep everything out.
- A record more than 60 s behind the mark cannot still be queued; it
  means the firmware clock started again and only sets a new mark.
- busy_ns reads stale once a statistics ring is quarantined, since
  nothing adds to it any more.

Credited windows never overlap and each lies at or before its own
record's timestamp, so busy_ns stays bounded by elapsed time. 25G83
integrates no busy time and is unchanged. The gated performance state
(off, valid 0) is left as it is.

Host tests: tools/asahi/run-host-tests.py --only telemetry passes: the
decoder's 13 cases, the integration fixture and every listed mutation.
New decoder cases: gates between every record, records kept out of the
epoch, interleaved roles, clock restart. The A18 Pro window case now
expects a record after a gap longer than two periods to credit its own
16 ms period. New ring case: records cut off at a gate and drained
while gated count, a repeat from the other role does not, suspend keeps
them out, quarantine reads stale. The fixture's quarantine mutation now
hits both the admission and the read, through statistics_quarantined().

Not yet run on hardware in this form; the M5 behaviour is the one
measured on the J815 before the A18 Pro protocol work.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
@m0d16l14n1 m0d16l14n1 changed the title drm/asahi: g17: M5: count busy time across power gates, in timestamp order (#1611 follow-up) drm/asahi: g17: count busy time across power gates, in timestamp order (#1611 follow-up) Nov 14, 2026
@m0d16l14n1

Copy link
Copy Markdown
Contributor Author

Rebased on integration/aurora 1f5037a, after #1853. Head is now 99daf59, still two commits.

#1853 moved the M5 decoder onto Protocol, so this is a port, not only a conflict fix:

  • busy_mark, record_busy() and the gap rule use Protocol::integrates_busy(), util_period_ticks and max_window_ticks() in place of the M5-only constants. The new accounting therefore applies to the A18 Pro too, with its 16 ms period. 25G83 is unchanged.
  • One A18 Pro expectation changes: in a18_pro_busy_time_integrates_16_ms_windows, a record more than two periods after the last now credits its own 16 ms period (28 → 32 ms) instead of only resetting the baseline. That is the same rule as on M5.
  • drm/asahi: g17: A18 Pro: report the performance state, its frequency and busy time #1853's gated reading (off, a valid 0) is kept as it is. The first commit now prints the status word only where the state isn't valid, so a gated GPU still reads pstate 0, achieved_frequency_hz 0.
  • Docs: the ABI and asahi-usage-stats.rst text for busy_ns describes both periods. The J700 measurement is kept and marked as taken with the earlier per-epoch windows.

Host tests (--only telemetry): the decoder's 13 cases, the integration fixture and every mutation pass, with no warnings. checkpatch --strict is clean. I haven't rebuilt aurora.ko or rerun this on the J815 in this form, so it stays a draft until I do.

@m0d16l14n1

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr out of draft (#1611 follow-up). On the J815, pstate stays valid across the ~95 power gates per second under load (36/36 records), and busy_ns tracks fdinfo engine time. Green and mergeable; please review.

Assisted-by: Claude Opus 5.5

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