Devicetree
 help / color / mirror / Atom feed
From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
To: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Tommaso Merciai <tomm.merciai@gmail.com>,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	"linux-renesas-soc@vger.kernel.org"
	<linux-renesas-soc@vger.kernel.org>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	"magnus.damm" <magnus.damm@gmail.com>,
	Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v10 02/12] drm: renesas: rz-du: vsp: Keep the planes in the VSP
Date: Wed, 18 Nov 2026 19:08:50 +0100	[thread overview]
Message-ID: <av3psmZ6rK8td1yx@tom-desktop> (raw)
In-Reply-To: <TYYPR01MB66036E5E97AD52E68DE078AE867A2@TYYPR01MB6603.jpnprd01.prod.outlook.com>

Hi Biju,
Thanks for your review.

On Wed, Nov 18, 2026 at 02:09:38PM +0000, Biju Das wrote:
> Hi Tommaso,
> 
> Thanks for the patch.
> 
> > -----Original Message-----
> > From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> > 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@bp.renesas.com>
> > ---
> > 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;

I think we can keep this function adding vsp_plane->index check:
	
	if (vsp_plane->vsp == crtc->vsp &&
	    vsp_plane->index == pipe_index)
	
While at it I notice that rzg2l_du_vsp_get_drm_plane() 
never return ERR_PTR(-EINVAL) because plane == NULL can't happens.

Will address also this into the next iteration.

Kind regards,
Tommaso

> 
> 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
> 

  reply	other threads:[~2026-11-18 18:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 12:19 [PATCH v10 00/12] drm: renesas: rz-du: Add RZ/G3E support Tommaso Merciai
2026-11-13 12:19 ` [PATCH v10 01/12] dt-bindings: display: renesas,rzg2l-du: Add support for RZ/G3E SoC Tommaso Merciai
2026-11-13 12:19 ` [PATCH v10 02/12] drm: renesas: rz-du: vsp: Keep the planes in the VSP Tommaso Merciai
2026-11-18 14:09   ` Biju Das
2026-11-18 18:08     ` Tommaso Merciai [this message]
2026-11-13 12:19 ` [PATCH v10 03/12] drm: renesas: rz-du: Reference the DRM device by pointer Tommaso Merciai
2026-11-13 12:20 ` [PATCH v10 04/12] drm: renesas: rz-du: Count all registered encoders for the possible clones Tommaso Merciai
2026-11-13 12:20 ` [PATCH v10 05/12] drm: renesas: rz-du: Split the mode setting initialization Tommaso Merciai
2026-11-13 12:20 ` [PATCH v10 06/12] drm: renesas: rz-du: Make the CRTC index relative to the DRM device Tommaso Merciai
2026-11-13 12:20 ` [PATCH v10 07/12] drm: renesas: rz-du: Share the encoder of an output driven by several DUs Tommaso Merciai
2026-11-13 12:20 ` [PATCH v10 08/12] drm: renesas: rz-du: Separate the DU instance from the DRM device Tommaso Merciai
2026-11-13 12:20 ` [PATCH v10 09/12] drm: renesas: rz-du: Move the DRM device initialization to helpers Tommaso Merciai
2026-11-13 12:20 ` [PATCH v10 10/12] drm: renesas: rz-du: Support several DU instances in one DRM device Tommaso Merciai
2026-11-13 12:20 ` [PATCH v10 11/12] drm: renesas: rz-du: Add RZ/G3E (R9A09G047) DU support Tommaso Merciai
2026-11-13 12:20 ` [PATCH v10 12/12] arm64: dts: renesas: r9a09g047: Add DU{0,1} nodes Tommaso Merciai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=av3psmZ6rK8td1yx@tom-desktop \
    --to=tommaso.merciai.xr@bp.renesas.com \
    --cc=airlied@gmail.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geert+renesas@glider.be \
    --cc=krzk+dt@kernel.org \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=magnus.damm@gmail.com \
    --cc=mripard@kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=robh@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tomm.merciai@gmail.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox