Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
39 changes: 33 additions & 6 deletions drivers/gpu/drm/asahi/g16/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@ fn plan_render_barriers(
}
}

/// Whether the TA ring's own order already holds TA(N) behind TA(N-1), so that the TA->TA
/// `prev_barrier` of [`plan_render_barriers`] would only re-check a stamp the ring implies.
///
/// Every render's TA work goes on the one firmware TA queue, whose works the firmware runs in
/// ring order: on Metal's TA ring, which carries no barriers, each pass's tiling starts after
/// the previous pass's tiling has ended. A same-VM predecessor shares this render's parameter
/// buffer and UMA slot only through that order. A predecessor of another VM
/// (`cross_vm_prev`, its own UMA slot and the conflict of [`msaa_render_conflict`]) and any
/// InitBM producer or consumer (`producer_initbm`) keep the barrier.
fn ta_ring_orders_prev(cross_vm_prev: bool, producer_initbm: bool) -> bool {
!cross_vm_prev && !producer_initbm
}

/// Engine of the previous member.
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub(crate) enum Prev {
Expand Down Expand Up @@ -435,6 +448,8 @@ struct Prefix {
last_ct: u32,
last_ta: u32,
last_fs: u32,
ta_prev: u64,
ta_order: u64,
}

/// Error provenance must remain independent of errno: EIO can be an ordinary failed VM
Expand Down Expand Up @@ -517,6 +532,9 @@ pub(crate) struct Stats {
pub(crate) job_cmds: u64,
pub(crate) job_max: u64,
pub(crate) early: u64,
/// TA->TA barriers posted, and those the TA ring's order made unnecessary.
pub(crate) ta_prev: u64,
pub(crate) ta_order: u64,
/// Type-0 FS->compute / compute->TA waits.
pub(crate) fs2c0: u64,
pub(crate) c2ta0: u64,
Expand Down Expand Up @@ -3318,6 +3336,8 @@ impl Firmware {
prefix.ta_head,
&mut self.engine.stats.publications[1],
)?;
self.engine.stats.ta_prev += prefix.ta_prev;
self.engine.stats.ta_order += prefix.ta_order;
self.graph.render.qstate[1].w32(qstate::WRITE, prefix.fs_head)?;
} else {
publish_producer(
Expand Down Expand Up @@ -3919,12 +3939,18 @@ impl Firmware {
|| fs_wait_render.is_some_and(|w| w.initbm)
|| ta_wait_fs.is_some_and(|w| w.initbm);
let render_bar = cross_engine_barrier_type(producer_initbm, init_buffer);
// Pipelined renders share TA/FS pipes across same-VM and cross-VM flights, so keep
// the TA(N-1)->TA(N) `prev_barrier` (matching G15) whenever `plan.ta_fs_wait` does not
// already serialize behind `prev_fs`. Emit `ta_fs_barrier` only when `plan.ta_fs_wait`
// names an in-flight FS stamp, and `fs_dep` when `plan.fs_render_wait` names an
// in-flight FS dependency (or cross-VM `prev_fs`) not already dominated by TA.
if plan.ta_prev_wait {
// Pipelined renders share TA/FS pipes across same-VM and cross-VM flights. The plan
// asks for the TA(N-1)->TA(N) `prev_barrier` (matching G15) whenever `plan.ta_fs_wait`
// does not already serialize behind `prev_fs`; it is posted unless the TA ring's own
// order already holds TA(N) behind TA(N-1) (`ta_ring_orders_prev`). Emit
// `ta_fs_barrier` only when `plan.ta_fs_wait` names an in-flight FS stamp, and `fs_dep`
// when `plan.fs_render_wait` names an in-flight FS dependency (or cross-VM `prev_fs`)
// not already dominated by TA.
let ta_ordered = ta_ring_orders_prev(cross_vm_prev, producer_initbm);
if plan.ta_prev_wait && ta_ordered {
pf.ta_order += 1;
}
if plan.ta_prev_wait && !ta_ordered {
let prev = encode::barrier(
r.fw_stamp[0].va,
prev_ta,
Expand All @@ -3936,6 +3962,7 @@ impl Firmware {
p.prev_barrier.write(0, &prev)?;
r.ring[0].w64(8 * pf.ta_head as usize, p.prev_barrier.va)?;
pf.ta_head = (pf.ta_head + 1) % cap;
pf.ta_prev += 1;
}
if let Some(wait_fs) = plan.ta_fs_wait {
let ta_fs = encode::barrier(
Expand Down
8 changes: 6 additions & 2 deletions drivers/gpu/drm/asahi/g16/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,10 +1282,14 @@ pub(crate) mod sizes {
pub(crate) const COALESCE_WINDOW_NS: u64 = (COALESCE_WINDOW_US as u64) * 1000;
/// Per-queue retired CDM execution EWMA threshold (microseconds) at or above which
/// barrier-free compute fans out across both CDM pipes instead of staying 1-pipe affine.
pub(crate) const COMPUTE_HEAVY_EMA_US: u32 = 200;
/// Light dispatches, a few tens of microseconds each, stay well below it and keep folding
/// on one pipe; heavy dispatches of about 185 us clear it with room to get faster.
pub(crate) const COMPUTE_HEAVY_EMA_US: u32 = 140;
/// Elapsed wall-clock time (nanoseconds) on a sole active single-command compute flight
/// that immediately classifies the queue as heavy before its first retirement updates EWMA.
pub(crate) const COMPUTE_HEAVY_INFLIGHT_NS: u64 = 180_000;
/// It is the same crossover as [`COMPUTE_HEAVY_EMA_US`], so a queue the probe promotes
/// stays heavy once its retired dispatches feed the EWMA.
pub(crate) const COMPUTE_HEAVY_INFLIGHT_NS: u64 = COMPUTE_HEAVY_EMA_US as u64 * 1000;
/// Jobs admitted to the engine per logical queue: enough to keep deep queues (`d=64`)
/// queued back to back without scheduler backpressure stalls; exact prior-command
/// dependencies still gate each one.
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/asahi/g16/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2265,6 +2265,11 @@ impl Firmware {
self.slots.tilemap_clear_bytes_total()
)?;
writeln!(f, "type0: fs2c {} c2ta {}", s.fs2c0, s.c2ta0)?;
writeln!(
f,
"ta_prev: barriers {} ring_ordered {}",
s.ta_prev, s.ta_order
)?;
write!(f, "horizon:")?;
for n in s.hz.iter() {
write!(f, " {}", n)?;
Expand Down
Loading
Loading