_dpu_plane_calc_bw() divides by the vertical blanking total: vbp = mode->vtotal - mode->vsync_end; vpw = mode->vsync_end - mode->vsync_start; vfp = mode->vsync_start - mode->vdisplay; if ((vbp+vpw) > hw_latency_lines) do_div(plane_prefill_bw, (vbp+vpw)); else if ((vbp+vpw+vfp) < hw_latency_lines) do_div(plane_prefill_bw, (vbp+vpw+vfp)); drm_mode_validate_basic() only checks that vsync_start >= vdisplay, vsync_end >= vsync_start and vtotal >= vsync_end, so it accepts a mode where all four are equal. vbp+vpw+vfp is then 0 and, since 0 < min_prefill_lines, the second branch divides by zero (dpu_crtc mode_valid only rejects modes that are too large). Such a mode can be supplied through an atomic commit with a crafted mode blob, or through the legacy SETCRTC ioctl, which also calls drm_mode_validate_driver(). Skip the zero case so it falls back to hw_latency_lines. Fixes: 0c3d3cc93811 ("drm/msm/dpu: consider vertical front porch in the prefill bw calculation") Cc: stable@vger.kernel.org Signed-off-by: Shirong Zhao --- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c index 1a471cd..7a8032e 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c @@ -146,7 +146,7 @@ static u64 _dpu_plane_calc_bw(const struct dpu_mdss_cfg *catalog, if ((vbp+vpw) > hw_latency_lines) do_div(plane_prefill_bw, (vbp+vpw)); - else if ((vbp+vpw+vfp) < hw_latency_lines) + else if ((vbp+vpw+vfp) && (vbp+vpw+vfp) < hw_latency_lines) do_div(plane_prefill_bw, (vbp+vpw+vfp)); else do_div(plane_prefill_bw, hw_latency_lines); -- 2.53.0