Takashi Iwai f71de3
From 448ea5ee473b9a41ec1235217648bd48096dfcf0 Mon Sep 17 00:00:00 2001
Takashi Iwai f71de3
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Takashi Iwai f71de3
Date: Thu, 19 Aug 2021 16:00:09 +0200
Takashi Iwai f71de3
Subject: [PATCH] media: cedrus: Fix SUNXI tile size calculation
Takashi Iwai f71de3
Git-commit: 448ea5ee473b9a41ec1235217648bd48096dfcf0
Takashi Iwai f71de3
Patch-mainline: v5.16-rc1
Takashi Iwai f71de3
References: git-fixes
Takashi Iwai f71de3
Takashi Iwai f71de3
Tiled formats requires full rows being allocated (even for Chroma
Takashi Iwai f71de3
planes). When the number of Luma tiles is odd, we need to round up
Takashi Iwai f71de3
to twice the tile width in order to roundup the number of Chroma
Takashi Iwai f71de3
tiles.
Takashi Iwai f71de3
Takashi Iwai f71de3
This was notice with a crash running BA1_FT_C compliance test using
Takashi Iwai f71de3
sunxi tiles using GStreamer. Cedrus driver would allocate 9 rows for
Takashi Iwai f71de3
Luma, but only 4.5 rows for Chroma, causing userspace to crash.
Takashi Iwai f71de3
Takashi Iwai f71de3
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Takashi Iwai f71de3
Fixes: 50e761516f2b8 ("media: platform: Add Cedrus VPU decoder driver")
Takashi Iwai f71de3
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Takashi Iwai f71de3
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Takashi Iwai f71de3
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Takashi Iwai f71de3
Acked-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai f71de3
Takashi Iwai f71de3
---
Takashi Iwai f71de3
 drivers/staging/media/sunxi/cedrus/cedrus_video.c |    2 +-
Takashi Iwai f71de3
 1 file changed, 1 insertion(+), 1 deletion(-)
Takashi Iwai f71de3
Takashi Iwai f71de3
--- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
Takashi Iwai f71de3
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
Takashi Iwai f71de3
@@ -150,7 +150,7 @@ void cedrus_prepare_format(struct v4l2_p
Takashi Iwai f71de3
 		sizeimage = bytesperline * height;
Takashi Iwai f71de3
 
Takashi Iwai f71de3
 		/* Chroma plane size. */
Takashi Iwai f71de3
-		sizeimage += bytesperline * height / 2;
Takashi Iwai f71de3
+		sizeimage += bytesperline * ALIGN(height, 64) / 2;
Takashi Iwai f71de3
 
Takashi Iwai f71de3
 		break;
Takashi Iwai f71de3
 	}