[PATCH] drm/msm/dpu: fix UV scanlines calculation for YUV UBWC formats

Neil Armstrong posted 1 patch 2 months ago
drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
[PATCH] drm/msm/dpu: fix UV scanlines calculation for YUV UBWC formats
Posted by Neil Armstrong 2 months ago
The UV scanlines is calculated with (height + 1) / 2 unlike
the Y scanlines, add back the correct scanlines calculation
for UBWC YUV formats.

Fixes: 2f3ff6ab8f5c ("drm/msm/dpu: use standard functions in _dpu_format_populate_plane_sizes_ubwc()")
Fixes: ada4a19ed21c ("drm/msm/dpu: rewrite _dpu_format_populate_plane_sizes_ubwc()")
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
index 6e8883dbfad4..590922c4f69b 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
@@ -61,7 +61,7 @@ static int _dpu_format_populate_plane_sizes_ubwc(
 	bool meta = MSM_FORMAT_IS_UBWC(fmt);
 
 	if (MSM_FORMAT_IS_YUV(fmt)) {
-		unsigned int stride, sclines;
+		unsigned int stride, y_sclines, uv_sclines;
 		unsigned int y_tile_width, y_tile_height;
 		unsigned int y_meta_stride, y_meta_scanlines;
 		unsigned int uv_meta_stride, uv_meta_scanlines;
@@ -77,23 +77,25 @@ static int _dpu_format_populate_plane_sizes_ubwc(
 				y_tile_width = 32;
 			}
 
-			sclines = round_up(fb->height, 16);
+			y_sclines = round_up(fb->height, 16);
+			uv_sclines = round_up((fb->height+1)>>1, 16);
 			y_tile_height = 4;
 		} else {
 			stride = round_up(fb->width, 128);
 			y_tile_width = 32;
 
-			sclines = round_up(fb->height, 32);
+			y_sclines = round_up(fb->height, 32);
+			uv_sclines = round_up((fb->height+1)>>1, 32);
 			y_tile_height = 8;
 		}
 
 		layout->plane_pitch[0] = stride;
 		layout->plane_size[0] = round_up(layout->plane_pitch[0] *
-			sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
+			y_sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
 
 		layout->plane_pitch[1] = stride;
 		layout->plane_size[1] = round_up(layout->plane_pitch[1] *
-			sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
+			uv_sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
 
 		if (!meta)
 			return 0;

---
base-commit: 66672af7a095d89f082c5327f3b15bc2f93d558e
change-id: 20260414-topic-sm8x50-msm-dpu1-formats-qc10c-78b3919a715d

Best regards,
--  
Neil Armstrong <neil.armstrong@linaro.org>
Re: [PATCH] drm/msm/dpu: fix UV scanlines calculation for YUV UBWC formats
Posted by Dmitry Baryshkov 1 month ago
On Tue, 14 Apr 2026 17:14:30 +0200, Neil Armstrong wrote:
> The UV scanlines is calculated with (height + 1) / 2 unlike
> the Y scanlines, add back the correct scanlines calculation
> for UBWC YUV formats.

Applied to msm-fixes, thanks!

[1/1] drm/msm/dpu: fix UV scanlines calculation for YUV UBWC formats
      https://gitlab.freedesktop.org/lumag/msm/-/commit/933430f1709b

Best regards,
-- 
With best wishes
Dmitry
Re: [PATCH] drm/msm/dpu: fix UV scanlines calculation for YUV UBWC formats
Posted by Dmitry Baryshkov 2 months ago
On Tue, Apr 14, 2026 at 05:14:30PM +0200, Neil Armstrong wrote:
> The UV scanlines is calculated with (height + 1) / 2 unlike
> the Y scanlines, add back the correct scanlines calculation
> for UBWC YUV formats.
> 
> Fixes: 2f3ff6ab8f5c ("drm/msm/dpu: use standard functions in _dpu_format_populate_plane_sizes_ubwc()")
> Fixes: ada4a19ed21c ("drm/msm/dpu: rewrite _dpu_format_populate_plane_sizes_ubwc()")
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry