* [PATCH v11 1/5] bus: simple-pm-bus: Avoid inconsistencies between probe() and remove()
[not found] <20261119113758.603074-1-herve.codina@bootlin.com>
@ 2026-11-19 11:37 ` Herve Codina
0 siblings, 0 replies; only message in thread
From: Herve Codina @ 2026-11-19 11:37 UTC (permalink / raw)
To: Andrew Lunn, Rob Herring, Saravana Kannan, Geert Uytterhoeven,
Kalle Niemi, Matti Vaittinen, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren, Russell King,
Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
Johan Hovold
Cc: linux-omap, linux-arm-kernel, driver-core, devicetree,
linux-kernel, Allan Nielsen, Horatiu Vultur, Daniel Machon,
Steen Hegelund, Luca Ceresoli, Thomas Petazzoni, Herve Codina,
Sashiko, stable
At probe(), operations done depends on device_has_driver_override().
At remove() a call to device_has_driver_override() is also present to
identify operations that need to be done in order to revert operations
previously done at probe().
Nothing prevents device_has_driver_override() to return a different
value when called at probe() and when called at remove(). Indeed, a user
can set driver_override (or clear it) after the probe() call and before
the remove() call.
In that case, inconsistencies are present between pm_runtime_enable()
called at probe() and pm_runtime_disable() called at remove().
In order to ensure that pm_runtime_disable() is called only if
pm_runtime_enable() has been called at probe(), use the devres version
of pm_runtime_enable().
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://lore.kernel.org/all/20260630105701.7D0471F00A3A@smtp.kernel.org/
Fixes: 98e96cf80045 ("drivers: bus: simple-pm-bus: Add support for probing simple bus only devices")
Cc: stable@vger.kernel.org
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
drivers/bus/simple-pm-bus.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c
index c920bd6fbaaf..4322a778e801 100644
--- a/drivers/bus/simple-pm-bus.c
+++ b/drivers/bus/simple-pm-bus.c
@@ -29,6 +29,7 @@ static int simple_pm_bus_probe(struct platform_device *pdev)
struct device_node *np = dev->of_node;
const struct of_device_id *match;
struct simple_pm_bus *bus;
+ int ret;
/*
* Allow user to use driver_override to bind this driver to a
@@ -66,7 +67,9 @@ static int simple_pm_bus_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "%s\n", __func__);
- pm_runtime_enable(&pdev->dev);
+ ret = devm_pm_runtime_enable(&pdev->dev);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "failed enable pm_runtime\n");
if (np)
of_platform_populate(np, NULL, lookup, &pdev->dev);
@@ -76,14 +79,7 @@ static int simple_pm_bus_probe(struct platform_device *pdev)
static void simple_pm_bus_remove(struct platform_device *pdev)
{
- const void *data = of_device_get_match_data(&pdev->dev);
-
- if (device_has_driver_override(&pdev->dev) || data)
- return;
-
dev_dbg(&pdev->dev, "%s\n", __func__);
-
- pm_runtime_disable(&pdev->dev);
}
static int simple_pm_bus_runtime_suspend(struct device *dev)
--
2.56.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-19 11:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261119113758.603074-1-herve.codina@bootlin.com>
2026-11-19 11:37 ` [PATCH v11 1/5] bus: simple-pm-bus: Avoid inconsistencies between probe() and remove() Herve Codina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox