diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_debugfs.c b/drivers/gpu/drm/rockchip/rockchip_drm_debugfs.c index 723c284a9c53..923bcf3b2aa9 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_debugfs.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_debugfs.c @@ -56,7 +56,7 @@ static int get_afbc_size(uint32_t width, uint32_t height, uint32_t bpp) int rockchip_drm_dump_plane_buffer(struct vop_dump_info *dump_info, int frame_count) { int flags; - int bpp = 32; + int bpp; const char *ptr; char file_name[100]; int width; @@ -70,6 +70,10 @@ int rockchip_drm_dump_plane_buffer(struct vop_dump_info *dump_info, int frame_co drm_get_format_name(dump_info->format->format, &format_name); strscpy(format, format_name.str, 5); bpp = rockchip_drm_get_bpp(dump_info->format); + if (!bpp) { + DRM_WARN("invalid bpp %d\n", bpp); + return 0; + } if (dump_info->yuv_format) { u8 hsub = dump_info->format->hsub; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index 1b38cac7aa1b..b3f403358d83 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -5142,7 +5142,7 @@ static void vop2_win_atomic_update(struct vop2_win *win, struct drm_rect *src, s actual_w = drm_rect_width(src) >> 16; actual_h = drm_rect_height(src) >> 16; - if (!actual_w || !actual_h) { + if (!actual_w || !actual_h || !bpp) { vop2_win_disable(win, true); return; } @@ -5263,10 +5263,6 @@ static void vop2_win_atomic_update(struct vop2_win *win, struct drm_rect *src, s /* AFBC pic_vir_width is count by pixel, this is different * with WIN_VIR_STRIDE. */ - if (!bpp) { - WARN(1, "bpp is zero\n"); - bpp = 1; - } stride = (fb->pitches[0] << 3) / bpp; if ((stride & 0x3f) && (vpstate->xmirror_en || vpstate->rotate_90_en || vpstate->rotate_270_en)) @@ -6586,7 +6582,7 @@ static size_t vop2_plane_line_bandwidth(struct drm_plane_state *pstate) size_t bandwidth; if (src_width <= 0 || src_height <= 0 || dst_width <= 0 || - dst_height <= 0) + dst_height <= 0 || !bpp) return 0; bandwidth = src_width * bpp / 8;