From eb051deba958def01753e1b1e224ec35615c2ba0 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sat, 7 Nov 2026 15:44:10 -0500 Subject: [PATCH] drm/asahi: Lay out the M5 Max render context store for four clusters J716C has four clusters, but ContextStore::selected used the two-cluster layout unless the board selected G17D forms. Select the physical cluster count for four-cluster boards as well. This changes the auxiliary and state-stream offsets and the host viewport location; the rounded backing allocation stays the same size. Add compile-time checks for the Max's selected offsets and the surrounding per-render storage layout. On M5 Max with identical Mesa, six full 17,073-case samples across two boots had no recoveries, timeouts, crashes or flakes. Reverting to the two-cluster layout reproduced an MMU recovery in the first full sample. All six 848-case synchronization rounds on the four-cluster build passed. Developed with Claude Code. Signed-off-by: Erik Bourget --- drivers/gpu/drm/asahi/g17/fw/m5/render_registers.rs | 10 +++++++--- drivers/gpu/drm/asahi/g17/queue/render/generation.rs | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/asahi/g17/fw/m5/render_registers.rs b/drivers/gpu/drm/asahi/g17/fw/m5/render_registers.rs index 15e1887cee272..03cbc862b3b19 100644 --- a/drivers/gpu/drm/asahi/g17/fw/m5/render_registers.rs +++ b/drivers/gpu/drm/asahi/g17/fw/m5/render_registers.rs @@ -25,15 +25,19 @@ impl ContextStore { Self { auxiliary, stream, extent: stream + 0x680 * clusters + 0x800 } } - /// `board`'s store: laid out for the G17D's own cluster count with its forms; other boards - /// keep the two-cluster store. + /// The four-cluster Max and G17D use their physical cluster count for the + /// control words and state stream. Other boards keep the two-cluster store. pub(crate) const fn selected(board: &super::initdata::Board) -> Self { - Self::of(if board.g17d_forms() { board.clusters as usize } else { 2 }) + Self::of(if board.g17d_forms() || board.clusters == 4 { + board.clusters as usize + } else { 2 }) } } const _: () = { let two = ContextStore::of(2); assert!(two.auxiliary == 0xc0 && two.stream == 0x980 && two.extent == 0x1e80); + let max = ContextStore::selected(&super::initdata::J716C); + assert!(max.auxiliary == 0x140 && max.stream == 0xfc0 && max.extent == 0x31c0); let eight = ContextStore::of(8); assert!(eight.auxiliary == 0x240 && eight.stream == 0x1c40 && eight.extent == 0x5840); }; diff --git a/drivers/gpu/drm/asahi/g17/queue/render/generation.rs b/drivers/gpu/drm/asahi/g17/queue/render/generation.rs index d03857cc10a56..dcfd7fd7daa95 100644 --- a/drivers/gpu/drm/asahi/g17/queue/render/generation.rs +++ b/drivers/gpu/drm/asahi/g17/queue/render/generation.rs @@ -76,6 +76,9 @@ const _: () = { let two = Layout::m5_for(ContextStore::of(2), true); assert!(two.bytes == 0x10000 && two.status == 0x4000 && two.auxiliary == 0x8000); assert!(matches!(two.viewport, Some(0x9c0))); + let max = Layout::m5(&crate::g17::fw::m5::initdata::J716C); + assert!(max.bytes == 0x10000 && max.status == 0x4000 && max.auxiliary == 0x8000); + assert!(matches!(max.viewport, Some(0x1000))); let eight = Layout::m5_for(ContextStore::of(8), false); assert!(eight.bytes == 0x14000 && eight.status == 0x8000 && eight.auxiliary == 0xc000); };