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
6 changes: 3 additions & 3 deletions drivers/gpu/drm/asahi/g16/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ pub(crate) struct Shared {
pub(crate) next_compute_uma_slot: AtomicU32,
/// Live open VMs currently holding each hardware compute UMA slot (`0..COMPUTE_UMA_SLOTS`).
pub(crate) compute_uma_slot_users: Arc<[AtomicU32; hw::sizes::COMPUTE_UMA_SLOTS]>,
/// Whether any base render pass slot (`0..BASE_RENDER_SLOTS`) has been quarantined.
pub(crate) base_render_quarantined: AtomicBool,
/// Bitmask of permanently quarantined device-wide render pass slots (`0..RENDER_SLOTS`).
pub(crate) quarantined_render_mask: AtomicU64,
/// Bitmask of permanently quarantined device-wide PB/UMA allocator slots (`0..PB_SLOTS`).
pub(crate) quarantined_pb_mask: AtomicU32,
/// Round-robin cursor assigning each rendering VM a `[home, alt]` pair in `0..WARM_PB_SLOTS`.
Expand Down Expand Up @@ -704,7 +704,7 @@ impl Gpu {
quarantined_compute_uma_mask: AtomicU32::new(0),
next_compute_uma_slot: AtomicU32::new(0),
compute_uma_slot_users,
base_render_quarantined: AtomicBool::new(false),
quarantined_render_mask: AtomicU64::new(0),
quarantined_pb_mask: AtomicU32::new(0),
next_pb_slot: AtomicU32::new(0),
active_render_vms,
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/asahi/g16/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,8 +1603,8 @@ impl Firmware {
Ordering::Release,
);
shared
.base_render_quarantined
.store(self.slots.base_render_quarantined(), Ordering::Release);
.quarantined_render_mask
.store(self.slots.quarantined_render_mask(), Ordering::Release);
shared
.quarantined_pb_mask
.store(self.pools.quarantined_mask(), Ordering::Release);
Expand Down
10 changes: 5 additions & 5 deletions drivers/gpu/drm/asahi/g16/pools/lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ impl<const N: usize> Lifetime<N> {
.iter()
.any(|u| matches!(u.state, State::Preparing | State::Published))
}
/// Bitmask of permanently quarantined owners in `0..N.min(32)`.
pub(crate) fn quarantined_mask(&self) -> u32 {
let mut mask = 0u32;
for k in 0..N.min(32) {
/// Bitmask of permanently quarantined owners in `0..N.min(64)`.
pub(crate) fn quarantined_mask(&self) -> u64 {
let mut mask = 0u64;
for k in 0..N.min(64) {
if self.units[k].state == State::Quarantined {
mask |= 1u32 << k;
mask |= 1u64 << k;
}
}
mask
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/asahi/g16/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl Queue {
.load(Ordering::Acquire),
next_compute_uma_slot: &self.shared.next_compute_uma_slot,
compute_uma_slot_users: &self.shared.compute_uma_slot_users,
expand_render_ext: self.shared.base_render_quarantined.load(Ordering::Acquire),
quarantined_render_mask: self.shared.quarantined_render_mask.load(Ordering::Acquire),
quarantined_pb_mask: self.shared.quarantined_pb_mask.load(Ordering::Acquire),
next_pb_slot: &self.shared.next_pb_slot,
active_render_vms: &self.shared.active_render_vms,
Expand Down
47 changes: 42 additions & 5 deletions drivers/gpu/drm/asahi/g16/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,8 +1222,9 @@ pub(crate) struct PrepareHints<'a> {
pub(crate) next_compute_uma_slot: &'a AtomicU32,
/// Live open VMs currently holding each hardware compute UMA slot (`0..COMPUTE_UMA_SLOTS`).
pub(crate) compute_uma_slot_users: &'a Arc<[AtomicU32; super::hw::sizes::COMPUTE_UMA_SLOTS]>,
/// A base render pass slot (`0..BASE_RENDER_SLOTS`) is quarantined: allocate extension slots.
pub(crate) expand_render_ext: bool,
/// Bitmask of permanently quarantined device-wide render pass slots (`0..RENDER_SLOTS`): back
/// extension tiers until enough slots outside it are backed.
pub(crate) quarantined_render_mask: u64,
/// Bitmask of permanently quarantined device-wide PB/UMA allocator slots (`0..PB_SLOTS`).
pub(crate) quarantined_pb_mask: u32,
/// Round-robin cursor assigning a VM's `[home, alt]` base PB/UMA slots in `0..WARM_PB_SLOTS`.
Expand Down Expand Up @@ -1437,6 +1438,29 @@ fn target_render_slots(
target.min(super::hw::sizes::RENDER_SLOTS)
}

/// The fewest backed render pass slots, `backed` or a higher tier's end, of which `want` are not in
/// `quarantined`; when no tier gets there, the fewest that hold the most such slots.
///
/// A quarantined slot is never claimed again: it only stops counting as capacity here. Without
/// this, a VM backed up to a tier whose slots are all quarantined could never render
/// (`Slots::render_exhausted_within`), though higher tiers have free slots.
fn skip_quarantined_render_slots(backed: usize, want: usize, quarantined: u64) -> usize {
if quarantined == 0 {
return backed;
}
let healthy = |n: usize| (0..n).filter(|&k| quarantined & (1u64 << k) == 0).count();
let mut target = backed;
for &(_, end) in &EXT_RENDER_TIERS {
if healthy(target) >= want {
break;
}
if healthy(end) > healthy(target) {
target = end;
}
}
target
}

/// Like [`target_render_slots`], returning `(effective_target, single_vm_target)`.
///
/// When `active_render_vms` reaches Tier 0's pass-slot ceiling (`EXT_RENDER_TIERS[0].1 == 8`)
Expand All @@ -1445,17 +1469,22 @@ fn target_render_slots(
/// keep a warm pass slot without cross-VM full-scrub thrashing. Steady 60/120 Hz single-pass
/// clients stay at `BASE_RENDER_SLOTS`, and `single_vm_target` keeps `PB_HEAP_EXT_TIERS` gated
/// on actual single-VM pass demand so multi-VM light renders do not expand to 256 MiB PB heaps.
///
/// `effective_target` then counts only the slots outside `quarantined` against the live passes,
/// this submission and one displacement slot ([`skip_quarantined_render_slots`]): two slots outside
/// it are enough for one of them to become claimable once the engine drains.
fn target_render_slots_for(
last_render_ns: &mut u64,
render_burst: &mut u32,
now: u64,
render_count: usize,
active_passes: u32,
base_quarantined: bool,
quarantined: u64,
current_slots: usize,
single_vm_slots: usize,
active_render_vms: u32,
) -> (usize, usize) {
let base_quarantined = quarantined & ((1u64 << BASE_RENDER_SLOTS) - 1) != 0;
let single = target_render_slots(
last_render_ns,
render_burst,
Expand All @@ -1479,7 +1508,15 @@ fn target_render_slots_for(
}
}
}
(target.min(super::hw::sizes::RENDER_SLOTS), single)
let live_need = (active_passes as usize)
.saturating_add(render_count)
.saturating_add(1);
let target = skip_quarantined_render_slots(
target.min(super::hw::sizes::RENDER_SLOTS),
live_need,
quarantined,
);
(target, single)
}

pub(crate) struct RenderArena(crate::cleanup::Deferred<RenderInner>);
Expand Down Expand Up @@ -2369,7 +2406,7 @@ impl Cache {
now,
render_count as usize,
active_passes,
hints.expand_render_ext,
hints.quarantined_render_mask,
current_slots,
state.single_vm_render_slots,
active_vms,
Expand Down
10 changes: 4 additions & 6 deletions drivers/gpu/drm/asahi/g16/slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ impl Slots {
}
/// Bitmask of permanently quarantined compute units (`0..COMPUTE_UNITS`).
pub(crate) fn quarantined_compute_mask(&self) -> u32 {
self.compute.lifetime.quarantined_mask()
self.compute.lifetime.quarantined_mask() as u32
}
pub(crate) fn render_exhausted(&self) -> bool {
self.render.lifetime.exhausted()
Expand All @@ -1299,11 +1299,9 @@ impl Slots {
.lifetime
.any_quarantined_within(super::resources::BASE_COMPUTE_UNITS)
}
/// Whether any base render pass slot (`0..BASE_RENDER_SLOTS`) is permanently quarantined.
pub(crate) fn base_render_quarantined(&self) -> bool {
self.render
.lifetime
.any_quarantined_within(super::resources::BASE_RENDER_SLOTS)
/// Bitmask of permanently quarantined render pass slots (`0..RENDER_SLOTS`).
pub(crate) fn quarantined_render_mask(&self) -> u64 {
self.render.lifetime.quarantined_mask()
}
pub(crate) fn lifetime_counts(&self) -> [super::pools::lifetime::Counts; 2] {
[self.compute.lifetime.counts(), self.render.lifetime.counts()]
Expand Down
Loading
Loading