[PATCH v3 3/6] pmdomain: imx93-blk-ctrl: Scan subnodes and bind drivers to them

Alexander Stein posted 6 patches 9 months, 2 weeks ago
[PATCH v3 3/6] pmdomain: imx93-blk-ctrl: Scan subnodes and bind drivers to them
Posted by Alexander Stein 9 months, 2 weeks ago
This particular block can have DT subnodes describing the LVDS LDB
bridge. Instead of misusing simple-bus to scan for those nodes, do
the scan within the driver.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/pmdomain/imx/imx93-blk-ctrl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
index 0e2ba8ec55d75..fe2ff7a457502 100644
--- a/drivers/pmdomain/imx/imx93-blk-ctrl.c
+++ b/drivers/pmdomain/imx/imx93-blk-ctrl.c
@@ -7,6 +7,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
@@ -297,8 +298,14 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
 
 	dev_set_drvdata(dev, bc);
 
+	ret = devm_of_platform_populate(dev);
+	if (ret)
+		goto cleanup_provider;
+
 	return 0;
 
+cleanup_provider:
+	of_genpd_del_provider(dev->of_node);
 cleanup_pds:
 	for (i--; i >= 0; i--)
 		pm_genpd_remove(&bc->domains[i].genpd);
-- 
2.43.0
Re: [PATCH v3 3/6] pmdomain: imx93-blk-ctrl: Scan subnodes and bind drivers to them
Posted by Krzysztof Kozlowski 9 months, 2 weeks ago
On Tue, Mar 04, 2025 at 04:49:22PM +0100, Alexander Stein wrote:
> +#include <linux/of_platform.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_domain.h>
>  #include <linux/pm_runtime.h>
> @@ -297,8 +298,14 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
>  
>  	dev_set_drvdata(dev, bc);
>  
> +	ret = devm_of_platform_populate(dev);

This means in remove() you will depopulate in different order than error
path (e.g. after genpd removal). This is rather unexpected - remove()
should be cleaning up in exactly reversed order of probe. Not sure if it
can lead to any issues, but usual recommendation is that you either use
devm() or not.

Best regards,
Krzysztof
Re: [PATCH v3 3/6] pmdomain: imx93-blk-ctrl: Scan subnodes and bind drivers to them
Posted by Alexander Stein 9 months, 2 weeks ago
Hi Krzysztof,

Am Mittwoch, 5. März 2025, 08:17:23 CET schrieb Krzysztof Kozlowski:
> On Tue, Mar 04, 2025 at 04:49:22PM +0100, Alexander Stein wrote:
> > +#include <linux/of_platform.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/pm_domain.h>
> >  #include <linux/pm_runtime.h>
> > @@ -297,8 +298,14 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
> >  
> >  	dev_set_drvdata(dev, bc);
> >  
> > +	ret = devm_of_platform_populate(dev);
> 
> This means in remove() you will depopulate in different order than error
> path (e.g. after genpd removal). This is rather unexpected - remove()
> should be cleaning up in exactly reversed order of probe. Not sure if it
> can lead to any issues, but usual recommendation is that you either use
> devm() or not.

Thanks for pointing out. I will add a devm_of_platform_depopulate() to
remove().

Best regards
Alexander
-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
Re: [PATCH v3 3/6] pmdomain: imx93-blk-ctrl: Scan subnodes and bind drivers to them
Posted by Frank Li 9 months, 2 weeks ago
On Tue, Mar 04, 2025 at 04:49:22PM +0100, Alexander Stein wrote:
> This particular block can have DT subnodes describing the LVDS LDB
> bridge. Instead of misusing simple-bus to scan for those nodes, do
> the scan within the driver.
>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> ---
>  drivers/pmdomain/imx/imx93-blk-ctrl.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> index 0e2ba8ec55d75..fe2ff7a457502 100644
> --- a/drivers/pmdomain/imx/imx93-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> @@ -7,6 +7,7 @@
>  #include <linux/device.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> +#include <linux/of_platform.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_domain.h>
>  #include <linux/pm_runtime.h>
> @@ -297,8 +298,14 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
>
>  	dev_set_drvdata(dev, bc);
>
> +	ret = devm_of_platform_populate(dev);
> +	if (ret)
> +		goto cleanup_provider;
> +
>  	return 0;
>
> +cleanup_provider:
> +	of_genpd_del_provider(dev->of_node);
>  cleanup_pds:
>  	for (i--; i >= 0; i--)
>  		pm_genpd_remove(&bc->domains[i].genpd);
> --
> 2.43.0
>