RE: [PATCH v10 02/12] drm: renesas: rz-du: vsp: Keep the planes in the VSP

From: Biju Das

Date: Wed Nov 18 2026 - 09:09:51 EST


Hi Tommaso,

Thanks for the patch.

> -----Original Message-----
> From: Tommaso Merciai <tommaso.merciai.xr@xxxxxxxxxxxxxx>
> Sent: 13 November 2026 12:20
> Subject: [PATCH v10 02/12] drm: renesas: rz-du: vsp: Keep the planes in the VSP
>
> Each VSP numbers its planes from zero, so the device-wide search in
> rzg2l_du_vsp_get_drm_plane() picks the wrong plane as soon as a SoC has more than one VSP: the primary
> plane of the second CRTC is looked up on the first VSP, whose possible_crtcs mask does not cover that
> CRTC.
>
> In preparation for supporting RZ/G3E, store the planes in the VSP that owns them and index the per-VSP
> array directly from rzg2l_du_crtc_create(), as the R-Car DU driver does, and drop the now unused
> search helper.
>
> No functional change intended.
>
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@xxxxxxxxxxxxxx>
> ---
> v9->v10:
> - No changes.
>
> v8->v9:
> - Dropped the vsp_pipe bounds check in rzg2l_du_crtc_create() and the
> now unused num_planes field, aligning with rcar_du_crtc_create().
> - Updated commit message accordingly.
>
> v7->v8:
> - New patch.
>
> drivers/gpu/drm/renesas/rz-du/rzg2l_du_crtc.c | 4 +--- drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.c
> | 19 ++----------------- drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.h | 10 +++-------
> 3 files changed, 6 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_crtc.c b/drivers/gpu/drm/renesas/rz-
> du/rzg2l_du_crtc.c
> index ab2f24cc7683..c57884ab5b9b 100644
> --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_crtc.c
> +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_crtc.c
> @@ -409,9 +409,7 @@ int rzg2l_du_crtc_create(struct rzg2l_du_device *rcdu)
> init_waitqueue_head(&rcrtc->flip_wait);
> rcrtc->dev = rcdu;
>
> - primary = rzg2l_du_vsp_get_drm_plane(rcrtc, rcrtc->vsp_pipe);
> - if (IS_ERR(primary))
> - return PTR_ERR(primary);
> + primary = &rcrtc->vsp->planes[rcrtc->vsp_pipe]->plane;

The bounds check on vsp_pipe  is dropped.  planes[vsp_pipe] is now indexed directly into a 2-entry array,
so a bad DT value oopses.

>
> ret = drmm_crtc_init_with_planes(&rcdu->ddev, crtc, primary, NULL,
> &crtc_funcs_rz, NULL);
> diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.c b/drivers/gpu/drm/renesas/rz-
> du/rzg2l_du_vsp.c
> index 944bc9ac9589..12fe35740c62 100644
> --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.c
> +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.c
> @@ -71,22 +71,6 @@ void rzg2l_du_vsp_atomic_flush(struct rzg2l_du_crtc *crtc)
> vsp1_du_atomic_flush(crtc->vsp->vsp, crtc->vsp_pipe, &cfg); }
>
> -struct drm_plane *rzg2l_du_vsp_get_drm_plane(struct rzg2l_du_crtc *crtc,
> - unsigned int pipe_index)
> -{
> - struct rzg2l_du_device *rcdu = crtc->vsp->dev;
> - struct drm_plane *plane = NULL;
> -
> - drm_for_each_plane(plane, &rcdu->ddev) {
> - struct rzg2l_du_vsp_plane *vsp_plane = to_rzg2l_vsp_plane(plane);
> -
> - if (vsp_plane->index == pipe_index)
> - break;

Do you need to remove this function?
as plane has vsp and index information.

plane->vsp = vsp;
plane->index = i;

Cheers,
Biju

> - }
> -
> - return plane ? plane : ERR_PTR(-EINVAL);
> -}
> -
> static const u32 rzg2l_du_vsp_formats[] = {
> DRM_FORMAT_RGB332,
> DRM_FORMAT_ARGB4444,
> @@ -303,7 +287,7 @@ int rzg2l_du_vsp_init(struct rzg2l_du_vsp *vsp, struct device_node *np,
> struct rzg2l_du_device *rcdu = vsp->dev;
> struct platform_device *pdev;
> unsigned int num_crtcs = hweight32(crtcs);
> - unsigned int num_planes = 2;
> + unsigned int num_planes = RZG2L_DU_VSP_MAX_PLANES;
> unsigned int i;
> int ret;
>
> @@ -350,6 +334,7 @@ int rzg2l_du_vsp_init(struct rzg2l_du_vsp *vsp, struct device_node *np,
>
> plane->vsp = vsp;
> plane->index = i;
> + vsp->planes[i] = plane;
>
> drm_plane_helper_add(&plane->plane,
> &rzg2l_du_vsp_plane_helper_funcs);
> diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.h b/drivers/gpu/drm/renesas/rz-
> du/rzg2l_du_vsp.h
> index a22aaf0843ed..acb41d343297 100644
> --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.h
> +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.h
> @@ -27,11 +27,14 @@ struct rzg2l_du_vsp_plane {
> unsigned int index;
> };
>
> +#define RZG2L_DU_VSP_MAX_PLANES 2
> +
> struct rzg2l_du_vsp {
> unsigned int index;
> struct device *vsp;
> struct device_link *link;
> struct rzg2l_du_device *dev;
> + struct rzg2l_du_vsp_plane *planes[RZG2L_DU_VSP_MAX_PLANES];
> };
>
> static inline struct rzg2l_du_vsp_plane *to_rzg2l_vsp_plane(struct drm_plane *p) @@ -62,8 +65,6 @@
> int rzg2l_du_vsp_init(struct rzg2l_du_vsp *vsp, struct device_node *np, void
> rzg2l_du_vsp_enable(struct rzg2l_du_crtc *crtc); void rzg2l_du_vsp_disable(struct rzg2l_du_crtc
> *crtc); void rzg2l_du_vsp_atomic_flush(struct rzg2l_du_crtc *crtc); -struct drm_plane
> *rzg2l_du_vsp_get_drm_plane(struct rzg2l_du_crtc *crtc,
> - unsigned int pipe_index);
> #else
> static inline int rzg2l_du_vsp_init(struct rzg2l_du_vsp *vsp, struct device_node *np,
> unsigned int crtcs)
> @@ -74,11 +75,6 @@ static inline int rzg2l_du_vsp_init(struct rzg2l_du_vsp *vsp, struct device_node
> static inline void rzg2l_du_vsp_enable(struct rzg2l_du_crtc *crtc) { }; static inline void
> rzg2l_du_vsp_disable(struct rzg2l_du_crtc *crtc) { }; static inline void
> rzg2l_du_vsp_atomic_flush(struct rzg2l_du_crtc *crtc) { }; -static inline struct drm_plane
> *rzg2l_du_vsp_get_drm_plane(struct rzg2l_du_crtc *crtc,
> - unsigned int pipe_index)
> -{
> - return ERR_PTR(-ENXIO);
> -}
> #endif
>
> #endif /* __RZG2L_DU_VSP_H__ */
> --
> 2.54.0