diff --git a/drivers/gpu/drm/asahi/g17/buffer/target.rs b/drivers/gpu/drm/asahi/g17/buffer/target.rs index bd96ecc9d460e..480e46d8ac9eb 100644 --- a/drivers/gpu/drm/asahi/g17/buffer/target.rs +++ b/drivers/gpu/drm/asahi/g17/buffer/target.rs @@ -35,6 +35,11 @@ const GTP_FIXED_SIZES: [usize; 4] = [0xc00, 0xa00, GTP6_SIZE, 0x80]; const GTP_SLOTS: usize = 64; const GTP6_SIZE: usize = GTP_SLOTS * (((cfg::TVB_MAX_BLOCKS * cfg::TVB_BLOCK_SIZE).div_ceil(0x8000) + 0x17ff) / 24 * 8 + 8); +/// Clustering metadata 2-4 (0x1c948, 0x1c888, 0x16c41/0x1ca40) on GPUs with more than two +/// clusters, at the sizes the M2 Pro/Max path gives them (`hw/t602x.rs` clustering config). +/// Metadata 1 (0x1c920) is sized per target there: [`META1_BLOCK_SIZE`] per block of tiles. +const GTP_MULTI_CLUSTER_SIZES: [usize; 3] = [0xc0 * 16, 0x280 * 16, 0x10 * 128]; +const META1_BLOCK_SIZE: usize = 0x44; /// Per-command geometry, independent of the capacity already allocated. #[derive(Copy, Clone, Debug)] @@ -113,15 +118,38 @@ impl Layout { let mut gtp = [None; 8]; let mut tpc_end = tpc_size; if programs == RegisterPrograms::V25G83 { + // The fixed sizes are the two-cluster M4 Pro's. With four clusters (M4 Max) clustered + // tiling outgrows them: the firmware then never starts a heavy render and kills it as + // no-progress (reason 0). Size them as the M2 Pro/Max path does. + let [meta2, meta3, meta4, meta1] = if clusters > 2 { + let meta1_blocks = aligned(tiles_x, 2)? + .checked_mul(aligned(tiles_y, 4)?) + .and_then(|v| v.checked_mul(utiles)) + .ok_or(EOVERFLOW)? + .div_ceil(0x1980); + [ + GTP_MULTI_CLUSTER_SIZES[0], + GTP_MULTI_CLUSTER_SIZES[1], + // Partial renders need the larger size here too. + GTP_MULTI_CLUSTER_SIZES[2].max(GTP6_SIZE), + aligned( + meta1_blocks.checked_mul(META1_BLOCK_SIZE).ok_or(EOVERFLOW)?, + 0x80, + )? + .max(GTP_FIXED_SIZES[3]), + ] + } else { + GTP_FIXED_SIZES + }; let sizes = [ tpc_size, tilemap_size.checked_mul(64).ok_or(EOVERFLOW)?, if layers > 1 { 0x4000 } else { 0 }, 0, - GTP_FIXED_SIZES[0], - GTP_FIXED_SIZES[1], - GTP_FIXED_SIZES[2], - GTP_FIXED_SIZES[3], + meta2, + meta3, + meta4, + meta1, ]; let mut position = 0; for ((offset, size), alignment) in gtp.iter_mut().zip(sizes).zip(GTP_ALIGNMENTS) {