From 63eaeee18e17f72f28ec976995dbc63fc5525197 Mon Sep 17 00:00:00 2001 From: Damon Ding Date: Wed, 5 Feb 2025 16:01:53 +0800 Subject: [PATCH] drm/rockchip: vop2: add possible_crtcs check for cursor plane initialization It makes sense to check whether the assigned cursor plane can be attached to a specific VP, as there may be an invalid DTS assignment for 'cursor-win-id'. The logs may be like: ...... [ 2.178737][ T81] rockchip-vop2 27d00000.vop: [drm:vop2_create_crtc] *ERROR* Assigned cursor plane: Esmart3 can not attach to VP0 [ 2.178753][ T81] [drm] failed to init cursor plane for vp0 [ 2.178823][ T81] rockchip-vop2 27d00000.vop: [drm:vop2_create_crtc] *ERROR* Assigned cursor plane: Esmart2 can not attach to VP1 [ 2.178838][ T81] [drm] failed to init cursor plane for vp1 ...... Change-Id: If18c4db1e8b295e72dae0c23bd0dd41203c4e3ac Signed-off-by: Damon Ding --- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index 743607816aad..3c0e0156ef26 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -1233,6 +1233,11 @@ static bool vop2_is_mirror_win(struct vop2_win *win) return soc_is_rk3566() && (win->feature & WIN_FEATURE_MIRROR); } +static bool vop2_win_can_attach_to_vp(struct vop2_video_port *vp, struct vop2_win *win) +{ + return win->possible_vp_mask & BIT(vp->id); +} + static uint64_t vop2_soc_id_fixup(uint64_t soc_id) { switch (soc_id) { @@ -14425,6 +14430,13 @@ static struct drm_plane *vop2_cursor_plane_init(struct vop2_video_port *vp, u8 e win = vop2_find_win_by_phys_id(vop2, vp->cursor_win_id); if (win) { + if (!vop2_win_can_attach_to_vp(vp, win)) { + DRM_DEV_ERROR(vop2->dev, + "Assigned cursor plane: %s can not attach to VP%d\n", + vop2_plane_phys_id_to_string(vp->cursor_win_id), vp->id); + return NULL; + } + if (vop2->disable_win_move) possible_crtcs = BIT(registered_num_crtcs); else @@ -14682,11 +14694,6 @@ static int vop2_crtc_create_post_sharp_property(struct vop2 *vop2, struct drm_cr #define RK3566_MIRROR_PLANE_MASK (BIT(ROCKCHIP_VOP2_CLUSTER1) | BIT(ROCKCHIP_VOP2_ESMART1) | \ BIT(ROCKCHIP_VOP2_SMART1)) -static inline bool vop2_win_can_attach_to_vp(struct vop2_video_port *vp, struct vop2_win *win) -{ - return win->possible_vp_mask & BIT(vp->id); -} - /* * Returns: * Registered crtc number on success, negative error code on failure.