Re: [PATCH 1/4] media: hantro: Read be32 words starting at every fourth byte

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx
Fixes: 00c30f42c7595f "media: rockchip vpu: remove some unused vars"
Reviewed-by: Ezequiel Garcia <ezequiel@xxxxxxxxxxxxx>

Thanks,
Ezequiel

> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxxxx>
> ---
>  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
> 
> 


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux