Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions Documentation/ABI/testing/sysfs-driver-asahi-agx-stats
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@ Description:
in other records (see below).
utilisation_status is never unsupported on these
firmwares. Numeric metrics are printed only while
their capability is valid; otherwise their value is
the string unsupported.
their capability is valid. Otherwise utilisation
values read unsupported; pstate and
achieved_frequency_hz read pstate_status (stale,
unavailable or unsupported), and achieved_frequency_hz
reads unsupported for a valid state with no
frequency in the board's table; busy_ns reads stale
when its total stopped and unsupported otherwise.

util_tiler_percent, util_renderer_percent, util_device_percent
Unsigned integer percent (0..100), from tag 0x13
Expand Down Expand Up @@ -186,18 +191,26 @@ Description:
0x13 records of these firmwares carry a timestamp in
24 MHz ticks (words 1 and 2), one every 8 ms on M5
and T6041 (192000 ticks) and every 16 ms on the A18
Pro (384000 ticks). Each record credits
the window since the previous record of its epoch at
its device utilisation. A record more than two
periods after the previous one, or with an earlier
timestamp, only starts a new window, so time the GPU
spent gated is never credited, and a load sparser
than one period reads low. MEASURED on T6050
(J716c): 871 and 863 ms for three 300 ms compute jobs
at full clock (905 and 919 ms of work). MEASURED on
T8140 (J700), 24 traces of GPU stress loads: within
about 20% of the union of the commands' own execution
intervals for loads busy more than half the time.
Pro (384000 ticks), and are credited in
that order at their device utilisation, from both
roles and across power epochs. The driver keeps the
timestamp up to which it has credited busy time; a
record at or before it gets nothing, so no interval
is credited twice. A later record credits the window
since that mark when it is at most two periods, and
only its own period after a longer gap, so time the
GPU spent gated is never credited. Records a power
boundary keeps out of the utilisation average (see
below) still count here; suspend, a real epoch
invalidation's discard and quarantine keep them out.
busy_ns reads stale once a statistics ring is
quarantined. MEASURED on T6050 (J716c): 871 and 863
ms for three 300 ms compute jobs at full clock (905
and 919 ms of work). MEASURED on T8140 (J700), 24
traces of GPU stress loads, with windows that ended
at each power epoch: within about 20% of the union
of the commands' own execution intervals for loads
busy more than half the time.

requested_frequency_hz, power_mw, temperature_raw
Unsupported.
Expand All @@ -219,15 +232,17 @@ Description:
Suspend/resume, restart, statistics-ring quarantine, observed
core gating and teardown end validity. After an epoch boundary,
each ring's already queued records are discarded before new
baselines are accepted. A quarantined statistics ring disables
both roles' exports until reprobe; a trace-ring error does not.
baselines are accepted; where busy_ns is integrated, those a
power boundary kept out still reach it, as described there. A
quarantined statistics ring disables both roles' exports until
reprobe; a trace-ring error does not.

Reads take the device mutex and do not wake the GPU. The
firmware_reports debugfs view retains per-role raw packets,
counts and host monotonic receive times, plus capability status,
policy, timestamp and diagnostic tick deltas. Tick deltas are
never accumulated as GPU busy time. Firmware role streams are
merged in drain order without deduplication.
policy, timestamp and diagnostic tick deltas. The tag 0x10 tick
deltas are never accumulated as GPU busy time. Firmware role
streams are merged in drain order without deduplication.
The diagnostic also identifies the platform device, records the
transport-admitted count and last-admission decision per role/tag,
and shows suspension, queued-record discard and quarantine state.
Expand Down
16 changes: 11 additions & 5 deletions Documentation/gpu/asahi-usage-stats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,17 @@ run on the same backend and decoder and carry more in their statistics ring.
ALU benchmark.
* ``busy_ns``: the utilisation records carry their own timestamps (words 1 and
2, 24 MHz ticks), one every 8 ms on the M5 and T6041 and every 16 ms on the
A18 Pro, so each record closes a window of known length, which is credited at
the record's device utilisation. A record that follows the previous one by
more than two periods, or whose timestamp went back, only starts a new
window: time the GPU spent gated is never credited, and a load sparser than
one period reads low. The total keeps counting across power epochs.
A18 Pro, so each record closes a window of known length, which is credited at the
record's device utilisation. Records are credited in timestamp order, from
both roles and across power epochs: the driver keeps the timestamp up to
which it has counted, and a record at or before it adds nothing. A record
within two periods of that mark closes the window since it; after a longer
gap it closes only its own period, so time the GPU spent gated is never
credited. Under a frame-paced load the cores gate many times a second, often
with one record per power epoch, so the records a power boundary keeps out of
the utilisation average still count here. Suspend, recovery and quarantine
keep them out, and ``busy_ns`` reads ``stale`` once a statistics ring is
quarantined.

The driver asks for full performance while work is in flight, which the
firmware takes as a floor for its state. An A18 Pro at work therefore normally
Expand Down
34 changes: 27 additions & 7 deletions drivers/gpu/drm/asahi/g17/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ use super::fw::{channels::*, initdata::status};
use super::initdata::InitData;
use super::Role;

// The busy-time rebase bound counts the statistics ring's records; `telemetry.rs` repeats the
// ring size so that it builds on its own for the host tests.
const _: () = assert!(super::telemetry::STATISTICS_RING_RECORDS == STATISTICS_SLOTS);

/// Device-control records published since the driver loaded. Counted across firmware
/// restarts, so it only grows.
static CONTROL_PUBLISHED: AtomicU64 = AtomicU64::new(0);
Expand Down Expand Up @@ -180,7 +184,19 @@ impl Rings {
}

pub(super) fn read_statistics(&self, now_ns: u64) -> super::telemetry::Readout {
self.telemetry.read(now_ns, self.max_age_ns)
let mut view = self.telemetry.read(now_ns, self.max_age_ns);
// A quarantined statistics ring adds nothing more: the total is no longer current.
if view.busy_status == super::telemetry::VALID && self.statistics_quarantined() {
view.busy_status = super::telemetry::STALE;
}
view
}

/// Either role's statistics ring is quarantined, which stops both roles' exports.
fn statistics_quarantined(&self) -> bool {
self.quarantined
.iter()
.any(|rings| rings[ReportRing::Statistics as usize])
}

pub(super) fn write_reports(&self, f: &mut kernel::fmt::Formatter<'_>) -> kernel::fmt::Result {
Expand Down Expand Up @@ -211,13 +227,13 @@ impl Rings {
return;
}
let statistics = matches!(ring, ReportRing::Statistics);
let accept = !self.suspended
&& self.statistics_powered
// Suspend, a real invalidation's discard and quarantine keep every record out.
let accept_busy = !self.suspended
&& !self.discard_statistics[role as usize]
&& !self
.quarantined
.iter()
.any(|rings| rings[ReportRing::Statistics as usize]);
&& !self.statistics_quarantined();
// A power boundary also keeps the records before it out of the averaging epoch;
// their own timestamps still place them for busy time (Telemetry::record_busy).
let accept = accept_busy && self.statistics_powered;
if let Err(error) = Self::consume_report(
init,
role,
Expand All @@ -226,6 +242,7 @@ impl Rings {
&mut self.telemetry,
self.max_age_ns,
accept,
accept_busy,
&mut self.statistics_cutoff[role as usize],
) {
self.stop_report(dev, role, ring, error);
Expand Down Expand Up @@ -256,6 +273,7 @@ impl Rings {
telemetry: &mut super::telemetry::Telemetry,
max_age_ns: u64,
accept_statistics: bool,
accept_busy: bool,
statistics_cutoff: &mut Option<u32>,
) -> Result {
let (state, entries, capacity, allowed_types) = ring.geometry(init);
Expand Down Expand Up @@ -295,6 +313,8 @@ impl Rings {
reports.record(role, words, host_ns, allowed_types, admitted);
if admitted {
telemetry.record(&words, host_ns, max_age_ns);
} else if accept_busy {
telemetry.record_busy(&words);
}
}
consumer = (consumer + 1) & (capacity - 1);
Expand Down
Loading
Loading