From 1898f023ac81cfa3561d80d0df3ff3be424ee1a2 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Tue, 1 Dec 2026 07:18:18 -0500 Subject: [PATCH 1/6] drm/asahi: g16: defer idle-to-active housekeeping until flight completion On an idle-to-active submission (!had_flights with a flight published, such as d=1 workloads and sync.signal host after its 200 us spin), submit_locked() previously checked housekeeping_due against the 1 ms HOUSEKEEPING_NS interval and immediately queued poll_now() onto the submitting CPU. Because the new single flight is still executing on the GPU, FAST_POLL_WORK immediately entered poll_step() without retiring anything and ran run_housekeeping() (session.check(), objects.health(), service_power(), auxiliary ring drains) under Shared::state right in the middle of the flight, blocking the incoming EP 0x20 completion and userspace wakeup. Skip the eager housekeeping poll_now() kick when transitioning from idle to active (!had_flights && !flights.is_empty()). submit_locked() already arms the resnap hrtimer (default 100 us, tunable 25-1000 us) and 1-jiffy backup poll, so short d=1 flights complete on EP 0x20 and wake userspace via complete_all() before deferred housekeeping runs. Long flights still service housekeeping on a later poll tick once the 5 ms ACTIVE_HOUSEKEEPING_NS deadline elapses (the first resnap tick can precede that deadline), and active bursts (had_flights) keep the 5 ms ACTIVE_HOUSEKEEPING_NS cadence unchanged. Add a host selftest regression verifying both idle-to-active suppression and idle no-flight housekeeping delivery. Signed-off-by: DjDeveloperr --- drivers/gpu/drm/asahi/g16/poll.rs | 9 +++- .../drivers/gpu/asahi-m4/test-poll-retire.py | 42 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/asahi/g16/poll.rs b/drivers/gpu/drm/asahi/g16/poll.rs index ce210b9b7b382..c7f3f37388762 100644 --- a/drivers/gpu/drm/asahi/g16/poll.rs +++ b/drivers/gpu/drm/asahi/g16/poll.rs @@ -261,7 +261,7 @@ impl Shared { } else { HOUSEKEEPING_NS }; - let housekeeping_due = + let mut housekeeping_due = now.wrapping_sub(firmware.last_housekeeping_ns) >= housekeeping_interval; let was_evented = had_flights && self.evented.swap(false, Ordering::AcqRel); let recovery_pending = firmware.recovery_pending().unwrap_or(true); @@ -325,6 +325,13 @@ impl Shared { firmware.fail_stop(error, done); self.fail_stop(error); } + if !had_flights && !firmware.engine.flights.is_empty() { + // On an idle-to-active transition, let the upcoming EP 0x20 completion (or the + // already-armed `resnap` hrtimer for long flights) drive deferred housekeeping + // after waking userspace instead of kicking an immediate `FAST_POLL_WORK` onto the + // submitter CPU that contends on `Shared::state` while the single flight runs. + housekeeping_due = false; + } if !firmware.engine.flights.is_empty() || firmware.engine.chan_wait { // If an EP 0x20 event retired an older flight while later flights remain active, // or arrived before the oldest receipt became visible, arm a short repoll so diff --git a/tools/testing/selftests/drivers/gpu/asahi-m4/test-poll-retire.py b/tools/testing/selftests/drivers/gpu/asahi-m4/test-poll-retire.py index 051f67e54b4d8..50f0a5a08224c 100755 --- a/tools/testing/selftests/drivers/gpu/asahi-m4/test-poll-retire.py +++ b/tools/testing/selftests/drivers/gpu/asahi-m4/test-poll-retire.py @@ -331,6 +331,7 @@ def item(declaration, text=source): drain_compute_delta: u32, coalesce_us: Option, publish_waits: Option<(bool, bool)>, + publish_adds_flight: bool, retire_calls: u32, publish_full_calls: u32, publish_checked_calls: u32, @@ -383,6 +384,7 @@ def item(declaration, text=source): drain_compute_delta: 0, coalesce_us: None, publish_waits: None, + publish_adds_flight: false, retire_calls: 0, publish_full_calls: 0, publish_checked_calls: 0, @@ -454,6 +456,16 @@ def item(declaration, text=source): self.engine.slot_wait = slot_wait; self.engine.held_wait = held_wait; } + if self.publish_adds_flight { + self.engine.flights.push(Flight { + computes: 1, + compute_pipe: 0, + renders: 0, + render_pair: 0, + target: 0x100, + fs_target: 0, + }); + } self.publish_checked_calls += 1; Ok(()) } @@ -705,6 +717,36 @@ def item(declaration, text=source): assert_eq!(shared.rearm_soon.get(), 1); } +#[test] +fn submit_locked_skips_eager_housekeeping_poll_on_idle_to_active_transition() { + // Idle GPU past HOUSEKEEPING_NS (1 ms): publishing a fresh single flight arms resnap + // instead of immediately kicking poll_now() onto the submitter CPU while the flight runs. + CLOCK.with(|c| c.set(3_000_000)); + let shared = Shared::new(); + let mut fw = Firmware::new(); + fw.last_housekeeping_ns = 1_000_000; + fw.publish_adds_flight = true; + + let mut done = vec![]; + shared + .submit_locked(&mut fw, Arc::new(Job { id: 10 }), &mut done) + .unwrap(); + assert_eq!(fw.publish_checked_calls, 1); + assert_eq!(fw.engine.flights.len(), 1); + assert_eq!(shared.rearmed.get(), 1); + assert_eq!(shared.poll_now_calls.get(), 0); + + // If an idle submit publishes no flight while housekeeping is due, poll_now() still runs. + let shared_idle = Shared::new(); + let mut fw_idle = Firmware::new(); + fw_idle.last_housekeeping_ns = 1_000_000; + shared_idle + .submit_locked(&mut fw_idle, Arc::new(Job { id: 11 }), &mut done) + .unwrap(); + assert_eq!(fw_idle.engine.flights.len(), 0); + assert_eq!(shared_idle.poll_now_calls.get(), 1); +} + #[test] fn poll_step_defers_active_housekeeping_until_five_ms_and_off_hot_lock() { let mut fw = Firmware::new(); From 8de982f03b61440c899b8946d41bccc6a5df0cfc Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Tue, 1 Dec 2026 06:30:50 -0500 Subject: [PATCH 2/6] drm/asahi: g16: skip busy coalescing on interleaved compute/render queues can_defer_busy_coalesce() holds a single-queue submission for up to COALESCE_WINDOW_US (18 us) when the queue already has >= 2 commands of that class in flight so consecutive same-class submits fold into one multi-command flight. When the same queue already has active flights of the other engine class (such as single-queue compute/render interleaving in concurrent.cr interleave), the next submit alternates classes and cannot fold, so holding for 18 us only stalls cross-engine overlap. Bypass busy coalescing in can_defer_busy_coalesce() whenever the other engine class is currently active in flights, and extend test-publication.py to cover same-queue interleaved C+R bypass in both directions. Signed-off-by: DjDeveloperr --- drivers/gpu/drm/asahi/g16/engine.rs | 6 +++++- .../drivers/gpu/asahi-m4/test-publication.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/asahi/g16/engine.rs b/drivers/gpu/drm/asahi/g16/engine.rs index 90c3f360c2411..462fffdadb58f 100644 --- a/drivers/gpu/drm/asahi/g16/engine.rs +++ b/drivers/gpu/drm/asahi/g16/engine.rs @@ -1839,6 +1839,7 @@ impl Firmware { || c.is_rt() || head_order.wait_through != [None, None] || !head.fw_waits.is_empty() + || self.engine.flights.iter().any(|fl| fl.renders != 0) || self.compute_queue_is_heavy(&head.queue, now) { return false; @@ -1914,7 +1915,10 @@ impl Firmware { cap > 1 && pending_cmds < cap } Some(Command::Render(_)) => { - if head.resources.render_scs() || !head.fw_waits.is_empty() { + if head.resources.render_scs() + || !head.fw_waits.is_empty() + || self.engine.flights.iter().any(|fl| fl.computes != 0) + { return false; } let queue_active: usize = self diff --git a/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py b/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py index 5464950cbc937..81f83c4287cf4 100644 --- a/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py +++ b/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py @@ -3047,11 +3047,22 @@ def item(declaration): assert_eq!(h.defer_busy_coalesce(425_000), None); h.engine.flights.pop(); + // Same-queue interleaved render active alongside computes bypasses compute coalescing. + let r_same = mk_job(&vm1, &q1, true, 1, [None, None]); + h.engine.flights.push(Flight { job: r_same, computes: 0, renders: 1, compute_pipe: 0, published_ns: 415_000, doomed: false, recovery_suspect: false, initbm: false }); + assert_eq!(h.defer_busy_coalesce(430_000), None); + h.engine.flights.pop(); + // A render with queue_active == 2 coalesces up to K=6 passes before flushing. let r1 = mk_job(&vm1, &q1, true, 1, [None, None]); h.engine.flights = vec![Flight { job: r1, computes: 0, renders: 2, compute_pipe: 0, published_ns: 490_000, doomed: false, recovery_suspect: false, initbm: false }]; h.engine.pending = vec![mk_job(&vm1, &q1, true, 3, [Some(2), None])]; assert_eq!(h.defer_busy_coalesce(500_000), Some(18)); + // Same-queue interleaved compute active alongside renders bypasses render coalescing. + h.engine.flights.push(Flight { job: c1.clone(), computes: 1, renders: 0, compute_pipe: 0, published_ns: 495_000, doomed: false, recovery_suspect: false, initbm: false }); + assert_eq!(h.defer_busy_coalesce(501_000), None); + h.engine.flights.pop(); + assert_eq!(h.defer_busy_coalesce(500_000), Some(18)); for seq in 4..=7 { h.engine.pending.push(mk_job(&vm1, &q1, true, seq, [Some(seq - 1), None])); assert_eq!(h.defer_busy_coalesce(502_000), Some(16)); From 1408ae85c1c4d3b2869de285ee88f1712f328800 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Tue, 1 Dec 2026 07:18:17 -0500 Subject: [PATCH 3/6] drm/asahi: g16: run drm_sched submit workqueue at WQ_HIGHPRI G16 logical queues currently allocate their ordered drm_sched submit workqueue with OwnedQueue::new_ordered_reclaim() (normal nice-0 CFS priority) and unconditionally restrict it to the creating CPU's cluster. When a host-signalled or dependency-blocked submission wakes via drm_sched_entity_wakeup() (such as sync.signal host after DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL), the submit kworker competes at normal CFS priority with busy application threads on the same cluster before running SchedJob::run() and ringing the doorbell. Switch Scheduler::new() to OwnedQueue::new_ordered_highpri_reclaim() (WQ_MEM_RECLAIM | WQ_HIGHPRI) and restrict to the creating CPU's cluster only when cluster.weight() > 1, matching g17/job.rs. Raising worker priority reduces contention with normal-priority threads, though scheduler latency remains possible. Add a host selftest regression executing production Scheduler::new() for both multi-CPU and single-CPU cluster topologies. Signed-off-by: DjDeveloperr --- drivers/gpu/drm/asahi/g16/job.rs | 16 +-- .../drivers/gpu/asahi-m4/test-job-failure.py | 97 ++++++++++++++++++- 2 files changed, 105 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/asahi/g16/job.rs b/drivers/gpu/drm/asahi/g16/job.rs index a5dbc19b7d3e9..c93f52c7f37c7 100644 --- a/drivers/gpu/drm/asahi/g16/job.rs +++ b/drivers/gpu/drm/asahi/g16/job.rs @@ -794,12 +794,16 @@ pub(crate) struct Scheduler { impl Scheduler { pub(crate) fn new(dev: &device::Device) -> Result { - // Keep drm_sched run/free work in the creating CPU's cluster (matching g17/job.rs). - // Completion work still follows the per-submit submitter_cpu, not queue creation, and - // an unbound workqueue restricted via apply_workqueue_attrs() falls back to - // wq_unbound_cpumask if the cluster goes offline (failing soft if restrict() errors). - let submit = workqueue::OwnedQueue::new_ordered_reclaim(c_str!("aurora_g16"))?; - let _ = submit.restrict(Cpumask::cluster_of(CpuId::current())); + // Run drm_sched's submit worker at WQ_HIGHPRI in the creating CPU's cluster (matching + // g17/job.rs) to raise worker priority for host-signalled and dependency-waited jobs + // (scheduler latency remains possible). Completion work still follows submitter_cpu, + // not queue creation, and without a multi-CPU cluster topology the queue stays + // unrestricted rather than pinned to a single CPU. + let submit = workqueue::OwnedQueue::new_ordered_highpri_reclaim(c_str!("aurora_g16"))?; + let cluster = Cpumask::cluster_of(CpuId::current()); + if cluster.weight() > 1 { + let _ = submit.restrict(cluster); + } let scheduler = sched::Scheduler::new_with_queues( dev, 1, diff --git a/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py b/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py index fe6818252cc83..9fc51779231f3 100755 --- a/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py +++ b/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py @@ -35,6 +35,7 @@ def function(text, name): queue_methods = '\n'.join(function(queue_source, name) for name in ['cancel', 'check', 'cancelled_through', 'is_compute_retired']) methods = '\n'.join(function(source, name) for name in ['latch_failure', 'complete', 'finish', 'is_started', 'try_start_inline', 'start', 'check_command_dependencies', 'command_retired', 'note_full_retirement', 'mark_terminal_retired', 'waits_on_queue']) push_method = function_from(source, 'pub(crate) fn push(&mut self, job: Arc') +sched_new_method = function_from(source, 'pub(crate) fn new(dev: &device::Device)') fence_methods = '\n'.join(function(fence_source, name) for name in ['dependency_status', 'check_dependencies', 'wait_dependencies']) harness = r''' #![allow(dead_code)] @@ -638,7 +639,99 @@ def function(text, name): q1.cancel(&p_orders,0); assert_eq!(cons.check_command_dependencies(0),Err(ECANCELED)); } -'''.replace('QUEUE_METHODS', queue_methods).replace('ORDER_SOURCE', order_source).replace('FENCE_METHODS', fence_methods).replace('METHODS', methods.replace('super::fence::','fence::').replace('super::command::','command::')).replace('PUSH_METHOD', push_method) +mod scheduler_new_check { + use core::sync::atomic::{AtomicUsize, Ordering}; + use std::cell::Cell; + use std::sync::{Arc, Mutex}; + type Result = core::result::Result; + const GFP_KERNEL: u32 = 0; + macro_rules! c_str { ($s:expr) => { $s }; } + thread_local! { + static CLUSTER_WEIGHT: Cell = const { Cell::new(4) }; + static HIGHPRI_CALLS: Cell = const { Cell::new(0) }; + static RESTRICT_CALLS: Cell = const { Cell::new(0) }; + } + mod device { pub struct Device; } + mod hw { + pub mod sizes { pub const SCHEDULER_CREDITS: u32 = 64; } + pub mod tuning { pub const SCHED_TIMEOUT_MS: u32 = 1000; } + } + struct CpuId; + impl CpuId { fn current() -> Self { Self } } + struct Cpumask(u32); + impl Cpumask { + fn cluster_of(_cpu: CpuId) -> Self { Self(CLUSTER_WEIGHT.with(Cell::get)) } + fn weight(&self) -> u32 { self.0 } + } + mod workqueue { + use super::*; + pub struct OwnedQueue; + impl OwnedQueue { + pub fn new_ordered_highpri_reclaim(_name: &str) -> Result { + HIGHPRI_CALLS.with(|c| c.set(c.get() + 1)); + Ok(Self) + } + pub fn restrict(&self, _mask: Cpumask) -> Result { + RESTRICT_CALLS.with(|c| c.set(c.get() + 1)); + Ok(()) + } + } + } + mod sched { + use super::*; + pub enum Priority { Kernel } + pub struct Scheduler(core::marker::PhantomData); + impl Scheduler { + pub fn new_with_queues( + _dev: &device::Device, + _rqs: u32, + _credits: u32, + _hang: u32, + _timeout: u32, + _name: &str, + submit: Option, + _timeout_wq: Option, + ) -> Result { + assert!(submit.is_some()); + Ok(Self(core::marker::PhantomData)) + } + } + pub struct Entity(core::marker::PhantomData); + impl Entity { + pub fn new(_s: &Scheduler, _p: Priority) -> Result { + Ok(Self(core::marker::PhantomData)) + } + } + } + struct SchedJob; + struct Scheduler { + entity: sched::Entity, + _scheduler: sched::Scheduler, + pending_sched: Arc, + } + struct ArcNew; + trait ArcExt { fn new_gfp(v: T, _gfp: u32) -> Result>; } + impl ArcExt for Arc { fn new_gfp(v: T, _gfp: u32) -> Result> { Ok(Arc::new(v)) } } + impl Scheduler { + SCHED_NEW_METHOD + } + #[test] + fn scheduler_new_uses_highpri_ordered_wq_and_restricts_only_multicpu_clusters() { + HIGHPRI_CALLS.with(|c| c.set(0)); + RESTRICT_CALLS.with(|c| c.set(0)); + CLUSTER_WEIGHT.with(|c| c.set(4)); + let _s = Scheduler::new(&device::Device).unwrap(); + assert_eq!(HIGHPRI_CALLS.with(Cell::get), 1); + assert_eq!(RESTRICT_CALLS.with(Cell::get), 1); + + CLUSTER_WEIGHT.with(|c| c.set(1)); + let _s2 = Scheduler::new(&device::Device).unwrap(); + assert_eq!(HIGHPRI_CALLS.with(Cell::get), 2); + assert_eq!(RESTRICT_CALLS.with(Cell::get), 1, "single-CPU cluster stays unrestricted"); + let _ = (Mutex::new(()), ArcNew, Ordering::Relaxed); + } +} +'''.replace('QUEUE_METHODS', queue_methods).replace('ORDER_SOURCE', order_source).replace('FENCE_METHODS', fence_methods).replace('METHODS', methods.replace('super::fence::','fence::').replace('super::command::','command::')).replace('PUSH_METHOD', push_method).replace('SCHED_NEW_METHOD', sched_new_method.replace('Arc::new(', 'Arc::new_gfp(').replace('core::sync::atomic::AtomicUsize', 'AtomicUsize')) with tempfile.TemporaryDirectory(prefix='m4-rust-job-') as directory: directory=pathlib.Path(directory); test=directory/'test.rs'; test.write_text(harness) @@ -649,6 +742,6 @@ def function(text, name): (OUT/'job-failure-host.log').write_text(result.stdout+result.stderr) (OUT/'job-failure-host.json').write_text(json.dumps({ 'source':str(SOURCE),'sha256':hashlib.sha256(SOURCE.read_bytes()).hexdigest(), - 'result':'pass','test_groups':25, + 'result':'pass','test_groups':26, 'limitations':'Production Job methods with host VM/fence mocks; actual DRM scheduler and firmware publication gates require kernel and execution integration validation.' },indent=2)+'\n') From 4fbf8db84b59af450d75f8da76d2a20ca9dae960 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Fri, 4 Dec 2026 18:21:14 -0500 Subject: [PATCH 4/6] drm/asahi: g16: keep housekeeping on the first submit after idle The matched J773g ABBA run found idle.wake d1 wake latency increased by 8.4% at a 20 ms gap. Awake latency matched the control. Restore the previous idle-to-active housekeeping path while keeping the mixed-flight coalescing and high-priority submit worker changes. The poll-retire host fixture passes all 44 remaining cases. The removed case asserted that the idle-to-active path suppressed housekeeping. Signed-off-by: DjDeveloperr --- drivers/gpu/drm/asahi/g16/poll.rs | 9 +--- .../drivers/gpu/asahi-m4/test-poll-retire.py | 42 ------------------- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/drivers/gpu/drm/asahi/g16/poll.rs b/drivers/gpu/drm/asahi/g16/poll.rs index cdef8b33bb759..febd55799998a 100644 --- a/drivers/gpu/drm/asahi/g16/poll.rs +++ b/drivers/gpu/drm/asahi/g16/poll.rs @@ -265,7 +265,7 @@ impl Shared { } else { HOUSEKEEPING_NS }; - let mut housekeeping_due = + let housekeeping_due = now.wrapping_sub(firmware.last_housekeeping_ns) >= housekeeping_interval; let was_evented = had_flights && self.evented.swap(false, Ordering::AcqRel); let recovery_pending = firmware.recovery_pending().unwrap_or(true); @@ -329,13 +329,6 @@ impl Shared { firmware.fail_stop(error, done); self.fail_stop(error); } - if !had_flights && !firmware.engine.flights.is_empty() { - // On an idle-to-active transition, let the upcoming EP 0x20 completion (or the - // already-armed `resnap` hrtimer for long flights) drive deferred housekeeping - // after waking userspace instead of kicking an immediate `FAST_POLL_WORK` onto the - // submitter CPU that contends on `Shared::state` while the single flight runs. - housekeeping_due = false; - } if !firmware.engine.flights.is_empty() || firmware.engine.chan_wait { // If an EP 0x20 event retired an older flight while later flights remain active, // or arrived before the oldest receipt became visible, arm a short repoll so diff --git a/tools/testing/selftests/drivers/gpu/asahi-m4/test-poll-retire.py b/tools/testing/selftests/drivers/gpu/asahi-m4/test-poll-retire.py index 0dfa56288aeaa..d3f05b4c7147f 100755 --- a/tools/testing/selftests/drivers/gpu/asahi-m4/test-poll-retire.py +++ b/tools/testing/selftests/drivers/gpu/asahi-m4/test-poll-retire.py @@ -331,7 +331,6 @@ def item(declaration, text=source): drain_compute_delta: u32, coalesce_us: Option, publish_waits: Option<(bool, bool)>, - publish_adds_flight: bool, retire_calls: u32, publish_full_calls: u32, publish_checked_calls: u32, @@ -384,7 +383,6 @@ def item(declaration, text=source): drain_compute_delta: 0, coalesce_us: None, publish_waits: None, - publish_adds_flight: false, retire_calls: 0, publish_full_calls: 0, publish_checked_calls: 0, @@ -456,16 +454,6 @@ def item(declaration, text=source): self.engine.slot_wait = slot_wait; self.engine.held_wait = held_wait; } - if self.publish_adds_flight { - self.engine.flights.push(Flight { - computes: 1, - compute_pipe: 0, - renders: 0, - render_pair: 0, - target: 0x100, - fs_target: 0, - }); - } self.publish_checked_calls += 1; Ok(()) } @@ -717,36 +705,6 @@ def item(declaration, text=source): assert_eq!(shared.rearm_soon.get(), 1); } -#[test] -fn submit_locked_skips_eager_housekeeping_poll_on_idle_to_active_transition() { - // Idle GPU past HOUSEKEEPING_NS (1 ms): publishing a fresh single flight arms resnap - // instead of immediately kicking poll_now() onto the submitter CPU while the flight runs. - CLOCK.with(|c| c.set(3_000_000)); - let shared = Shared::new(); - let mut fw = Firmware::new(); - fw.last_housekeeping_ns = 1_000_000; - fw.publish_adds_flight = true; - - let mut done = vec![]; - shared - .submit_locked(&mut fw, Arc::new(Job { id: 10 }), &mut done) - .unwrap(); - assert_eq!(fw.publish_checked_calls, 1); - assert_eq!(fw.engine.flights.len(), 1); - assert_eq!(shared.rearmed.get(), 1); - assert_eq!(shared.poll_now_calls.get(), 0); - - // If an idle submit publishes no flight while housekeeping is due, poll_now() still runs. - let shared_idle = Shared::new(); - let mut fw_idle = Firmware::new(); - fw_idle.last_housekeeping_ns = 1_000_000; - shared_idle - .submit_locked(&mut fw_idle, Arc::new(Job { id: 11 }), &mut done) - .unwrap(); - assert_eq!(fw_idle.engine.flights.len(), 0); - assert_eq!(shared_idle.poll_now_calls.get(), 1); -} - #[test] fn poll_step_defers_active_housekeeping_until_five_ms_and_off_hot_lock() { let mut fw = Firmware::new(); From cfc9f1fd945885d2fb398cf22bca7b170653cc44 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Sat, 5 Dec 2026 14:27:42 -0500 Subject: [PATCH 5/6] drm/asahi: g16: preserve the G15 mixed-submit scheduling path Keep mixed render and compute coalescing and scheduler workqueue selection unchanged on G15. Apply the short-submit changes from G16 onward, and exercise both scheduling paths in the host fixtures. Signed-off-by: DjDeveloperr --- drivers/gpu/drm/asahi/g16/engine.rs | 5 +-- drivers/gpu/drm/asahi/g16/job.rs | 18 ++++++----- drivers/gpu/drm/asahi/g16/queue.rs | 2 +- tools/asahi/g16-vm-share-tests.py | 2 +- .../drivers/gpu/asahi-m4/test-job-failure.py | 31 ++++++++++++++++--- .../drivers/gpu/asahi-m4/test-publication.py | 17 ++++++++-- 6 files changed, 58 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/asahi/g16/engine.rs b/drivers/gpu/drm/asahi/g16/engine.rs index 4f4848c4988e6..cbb032959bd72 100644 --- a/drivers/gpu/drm/asahi/g16/engine.rs +++ b/drivers/gpu/drm/asahi/g16/engine.rs @@ -1869,13 +1869,14 @@ impl Firmware { let Some(head_order) = head.command_order(head_sent) else { return false; }; + let skip_mixed = self.cfg.gpu_generation >= 16; match command(head, head_sent) { Some(Command::Compute(c)) => { if head.resources.compute_scs() || c.is_rt() || head_order.wait_through != [None, None] || !head.fw_waits.is_empty() - || self.engine.flights.iter().any(|fl| fl.renders != 0) + || (skip_mixed && self.engine.flights.iter().any(|fl| fl.renders != 0)) || self.compute_queue_is_heavy(&head.queue, now) { return false; @@ -1953,7 +1954,7 @@ impl Firmware { Some(Command::Render(_)) => { if head.resources.render_scs() || !head.fw_waits.is_empty() - || self.engine.flights.iter().any(|fl| fl.computes != 0) + || (skip_mixed && self.engine.flights.iter().any(|fl| fl.computes != 0)) { return false; } diff --git a/drivers/gpu/drm/asahi/g16/job.rs b/drivers/gpu/drm/asahi/g16/job.rs index c93f52c7f37c7..8f911e3de5b9b 100644 --- a/drivers/gpu/drm/asahi/g16/job.rs +++ b/drivers/gpu/drm/asahi/g16/job.rs @@ -793,13 +793,17 @@ pub(crate) struct Scheduler { } impl Scheduler { - pub(crate) fn new(dev: &device::Device) -> Result { - // Run drm_sched's submit worker at WQ_HIGHPRI in the creating CPU's cluster (matching - // g17/job.rs) to raise worker priority for host-signalled and dependency-waited jobs - // (scheduler latency remains possible). Completion work still follows submitter_cpu, - // not queue creation, and without a multi-CPU cluster topology the queue stays - // unrestricted rather than pinned to a single CPU. - let submit = workqueue::OwnedQueue::new_ordered_highpri_reclaim(c_str!("aurora_g16"))?; + pub(crate) fn new(dev: &device::Device, highpri_submit: bool) -> Result { + // On G16+ (T8132), run drm_sched's submit worker at WQ_HIGHPRI to cut host-signalled + // and dependency-waited wakeup latency. On G15 (T6030/T6031/T8122), keep the normal + // ordered workqueue so interleaved render/compute submits retain saved cadence. + // Completion work still follows submitter_cpu, not queue creation, and without a + // multi-CPU cluster topology the queue stays unrestricted rather than pinned to one CPU. + let submit = if highpri_submit { + workqueue::OwnedQueue::new_ordered_highpri_reclaim(c_str!("aurora_g16"))? + } else { + workqueue::OwnedQueue::new_ordered_reclaim(c_str!("aurora_g16"))? + }; let cluster = Cpumask::cluster_of(CpuId::current()); if cluster.weight() > 1 { let _ = submit.restrict(cluster); diff --git a/drivers/gpu/drm/asahi/g16/queue.rs b/drivers/gpu/drm/asahi/g16/queue.rs index c73961f039fd8..9589c24883577 100644 --- a/drivers/gpu/drm/asahi/g16/queue.rs +++ b/drivers/gpu/drm/asahi/g16/queue.rs @@ -214,7 +214,7 @@ impl Queue { } let credit = QueueCredit::acquire(&usage)?; let timeline = Timeline::new()?; - let scheduler = Scheduler::new(&gpu.shared.dev)?; + let scheduler = Scheduler::new(&gpu.shared.dev, gpu.cfg.gpu_generation >= 16)?; let state = Arc::new( QueueState { priority, diff --git a/tools/asahi/g16-vm-share-tests.py b/tools/asahi/g16-vm-share-tests.py index 08303f2fa19f2..337cc814b2fe6 100755 --- a/tools/asahi/g16-vm-share-tests.py +++ b/tools/asahi/g16-vm-share-tests.py @@ -209,7 +209,7 @@ def check_queue_new_binds_vm_last(): for step in ( 'QueueCredit::acquire(&usage)?', 'Timeline::new()?', - 'Scheduler::new(&gpu.shared.dev)?', + 'Scheduler::new(&gpu.shared.dev, gpu.cfg.gpu_generation >= 16)?', 'command::SpanProof::new_boxed()?', ): pos = body.index(step) diff --git a/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py b/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py index 9fc51779231f3..c8e24c071ada8 100755 --- a/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py +++ b/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py @@ -35,7 +35,7 @@ def function(text, name): queue_methods = '\n'.join(function(queue_source, name) for name in ['cancel', 'check', 'cancelled_through', 'is_compute_retired']) methods = '\n'.join(function(source, name) for name in ['latch_failure', 'complete', 'finish', 'is_started', 'try_start_inline', 'start', 'check_command_dependencies', 'command_retired', 'note_full_retirement', 'mark_terminal_retired', 'waits_on_queue']) push_method = function_from(source, 'pub(crate) fn push(&mut self, job: Arc') -sched_new_method = function_from(source, 'pub(crate) fn new(dev: &device::Device)') +sched_new_method = function_from(source, 'pub(crate) fn new(dev: &device::Device, highpri_submit: bool)') fence_methods = '\n'.join(function(fence_source, name) for name in ['dependency_status', 'check_dependencies', 'wait_dependencies']) harness = r''' #![allow(dead_code)] @@ -649,6 +649,7 @@ def function(text, name): thread_local! { static CLUSTER_WEIGHT: Cell = const { Cell::new(4) }; static HIGHPRI_CALLS: Cell = const { Cell::new(0) }; + static NORMAL_CALLS: Cell = const { Cell::new(0) }; static RESTRICT_CALLS: Cell = const { Cell::new(0) }; } mod device { pub struct Device; } @@ -671,6 +672,10 @@ def function(text, name): HIGHPRI_CALLS.with(|c| c.set(c.get() + 1)); Ok(Self) } + pub fn new_ordered_reclaim(_name: &str) -> Result { + NORMAL_CALLS.with(|c| c.set(c.get() + 1)); + Ok(Self) + } pub fn restrict(&self, _mask: Cpumask) -> Result { RESTRICT_CALLS.with(|c| c.set(c.get() + 1)); Ok(()) @@ -716,18 +721,36 @@ def function(text, name): SCHED_NEW_METHOD } #[test] - fn scheduler_new_uses_highpri_ordered_wq_and_restricts_only_multicpu_clusters() { + fn scheduler_new_gates_highpri_wq_and_restricts_only_multicpu_clusters() { HIGHPRI_CALLS.with(|c| c.set(0)); + NORMAL_CALLS.with(|c| c.set(0)); RESTRICT_CALLS.with(|c| c.set(0)); + + // G16+ path: WQ_HIGHPRI on multi-CPU cluster restricts to cluster; single-CPU stays unrestricted. CLUSTER_WEIGHT.with(|c| c.set(4)); - let _s = Scheduler::new(&device::Device).unwrap(); + let _s = Scheduler::new(&device::Device, true).unwrap(); assert_eq!(HIGHPRI_CALLS.with(Cell::get), 1); + assert_eq!(NORMAL_CALLS.with(Cell::get), 0); assert_eq!(RESTRICT_CALLS.with(Cell::get), 1); CLUSTER_WEIGHT.with(|c| c.set(1)); - let _s2 = Scheduler::new(&device::Device).unwrap(); + let _s2 = Scheduler::new(&device::Device, true).unwrap(); assert_eq!(HIGHPRI_CALLS.with(Cell::get), 2); + assert_eq!(NORMAL_CALLS.with(Cell::get), 0); assert_eq!(RESTRICT_CALLS.with(Cell::get), 1, "single-CPU cluster stays unrestricted"); + + // G15 (J516s) path: keeps saved normal-priority ordered reclaim queue. + CLUSTER_WEIGHT.with(|c| c.set(6)); + let _s3 = Scheduler::new(&device::Device, false).unwrap(); + assert_eq!(HIGHPRI_CALLS.with(Cell::get), 2); + assert_eq!(NORMAL_CALLS.with(Cell::get), 1); + assert_eq!(RESTRICT_CALLS.with(Cell::get), 2); + + CLUSTER_WEIGHT.with(|c| c.set(1)); + let _s4 = Scheduler::new(&device::Device, false).unwrap(); + assert_eq!(HIGHPRI_CALLS.with(Cell::get), 2); + assert_eq!(NORMAL_CALLS.with(Cell::get), 2); + assert_eq!(RESTRICT_CALLS.with(Cell::get), 2, "single-CPU cluster stays unrestricted"); let _ = (Mutex::new(()), ArcNew, Ordering::Relaxed); } } diff --git a/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py b/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py index 7ba762418125b..03d9a8d2921a2 100644 --- a/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py +++ b/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py @@ -3095,7 +3095,9 @@ def item(declaration): impl Slots { fn free_compute_in_mask_for_pipe(&self, _m: u64, _p: usize) -> u32 { self.free_c } } + struct Cfg { gpu_generation: u32 } struct Host { + cfg: Cfg, recovery: Recovery, engine: Engine, slots: Slots, @@ -3128,6 +3130,7 @@ def item(declaration): let q2 = Queue::new(0, 2); let c1 = mk_job(&vm1, &q1, false, 1, [None, None]); let mut h = Host { + cfg: Cfg { gpu_generation: 16 }, recovery: Recovery { error: None, publication_wait_deadline: None }, engine: Engine { flights: vec![Flight { job: c1.clone(), computes: 1, renders: 0, compute_pipe: 0, published_ns: 90_000, doomed: false, recovery_suspect: false, initbm: false }], @@ -3193,10 +3196,15 @@ def item(declaration): assert_eq!(h.defer_busy_coalesce(425_000), None); h.engine.flights.pop(); - // Same-queue interleaved render active alongside computes bypasses compute coalescing. + // Same-queue interleaved render active alongside computes bypasses compute coalescing on G16+, + // while G15 keeps the saved coalescing path. let r_same = mk_job(&vm1, &q1, true, 1, [None, None]); h.engine.flights.push(Flight { job: r_same, computes: 0, renders: 1, compute_pipe: 0, published_ns: 415_000, doomed: false, recovery_suspect: false, initbm: false }); assert_eq!(h.defer_busy_coalesce(430_000), None); + h.cfg.gpu_generation = 15; + assert_eq!(h.defer_busy_coalesce(431_000), Some(18)); + h.engine.coalesce_deadline_ns = 0; + h.cfg.gpu_generation = 16; h.engine.flights.pop(); // A render with queue_active == 2 coalesces up to K=6 passes before flushing. @@ -3204,9 +3212,14 @@ def item(declaration): h.engine.flights = vec![Flight { job: r1, computes: 0, renders: 2, compute_pipe: 0, published_ns: 490_000, doomed: false, recovery_suspect: false, initbm: false }]; h.engine.pending = vec![mk_job(&vm1, &q1, true, 3, [Some(2), None])]; assert_eq!(h.defer_busy_coalesce(500_000), Some(18)); - // Same-queue interleaved compute active alongside renders bypasses render coalescing. + // Same-queue interleaved compute active alongside renders bypasses render coalescing on G16+, + // while G15 keeps the saved coalescing path. h.engine.flights.push(Flight { job: c1.clone(), computes: 1, renders: 0, compute_pipe: 0, published_ns: 495_000, doomed: false, recovery_suspect: false, initbm: false }); assert_eq!(h.defer_busy_coalesce(501_000), None); + h.cfg.gpu_generation = 15; + assert_eq!(h.defer_busy_coalesce(502_000), Some(18)); + h.engine.coalesce_deadline_ns = 0; + h.cfg.gpu_generation = 16; h.engine.flights.pop(); assert_eq!(h.defer_busy_coalesce(500_000), Some(18)); for seq in 4..=7 { From 8738b49678828af7ad0f45297227c30ccfc4e524 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Sat, 5 Dec 2026 17:06:39 -0500 Subject: [PATCH 6/6] drm/asahi: g16: drop generation gate and avoid submit/event pool collision Remove the gpu_generation >= 16 gate from mixed-engine busy coalescing and the WQ_HIGHPRI submit workqueue, and stop calling submit.restrict() on the per-queue drm_sched submit workqueue. Root cause on J516s (T6030, G15S B1): - kernel/workqueue.c clears attrs->ordered in wqattrs_clear_for_pool() before hashing unbound pools by (nice, affn_strict, __pod_cpumask, cpumask). - Giving the ordered submit queue `aurora_g16` WQ_HIGHPRI (nice=-20) while calling submit.restrict(cluster) made it collide with the exact same per-cluster unbound worker_pools used by `aurora_g16_events_unbound` (nice=-20, cluster-restricted). - Persistent E-core desktop DRM clients keep the E-cluster nice=-20 pool alive; on transition from render_only to interleave, completion work on that shared pool woke unpinned gpubench-vk onto an E-core via wake-affine and kept it there (+8.2% on concurrent.cr interleave d4), even though `aurora_g16` itself executed 0 queued work items (inline submit handled 100% of steady-state pushes). - Leaving `aurora_g16` unrestricted keeps it on default cache-affinity unbound pods, disjoint from `aurora_g16_events_unbound`'s cluster pools, eliminating the J516s regression without any chip/generation gate while keeping both skip_mixed and WQ_HIGHPRI active across all G15+ GPUs. Signed-off-by: DjDeveloperr --- drivers/gpu/drm/asahi/g16/engine.rs | 5 ++- drivers/gpu/drm/asahi/g16/job.rs | 26 ++++++--------- drivers/gpu/drm/asahi/g16/queue.rs | 2 +- tools/asahi/g16-vm-share-tests.py | 2 +- .../drivers/gpu/asahi-m4/test-job-failure.py | 32 ++++++------------- .../drivers/gpu/asahi-m4/test-publication.py | 17 ++-------- 6 files changed, 25 insertions(+), 59 deletions(-) diff --git a/drivers/gpu/drm/asahi/g16/engine.rs b/drivers/gpu/drm/asahi/g16/engine.rs index cbb032959bd72..4f4848c4988e6 100644 --- a/drivers/gpu/drm/asahi/g16/engine.rs +++ b/drivers/gpu/drm/asahi/g16/engine.rs @@ -1869,14 +1869,13 @@ impl Firmware { let Some(head_order) = head.command_order(head_sent) else { return false; }; - let skip_mixed = self.cfg.gpu_generation >= 16; match command(head, head_sent) { Some(Command::Compute(c)) => { if head.resources.compute_scs() || c.is_rt() || head_order.wait_through != [None, None] || !head.fw_waits.is_empty() - || (skip_mixed && self.engine.flights.iter().any(|fl| fl.renders != 0)) + || self.engine.flights.iter().any(|fl| fl.renders != 0) || self.compute_queue_is_heavy(&head.queue, now) { return false; @@ -1954,7 +1953,7 @@ impl Firmware { Some(Command::Render(_)) => { if head.resources.render_scs() || !head.fw_waits.is_empty() - || (skip_mixed && self.engine.flights.iter().any(|fl| fl.computes != 0)) + || self.engine.flights.iter().any(|fl| fl.computes != 0) { return false; } diff --git a/drivers/gpu/drm/asahi/g16/job.rs b/drivers/gpu/drm/asahi/g16/job.rs index 8f911e3de5b9b..5e40081fd2e41 100644 --- a/drivers/gpu/drm/asahi/g16/job.rs +++ b/drivers/gpu/drm/asahi/g16/job.rs @@ -32,8 +32,6 @@ use core::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use kernel::{ c_str, - cpu::CpuId, - cpumask::Cpumask, device, dma_fence::Fence, drm::sched, @@ -793,21 +791,15 @@ pub(crate) struct Scheduler { } impl Scheduler { - pub(crate) fn new(dev: &device::Device, highpri_submit: bool) -> Result { - // On G16+ (T8132), run drm_sched's submit worker at WQ_HIGHPRI to cut host-signalled - // and dependency-waited wakeup latency. On G15 (T6030/T6031/T8122), keep the normal - // ordered workqueue so interleaved render/compute submits retain saved cadence. - // Completion work still follows submitter_cpu, not queue creation, and without a - // multi-CPU cluster topology the queue stays unrestricted rather than pinned to one CPU. - let submit = if highpri_submit { - workqueue::OwnedQueue::new_ordered_highpri_reclaim(c_str!("aurora_g16"))? - } else { - workqueue::OwnedQueue::new_ordered_reclaim(c_str!("aurora_g16"))? - }; - let cluster = Cpumask::cluster_of(CpuId::current()); - if cluster.weight() > 1 { - let _ = submit.restrict(cluster); - } + pub(crate) fn new(dev: &device::Device) -> Result { + // Run drm_sched's submit worker at WQ_HIGHPRI to cut host-signalled and + // dependency-waited wakeup latency. Do not restrict() this queue to a CPU cluster: + // kernel/workqueue.c clears `ordered` in wqattrs_clear_for_pool() before hashing + // unbound pools by (nice, affn_strict, __pod_cpumask, cpumask), so a cluster-restricted + // nice=-20 submit queue collides with `aurora_g16_events_unbound`'s per-cluster worker + // pools and lets background clients on another cluster pin unpinned submitters across + // clusters via wake-affine. + let submit = workqueue::OwnedQueue::new_ordered_highpri_reclaim(c_str!("aurora_g16"))?; let scheduler = sched::Scheduler::new_with_queues( dev, 1, diff --git a/drivers/gpu/drm/asahi/g16/queue.rs b/drivers/gpu/drm/asahi/g16/queue.rs index 9589c24883577..c73961f039fd8 100644 --- a/drivers/gpu/drm/asahi/g16/queue.rs +++ b/drivers/gpu/drm/asahi/g16/queue.rs @@ -214,7 +214,7 @@ impl Queue { } let credit = QueueCredit::acquire(&usage)?; let timeline = Timeline::new()?; - let scheduler = Scheduler::new(&gpu.shared.dev, gpu.cfg.gpu_generation >= 16)?; + let scheduler = Scheduler::new(&gpu.shared.dev)?; let state = Arc::new( QueueState { priority, diff --git a/tools/asahi/g16-vm-share-tests.py b/tools/asahi/g16-vm-share-tests.py index 337cc814b2fe6..08303f2fa19f2 100755 --- a/tools/asahi/g16-vm-share-tests.py +++ b/tools/asahi/g16-vm-share-tests.py @@ -209,7 +209,7 @@ def check_queue_new_binds_vm_last(): for step in ( 'QueueCredit::acquire(&usage)?', 'Timeline::new()?', - 'Scheduler::new(&gpu.shared.dev, gpu.cfg.gpu_generation >= 16)?', + 'Scheduler::new(&gpu.shared.dev)?', 'command::SpanProof::new_boxed()?', ): pos = body.index(step) diff --git a/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py b/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py index c8e24c071ada8..d5fd7b72eab27 100755 --- a/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py +++ b/tools/testing/selftests/drivers/gpu/asahi-m4/test-job-failure.py @@ -35,7 +35,7 @@ def function(text, name): queue_methods = '\n'.join(function(queue_source, name) for name in ['cancel', 'check', 'cancelled_through', 'is_compute_retired']) methods = '\n'.join(function(source, name) for name in ['latch_failure', 'complete', 'finish', 'is_started', 'try_start_inline', 'start', 'check_command_dependencies', 'command_retired', 'note_full_retirement', 'mark_terminal_retired', 'waits_on_queue']) push_method = function_from(source, 'pub(crate) fn push(&mut self, job: Arc') -sched_new_method = function_from(source, 'pub(crate) fn new(dev: &device::Device, highpri_submit: bool)') +sched_new_method = function_from(source, 'pub(crate) fn new(dev: &device::Device)') fence_methods = '\n'.join(function(fence_source, name) for name in ['dependency_status', 'check_dependencies', 'wait_dependencies']) harness = r''' #![allow(dead_code)] @@ -721,37 +721,25 @@ def function(text, name): SCHED_NEW_METHOD } #[test] - fn scheduler_new_gates_highpri_wq_and_restricts_only_multicpu_clusters() { + fn scheduler_new_uses_unrestricted_highpri_wq() { HIGHPRI_CALLS.with(|c| c.set(0)); NORMAL_CALLS.with(|c| c.set(0)); RESTRICT_CALLS.with(|c| c.set(0)); - // G16+ path: WQ_HIGHPRI on multi-CPU cluster restricts to cluster; single-CPU stays unrestricted. - CLUSTER_WEIGHT.with(|c| c.set(4)); - let _s = Scheduler::new(&device::Device, true).unwrap(); + // Submit queue uses WQ_HIGHPRI unconditionally without restrict(), keeping its + // unbound worker pool disjoint from aurora_g16_events_unbound's cluster-restricted pools. + CLUSTER_WEIGHT.with(|c| c.set(6)); + let _s = Scheduler::new(&device::Device).unwrap(); assert_eq!(HIGHPRI_CALLS.with(Cell::get), 1); assert_eq!(NORMAL_CALLS.with(Cell::get), 0); - assert_eq!(RESTRICT_CALLS.with(Cell::get), 1); + assert_eq!(RESTRICT_CALLS.with(Cell::get), 0, "submit wq must not share cluster-restricted pools"); CLUSTER_WEIGHT.with(|c| c.set(1)); - let _s2 = Scheduler::new(&device::Device, true).unwrap(); + let _s2 = Scheduler::new(&device::Device).unwrap(); assert_eq!(HIGHPRI_CALLS.with(Cell::get), 2); assert_eq!(NORMAL_CALLS.with(Cell::get), 0); - assert_eq!(RESTRICT_CALLS.with(Cell::get), 1, "single-CPU cluster stays unrestricted"); - - // G15 (J516s) path: keeps saved normal-priority ordered reclaim queue. - CLUSTER_WEIGHT.with(|c| c.set(6)); - let _s3 = Scheduler::new(&device::Device, false).unwrap(); - assert_eq!(HIGHPRI_CALLS.with(Cell::get), 2); - assert_eq!(NORMAL_CALLS.with(Cell::get), 1); - assert_eq!(RESTRICT_CALLS.with(Cell::get), 2); - - CLUSTER_WEIGHT.with(|c| c.set(1)); - let _s4 = Scheduler::new(&device::Device, false).unwrap(); - assert_eq!(HIGHPRI_CALLS.with(Cell::get), 2); - assert_eq!(NORMAL_CALLS.with(Cell::get), 2); - assert_eq!(RESTRICT_CALLS.with(Cell::get), 2, "single-CPU cluster stays unrestricted"); - let _ = (Mutex::new(()), ArcNew, Ordering::Relaxed); + assert_eq!(RESTRICT_CALLS.with(Cell::get), 0); + let _ = (Mutex::new(()), ArcNew, Ordering::Relaxed, CpuId::current(), Cpumask::cluster_of(CpuId::current()).weight()); } } '''.replace('QUEUE_METHODS', queue_methods).replace('ORDER_SOURCE', order_source).replace('FENCE_METHODS', fence_methods).replace('METHODS', methods.replace('super::fence::','fence::').replace('super::command::','command::')).replace('PUSH_METHOD', push_method).replace('SCHED_NEW_METHOD', sched_new_method.replace('Arc::new(', 'Arc::new_gfp(').replace('core::sync::atomic::AtomicUsize', 'AtomicUsize')) diff --git a/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py b/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py index 03d9a8d2921a2..7ba762418125b 100644 --- a/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py +++ b/tools/testing/selftests/drivers/gpu/asahi-m4/test-publication.py @@ -3095,9 +3095,7 @@ def item(declaration): impl Slots { fn free_compute_in_mask_for_pipe(&self, _m: u64, _p: usize) -> u32 { self.free_c } } - struct Cfg { gpu_generation: u32 } struct Host { - cfg: Cfg, recovery: Recovery, engine: Engine, slots: Slots, @@ -3130,7 +3128,6 @@ def item(declaration): let q2 = Queue::new(0, 2); let c1 = mk_job(&vm1, &q1, false, 1, [None, None]); let mut h = Host { - cfg: Cfg { gpu_generation: 16 }, recovery: Recovery { error: None, publication_wait_deadline: None }, engine: Engine { flights: vec![Flight { job: c1.clone(), computes: 1, renders: 0, compute_pipe: 0, published_ns: 90_000, doomed: false, recovery_suspect: false, initbm: false }], @@ -3196,15 +3193,10 @@ def item(declaration): assert_eq!(h.defer_busy_coalesce(425_000), None); h.engine.flights.pop(); - // Same-queue interleaved render active alongside computes bypasses compute coalescing on G16+, - // while G15 keeps the saved coalescing path. + // Same-queue interleaved render active alongside computes bypasses compute coalescing. let r_same = mk_job(&vm1, &q1, true, 1, [None, None]); h.engine.flights.push(Flight { job: r_same, computes: 0, renders: 1, compute_pipe: 0, published_ns: 415_000, doomed: false, recovery_suspect: false, initbm: false }); assert_eq!(h.defer_busy_coalesce(430_000), None); - h.cfg.gpu_generation = 15; - assert_eq!(h.defer_busy_coalesce(431_000), Some(18)); - h.engine.coalesce_deadline_ns = 0; - h.cfg.gpu_generation = 16; h.engine.flights.pop(); // A render with queue_active == 2 coalesces up to K=6 passes before flushing. @@ -3212,14 +3204,9 @@ def item(declaration): h.engine.flights = vec![Flight { job: r1, computes: 0, renders: 2, compute_pipe: 0, published_ns: 490_000, doomed: false, recovery_suspect: false, initbm: false }]; h.engine.pending = vec![mk_job(&vm1, &q1, true, 3, [Some(2), None])]; assert_eq!(h.defer_busy_coalesce(500_000), Some(18)); - // Same-queue interleaved compute active alongside renders bypasses render coalescing on G16+, - // while G15 keeps the saved coalescing path. + // Same-queue interleaved compute active alongside renders bypasses render coalescing. h.engine.flights.push(Flight { job: c1.clone(), computes: 1, renders: 0, compute_pipe: 0, published_ns: 495_000, doomed: false, recovery_suspect: false, initbm: false }); assert_eq!(h.defer_busy_coalesce(501_000), None); - h.cfg.gpu_generation = 15; - assert_eq!(h.defer_busy_coalesce(502_000), Some(18)); - h.engine.coalesce_deadline_ns = 0; - h.cfg.gpu_generation = 16; h.engine.flights.pop(); assert_eq!(h.defer_busy_coalesce(500_000), Some(18)); for seq in 4..=7 {