scl_cal_scale2() is called unconditionally on the non-ext VOP path (including when src == dst) and scl_cal_scale() on the scale-up/-down path, both dividing by (dst - 1) where dst is the plane destination size. Two reachable cases hit a zero divisor: - dst == 1 is a legal one-pixel destination, so (dst - 1) is 0. This is the extreme down-scale; saturate to 0xffff, the maximum 16-bit factor, like vop2_scale_factor() does for dst < 2. - scl_cal_scale2() also runs when src == dst. The original formula then evaluates to 1 << 12, the fixed-point 1.0 factor for this register (scl_vop_cal_scale() uses 1 << SCL_FT_DEFAULT_FIXPOINT_SHIFT as the no-scale default). Return that value explicitly so a 1x1 plane no longer computes 0 / 0. Note the VOP2 driver encodes 1:1 differently (scale factor 0 together with a separate SCALE_NONE mode register), so its "return 0" for src == dst is not the value to use here; the non-ext VOP has no such mode register and represents 1:1 with 1 << 12. Fixes: 4c156c21c794 ("drm/rockchip: vop: support plane scale") Signed-off-by: Shirong Zhao --- drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h index f04c973..785d28b 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h @@ -355,11 +355,17 @@ enum vop_pol { static inline uint16_t scl_cal_scale(int src, int dst, int shift) { + if (dst < 2) + return 0xffff; return ((src * 2 - 3) << (shift - 1)) / (dst - 1); } static inline uint16_t scl_cal_scale2(int src, int dst) { + if (src == dst) + return 1 << SCL_FT_DEFAULT_FIXPOINT_SHIFT; + if (dst < 2) + return 0xffff; return ((src - 1) << 12) / (dst - 1); } -- 2.53.0