drm/msm/mdp5: fix 64-bit division in bandwidth calculation
PATCH 1/1 drm/msm/mdp5: fix 64-bit division in bandwidth calculation
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!
--- 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(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c +1 -1
@@ -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;/*
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +4 -1
@@ -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);
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c +1 -1
@@ -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,
include/linux/math.h +13 -0
@@ -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)/**
Signature · 1 line
2.30.2
Quoted 9 lines · Dmitry Baryshkov
Fix undefined symbols errors arising from 64-bit division on 32-bit arm targets. Add 64-bit version of
mult_fracand 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 <[email protected]>
We are reworking now bandwidth management for mdp5, so both the original patch and the fix can be ignored for now.
Quoted 81 lines
--- 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(-)drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c +1
-1@@ -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;/* drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +4
-1@@ -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);drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c +1
-1@@ -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,include/linux/math.h +13
-0@@ -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)/**
Signature · 2 lines
With best wishes Dmitry