Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Aradhya Bhatia <aradhya.bhatia@linux.dev>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>, Lee Jones <lee@kernel.org>,
	Nishanth Menon <nm@ti.com>, Vignesh Raghavendra <vigneshr@ti.com>,
	Swamil Jain <s-jain1@ti.com>, Devarsh Thakkar <devarsht@ti.com>,
	Louis Chauvet <louis.chauvet@bootlin.com>
Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 11/14] drm/tidss: oldi: Add power domain support
Date: Mon, 2 Nov 2026 13:45:59 +0000	[thread overview]
Message-ID: <4148e258-b406-4964-82b3-11ea624f974e@linux.dev> (raw)
In-Reply-To: <20261029-beagley-ai-display-v4-11-dc7f2b532478@ideasonboard.com>

Hi Tomi,

On 29/10/26 10:18, Tomi Valkeinen wrote:
> The OLDI TXes on AM62P and J722S have power domains of their own,
> described in the DT, unlike the earlier SoCs. The OLDI TX nodes are not
> real devices, so the driver core does not attach these power domains,
> and nothing in the core turns them on.
> 
> Add support to attach the PDs with dev_pm_domain_attach_by_node(), and
> manage the power state of the returned virtual devices with runtime PM
> functions.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  drivers/gpu/drm/tidss/tidss_oldi.c | 88 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 88 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tidss/tidss_oldi.c b/drivers/gpu/drm/tidss/tidss_oldi.c
> index 5552c1c51074..df2326db3302 100644
> --- a/drivers/gpu/drm/tidss/tidss_oldi.c
> +++ b/drivers/gpu/drm/tidss/tidss_oldi.c
> @@ -10,6 +10,8 @@
>  #include <linux/of_graph.h>
>  #include <linux/mfd/syscon.h>
>  #include <linux/media-bus-format.h>
> +#include <linux/pm_domain.h>
> +#include <linux/pm_runtime.h>
>  #include <linux/regmap.h>
>  
>  #include <drm/drm_atomic_helper.h>
> @@ -35,6 +37,12 @@ struct tidss_oldi {
>  
>  	struct clk *serial;
>  	struct regmap *io_ctrl;
> +
> +	/*
> +	 * The power domains of this OLDI TX and, in dual-link mode, of its
> +	 * companion. NULL for an OLDI TX without a power domain of its own.
> +	 */
> +	struct device *pd_devs[2];
>  };
>  
>  struct oldi_bus_format {
> @@ -238,6 +246,22 @@ static int tidss_oldi_atomic_check(struct drm_bridge *bridge,
>  	return 0;
>  }
>  
> +static void tidss_oldi_power_get(struct tidss_oldi *oldi)
> +{
> +	for (unsigned int i = 0; i < ARRAY_SIZE(oldi->pd_devs); i++) {
> +		if (oldi->pd_devs[i])
> +			WARN_ON(pm_runtime_get_sync(oldi->pd_devs[i]) < 0);
> +	}
> +}
> +
> +static void tidss_oldi_power_put(struct tidss_oldi *oldi)
> +{
> +	for (unsigned int i = 0; i < ARRAY_SIZE(oldi->pd_devs); i++) {
> +		if (oldi->pd_devs[i])
> +			pm_runtime_put(oldi->pd_devs[i]);
> +	}
> +}
> +
>  static void tidss_oldi_atomic_pre_enable(struct drm_bridge *bridge,
>  					 struct drm_atomic_commit *state)
>  {
> @@ -251,6 +275,8 @@ static void tidss_oldi_atomic_pre_enable(struct drm_bridge *bridge,
>  	if (oldi->link_type == OLDI_MODE_SECONDARY_CLONE_SINGLE_LINK)
>  		return;
>  
> +	tidss_oldi_power_get(oldi);
> +
>  	connector = drm_atomic_get_new_connector_for_encoder(state,
>  							     bridge->encoder);
>  	if (WARN_ON(!connector))
> @@ -296,6 +322,8 @@ static void tidss_oldi_atomic_post_disable(struct drm_bridge *bridge,
>  
>  	/* Clear OLDI Config */
>  	tidss_disable_oldi(oldi->tidss, oldi->parent_vp);
> +
> +	tidss_oldi_power_put(oldi);
>  }
>  
>  #define MAX_INPUT_SEL_FORMATS	1
> @@ -468,6 +496,60 @@ static int get_parent_dss_vp(struct device_node *oldi_tx, u32 *parent_vp)
>  	return -ENODEV;
>  }
>  
> +static void tidss_oldi_detach_pd(void *data)
> +{
> +	struct device *pd_dev = data;
> +
> +	dev_pm_domain_detach(pd_dev, true);
> +}
> +
> +static struct device *tidss_oldi_create_pd_dev(struct tidss_device *tidss,
> +					       struct device_node *oldi_tx)
> +{
> +	struct device *dev;
> +	int ret;
> +
> +	dev = dev_pm_domain_attach_by_node(tidss->dev, oldi_tx, 0);
> +	if (IS_ERR_OR_NULL(dev))
> +		return dev;
> +
> +	ret = devm_add_action_or_reset(tidss->dev, tidss_oldi_detach_pd, dev);
> +	if (ret)
> +		return ERR_PTR(ret);
> +
> +	return dev;
> +}
> +
> +static int tidss_oldi_create_pd_devs(struct tidss_device *tidss,
> +				     struct tidss_oldi *oldi,
> +				     struct device_node *oldi_tx)
> +{
> +	struct device_node *companion;
> +	struct device *pd_dev;
> +
> +	pd_dev = tidss_oldi_create_pd_dev(tidss, oldi_tx);
> +	if (IS_ERR(pd_dev))
> +		return PTR_ERR(pd_dev);
> +
> +	oldi->pd_devs[0] = pd_dev;
> +
> +	if (oldi->companion_instance < 0)
> +		return 0;
> +
> +	companion = of_parse_phandle(oldi_tx, "ti,companion-oldi", 0);
> +	if (!companion)
> +		return -EINVAL;
> +
> +	pd_dev = tidss_oldi_create_pd_dev(tidss, companion);
> +	of_node_put(companion);
> +	if (IS_ERR(pd_dev))
> +		return PTR_ERR(pd_dev);
> +
> +	oldi->pd_devs[1] = pd_dev;
> +
> +	return 0;
> +}
> +
>  void tidss_oldi_deinit(struct tidss_device *tidss)
>  {
>  	for (int i = 0; i < tidss->num_oldis; i++) {
> @@ -610,6 +692,12 @@ static int tidss_oldi_init_one(struct tidss_device *tidss,
>  		}
>  	}
>  
> +	ret = tidss_oldi_create_pd_devs(tidss, oldi, oldi_tx);
> +	if (ret)
> +		return dev_err_probe(tidss->dev, ret,
> +				     "OLDI%u: Failed to set up the power domains.\n",
> +				     oldi_instance);
> +

I agree with the what this patch is trying to do, but the
tidss_oldi_create_pd_devs() should be within the if() block above.

It seems like you are giving the pd_dev of the secondary OLDI TX to the
primary, but this path would be executed for secondary OLDI TX in clone
mode as well, whenever it gets supported.
Which is not ideal, because the primary OLDI TX in clone mode would
already be taking care of the secondary's pd_dev.

The conditional block above with,
`if (link_type != OLDI_MODE_SECONDARY_CLONE_SINGLE_LINK)`, is exactly
for things that _can_ be setup per OLDI Tx, but shouldn't, like the
clock and the IO control.

-- 
Regards
Aradhya



  reply	other threads:[~2026-11-02 13:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 10:18 [PATCH v4 00/14] drm/tidss: Add BeagleY-AI display support (and some more) Tomi Valkeinen
2026-10-29 10:18 ` [PATCH v4 01/14] dt-bindings: display: ti,am65x-dss: Add AM62P DSS Tomi Valkeinen
2026-11-01 13:49   ` Aradhya Bhatia
2026-10-29 10:18 ` [PATCH v4 02/14] drm/tidss: Add helper to identify the AM65x OLDI video port Tomi Valkeinen
2026-11-01 13:50   ` Aradhya Bhatia
2026-10-29 10:18 ` [PATCH v4 03/14] drm/tidss: Stop using vp_bus_type for directly connected panels Tomi Valkeinen
2026-11-01 14:07   ` Aradhya Bhatia
2026-10-29 10:18 ` [PATCH v4 04/14] drm/tidss: Drop the tied off video port check from mode validation Tomi Valkeinen
2026-11-01 14:07   ` Aradhya Bhatia
2026-10-29 10:18 ` [PATCH v4 05/14] drm/tidss: Remove the unused vp_bus_type feat Tomi Valkeinen
2026-11-01 14:09   ` Aradhya Bhatia
2026-10-29 10:18 ` [PATCH v4 06/14] drm/tidss: oldi: Drop unnecessary forward declaration Tomi Valkeinen
2026-11-01 14:11   ` Aradhya Bhatia
2026-11-02 11:41     ` Tomi Valkeinen
2026-10-29 10:18 ` [PATCH v4 07/14] drm/tidss: oldi: Fix wrong return value from tidss_oldi_mode_valid() Tomi Valkeinen
2026-11-01 14:17   ` Aradhya Bhatia
2026-10-29 10:18 ` [PATCH v4 08/14] drm/tidss: oldi: Fix serial clock reference leak Tomi Valkeinen
2026-11-01 14:17   ` Aradhya Bhatia
2026-10-29 10:18 ` [PATCH v4 09/14] drm/tidss: oldi: Fix cleanup on a failed init Tomi Valkeinen
2026-11-01 14:14   ` Aradhya Bhatia
2026-11-02 11:46     ` Tomi Valkeinen
2026-11-02 13:30       ` Aradhya Bhatia
2026-10-29 10:18 ` [PATCH v4 10/14] drm/tidss: oldi: Move the setup of one OLDI TX to its own function Tomi Valkeinen
2026-11-02 13:31   ` Aradhya Bhatia
2026-10-29 10:18 ` [PATCH v4 11/14] drm/tidss: oldi: Add power domain support Tomi Valkeinen
2026-11-02 13:45   ` Aradhya Bhatia [this message]
2026-10-29 10:18 ` [PATCH v4 12/14] drm/tidss: Add support for AM62P display subsystem Tomi Valkeinen
2026-11-02 14:02   ` Aradhya Bhatia
2026-10-29 10:18 ` [PATCH v4 13/14] arm64: dts: ti: k3-am62p-j722s-common-main: Add support for DSS Tomi Valkeinen
2026-10-29 10:19 ` [PATCH v4 14/14] arm64: dts: ti: beagley-ai: Enable HDMI display and audio Tomi Valkeinen

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=4148e258-b406-4964-82b3-11ea624f974e@linux.dev \
    --to=aradhya.bhatia@linux.dev \
    --cc=airlied@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devarsht@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louis.chauvet@bootlin.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nm@ti.com \
    --cc=robh@kernel.org \
    --cc=s-jain1@ti.com \
    --cc=simona@ffwll.ch \
    --cc=tomi.valkeinen@ideasonboard.com \
    --cc=tzimmermann@suse.de \
    --cc=vigneshr@ti.com \
    /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