_dpu_plane_calc_bw() derives three vertical blanking intervals: vbp = mode->vtotal - mode->vsync_end; vpw = mode->vsync_end - mode->vsync_start; vfp = mode->vsync_start - mode->vdisplay; and divides by one of them: hw_latency_lines = catalog->perf->min_prefill_lines; plane_prefill_bw = plane_bw * hw_latency_lines; 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)); else do_div(plane_prefill_bw, hw_latency_lines); Two divisors can be zero. First, 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, as long as 0 < min_prefill_lines, the second branch divides by zero. Such a mode can be supplied through an atomic commit with a crafted mode blob, or through the legacy SETCRTC ioctl; dpu_crtc_mode_valid() only rejects modes that are too large. Second, sc8280xp_perf_data is the only catalog that leaves min_prefill_lines unset. On that platform hw_latency_lines is 0, so the else branch divides by zero whenever vbp+vpw is 0 as well, and normal modes merely compute a prefill bandwidth of 0. Skip the zero-blanking case so it falls back to hw_latency_lines, and return plane_bw directly when min_prefill_lines is unset, since there is no prefill latency budget to scale against on such catalogs. Fixes: 0c3d3cc93811 ("drm/msm/dpu: consider vertical front porch in the prefill bw calculation") Cc: stable@vger.kernel.org Signed-off-by: Shirong Zhao --- v2: - Also handle min_prefill_lines == 0. sc8280xp leaves it unset, so the previous version still divided by zero in the else branch there, as pointed out by Sashiko. Return plane_bw early in that case instead of scaling the prefill bandwidth against a zero budget. drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 8 +++++++- 1 file changed, 7 insertions(+), 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..eef8826 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c @@ -142,11 +142,17 @@ static u64 _dpu_plane_calc_bw(const struct dpu_mdss_cfg *catalog, plane_bw = plane_bit_rate * scale_factor; + /* Some catalogs (e.g. sc8280xp) leave min_prefill_lines unset; there is + * then no prefill latency budget to scale against. + */ + if (!hw_latency_lines) + return plane_bw; + plane_prefill_bw = plane_bw * hw_latency_lines; 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