All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/msm/dpu: avoid division by zero in plane bandwidth calc
@ 2026-12-06  4:27 Shirong Zhao
  2026-12-06  4:43 ` sashiko-bot
  2026-12-06  4:57 ` [PATCH v2] " Shirong Zhao
  0 siblings, 2 replies; 3+ messages in thread
From: Shirong Zhao @ 2026-12-06  4:27 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	dri-devel, linux-arm-msm, stable, Shirong Zhao

_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 <shxzhaosr@163.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-06  4:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-06  4:27 [PATCH] drm/msm/dpu: avoid division by zero in plane bandwidth calc Shirong Zhao
2026-12-06  4:43 ` sashiko-bot
2026-12-06  4:57 ` [PATCH v2] " Shirong Zhao

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.