[PATCH] drm/msm/mdp5: fix 64-bit division in bandwidth calculation
Dmitry Baryshkov
dmitry.baryshkov at linaro.org
Thu Jul 8 11:53:14 UTC 2021
On 22/06/2021 11:03, Dmitry Baryshkov wrote:
> Fix undefined symbols errors arising from 64-bit division on 32-bit
> arm targets. Add 64-bit version of mult_frac and use it for calculating
> bandwidth.
>
> ERROR: modpost: "__aeabi_ldivmod" [drivers/gpu/drm/msm/msm.ko] undefined!
> ERROR: modpost: "__aeabi_uldivmod" [drivers/gpu/drm/msm/msm.ko] undefined!
>
> Fixes: 7e0230fd096c ("drm/msm/mdp5: provide dynamic bandwidth management")
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>
We are reworking now bandwidth management for mdp5, so both the original
patch and the fix can be ignored for now.
> ---
> drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 2 +-
> drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 5 ++++-
> drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 2 +-
> include/linux/math.h | 13 +++++++++++++
> 4 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
> index a9332078aa13..52724d0a6fea 100644
> --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
> @@ -755,7 +755,7 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
> hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
>
> if (hw_cfg->perf.ab_inefficiency)
> - crtc_bw = mult_frac(crtc_bw, hw_cfg->perf.ab_inefficiency, 100);
> + crtc_bw = mult_frac_ull(crtc_bw, hw_cfg->perf.ab_inefficiency, 100);
> mdp5_cstate->new_crtc_bw = crtc_bw;
>
> /*
> diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
> index 3e1b28d3e41b..85b7093a1218 100644
> --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
> +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
> @@ -301,6 +301,7 @@ static const struct mdp_kms_funcs kms_funcs = {
> void mdp5_kms_set_bandwidth(struct mdp5_kms *mdp5_kms)
> {
> int i;
> + u64 bw;
> u32 full_bw = 0;
> struct drm_crtc *tmp_crtc;
>
> @@ -311,7 +312,9 @@ void mdp5_kms_set_bandwidth(struct mdp5_kms *mdp5_kms)
> if (!tmp_crtc->enabled)
> continue;
>
> - full_bw += Bps_to_icc(to_mdp5_crtc_state(tmp_crtc->state)->new_crtc_bw / mdp5_kms->num_paths);
> + bw = to_mdp5_crtc_state(tmp_crtc->state)->new_crtc_bw;
> + do_div(bw, mdp5_kms->num_paths * 1000); /* Bps_to_icc */
> + full_bw += bw;
> }
>
> DBG("SET BW to %d\n", full_bw);
> diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> index 85275665558b..2ede34177a90 100644
> --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> @@ -191,7 +191,7 @@ static void mdp5_plane_calc_bw(struct drm_plane_state *state, struct drm_crtc_st
> prefill_div = vbp + vpw + vfp;
> #endif
>
> - pstate->plane_bw = max(plane_bw, mult_frac(plane_bw, hw_latency_lines, prefill_div));
> + pstate->plane_bw = max(plane_bw, mult_frac_ull(plane_bw, hw_latency_lines, prefill_div));
> }
>
> static int mdp5_plane_atomic_check_with_state(struct drm_crtc_state *crtc_state,
> diff --git a/include/linux/math.h b/include/linux/math.h
> index 53674a327e39..1327385905df 100644
> --- a/include/linux/math.h
> +++ b/include/linux/math.h
> @@ -118,6 +118,19 @@
> } \
> )
>
> +#define mult_frac_ull(x, numer, denom)( \
> +{ \
> + typeof(x) quot = (x); \
> + typeof(x) rem; \
> + do_div(quot, (denom)); \
> + rem = (x) - quot * (denom); \
> + rem = (rem * (numer)); \
> + do_div(rem, (denom)); \
> + (quot * (numer)) + rem; \
> +} \
> +)
> +
> +
> #define sector_div(a, b) do_div(a, b)
>
> /**
>
--
With best wishes
Dmitry
More information about the dri-devel
mailing list