Re: [PATCH] drm/mcde: Use power domain for display power

From: Ulf Hansson

Date: Mon Nov 23 2026 - 11:16:00 EST


On Sun, Nov 15, 2026 at 7:10 PM Linus Walleij <linusw@xxxxxxxxxx> wrote:
>
> Replace explicit EPOD regulator handling with runtime PM, including the
> power cycle used to reset the display hardware. Treat only negative
> pm_runtime_put_sync_suspend() return values as errors.
>
> Keep the separate VANA regulator enabled while the driver is bound:
> the AB8500 CSI/DSI analog supply is not controlled by the MCDE power
> domain. Preserve its probe failure and removal cleanup.
>
> Signed-off-by: Linus Walleij <linusw@xxxxxxxxxx>
> ---
> The Ux500 genpd prerequisites have been merged into the powerdomain tree.
> Please take this conversion through DRM; the companion bindings and DTS
> changes will be submitted separately.
> ---
> drivers/gpu/drm/mcde/mcde_clk_div.c | 4 +--
> drivers/gpu/drm/mcde/mcde_display.c | 13 ++++-----
> drivers/gpu/drm/mcde/mcde_drm.h | 1 -
> drivers/gpu/drm/mcde/mcde_drv.c | 56 +++++++++++++++++--------------------
> drivers/gpu/drm/mcde/mcde_dsi.c | 1 -
> 5 files changed, 33 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/gpu/drm/mcde/mcde_clk_div.c b/drivers/gpu/drm/mcde/mcde_clk_div.c
> index 8c5af2677357..1a22e6233946 100644
> --- a/drivers/gpu/drm/mcde/mcde_clk_div.c
> +++ b/drivers/gpu/drm/mcde/mcde_clk_div.c
> @@ -1,7 +1,7 @@
> // SPDX-License-Identifier: GPL-2.0
> #include <linux/clk-provider.h>
> #include <linux/io.h>
> -#include <linux/regulator/consumer.h>
> +#include <linux/pm_runtime.h>
>
> #include "mcde_drm.h"
> #include "mcde_display_regs.h"
> @@ -95,7 +95,7 @@ static unsigned long mcde_clk_div_recalc_rate(struct clk_hw *hw,
> * It will come up with 0 in the divider register bits, which
> * means "divide by 2".
> */
> - if (!regulator_is_enabled(mcde->epod))
> + if (!pm_runtime_active(mcde->dev))
> return DIV_ROUND_UP_ULL(prate, 2);
>
> cr = readl(mcde->regs + cdiv->cr);
> diff --git a/drivers/gpu/drm/mcde/mcde_display.c b/drivers/gpu/drm/mcde/mcde_display.c
> index 281f5b3274bd..57305fdbcdcc 100644
> --- a/drivers/gpu/drm/mcde/mcde_display.c
> +++ b/drivers/gpu/drm/mcde/mcde_display.c
> @@ -7,7 +7,7 @@
> #include <linux/clk.h>
> #include <linux/delay.h>
> #include <linux/dma-buf.h>
> -#include <linux/regulator/consumer.h>
> +#include <linux/pm_runtime.h>
> #include <linux/media-bus-format.h>
>
> #include <drm/drm_atomic_helper.h>
> @@ -1187,16 +1187,15 @@ static void mcde_crtc_helper_atomic_enable(struct drm_crtc *crtc,
> int ret;
>
> /* This powers up the entire MCDE block and the DSI hardware */
> - ret = regulator_enable(mcde->epod);
> + ret = pm_runtime_resume_and_get(mcde->dev);
> if (ret) {
> - dev_err(drm->dev, "can't re-enable EPOD regulator\n");
> + dev_err(drm->dev, "can't enable MCDE power domain\n");
> return;
> }

Neither regulator_enable() or pm_runtime_resume_and_get() (unless
marked irq_safe) are supposed to be called from atomic context.

Isn't mcde_crtc_helper_atomic_enable() called from atomic context?

That said, converting to pm_runtime_resume_and_get() doesn't makes
this any worse.

>
> dev_info(drm->dev, "enable MCDE, %d x %d format %p4cc\n",
> mode->hdisplay, mode->vdisplay, &format);
>
> -
> /* Clear any pending interrupts */
> mcde_display_disable_irqs(mcde);
> writel(0, mcde->regs + MCDE_IMSCERR);
> @@ -1347,9 +1346,9 @@ static void mcde_crtc_helper_atomic_disable(struct drm_crtc *crtc,
> spin_unlock_irq(&crtc->dev->event_lock);
> }
>
> - ret = regulator_disable(mcde->epod);
> - if (ret)
> - dev_err(drm->dev, "can't disable EPOD regulator\n");
> + ret = pm_runtime_put_sync_suspend(mcde->dev);
> + if (ret < 0)
> + dev_err(drm->dev, "can't disable MCDE power domain\n");

I suppose this is kind of equivalent with the error handling to
regulator_disable(). So I would argue that that this is okay for now.

However, even if pm_runtime_put_sync_suspend() doesn't return an error
code, there is no guarantee that the corresponding PM domain (managed
by genpd) actually gets turned off. What we probably want instead is
to is to get a notification from genpd to let us know when this has
happened.
See dev_pm_genpd_add_notifier().

> /* Make sure we are powered down (before we may power up again) */
> usleep_range(50000, 70000);
>
> diff --git a/drivers/gpu/drm/mcde/mcde_drm.h b/drivers/gpu/drm/mcde/mcde_drm.h
> index edbb4580a7d8..296edf9ebef4 100644
> --- a/drivers/gpu/drm/mcde/mcde_drm.h
> +++ b/drivers/gpu/drm/mcde/mcde_drm.h
> @@ -93,7 +93,6 @@ struct mcde {
> /* Locks the MCDE FIFO control register A and B */
> spinlock_t fifo_crx1_lock;
>
> - struct regulator *epod;
> struct regulator *vana;
> };
>
> diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
> index 759e279b645a..af26ac5a4455 100644
> --- a/drivers/gpu/drm/mcde/mcde_drv.c
> +++ b/drivers/gpu/drm/mcde/mcde_drv.c
> @@ -61,6 +61,7 @@
> #include <linux/module.h>
> #include <linux/of_platform.h>
> #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
> #include <linux/regulator/consumer.h>
> #include <linux/slab.h>
> #include <linux/delay.h>
> @@ -283,33 +284,26 @@ static int mcde_probe(struct platform_device *pdev)
> mcde->dev = dev;
> platform_set_drvdata(pdev, drm);
>
> - /* First obtain and turn on the main power */
> - mcde->epod = devm_regulator_get(dev, "epod");
> - if (IS_ERR(mcde->epod)) {
> - ret = PTR_ERR(mcde->epod);
> - dev_err(dev, "can't get EPOD regulator\n");
> - return ret;
> - }
> - ret = regulator_enable(mcde->epod);
> + pm_runtime_enable(dev);
> + ret = pm_runtime_resume_and_get(dev);
> if (ret) {
> - dev_err(dev, "can't enable EPOD regulator\n");
> + dev_err(dev, "can't enable MCDE power domain\n");
> + pm_runtime_disable(dev);
> return ret;
> }
> +
> + /* The CSI/DSI analog supply is separate from the MCDE power domain. */
> mcde->vana = devm_regulator_get(dev, "vana");
> if (IS_ERR(mcde->vana)) {
> ret = PTR_ERR(mcde->vana);
> dev_err(dev, "can't get VANA regulator\n");
> - goto regulator_epod_off;
> + goto pm_runtime_put;
> }
> ret = regulator_enable(mcde->vana);
> if (ret) {
> dev_err(dev, "can't enable VANA regulator\n");
> - goto regulator_epod_off;
> + goto pm_runtime_put;
> }
> - /*
> - * The vendor code uses ESRAM (onchip RAM) and need to activate
> - * the v-esram34 regulator, but we don't use that yet
> - */
>
> /* Clock the silicon so we can access the registers */
> mcde->mcde_clk = devm_clk_get(dev, "mcde");
> @@ -412,14 +406,15 @@ static int mcde_probe(struct platform_device *pdev)
>
> /*
> * Perform an invasive reset of the MCDE and all blocks by
> - * cutting the power to the subsystem, then bring it back up
> + * powering down the subsystem, then bring it back up
> * later when we enable the display as a result of
> * component_master_add_with_match().
> */
> - ret = regulator_disable(mcde->epod);
> - if (ret) {
> - dev_err(dev, "can't disable EPOD regulator\n");
> - return ret;
> + ret = pm_runtime_put_sync_suspend(dev);
> + if (ret < 0) {
> + dev_err(dev, "can't disable MCDE power domain\n");
> + pm_runtime_get_noresume(dev);
> + goto clk_disable;
> }
> /* Wait 50 ms so we are sure we cut the power */
> usleep_range(50000, 70000);
> @@ -428,13 +423,7 @@ static int mcde_probe(struct platform_device *pdev)
> match);
> if (ret) {
> dev_err(dev, "failed to add component master\n");
> - /*
> - * The EPOD regulator is already disabled at this point so some
> - * special errorpath code is needed
> - */
> - clk_disable_unprepare(mcde->mcde_clk);
> - regulator_disable(mcde->vana);
> - return ret;
> + goto clk_disable_pm_disabled;
> }
>
> return 0;
> @@ -443,10 +432,15 @@ static int mcde_probe(struct platform_device *pdev)
> clk_disable_unprepare(mcde->mcde_clk);
> regulator_off:
> regulator_disable(mcde->vana);
> -regulator_epod_off:
> - regulator_disable(mcde->epod);
> +pm_runtime_put:
> + pm_runtime_put_sync_suspend(dev);
> + goto pm_runtime_disable;
> +clk_disable_pm_disabled:
> + clk_disable_unprepare(mcde->mcde_clk);
> + regulator_disable(mcde->vana);
> +pm_runtime_disable:
> + pm_runtime_disable(dev);
> return ret;
> -
> }
>
> static void mcde_remove(struct platform_device *pdev)
> @@ -457,7 +451,7 @@ static void mcde_remove(struct platform_device *pdev)
> component_master_del(&pdev->dev, &mcde_drm_comp_ops);
> clk_disable_unprepare(mcde->mcde_clk);
> regulator_disable(mcde->vana);
> - regulator_disable(mcde->epod);
> + pm_runtime_disable(&pdev->dev);
> }
>
> static void mcde_shutdown(struct platform_device *pdev)
> diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
> index daac8d67913d..86ae23894cda 100644
> --- a/drivers/gpu/drm/mcde/mcde_dsi.c
> +++ b/drivers/gpu/drm/mcde/mcde_dsi.c
> @@ -8,7 +8,6 @@
> #include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/regmap.h>
> -#include <linux/regulator/consumer.h>
> #include <video/mipi_display.h>
>
> #include <drm/drm_atomic_state_helper.h>
>
> ---
> base-commit: 9ae477db090b44816741fd9c49a3c459fc7d407b
> change-id: 20261115-ux500-drm-mcde-powerdomain-8a8d9d4c5a44
>
> Best regards,
> --
> Linus Walleij <linusw@xxxxxxxxxx>
>

Even with the comments above, feel free to add:

Reviewed-by: Ulf Hansson <ulfh@xxxxxxxxxx>

Kind regards
Uffe