From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>,
Abhinav Kumar <abhinavk@codeaurora.org>
Cc: Jonathan Marek <jonathan@marek.ca>,
Stephen Boyd <sboyd@kernel.org>, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org
Subject: Re: [PATCH] drm/msm/mdp5: fix 64-bit division in bandwidth calculation
Date: Thu, 8 Jul 2021 14:53:14 +0300 [thread overview]
Message-ID: <d41cf4c6-0368-75ad-3dcf-561e283a22ec@linaro.org> (raw)
In-Reply-To: <20210622080348.1679589-1-dmitry.baryshkov@linaro.org>
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@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
WARNING: multiple messages have this Message-ID
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>,
Abhinav Kumar <abhinavk@codeaurora.org>
Cc: Jonathan Marek <jonathan@marek.ca>,
Stephen Boyd <sboyd@kernel.org>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
David Airlie <airlied@linux.ie>,
freedreno@lists.freedesktop.org
Subject: Re: [PATCH] drm/msm/mdp5: fix 64-bit division in bandwidth calculation
Date: Thu, 8 Jul 2021 14:53:14 +0300 [thread overview]
Message-ID: <d41cf4c6-0368-75ad-3dcf-561e283a22ec@linaro.org> (raw)
In-Reply-To: <20210622080348.1679589-1-dmitry.baryshkov@linaro.org>
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@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
next prev parent reply other threads:[~2021-07-08 11:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 8:03 [PATCH] drm/msm/mdp5: fix 64-bit division in bandwidth calculation Dmitry Baryshkov
2021-06-22 8:03 ` Dmitry Baryshkov
2021-07-08 11:53 ` Dmitry Baryshkov [this message]
2021-07-08 11:53 ` Dmitry Baryshkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d41cf4c6-0368-75ad-3dcf-561e283a22ec@linaro.org \
--to=dmitry.baryshkov@linaro.org \
--cc=abhinavk@codeaurora.org \
--cc=airlied@linux.ie \
--cc=bjorn.andersson@linaro.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jonathan@marek.ca \
--cc=linux-arm-msm@vger.kernel.org \
--cc=robdclark@gmail.com \
--cc=sboyd@kernel.org \
--cc=sean@poorly.run \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.