From e962ea203443d0ca1b8971f1f590143286f06423 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Fri, 6 Nov 2026 18:23:56 -0500 Subject: [PATCH] drm/asahi: g17: Wait for producers on the host without the G17D forms Without the G17D forms, an M5 compute kick's implicit parent is pipelined: the next kick on a ring may start while its predecessor still runs. The M5 Max needs it that way; with the G17D forms' completion parent its compute kicks never complete. Converting a compute input fence into ring order therefore let a consumer run alongside its producer on the same queue. Leaving other-engine producers to firmware waits also lost devices to submission timeouts under load. On those boards, keep compute inputs as completion fences, and wait on the host for other-engine producers to complete, checking their errors before publication. Boards with the G17D forms keep their firmware dependencies. On the M5 Max, three synchronization2 multi-queue cases returned incorrect memory contents on every run, and the 17,073-case CTS sample recorded 17 job timeouts. With this change, 195 repeats of 65 previously failing synchronization cases pass, and three samples record no job timeouts. Disabling only the input conversion still left 24 and 60 timeouts in two samples. Developed with Claude Code. Signed-off-by: Erik Bourget --- drivers/gpu/drm/asahi/g17/job.rs | 4 +++ drivers/gpu/drm/asahi/g17/queue/mod.rs | 31 ++++++++++++++++---- drivers/gpu/drm/asahi/g17/runtime/backend.rs | 3 ++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/asahi/g17/job.rs b/drivers/gpu/drm/asahi/g17/job.rs index c724a2266bb15..9b85de020d24d 100644 --- a/drivers/gpu/drm/asahi/g17/job.rs +++ b/drivers/gpu/drm/asahi/g17/job.rs @@ -315,6 +315,10 @@ pub(crate) trait Backend: Send + Sync { fn supports_submission(&self) -> bool { true } /// Whether this backend's scheduler workers run in their queue creator's cluster (M5). fn creator_cluster_scheduling(&self) -> bool { false } + /// Whether to keep compute input completion waits and wait on the host for other-engine + /// prefix producers: without the G17D forms an M5 kick may start while its ring + /// predecessor still runs. + fn host_producer_waits(&self) -> bool { false } /// The reclaim-safe queue for the scheduler's timeout work, whose handler signals the /// fences of timed-out jobs. fn fence_queue(&self) -> Arc; diff --git a/drivers/gpu/drm/asahi/g17/queue/mod.rs b/drivers/gpu/drm/asahi/g17/queue/mod.rs index 32a7e9e19fd25..b750313faa76a 100644 --- a/drivers/gpu/drm/asahi/g17/queue/mod.rs +++ b/drivers/gpu/drm/asahi/g17/queue/mod.rs @@ -225,7 +225,11 @@ impl Queue { if engine == Engine::Compute { super::trace::inputs(self.context.id(), order.sequence, 0, inputs.len(), None); } - let sources = if engine == Engine::Compute + // Ring order completes a converted input only if a kick waits for its + // ring predecessor; without that, keep the input's completion wait. + let host_waits = self.backend.host_producer_waits(); + let sources = if !host_waits + && engine == Engine::Compute && !inputs.is_empty() && !destinations.has_outputs() && self.frontiers[0].iter().all(|(sequence, fences)| { @@ -325,9 +329,17 @@ impl Queue { inputs.len() + count + timestamp_count + failure_count, GFP_KERNEL, )?; - let mut checked_inputs = - KVec::with_capacity(inputs.len() + timestamp_count + failure_count, GFP_KERNEL)?; - let mut firmware = KVec::with_capacity(count, GFP_KERNEL)?; + // Host-waited producers are checked on the host instead of in firmware. + let (host_count, firmware_count) = if host_waits { + (count, 0) + } else { + (0, count) + }; + let mut checked_inputs = KVec::with_capacity( + inputs.len() + host_count + timestamp_count + failure_count, + GFP_KERNEL, + )?; + let mut firmware = KVec::with_capacity(firmware_count, GFP_KERNEL)?; for fence in failures.into_iter().flatten() { checked_inputs.push(fence.clone(), GFP_KERNEL)?; dependencies.push(fence.clone(), GFP_KERNEL)?; @@ -348,8 +360,15 @@ impl Queue { if fences.status() > 0 { continue; } - dependencies.push(fences.ready.clone(), GFP_KERNEL)?; - firmware.push(fences.completed.clone(), GFP_KERNEL)?; + if host_waits { + // Keep other-engine producers on the host until completion, and + // propagate their errors before publishing the consumer. + dependencies.push(fences.completed.clone(), GFP_KERNEL)?; + checked_inputs.push(fences.completed.clone(), GFP_KERNEL)?; + } else { + dependencies.push(fences.ready.clone(), GFP_KERNEL)?; + firmware.push(fences.completed.clone(), GFP_KERNEL)?; + } } // Each command owns every input fence; independent engines may publish in // either order and must each consume an input's error status before running. diff --git a/drivers/gpu/drm/asahi/g17/runtime/backend.rs b/drivers/gpu/drm/asahi/g17/runtime/backend.rs index c83edeef6ba1a..af0e4b801ba99 100644 --- a/drivers/gpu/drm/asahi/g17/runtime/backend.rs +++ b/drivers/gpu/drm/asahi/g17/runtime/backend.rs @@ -121,6 +121,9 @@ impl job::Backend for Backend { fn creator_cluster_scheduling(&self) -> bool { self.shared.follows_submitter() } + fn host_producer_waits(&self) -> bool { + self.shared.m5_board.is_some_and(|board| !board.g17d_forms()) + } fn fence_queue(&self) -> Arc { self.shared.fence_queue() }