Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: rkvdec: Add required padding

The addresses of two elements of the segmap[][] member are passed to the
hardware which expects 128-bit aligned addresses. However, without this
patch offsetof(struct rkvdec_vp9_priv_tbl, segmap[0]) is an odd number
(2421) but the hardware just ignores the 5 least significant bits of the
address. As a result, the hardware writes the segmentation map to incorrect
locations.

Inserting 11 bytes of padding corrects this situation by making the said
addresses divisible by 16 (i.e. aligned on a 128-bit boundary).

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Fixes: f25709c4ff15 ("media: rkvdec: Add the VP9 backend")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

authored by

Andrzej Pietrasiewicz and committed by
Hans Verkuil
00c47aa8 5b16db4f

+3
+3
drivers/staging/media/rkvdec/rkvdec-vp9.c
··· 84 84 struct rkvdec_vp9_inter_frame_probs inter; 85 85 struct rkvdec_vp9_intra_only_frame_probs intra_only; 86 86 }; 87 + /* 128 bit alignment */ 88 + u8 padding1[11]; 87 89 }; 88 90 89 91 /* Data structure describing auxiliary buffer format. */ ··· 1008 1006 1009 1007 ctx->priv = vp9_ctx; 1010 1008 1009 + BUILD_BUG_ON(sizeof(priv_tbl->probs) % 16); /* ensure probs size is 128-bit aligned */ 1011 1010 priv_tbl = dma_alloc_coherent(rkvdec->dev, sizeof(*priv_tbl), 1012 1011 &vp9_ctx->priv_tbl.dma, GFP_KERNEL); 1013 1012 if (!priv_tbl) {