[PATCH] drm/amd/display: fix 64 bit divide

Randy Dunlap rdunlap at infradead.org
Wed Nov 24 21:07:55 UTC 2021


On 11/24/21 8:36 AM, Alex Deucher wrote:
> Use do_div.
> 
> Fixes: c34f1652a18c4b ("drm/amd/display: fixed an error related to 4:2:0/4:2:2 DSC")
> Reported-by: kernel test robot <lkp at intel.com>
> Reported-by: Randy Dunlap <rdunlap at infradead.org>
> Cc: Bing Guo <Bing.Guo at amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

Acked-by: Randy Dunlap <rdunlap at infradead.org> # build-tested

Thanks.

> ---
>   drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c b/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
> index 381561ee0026..7e306aa3e2b9 100644
> --- a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
> +++ b/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
> @@ -100,6 +100,7 @@ int dscc_compute_dsc_parameters(const struct drm_dsc_config *pps, struct dsc_par
>   	int              ret;
>   	struct rc_params rc;
>   	struct drm_dsc_config   dsc_cfg;
> +	unsigned long long tmp;
>   
>   	calc_rc_params(&rc, pps);
>   	dsc_params->pps = *pps;
> @@ -111,9 +112,9 @@ int dscc_compute_dsc_parameters(const struct drm_dsc_config *pps, struct dsc_par
>   	dsc_cfg.mux_word_size = dsc_params->pps.bits_per_component <= 10 ? 48 : 64;
>   
>   	ret = drm_dsc_compute_rc_parameters(&dsc_cfg);
> -	dsc_params->bytes_per_pixel =
> -			(uint32_t)(((unsigned long long)dsc_cfg.slice_chunk_size * 0x10000000 + (dsc_cfg.slice_width - 1))
> -							/ (uint32_t)dsc_cfg.slice_width);  //ROUND-UP
> +	tmp = (unsigned long long)dsc_cfg.slice_chunk_size * 0x10000000 + (dsc_cfg.slice_width - 1);
> +	do_div(tmp, (uint32_t)dsc_cfg.slice_width);  //ROUND-UP
> +	dsc_params->bytes_per_pixel = (uint32_t)tmp;
>   
>   	copy_pps_fields(&dsc_params->pps, &dsc_cfg);
>   	dsc_params->rc_buffer_model_size = dsc_cfg.rc_bits;
> 


-- 
~Randy


More information about the amd-gfx mailing list