From a308bbdfd59a49387e708c17f8876251d0c3c17d Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Thu, 27 Feb 2025 17:53:10 +0000 Subject: [PATCH] drm: vc4: plane: Avoid using pitch in calculating UBM for SAND The SAND modifier with height 0 is now using the provided pitch as the column stride, but the UBM allocation needs to be done based on the plane width. Recompute the width in these conditions. Signed-off-by: Dave Stevenson --- drivers/gpu/drm/vc4/vc4_plane.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -843,7 +843,14 @@ static size_t vc6_upm_size(const struct { const struct vc4_plane_state *vc4_state = to_vc4_plane_state(state); unsigned int stride = state->fb->pitches[plane]; + u64 base_format_mod = fourcc_mod_broadcom_mod(state->fb->modifier); + if (base_format_mod == DRM_FORMAT_MOD_BROADCOM_SAND128) { + if (state->fb->format->format == DRM_FORMAT_P030) + stride = (ALIGN(state->fb->width, 96) * 4) / 3; + else + stride = ALIGN(state->fb->width, 128); + } /* * TODO: This only works for raster formats, and is sub-optimal * for buffers with a stride aligned on 32 bytes.