* [PATCH] drm/mcde: Use power domain for display power
@ 2026-11-15 18:10 Linus Walleij
2026-11-15 18:30 ` sashiko-bot
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2026-11-15 18:10 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter
Cc: dri-devel, linux-kernel, Ulf Hansson, linux-pm, Linus Walleij
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@kernel.org>
---
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;
}
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");
/* 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@kernel.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/mcde: Use power domain for display power
2026-11-15 18:10 [PATCH] drm/mcde: Use power domain for display power Linus Walleij
@ 2026-11-15 18:30 ` sashiko-bot
2026-11-15 22:44 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: sashiko-bot @ 2026-11-15 18:30 UTC (permalink / raw)
To: Linus Walleij; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/mcde: TOCTOU race in mcde_clk_div_recalc_rate() [1]
--
commit b6626239eb4624a10d2245cb12fab62bbafe702d
Author: Linus Walleij <linusw@kernel.org>
drm/mcde: Use power domain for display power
This commit replaces explicit EPOD regulator handling in the MCDE DRM
driver with runtime PM calls while keeping the separate VANA analog supply
enabled during driver binding.
> diff --git a/drivers/gpu/drm/mcde/mcde_clk_div.c b/drivers/gpu/drm/mcde/mcde_clk_div.c
> index 8c5af2677357f..1a22e6233946c 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);
[Severity: High]
This problem wasn't introduced by this patch, but can mcde->dev runtime-suspend [1] between pm_runtime_active() and readl()?
pm_runtime_active() does not take a runtime PM reference, so a concurrent
suspend can power down the MCDE block before the register read completes:
CPU0 CPU1
mcde_clk_div_recalc_rate()
pm_runtime_active(mcde->dev)
pm_runtime_put_sync_suspend(mcde->dev)
readl(mcde->regs + cdiv->cr) <-- unpowered MMIO access
Reading MCDE registers while the power domain is off causes an unhandled
hardware fault. Using pm_runtime_get_if_in_use() and dropping the
reference after readl() would keep the domain powered across the register
read.
[1] https://sashiko.dev/#/bug/linux-29030bde-9a9e-4287-978a-034b8c472d84
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261115-ux500-drm-mcde-powerdomain-v1-1-afdc326cceb7@kernel.org?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/mcde: Use power domain for display power
2026-11-15 18:30 ` sashiko-bot
@ 2026-11-15 22:44 ` Linus Walleij
0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2026-11-15 22:44 UTC (permalink / raw)
To: sashiko-reviews; +Cc: dri-devel
On Sun, Nov 15, 2026 at 7:30 PM <sashiko-bot@kernel.org> wrote:
> Thank you for your contribution! Sashiko AI review found no new issues
> in this patch, but noticed 1 related pre-existing issue it does not
> introduce:
> - [High] drm/mcde: TOCTOU race in mcde_clk_div_recalc_rate() [1]
I'm happy to work on this *SEPARATELY* and on top of this one
since this functional patch is important, I don't want to build up a
typical Sashiko-tail of patches after this one.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-15 22:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-15 18:10 [PATCH] drm/mcde: Use power domain for display power Linus Walleij
2026-11-15 18:30 ` sashiko-bot
2026-11-15 22:44 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.