RE: [PATCH v10 10/12] drm: renesas: rz-du: Support several DU instances in one DRM device

From: Biju Das

Date: Tue Nov 24 2026 - 09:11:45 EST


Hi Tommaso,

> -----Original Message-----
> From: Tommaso Merciai <tommaso.merciai.xr@xxxxxxxxxxxxxx>
> Sent: 24 November 2026 13:59
> Subject: Re: [PATCH v10 10/12] drm: renesas: rz-du: Support several DU instances in one DRM device
>
> Hi Biju,
>
> On Tue, Nov 24, 2026 at 01:18:43PM +0000, Biju Das wrote:
> > Hi Tommaso,
> >
> > > -----Original Message-----
> > > From: Tommaso Merciai <tommaso.merciai.xr@xxxxxxxxxxxxxx>
> > > Sent: 24 November 2026 11:53
> > > Subject: Re: [PATCH v10 10/12] drm: renesas: rz-du: Support several
> > > DU instances in one DRM device
> > >
> > > Hi Biju,
> > > Thanks for your review.
> > >
> > > On Tue, Nov 24, 2026 at 07:47:04AM +0000, Biju Das wrote:
> > > > Hi Tommaso,
> > > >
> > > > > -----Original Message-----
> > > > > From: Tommaso Merciai <tommaso.merciai.xr@xxxxxxxxxxxxxx>
> > > > > Sent: 13 November 2026 12:20
> > > > > Subject: [PATCH v10 10/12] drm: renesas: rz-du: Support several
> > > > > DU instances in one DRM device
> > > > >
> > > > > RZ/G3E has two DU instances that share a single DRM device.
> > > > >
> > > > > Add an RZG2L_DU_FEATURE_COMPONENT flag and use the component
> > > > > framework for it. The first available
> > > DU
> > > > > instance is the master and creates the DRM device, the other one binds to it as a component.
> > > > >
> > > > > If only one DU instance is available, it creates the DRM device
> > > > > directly at probe time, as on SoCs without the flag.
> > > > >
> > > > > Set the index of each instance to the number of CRTCs already created.
> > > > >
> > > > > Signed-off-by: Tommaso Merciai
> > > > > <tommaso.merciai.xr@xxxxxxxxxxxxxx>
> > > > > ---
> > > > > v9->v10:
> > > > > - New patch.
> > > > >
> > > > > drivers/gpu/drm/renesas/rz-du/rzg2l_du_drv.c | 118 ++++++++++++++++++-
> > > > > drivers/gpu/drm/renesas/rz-du/rzg2l_du_drv.h | 2 +
> > > > > 2 files changed, 115 insertions(+), 5 deletions(-)
> > > > >
> > > > > diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_drv.c
> > > > > b/drivers/gpu/drm/renesas/rz- du/rzg2l_du_drv.c index
> > > > > 93d59e2cf8a4..873586f2ef28 100644
> > > > > --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_drv.c
> > > > > +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_drv.c
> > > > > @@ -7,6 +7,7 @@
> > > > > * Based on rcar_du_drv.c
> > > > > */
> > > > >
> > > > > +#include <linux/component.h>
> > > > > #include <linux/dma-mapping.h>
> > > > > #include <linux/module.h>
> > > > > #include <linux/of.h>
> > > > > @@ -14,10 +15,12 @@
> > > > >
> > > > > #include <drm/clients/drm_client_setup.h> #include
> > > > > <drm/drm_atomic_helper.h>
> > > > > +#include <drm/drm_crtc.h>
> > > > > #include <drm/drm_drv.h>
> > > > > #include <drm/drm_fbdev_dma.h>
> > > > > #include <drm/drm_gem_dma_helper.h> #include
> > > > > <drm/drm_managed.h>
> > > > > +#include <drm/drm_of.h>
> > > > > #include <drm/drm_print.h>
> > > > > #include <drm/drm_probe_helper.h>
> > > > >
> > > > > @@ -170,6 +173,7 @@ static int rzg2l_du_instance_init(struct rzg2l_du_device *du,
> > > > > struct drm_device *ddev)
> > > > > {
> > > > > struct rzg2l_du_device *rcdu;
> > > > > + int ret;
> > > > >
> > > > > rcdu = drmm_kzalloc(ddev, sizeof(*rcdu), GFP_KERNEL);
> > > > > if (!rcdu)
> > > > > @@ -180,9 +184,28 @@ static int rzg2l_du_instance_init(struct rzg2l_du_device *du,
> > > > > rcdu->mmio = du->mmio;
> > > > > rcdu->ddev = ddev;
> > > > >
> > > > > - return rzg2l_du_modeset_init_du(rcdu);
> > > > > + rcdu->index = ddev->mode_config.num_crtc;
> > > > > +
> > > > > + ret = rzg2l_du_modeset_init_du(rcdu);
> > > > > + if (ret < 0)
> > > > > + return ret;
> > > > > +
> > > > > + if (WARN_ON(drm_crtc_index(&rcdu->crtcs[0].crtc) != rcdu->index))
> > > > > + return -EINVAL;
> > > > > +
> > > > > + return 0;
> > > > > }
> > > > >
> > > > > +static int rzg2l_du_instance_bind(struct device *dev, struct device *master,
> > > > > + void *data)
> > > > > +{
> > > > > + return rzg2l_du_instance_init(dev_get_drvdata(dev), data); }
> > > > > +
> > > > > +static const struct component_ops rzg2l_du_instance_ops = {
> > > > > + .bind = rzg2l_du_instance_bind, };
> > > > > +
> > > > > /* -----------------------------------------------------------------------------
> > > > > * DRM device
> > > > > */
> > > > > @@ -191,7 +214,7 @@ struct rzg2l_du_drm {
> > > > > struct drm_device ddev;
> > > > > };
> > > > >
> > > > > -static int rzg2l_du_drm_init(struct device *dev)
> > > > > +static int rzg2l_du_drm_init(struct device *dev, bool
> > > > > +has_components)
> > > > > {
> > > > > struct rzg2l_du_device *du = dev_get_drvdata(dev);
> > > > > struct rzg2l_du_drm *rzgdrm;
> > > > > @@ -213,6 +236,12 @@ static int rzg2l_du_drm_init(struct device *dev)
> > > > > if (ret < 0)
> > > > > goto error;
> > > > >
> > > > > + if (has_components) {
> > > > > + ret = component_bind_all(dev, ddev);
> > > > > + if (ret < 0)
> > > > > + goto error;
> > > > > + }
> > > > > +
> > > > > ret = rzg2l_du_modeset_init_finish(ddev);
> > > > > if (ret < 0)
> > > > > goto error_fini;
> > > > > @@ -235,6 +264,8 @@ static int rzg2l_du_drm_init(struct device
> > > > > *dev)
> > > > >
> > > > > error_fini:
> > > > > drm_kms_helper_poll_fini(ddev);
> > > > > + if (has_components)
> > > > > + component_unbind_all(dev, ddev);
> > > > > error:
> > > > > /*
> > > > > * Don't use dev_err_probe(), as it would overwrite the probe
> > > > > deferral @@ -246,7 +277,7 @@ static int rzg2l_du_drm_init(struct device *dev)
> > > > > return ret;
> > > > > }
> > > > >
> > > > > -static void rzg2l_du_drm_fini(struct device *dev)
> > > > > +static void rzg2l_du_drm_fini(struct device *dev, bool
> > > > > +has_components)
> > > > > {
> > > > > struct rzg2l_du_device *du = dev_get_drvdata(dev);
> > > > > struct drm_device *ddev = du->ddev; @@ -254,6 +285,83 @@
> > > > > static void rzg2l_du_drm_fini(struct device *dev)
> > > > > drm_dev_unregister(ddev);
> > > > > drm_atomic_helper_shutdown(ddev);
> > > > > drm_kms_helper_poll_fini(ddev);
> > > > > +
> > > > > + if (has_components)
> > > > > + component_unbind_all(dev, ddev);
> > > > > +
> > > > > + du->ddev = NULL;
> > > > > +}
> > > > > +
> > > > > +/*
> > > > > +---------------------------------------------------------------
> > > > > +--------
> > > > > +------
> > > > > + * Component master
> > > > > + */
> > > > > +
> > > > > +static int rzg2l_du_master_bind(struct device *dev) {
> > > > > + return rzg2l_du_drm_init(dev, true); }
> > > > > +
> > > > > +static void rzg2l_du_master_unbind(struct device *dev) {
> > > > > + rzg2l_du_drm_fini(dev, true);
> > > > > +}
> > > > > +
> > > > > +static const struct component_master_ops rzg2l_du_master_ops = {
> > > > > + .bind = rzg2l_du_master_bind,
> > > > > + .unbind = rzg2l_du_master_unbind, };
> > > > > +
> > > > > +static int rzg2l_du_instance_probe(struct rzg2l_du_device *du) {
> > > > > + struct component_match *match = NULL;
> > > > > + const struct of_device_id *of_id;
> > > > > + struct device *dev = du->dev;
> > > > > +
> > > > > + if (!rzg2l_du_has(du, RZG2L_DU_FEATURE_COMPONENT))
> > > > > + return rzg2l_du_drm_init(dev, false);
> > > > > +
> > > > > + for_each_available_child_of_node_scoped(dev->of_node->parent, np) {
> > > > > + of_id = of_match_node(dev->driver->of_match_table, np);
> > > > > + if (!of_id || of_id->data != du->info)
> > > > > + continue;
> > > > > +
> > > > > + /* The first available DU instance is the component master. */
> > > > > + if (!du->is_master) {
> > > > > + if (np != dev->of_node)
> > > > > + return component_add(dev, &rzg2l_du_instance_ops);
> > > > > +
> > > > > + du->is_master = true;
> > > > > + continue;
> > > > > + }
> > > > > +
> > > > > + drm_of_component_match_add(dev, &match, component_compare_of,
> > > > > +np);
> > > >
> > > >
> > > > The master is chosen purely by DT order. If the first available DU
> > > > never probes, the second never gets a DRM device. How do you handle this case?
> > >
> > > All available instances are part of the component match, so the DRM
> > > device is only created once all of them have probed, whichever one
> > > is the master.
> > >
> > > This is how the component framework works.
> > >
> > > To use a single DU, the other one can be disabled in DT, in this
> > > case the remaining instance becomes the master and initializes the
> > > DRM device on its own.
> >
> >
> > Assume both DU's available and run time
> >
> > second DU is probed first and master never probed at all.
> > What is the state of second DU as bind never calls?
>
>
> The second DU probes, registers itself with component_add() and stays idle, without touching the
> hardware.
>
> When the master probes, both instances are bound and the DRM device is created.
>
> If the master never probes, there is no DRM device, because the bind is only triggered once the master
> has registered the aggregate device with
> component_master_add_with_match()

Not sure is it the normal use case? DU0 and DU1 are independent devices

1) DU0 or DU1 should work independently irrespective of the probe failure of
other device

2) When both DU's are probed, then we need to aggregate the device using component
framework so that use case like dynamically switching DSI0 to DSI1 can be achieved.

Cheers,
Biju