Skip to content

Commit 95e681c

Browse files
author
Abhinav Kumar
committed
drm/msm/dpu: change _dpu_plane_calc_bw() to use u64 to avoid overflow
_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: c33b7c0 ("drm/msm/dpu: add support for clk and bw scaling for display") Reviewed-by: Dmitry Baryshkov <[email protected]> Reported-by: Nia Espera <[email protected]> Closes: https://gitlab.freedesktop.org/drm/msm/-/issues/32 Tested-by: Nia Espera <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/556288/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Abhinav Kumar <[email protected]>
1 parent 6a1d4c7 commit 95e681c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ static u64 _dpu_plane_calc_bw(const struct dpu_mdss_cfg *catalog,
119119
struct dpu_sw_pipe_cfg *pipe_cfg)
120120
{
121121
int src_width, src_height, dst_height, fps;
122+
u64 plane_pixel_rate, plane_bit_rate;
122123
u64 plane_prefill_bw;
123124
u64 plane_bw;
124125
u32 hw_latency_lines;
@@ -136,13 +137,12 @@ static u64 _dpu_plane_calc_bw(const struct dpu_mdss_cfg *catalog,
136137
scale_factor = src_height > dst_height ?
137138
mult_frac(src_height, 1, dst_height) : 1;
138139

139-
plane_bw =
140-
src_width * mode->vtotal * fps * fmt->bpp *
141-
scale_factor;
140+
plane_pixel_rate = src_width * mode->vtotal * fps;
141+
plane_bit_rate = plane_pixel_rate * fmt->bpp;
142142

143-
plane_prefill_bw =
144-
src_width * hw_latency_lines * fps * fmt->bpp *
145-
scale_factor * mode->vtotal;
143+
plane_bw = plane_bit_rate * scale_factor;
144+
145+
plane_prefill_bw = plane_bw * hw_latency_lines;
146146

147147
if ((vbp+vpw) > hw_latency_lines)
148148
do_div(plane_prefill_bw, (vbp+vpw));

0 commit comments

Comments
 (0)