media: cedrus: Fix SUNXI tile size calculation
Commit Message
Tiled formats requires full rows being allocated (even for Chroma
planes). When the number of Luma tiles is odd, we need to round up
to twice the tile width in order to roundup the number of Chroma
tiles.
This was notice with a crash running BA1_FT_C compliance test using
sunxi tiles using GStreamer. Cedrus driver would allocate 9 rows for
Luma, but only 4.5 rows for Chroma, causing userspace to crash.
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
drivers/staging/media/sunxi/cedrus/cedrus_video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi Nicolas!
Dne četrtek, 19. avgust 2021 ob 16:00:09 CEST je Nicolas Dufresne napisal(a):
> Tiled formats requires full rows being allocated (even for Chroma
> planes). When the number of Luma tiles is odd, we need to round up
> to twice the tile width in order to roundup the number of Chroma
> tiles.
>
> This was notice with a crash running BA1_FT_C compliance test using
> sunxi tiles using GStreamer. Cedrus driver would allocate 9 rows for
> Luma, but only 4.5 rows for Chroma, causing userspace to crash.
>
> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Fixes tag would be nice so it would be picked up for stable branches.
Otherwise it looks good. It also aligns logic with libvdpau-sunxi.
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Best regards,
Jernej
Le jeudi 19 août 2021 à 18:30 +0200, Jernej Škrabec a écrit :
> Hi Nicolas!
>
> Dne četrtek, 19. avgust 2021 ob 16:00:09 CEST je Nicolas Dufresne napisal(a):
> > Tiled formats requires full rows being allocated (even for Chroma
> > planes). When the number of Luma tiles is odd, we need to round up
> > to twice the tile width in order to roundup the number of Chroma
> > tiles.
> >
> > This was notice with a crash running BA1_FT_C compliance test using
> > sunxi tiles using GStreamer. Cedrus driver would allocate 9 rows for
> > Luma, but only 4.5 rows for Chroma, causing userspace to crash.
> >
> > Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
>
> Fixes tag would be nice so it would be picked up for stable branches.
> Otherwise it looks good. It also aligns logic with libvdpau-sunxi.
Sure, I'd say can be merged adding (it was broken since when cedrus was added):
Fixes: 50e761516f2b8 ("media: platform: Add Cedrus VPU decoder driver")
>
> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
>
> Best regards,
> Jernej
>
>
@@ -135,7 +135,7 @@ void cedrus_prepare_format(struct v4l2_pix_format *pix_fmt)
sizeimage = bytesperline * height;
/* Chroma plane size. */
- sizeimage += bytesperline * height / 2;
+ sizeimage += bytesperline * ALIGN(height, 64) / 2;
break;