linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] i.MX91/93 BLK-CTRL improvements
@ 2025-12-01 17:12 Marco Felsch
  2025-12-01 17:12 ` [PATCH 1/3] pmdomain: imx93-blk-ctrl: cleanup error path Marco Felsch
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Marco Felsch @ 2025-12-01 17:12 UTC (permalink / raw)
  To: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam
  Cc: linux-pm, imx, linux-arm-kernel, linux-kernel, Marco Felsch

Hi,

there were several approaches to bring the sub-devices population
mainline [1,2] but non of them made it upstream. Both approaches were
part of either the i.MX93 LVDS or MIPI-CSI enablement.

This small patchset decouples the blk-ctrl changes which allows the
MIPI-CSI and LVDS patchstack to be rebased ontop of this patchset.

Before adding the sub-device supprt, I converted the driver to devm_*
only API.

Regards,
  Marco

[1] https://lore.kernel.org/all/20250701-95_cam-v1-3-c5172bab387b@nxp.com/
[2] https://lore.kernel.org/all/20250304154929.1785200-4-alexander.stein@ew.tq-group.com/

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
Marco Felsch (3):
      pmdomain: imx93-blk-ctrl: cleanup error path
      pmdomain: imx93-blk-ctrl: convert to devm_* only
      pmdomain: imx93-blk-ctrl: add support for optional subnodes

 drivers/pmdomain/imx/imx93-blk-ctrl.c | 75 ++++++++++++++++-------------------
 1 file changed, 34 insertions(+), 41 deletions(-)
---
base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
change-id: 20251201-v6-18-topic-imx93-blkctrl-341220f7084d

Best regards,
-- 
Marco Felsch <m.felsch@pengutronix.de>



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] pmdomain: imx93-blk-ctrl: cleanup error path
  2025-12-01 17:12 [PATCH 0/3] i.MX91/93 BLK-CTRL improvements Marco Felsch
@ 2025-12-01 17:12 ` Marco Felsch
  2025-12-01 22:37   ` Frank Li
  2025-12-02  7:48   ` Alexander Stein
  2025-12-01 17:12 ` [PATCH 2/3] pmdomain: imx93-blk-ctrl: convert to devm_* only Marco Felsch
  2025-12-01 17:12 ` [PATCH 3/3] pmdomain: imx93-blk-ctrl: add support for optional subnodes Marco Felsch
  2 siblings, 2 replies; 10+ messages in thread
From: Marco Felsch @ 2025-12-01 17:12 UTC (permalink / raw)
  To: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam
  Cc: linux-pm, imx, linux-arm-kernel, linux-kernel, Marco Felsch

Call dev_err_probe() directly during return to make the code more
compact.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/pmdomain/imx/imx93-blk-ctrl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
index e094fe5a42bf646c712f3eca4e66a313fa5a914c..2aa163aef8de4ee901b9cde76ce2aad246c8c08a 100644
--- a/drivers/pmdomain/imx/imx93-blk-ctrl.c
+++ b/drivers/pmdomain/imx/imx93-blk-ctrl.c
@@ -240,10 +240,8 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
 	bc->num_clks = bc_data->num_clks;
 
 	ret = devm_clk_bulk_get(dev, bc->num_clks, bc->clks);
-	if (ret) {
-		dev_err_probe(dev, ret, "failed to get bus clock\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to get bus clock\n");
 
 	for (i = 0; i < bc_data->num_domains; i++) {
 		const struct imx93_blk_ctrl_domain_data *data = &bc_data->domains[i];

-- 
2.47.3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] pmdomain: imx93-blk-ctrl: convert to devm_* only
  2025-12-01 17:12 [PATCH 0/3] i.MX91/93 BLK-CTRL improvements Marco Felsch
  2025-12-01 17:12 ` [PATCH 1/3] pmdomain: imx93-blk-ctrl: cleanup error path Marco Felsch
@ 2025-12-01 17:12 ` Marco Felsch
  2025-12-01 22:41   ` Frank Li
  2025-12-01 17:12 ` [PATCH 3/3] pmdomain: imx93-blk-ctrl: add support for optional subnodes Marco Felsch
  2 siblings, 1 reply; 10+ messages in thread
From: Marco Felsch @ 2025-12-01 17:12 UTC (permalink / raw)
  To: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam
  Cc: linux-pm, imx, linux-arm-kernel, linux-kernel, Marco Felsch

Some APIs used by this driver don't have devm_ helpers yet. Instead of
using the devm_add_action_or_reset() the current driver is based on hand
crafted error goto paths and a .remove() callback.

Convert the driver to devm_ APIs only by making use of
devm_add_action_or_reset() and devm_pm_runtime_enable() to simplify the
release and error path.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/pmdomain/imx/imx93-blk-ctrl.c | 64 +++++++++++++++--------------------
 1 file changed, 27 insertions(+), 37 deletions(-)

diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
index 2aa163aef8de4ee901b9cde76ce2aad246c8c08a..13b0de6dd689cf944e034f7666a4e97b0118e3bd 100644
--- a/drivers/pmdomain/imx/imx93-blk-ctrl.c
+++ b/drivers/pmdomain/imx/imx93-blk-ctrl.c
@@ -188,6 +188,20 @@ static int imx93_blk_ctrl_power_off(struct generic_pm_domain *genpd)
 	return 0;
 }
 
+static void imx93_release_genpd_provider(void *data)
+{
+	struct device_node *of_node = data;
+
+	of_genpd_del_provider(of_node);
+}
+
+static void imx93_release_pm_genpd(void *data)
+{
+	struct generic_pm_domain *genpd = data;
+
+	pm_genpd_remove(genpd);
+}
+
 static struct lock_class_key blk_ctrl_genpd_lock_class;
 
 static int imx93_blk_ctrl_probe(struct platform_device *pdev)
@@ -256,10 +270,8 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
 			domain->clks[j].id = data->clk_names[j];
 
 		ret = devm_clk_bulk_get(dev, data->num_clks, domain->clks);
-		if (ret) {
-			dev_err_probe(dev, ret, "failed to get clock\n");
-			goto cleanup_pds;
-		}
+		if (ret)
+			return dev_err_probe(dev, ret, "failed to get clock\n");
 
 		domain->genpd.name = data->name;
 		domain->genpd.power_on = imx93_blk_ctrl_power_on;
@@ -267,11 +279,12 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
 		domain->bc = bc;
 
 		ret = pm_genpd_init(&domain->genpd, NULL, true);
-		if (ret) {
-			dev_err_probe(dev, ret, "failed to init power domain\n");
-			goto cleanup_pds;
-		}
+		if (ret)
+			return dev_err_probe(dev, ret, "failed to init power domain\n");
 
+		ret = devm_add_action_or_reset(dev, imx93_release_pm_genpd, &domain->genpd);
+		if (ret)
+			return dev_err_probe(dev, ret, "failed to add pm_genpd release callback\n");
 		/*
 		 * We use runtime PM to trigger power on/off of the upstream GPC
 		 * domain, as a strict hierarchical parent/child power domain
@@ -288,39 +301,17 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
 		bc->onecell_data.domains[i] = &domain->genpd;
 	}
 
-	pm_runtime_enable(dev);
+	devm_pm_runtime_enable(dev);
 
 	ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data);
-	if (ret) {
-		dev_err_probe(dev, ret, "failed to add power domain provider\n");
-		goto cleanup_pds;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to add power domain provider\n");
 
-	dev_set_drvdata(dev, bc);
+	ret = devm_add_action_or_reset(dev, imx93_release_genpd_provider, dev->of_node);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to add genpd_provider release callback\n");
 
 	return 0;
-
-cleanup_pds:
-	for (i--; i >= 0; i--)
-		pm_genpd_remove(&bc->domains[i].genpd);
-
-	return ret;
-}
-
-static void imx93_blk_ctrl_remove(struct platform_device *pdev)
-{
-	struct imx93_blk_ctrl *bc = dev_get_drvdata(&pdev->dev);
-	int i;
-
-	of_genpd_del_provider(pdev->dev.of_node);
-
-	pm_runtime_disable(&pdev->dev);
-
-	for (i = 0; i < bc->onecell_data.num_domains; i++) {
-		struct imx93_blk_ctrl_domain *domain = &bc->domains[i];
-
-		pm_genpd_remove(&domain->genpd);
-	}
 }
 
 static const struct imx93_blk_ctrl_domain_data imx93_media_blk_ctl_domain_data[] = {
@@ -455,7 +446,6 @@ MODULE_DEVICE_TABLE(of, imx93_blk_ctrl_of_match);
 
 static struct platform_driver imx93_blk_ctrl_driver = {
 	.probe = imx93_blk_ctrl_probe,
-	.remove = imx93_blk_ctrl_remove,
 	.driver = {
 		.name = "imx93-blk-ctrl",
 		.of_match_table = imx93_blk_ctrl_of_match,

-- 
2.47.3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] pmdomain: imx93-blk-ctrl: add support for optional subnodes
  2025-12-01 17:12 [PATCH 0/3] i.MX91/93 BLK-CTRL improvements Marco Felsch
  2025-12-01 17:12 ` [PATCH 1/3] pmdomain: imx93-blk-ctrl: cleanup error path Marco Felsch
  2025-12-01 17:12 ` [PATCH 2/3] pmdomain: imx93-blk-ctrl: convert to devm_* only Marco Felsch
@ 2025-12-01 17:12 ` Marco Felsch
  2025-12-01 22:42   ` Frank Li
  2025-12-02  7:49   ` Alexander Stein
  2 siblings, 2 replies; 10+ messages in thread
From: Marco Felsch @ 2025-12-01 17:12 UTC (permalink / raw)
  To: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam
  Cc: linux-pm, imx, linux-arm-kernel, linux-kernel, Marco Felsch

This particular block can have DT subnodes describing the LVDS LDB, MIPI
DSI and parallel DPI bridge.

Scan for possible sub-devices within the driver, instead of misusing the
simple-bus to perform the scan.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/pmdomain/imx/imx93-blk-ctrl.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
index 13b0de6dd689cf944e034f7666a4e97b0118e3bd..8f79cabe07face872cb396bfb7329c230c4a97fe 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>
@@ -311,6 +312,10 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(dev, ret, "failed to add genpd_provider release callback\n");
 
+	ret = devm_of_platform_populate(dev);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to populate blk-ctrl sub-devices\n");
+
 	return 0;
 }
 

-- 
2.47.3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] pmdomain: imx93-blk-ctrl: cleanup error path
  2025-12-01 17:12 ` [PATCH 1/3] pmdomain: imx93-blk-ctrl: cleanup error path Marco Felsch
@ 2025-12-01 22:37   ` Frank Li
  2025-12-02  7:48   ` Alexander Stein
  1 sibling, 0 replies; 10+ messages in thread
From: Frank Li @ 2025-12-01 22:37 UTC (permalink / raw)
  To: Marco Felsch
  Cc: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, linux-pm, imx, linux-arm-kernel, linux-kernel

On Mon, Dec 01, 2025 at 06:12:05PM +0100, Marco Felsch wrote:
> Call dev_err_probe() directly during return to make the code more
> compact.
>
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/pmdomain/imx/imx93-blk-ctrl.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> index e094fe5a42bf646c712f3eca4e66a313fa5a914c..2aa163aef8de4ee901b9cde76ce2aad246c8c08a 100644
> --- a/drivers/pmdomain/imx/imx93-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> @@ -240,10 +240,8 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
>  	bc->num_clks = bc_data->num_clks;
>
>  	ret = devm_clk_bulk_get(dev, bc->num_clks, bc->clks);
> -	if (ret) {
> -		dev_err_probe(dev, ret, "failed to get bus clock\n");
> -		return ret;
> -	}
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to get bus clock\n");
>
>  	for (i = 0; i < bc_data->num_domains; i++) {
>  		const struct imx93_blk_ctrl_domain_data *data = &bc_data->domains[i];
>
> --
> 2.47.3
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] pmdomain: imx93-blk-ctrl: convert to devm_* only
  2025-12-01 17:12 ` [PATCH 2/3] pmdomain: imx93-blk-ctrl: convert to devm_* only Marco Felsch
@ 2025-12-01 22:41   ` Frank Li
  2025-12-02  7:57     ` Marco Felsch
  0 siblings, 1 reply; 10+ messages in thread
From: Frank Li @ 2025-12-01 22:41 UTC (permalink / raw)
  To: Marco Felsch
  Cc: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, linux-pm, imx, linux-arm-kernel, linux-kernel

On Mon, Dec 01, 2025 at 06:12:06PM +0100, Marco Felsch wrote:
> Some APIs used by this driver don't have devm_ helpers yet. Instead of
> using the devm_add_action_or_reset() the current driver is based on hand
> crafted error goto paths and a .remove() callback.
>
> Convert the driver to devm_ APIs only by making use of
> devm_add_action_or_reset() and devm_pm_runtime_enable() to simplify the
> release and error path.

Nit: I think keep this paragaph should be enough.

>
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  drivers/pmdomain/imx/imx93-blk-ctrl.c | 64 +++++++++++++++--------------------
>  1 file changed, 27 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> index 2aa163aef8de4ee901b9cde76ce2aad246c8c08a..13b0de6dd689cf944e034f7666a4e97b0118e3bd 100644
> --- a/drivers/pmdomain/imx/imx93-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> @@ -188,6 +188,20 @@ static int imx93_blk_ctrl_power_off(struct generic_pm_domain *genpd)
>  	return 0;
>  }
>
...
>  static struct lock_class_key blk_ctrl_genpd_lock_class;
>
>  static int imx93_blk_ctrl_probe(struct platform_device *pdev)
> @@ -256,10 +270,8 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
>  			domain->clks[j].id = data->clk_names[j];
>
>  		ret = devm_clk_bulk_get(dev, data->num_clks, domain->clks);
> -		if (ret) {
> -			dev_err_probe(dev, ret, "failed to get clock\n");
> -			goto cleanup_pds;
> -		}
> +		if (ret)
> +			return dev_err_probe(dev, ret, "failed to get clock\n");
>
>  		domain->genpd.name = data->name;
>  		domain->genpd.power_on = imx93_blk_ctrl_power_on;
> @@ -267,11 +279,12 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
>  		domain->bc = bc;
>
>  		ret = pm_genpd_init(&domain->genpd, NULL, true);
> -		if (ret) {
> -			dev_err_probe(dev, ret, "failed to init power domain\n");
> -			goto cleanup_pds;
> -		}
> +		if (ret)
> +			return dev_err_probe(dev, ret, "failed to init power domain\n");
>
> +		ret = devm_add_action_or_reset(dev, imx93_release_pm_genpd, &domain->genpd);
> +		if (ret)
> +			return dev_err_probe(dev, ret, "failed to add pm_genpd release callback\n");
>  		/*
>  		 * We use runtime PM to trigger power on/off of the upstream GPC
>  		 * domain, as a strict hierarchical parent/child power domain
> @@ -288,39 +301,17 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
>  		bc->onecell_data.domains[i] = &domain->genpd;
>  	}
>
> -	pm_runtime_enable(dev);
> +	devm_pm_runtime_enable(dev);

Need check return value

>
>  	ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data);
> -	if (ret) {
> -		dev_err_probe(dev, ret, "failed to add power domain provider\n");
> -		goto cleanup_pds;
> -	}
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to add power domain provider\n");
>
> -	dev_set_drvdata(dev, bc);

why remove dev_set_drvdata(dev, bc)

Frank
> +	ret = devm_add_action_or_reset(dev, imx93_release_genpd_provider, dev->of_node);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to add genpd_provider release callback\n");
>
>  	return 0;
> -
> -cleanup_pds:
> -	for (i--; i >= 0; i--)
> -		pm_genpd_remove(&bc->domains[i].genpd);
> -
> -	return ret;
> -}
> -
> -static void imx93_blk_ctrl_remove(struct platform_device *pdev)
> -{
> -	struct imx93_blk_ctrl *bc = dev_get_drvdata(&pdev->dev);
> -	int i;
> -
> -	of_genpd_del_provider(pdev->dev.of_node);
> -
> -	pm_runtime_disable(&pdev->dev);
> -
> -	for (i = 0; i < bc->onecell_data.num_domains; i++) {
> -		struct imx93_blk_ctrl_domain *domain = &bc->domains[i];
> -
> -		pm_genpd_remove(&domain->genpd);
> -	}
>  }
>
>  static const struct imx93_blk_ctrl_domain_data imx93_media_blk_ctl_domain_data[] = {
> @@ -455,7 +446,6 @@ MODULE_DEVICE_TABLE(of, imx93_blk_ctrl_of_match);
>
>  static struct platform_driver imx93_blk_ctrl_driver = {
>  	.probe = imx93_blk_ctrl_probe,
> -	.remove = imx93_blk_ctrl_remove,
>  	.driver = {
>  		.name = "imx93-blk-ctrl",
>  		.of_match_table = imx93_blk_ctrl_of_match,
>
> --
> 2.47.3
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] pmdomain: imx93-blk-ctrl: add support for optional subnodes
  2025-12-01 17:12 ` [PATCH 3/3] pmdomain: imx93-blk-ctrl: add support for optional subnodes Marco Felsch
@ 2025-12-01 22:42   ` Frank Li
  2025-12-02  7:49   ` Alexander Stein
  1 sibling, 0 replies; 10+ messages in thread
From: Frank Li @ 2025-12-01 22:42 UTC (permalink / raw)
  To: Marco Felsch
  Cc: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, linux-pm, imx, linux-arm-kernel, linux-kernel

On Mon, Dec 01, 2025 at 06:12:07PM +0100, Marco Felsch wrote:
> This particular block can have DT subnodes describing the LVDS LDB, MIPI
> DSI and parallel DPI bridge.
>
> Scan for possible sub-devices within the driver, instead of misusing the
> simple-bus to perform the scan.
>
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---

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

>  drivers/pmdomain/imx/imx93-blk-ctrl.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> index 13b0de6dd689cf944e034f7666a4e97b0118e3bd..8f79cabe07face872cb396bfb7329c230c4a97fe 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>
> @@ -311,6 +312,10 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
>  	if (ret)
>  		return dev_err_probe(dev, ret, "failed to add genpd_provider release callback\n");
>
> +	ret = devm_of_platform_populate(dev);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to populate blk-ctrl sub-devices\n");
> +
>  	return 0;
>  }
>
>
> --
> 2.47.3
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] pmdomain: imx93-blk-ctrl: cleanup error path
  2025-12-01 17:12 ` [PATCH 1/3] pmdomain: imx93-blk-ctrl: cleanup error path Marco Felsch
  2025-12-01 22:37   ` Frank Li
@ 2025-12-02  7:48   ` Alexander Stein
  1 sibling, 0 replies; 10+ messages in thread
From: Alexander Stein @ 2025-12-02  7:48 UTC (permalink / raw)
  To: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, linux-arm-kernel
  Cc: linux-pm, imx, linux-arm-kernel, linux-kernel, Marco Felsch,
	Marco Felsch

Am Montag, 1. Dezember 2025, 18:12:05 CET schrieb Marco Felsch:
> Call dev_err_probe() directly during return to make the code more
> compact.
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>

Reviewed-by: Alexander Stein <alexander.stein@ew.tq-group.com>

> ---
>  drivers/pmdomain/imx/imx93-blk-ctrl.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> index e094fe5a42bf646c712f3eca4e66a313fa5a914c..2aa163aef8de4ee901b9cde76ce2aad246c8c08a 100644
> --- a/drivers/pmdomain/imx/imx93-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> @@ -240,10 +240,8 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
>  	bc->num_clks = bc_data->num_clks;
>  
>  	ret = devm_clk_bulk_get(dev, bc->num_clks, bc->clks);
> -	if (ret) {
> -		dev_err_probe(dev, ret, "failed to get bus clock\n");
> -		return ret;
> -	}
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to get bus clock\n");
>  
>  	for (i = 0; i < bc_data->num_domains; i++) {
>  		const struct imx93_blk_ctrl_domain_data *data = &bc_data->domains[i];
> 
> 


-- 
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/




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] pmdomain: imx93-blk-ctrl: add support for optional subnodes
  2025-12-01 17:12 ` [PATCH 3/3] pmdomain: imx93-blk-ctrl: add support for optional subnodes Marco Felsch
  2025-12-01 22:42   ` Frank Li
@ 2025-12-02  7:49   ` Alexander Stein
  1 sibling, 0 replies; 10+ messages in thread
From: Alexander Stein @ 2025-12-02  7:49 UTC (permalink / raw)
  To: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, linux-arm-kernel
  Cc: linux-pm, imx, linux-arm-kernel, linux-kernel, Marco Felsch,
	Marco Felsch

[-- Attachment #1: Type: text/plain, Size: 1626 bytes --]

Am Montag, 1. Dezember 2025, 18:12:07 CET schrieb Marco Felsch:
> This particular block can have DT subnodes describing the LVDS LDB, MIPI
> DSI and parallel DPI bridge.
> 
> Scan for possible sub-devices within the driver, instead of misusing the
> simple-bus to perform the scan.
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>

Reviewed-by: Alexander Stein <alexander.stein@ew.tq-group.com>

> ---
>  drivers/pmdomain/imx/imx93-blk-ctrl.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> index 13b0de6dd689cf944e034f7666a4e97b0118e3bd..8f79cabe07face872cb396bfb7329c230c4a97fe 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>
> @@ -311,6 +312,10 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
>  	if (ret)
>  		return dev_err_probe(dev, ret, "failed to add genpd_provider release callback\n");
>  
> +	ret = devm_of_platform_populate(dev);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to populate blk-ctrl sub-devices\n");
> +
>  	return 0;
>  }
>  
> 
> 


-- 
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/

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] pmdomain: imx93-blk-ctrl: convert to devm_* only
  2025-12-01 22:41   ` Frank Li
@ 2025-12-02  7:57     ` Marco Felsch
  0 siblings, 0 replies; 10+ messages in thread
From: Marco Felsch @ 2025-12-02  7:57 UTC (permalink / raw)
  To: Frank Li
  Cc: Ulf Hansson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, linux-pm, imx, linux-arm-kernel, linux-kernel

On 25-12-01, Frank Li wrote:
> On Mon, Dec 01, 2025 at 06:12:06PM +0100, Marco Felsch wrote:
> > Some APIs used by this driver don't have devm_ helpers yet. Instead of
> > using the devm_add_action_or_reset() the current driver is based on hand
> > crafted error goto paths and a .remove() callback.
> >
> > Convert the driver to devm_ APIs only by making use of
> > devm_add_action_or_reset() and devm_pm_runtime_enable() to simplify the
> > release and error path.
> 
> Nit: I think keep this paragaph should be enough.

I can re-phrase it.

> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > ---
> >  drivers/pmdomain/imx/imx93-blk-ctrl.c | 64 +++++++++++++++--------------------
> >  1 file changed, 27 insertions(+), 37 deletions(-)
> >
> > diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> > index 2aa163aef8de4ee901b9cde76ce2aad246c8c08a..13b0de6dd689cf944e034f7666a4e97b0118e3bd 100644
> > --- a/drivers/pmdomain/imx/imx93-blk-ctrl.c
> > +++ b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> > @@ -188,6 +188,20 @@ static int imx93_blk_ctrl_power_off(struct generic_pm_domain *genpd)
> >  	return 0;
> >  }
> >
> ...
> >  static struct lock_class_key blk_ctrl_genpd_lock_class;
> >
> >  static int imx93_blk_ctrl_probe(struct platform_device *pdev)
> > @@ -256,10 +270,8 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
> >  			domain->clks[j].id = data->clk_names[j];
> >
> >  		ret = devm_clk_bulk_get(dev, data->num_clks, domain->clks);
> > -		if (ret) {
> > -			dev_err_probe(dev, ret, "failed to get clock\n");
> > -			goto cleanup_pds;
> > -		}
> > +		if (ret)
> > +			return dev_err_probe(dev, ret, "failed to get clock\n");
> >
> >  		domain->genpd.name = data->name;
> >  		domain->genpd.power_on = imx93_blk_ctrl_power_on;
> > @@ -267,11 +279,12 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
> >  		domain->bc = bc;
> >
> >  		ret = pm_genpd_init(&domain->genpd, NULL, true);
> > -		if (ret) {
> > -			dev_err_probe(dev, ret, "failed to init power domain\n");
> > -			goto cleanup_pds;
> > -		}
> > +		if (ret)
> > +			return dev_err_probe(dev, ret, "failed to init power domain\n");
> >
> > +		ret = devm_add_action_or_reset(dev, imx93_release_pm_genpd, &domain->genpd);
> > +		if (ret)
> > +			return dev_err_probe(dev, ret, "failed to add pm_genpd release callback\n");
> >  		/*
> >  		 * We use runtime PM to trigger power on/off of the upstream GPC
> >  		 * domain, as a strict hierarchical parent/child power domain
> > @@ -288,39 +301,17 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
> >  		bc->onecell_data.domains[i] = &domain->genpd;
> >  	}
> >
> > -	pm_runtime_enable(dev);
> > +	devm_pm_runtime_enable(dev);
> 
> Need check return value

Missed this one, thanks.

> >  	ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data);
> > -	if (ret) {
> > -		dev_err_probe(dev, ret, "failed to add power domain provider\n");
> > -		goto cleanup_pds;
> > -	}
> > +	if (ret)
> > +		return dev_err_probe(dev, ret, "failed to add power domain provider\n");
> >
> > -	dev_set_drvdata(dev, bc);
> 
> why remove dev_set_drvdata(dev, bc)

Because it's no longer needed, it was required due to the .remove()
callback. I wasn't sure if I should mention this within the commit
message. I'm going to add it to the commit message since you asked.

Regards,
  Marco

> 
> Frank
> > +	ret = devm_add_action_or_reset(dev, imx93_release_genpd_provider, dev->of_node);
> > +	if (ret)
> > +		return dev_err_probe(dev, ret, "failed to add genpd_provider release callback\n");
> >
> >  	return 0;
> > -
> > -cleanup_pds:
> > -	for (i--; i >= 0; i--)
> > -		pm_genpd_remove(&bc->domains[i].genpd);
> > -
> > -	return ret;
> > -}
> > -
> > -static void imx93_blk_ctrl_remove(struct platform_device *pdev)
> > -{
> > -	struct imx93_blk_ctrl *bc = dev_get_drvdata(&pdev->dev);
> > -	int i;
> > -
> > -	of_genpd_del_provider(pdev->dev.of_node);
> > -
> > -	pm_runtime_disable(&pdev->dev);
> > -
> > -	for (i = 0; i < bc->onecell_data.num_domains; i++) {
> > -		struct imx93_blk_ctrl_domain *domain = &bc->domains[i];
> > -
> > -		pm_genpd_remove(&domain->genpd);
> > -	}
> >  }
> >
> >  static const struct imx93_blk_ctrl_domain_data imx93_media_blk_ctl_domain_data[] = {
> > @@ -455,7 +446,6 @@ MODULE_DEVICE_TABLE(of, imx93_blk_ctrl_of_match);
> >
> >  static struct platform_driver imx93_blk_ctrl_driver = {
> >  	.probe = imx93_blk_ctrl_probe,
> > -	.remove = imx93_blk_ctrl_remove,
> >  	.driver = {
> >  		.name = "imx93-blk-ctrl",
> >  		.of_match_table = imx93_blk_ctrl_of_match,
> >
> > --
> > 2.47.3
> >
> 

-- 
#gernperDu 
#CallMeByMyFirstName

Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-9    |


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-12-02  7:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-01 17:12 [PATCH 0/3] i.MX91/93 BLK-CTRL improvements Marco Felsch
2025-12-01 17:12 ` [PATCH 1/3] pmdomain: imx93-blk-ctrl: cleanup error path Marco Felsch
2025-12-01 22:37   ` Frank Li
2025-12-02  7:48   ` Alexander Stein
2025-12-01 17:12 ` [PATCH 2/3] pmdomain: imx93-blk-ctrl: convert to devm_* only Marco Felsch
2025-12-01 22:41   ` Frank Li
2025-12-02  7:57     ` Marco Felsch
2025-12-01 17:12 ` [PATCH 3/3] pmdomain: imx93-blk-ctrl: add support for optional subnodes Marco Felsch
2025-12-01 22:42   ` Frank Li
2025-12-02  7:49   ` Alexander Stein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).