mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
drm/msm/dpu: change _dpu_plane_calc_bw() to use u64 to avoid overflow
[ Upstream commit95e681ca3b] _dpu_plane_calc_bw() uses integer variables to calculate the bandwidth used during plane bandwidth calculations. However for high resolution displays this overflows easily and leads to below errors [dpu error]crtc83 failed performance check -7 Promote the intermediate variables to u64 to avoid overflow. changes in v2: - change to u64 where actually needed in the math Fixes:c33b7c0389("drm/msm/dpu: add support for clk and bw scaling for display") Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Reported-by: Nia Espera <nespera@igalia.com> Closes: https://gitlab.freedesktop.org/drm/msm/-/issues/32 Tested-by: Nia Espera <nespera@igalia.com> Patchwork: https://patchwork.freedesktop.org/patch/556288/ Link: https://lore.kernel.org/r/20230908012616.20654-1-quic_abhinavk@quicinc.com Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
85ae07d4dc
commit
3f39de2bd1
@@ -158,6 +158,7 @@ static void _dpu_plane_calc_bw(struct drm_plane *plane,
|
|||||||
const struct dpu_format *fmt = NULL;
|
const struct dpu_format *fmt = NULL;
|
||||||
struct dpu_kms *dpu_kms = _dpu_plane_get_kms(plane);
|
struct dpu_kms *dpu_kms = _dpu_plane_get_kms(plane);
|
||||||
int src_width, src_height, dst_height, fps;
|
int src_width, src_height, dst_height, fps;
|
||||||
|
u64 plane_pixel_rate, plane_bit_rate;
|
||||||
u64 plane_prefill_bw;
|
u64 plane_prefill_bw;
|
||||||
u64 plane_bw;
|
u64 plane_bw;
|
||||||
u32 hw_latency_lines;
|
u32 hw_latency_lines;
|
||||||
@@ -180,13 +181,12 @@ static void _dpu_plane_calc_bw(struct drm_plane *plane,
|
|||||||
scale_factor = src_height > dst_height ?
|
scale_factor = src_height > dst_height ?
|
||||||
mult_frac(src_height, 1, dst_height) : 1;
|
mult_frac(src_height, 1, dst_height) : 1;
|
||||||
|
|
||||||
plane_bw =
|
plane_pixel_rate = src_width * mode->vtotal * fps;
|
||||||
src_width * mode->vtotal * fps * fmt->bpp *
|
plane_bit_rate = plane_pixel_rate * fmt->bpp;
|
||||||
scale_factor;
|
|
||||||
|
|
||||||
plane_prefill_bw =
|
plane_bw = plane_bit_rate * scale_factor;
|
||||||
src_width * hw_latency_lines * fps * fmt->bpp *
|
|
||||||
scale_factor * mode->vtotal;
|
plane_prefill_bw = plane_bw * hw_latency_lines;
|
||||||
|
|
||||||
if ((vbp+vpw) > hw_latency_lines)
|
if ((vbp+vpw) > hw_latency_lines)
|
||||||
do_div(plane_prefill_bw, (vbp+vpw));
|
do_div(plane_prefill_bw, (vbp+vpw));
|
||||||
|
|||||||
Reference in New Issue
Block a user