Message ID | 20200127143009.15677-2-andrzej.p@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Hantro VPU JPEG encoder fixes | expand |
On Mon, 2020-01-27 at 15:30 +0100, Andrzej Pietrasiewicz wrote: > Since (luma/chroma)_qtable is an array of unsigned char, indexing it > returns consecutive byte locations, but we are supposed to read the arrays > in four-byte words. Consequently, we should be pointing > get_unaligned_be32() at consecutive word locations instead. > Ouch! Seems we were too fast on that cleanup. Please add: Cc: stable@vger.kernel.org Fixes: 00c30f42c7595f "media: rockchip vpu: remove some unused vars" Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com> Thanks, Ezequiel > Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> > --- > drivers/staging/media/hantro/hantro_h1_jpeg_enc.c | 9 +++++++-- > drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c | 9 +++++++-- > 2 files changed, 14 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c b/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c > index 938b48d4d3d9..be787a045c7e 100644 > --- a/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c > +++ b/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c > @@ -67,12 +67,17 @@ hantro_h1_jpeg_enc_set_qtable(struct hantro_dev *vpu, > unsigned char *chroma_qtable) > { > u32 reg, i; > + __be32 *luma_qtable_p; > + __be32 *chroma_qtable_p; > + > + luma_qtable_p = (__be32 *)luma_qtable; > + chroma_qtable_p = (__be32 *)chroma_qtable; > > for (i = 0; i < H1_JPEG_QUANT_TABLE_COUNT; i++) { > - reg = get_unaligned_be32(&luma_qtable[i]); > + reg = get_unaligned_be32(&luma_qtable_p[i]); > vepu_write_relaxed(vpu, reg, H1_REG_JPEG_LUMA_QUAT(i)); > > - reg = get_unaligned_be32(&chroma_qtable[i]); > + reg = get_unaligned_be32(&chroma_qtable_p[i]); > vepu_write_relaxed(vpu, reg, H1_REG_JPEG_CHROMA_QUAT(i)); > } > } > diff --git a/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c b/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c > index 067892345b5d..bdb95652d6a8 100644 > --- a/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c > +++ b/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c > @@ -98,12 +98,17 @@ rk3399_vpu_jpeg_enc_set_qtable(struct hantro_dev *vpu, > unsigned char *chroma_qtable) > { > u32 reg, i; > + __be32 *luma_qtable_p; > + __be32 *chroma_qtable_p; > + > + luma_qtable_p = (__be32 *)luma_qtable; > + chroma_qtable_p = (__be32 *)chroma_qtable; > > for (i = 0; i < VEPU_JPEG_QUANT_TABLE_COUNT; i++) { > - reg = get_unaligned_be32(&luma_qtable[i]); > + reg = get_unaligned_be32(&luma_qtable_p[i]); > vepu_write_relaxed(vpu, reg, VEPU_REG_JPEG_LUMA_QUAT(i)); > > - reg = get_unaligned_be32(&chroma_qtable[i]); > + reg = get_unaligned_be32(&chroma_qtable_p[i]); > vepu_write_relaxed(vpu, reg, VEPU_REG_JPEG_CHROMA_QUAT(i)); > } > } > -- > 2.17.1 > >
diff --git a/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c b/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c index 938b48d4d3d9..be787a045c7e 100644 --- a/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c +++ b/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c @@ -67,12 +67,17 @@ hantro_h1_jpeg_enc_set_qtable(struct hantro_dev *vpu, unsigned char *chroma_qtable) { u32 reg, i; + __be32 *luma_qtable_p; + __be32 *chroma_qtable_p; + + luma_qtable_p = (__be32 *)luma_qtable; + chroma_qtable_p = (__be32 *)chroma_qtable; for (i = 0; i < H1_JPEG_QUANT_TABLE_COUNT; i++) { - reg = get_unaligned_be32(&luma_qtable[i]); + reg = get_unaligned_be32(&luma_qtable_p[i]); vepu_write_relaxed(vpu, reg, H1_REG_JPEG_LUMA_QUAT(i)); - reg = get_unaligned_be32(&chroma_qtable[i]); + reg = get_unaligned_be32(&chroma_qtable_p[i]); vepu_write_relaxed(vpu, reg, H1_REG_JPEG_CHROMA_QUAT(i)); } } diff --git a/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c b/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c index 067892345b5d..bdb95652d6a8 100644 --- a/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c +++ b/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c @@ -98,12 +98,17 @@ rk3399_vpu_jpeg_enc_set_qtable(struct hantro_dev *vpu, unsigned char *chroma_qtable) { u32 reg, i; + __be32 *luma_qtable_p; + __be32 *chroma_qtable_p; + + luma_qtable_p = (__be32 *)luma_qtable; + chroma_qtable_p = (__be32 *)chroma_qtable; for (i = 0; i < VEPU_JPEG_QUANT_TABLE_COUNT; i++) { - reg = get_unaligned_be32(&luma_qtable[i]); + reg = get_unaligned_be32(&luma_qtable_p[i]); vepu_write_relaxed(vpu, reg, VEPU_REG_JPEG_LUMA_QUAT(i)); - reg = get_unaligned_be32(&chroma_qtable[i]); + reg = get_unaligned_be32(&chroma_qtable_p[i]); vepu_write_relaxed(vpu, reg, VEPU_REG_JPEG_CHROMA_QUAT(i)); } }
Since (luma/chroma)_qtable is an array of unsigned char, indexing it returns consecutive byte locations, but we are supposed to read the arrays in four-byte words. Consequently, we should be pointing get_unaligned_be32() at consecutive word locations instead. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> --- drivers/staging/media/hantro/hantro_h1_jpeg_enc.c | 9 +++++++-- drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)