From: Biju Das <biju.das.jz@bp.renesas.com>
To: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>,
Tommaso Merciai <tomm.merciai@gmail.com>,
Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
Cc: "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 10/12] drm: renesas: rz-du: Support several DU instances in one DRM device
Date: Tue, 24 Nov 2026 07:47:04 +0000 [thread overview]
Message-ID: <TYYPR01MB660397C3B66F6EED53656B2086442@TYYPR01MB6603.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <e22a176720a38df652c7f7eabe27219da50f217d.1794502191.git.tommaso.merciai.xr@bp.renesas.com>
Hi Tommaso,
> -----Original Message-----
> From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> 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@bp.renesas.com>
> ---
> 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?
Deferral from master_bind also only works via the component_add/
component_master_add_with_match return path,
Have you tested with a late-probing DSI or LVDS bridge?
Have you tested component bind/unbind/rebind of both master and slave?
Have you tested PM and shutdown on the second DU?
du->ddev is only set on the master's platform data. The slave's PM suspend/resume and
shutdown therefore call the helpers with NULL
> + }
> +
> + if (IS_ERR(match))
> + return PTR_ERR(match);
Why this error path cannot be inside loop?
Cheers,
Biju
> +
> + if (!match)
> + return rzg2l_du_drm_init(dev, false);
> +
> + return component_master_add_with_match(dev, &rzg2l_du_master_ops,
> +match); }
> +
> +static void rzg2l_du_instance_remove(struct rzg2l_du_device *du) {
> + if (!rzg2l_du_has(du, RZG2L_DU_FEATURE_COMPONENT)) {
> + rzg2l_du_drm_fini(du->dev, false);
> + return;
> + }
> +
> + if (!du->is_master) {
> + component_del(du->dev, &rzg2l_du_instance_ops);
> + return;
> + }
> +
> + component_master_del(du->dev, &rzg2l_du_master_ops);
> +
> + if (du->ddev)
> + rzg2l_du_drm_fini(du->dev, false);
> }
>
> /* -----------------------------------------------------------------------------
> @@ -262,7 +370,7 @@ static void rzg2l_du_drm_fini(struct device *dev)
>
> static void rzg2l_du_remove(struct platform_device *pdev) {
> - rzg2l_du_drm_fini(&pdev->dev);
> + rzg2l_du_instance_remove(platform_get_drvdata(pdev));
> }
>
> static void rzg2l_du_shutdown(struct platform_device *pdev) @@ -304,7 +412,7 @@ static int
> rzg2l_du_probe(struct platform_device *pdev)
> rcdu->info = info;
> rcdu->mmio = mmio;
>
> - return rzg2l_du_drm_init(&pdev->dev);
> + return rzg2l_du_instance_probe(rcdu);
> }
>
> static struct platform_driver rzg2l_du_platform_driver = { diff --git a/drivers/gpu/drm/renesas/rz-
> du/rzg2l_du_drv.h b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_drv.h
> index 2952c9d7348b..4c2e12206d83 100644
> --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_drv.h
> +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_drv.h
> @@ -21,6 +21,7 @@ struct device;
> struct drm_property;
>
> #define RZG2L_DU_FEATURE_DPIO_OE BIT(0) /* Has DPIO output enable control */
> +#define RZG2L_DU_FEATURE_COMPONENT BIT(1) /* Has several DU instances in one DRM device */
>
> enum rzg2l_du_output {
> RZG2L_DU_OUTPUT_DSI0,
> @@ -71,6 +72,7 @@ struct rzg2l_du_device {
>
> struct drm_device *ddev;
> unsigned int index;
> + bool is_master;
>
> struct rzg2l_du_crtc crtcs[RZG2L_DU_MAX_CRTCS];
> unsigned int num_crtcs;
> --
> 2.54.0
next prev parent reply other threads:[~2026-11-24 7:47 UTC|newest]
Thread overview: 24+ 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
2026-11-13 12:19 ` [PATCH v10 03/12] drm: renesas: rz-du: Reference the DRM device by pointer Tommaso Merciai
2026-11-23 15:55 ` Biju Das
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-23 16:16 ` Biju Das
2026-11-13 12:20 ` [PATCH v10 05/12] drm: renesas: rz-du: Split the mode setting initialization Tommaso Merciai
2026-11-23 16:31 ` Biju Das
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-23 16:37 ` Biju Das
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-23 16:44 ` Biju Das
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-23 16:59 ` Biju Das
2026-11-24 9:20 ` Tommaso Merciai
2026-11-24 9:33 ` Biju Das
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-24 7:47 ` Biju Das [this message]
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=TYYPR01MB660397C3B66F6EED53656B2086442@TYYPR01MB6603.jpnprd01.prod.outlook.com \
--to=biju.das.jz@bp.renesas.com \
--cc=airlied@gmail.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=tommaso.merciai.xr@bp.renesas.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
all inboxes | Powered by JetHome®