All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 30/31] PM / devfreq: exynos: convert to use devm_pm_opp_* API
@ 2021-01-03  3:56 ` Yangtao Li
  0 siblings, 0 replies; 4+ messages in thread
From: Yangtao Li @ 2021-01-03  3:56 UTC (permalink / raw)
  To: myungjoo.ham, kyungmin.park, cw00.choi, krzk, shawnguo, s.hauer,
	kernel, festevam, linux-imx, digetx, thierry.reding, jonathanh,
	yuq825, airlied, daniel, robdclark, sean, robh, tomeu.vizoso,
	steven.price, alyssa.rosenzweig, stanimir.varbanov, agross,
	bjorn.andersson, mchehab, lukasz.luba, adrian.hunter,
	ulf.hansson, vireshk, nm, sboyd, broonie, gregkh, jirislaby, rjw,
	jcrouse, hoegsberg, eric, tzimmermann, marijn.suijten,
	gustavoars, emil.velikov, jonathan, akhilpo, smasetty, airlied,
	masneyb, kalyan_t, tanmay, tiny.windzz, ddavenport, jsanka,
	rnayak, tongtiangen, miaoqinglang, khsieh, abhinavk, chandanu,
	groeck, varar, mka, harigovi, rikard.falkeborn, natechancellor,
	georgi.djakov, akashast, parashar, dianders
  Cc: linux-pm, linux-kernel, linux-samsung-soc, linux-arm-kernel,
	linux-tegra, dri-devel, lima, linux-arm-msm, freedreno,
	linux-media, linux-mmc, linux-spi, linux-serial

Use devm_pm_opp_* API to simplify code, and remove opp_table
from exynos_bus.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/devfreq/exynos-bus.c | 42 ++++++++----------------------------
 1 file changed, 9 insertions(+), 33 deletions(-)

diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
index e689101abc93..51752e5ce980 100644
--- a/drivers/devfreq/exynos-bus.c
+++ b/drivers/devfreq/exynos-bus.c
@@ -33,7 +33,6 @@ struct exynos_bus {
 
 	unsigned long curr_freq;
 
-	struct opp_table *opp_table;
 	struct clk *clk;
 	unsigned int ratio;
 };
@@ -159,10 +158,7 @@ static void exynos_bus_exit(struct device *dev)
 
 	platform_device_unregister(bus->icc_pdev);
 
-	dev_pm_opp_of_remove_table(dev);
 	clk_disable_unprepare(bus->clk);
-	dev_pm_opp_put_regulators(bus->opp_table);
-	bus->opp_table = NULL;
 }
 
 static void exynos_bus_passive_exit(struct device *dev)
@@ -171,7 +167,6 @@ static void exynos_bus_passive_exit(struct device *dev)
 
 	platform_device_unregister(bus->icc_pdev);
 
-	dev_pm_opp_of_remove_table(dev);
 	clk_disable_unprepare(bus->clk);
 }
 
@@ -183,15 +178,13 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
 	const char *vdd = "vdd";
 	int i, ret, count, size;
 
-	opp_table = dev_pm_opp_set_regulators(dev, &vdd, 1);
+	opp_table = devm_pm_opp_set_regulators(dev, &vdd, 1);
 	if (IS_ERR(opp_table)) {
 		ret = PTR_ERR(opp_table);
 		dev_err(dev, "failed to set regulators %d\n", ret);
 		return ret;
 	}
 
-	bus->opp_table = opp_table;
-
 	/*
 	 * Get the devfreq-event devices to get the current utilization of
 	 * buses. This raw data will be used in devfreq ondemand governor.
@@ -199,25 +192,20 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
 	count = devfreq_event_get_edev_count(dev, "devfreq-events");
 	if (count < 0) {
 		dev_err(dev, "failed to get the count of devfreq-event dev\n");
-		ret = count;
-		goto err_regulator;
+		return count;
 	}
 	bus->edev_count = count;
 
 	size = sizeof(*bus->edev) * count;
 	bus->edev = devm_kzalloc(dev, size, GFP_KERNEL);
-	if (!bus->edev) {
-		ret = -ENOMEM;
-		goto err_regulator;
-	}
+	if (!bus->edev)
+		return -ENOMEM;
 
 	for (i = 0; i < count; i++) {
 		bus->edev[i] = devfreq_event_get_edev_by_phandle(dev,
 							"devfreq-events", i);
-		if (IS_ERR(bus->edev[i])) {
-			ret = -EPROBE_DEFER;
-			goto err_regulator;
-		}
+		if (IS_ERR(bus->edev[i]))
+			return -EPROBE_DEFER;
 	}
 
 	/*
@@ -234,12 +222,6 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
 		bus->ratio = DEFAULT_SATURATION_RATIO;
 
 	return 0;
-
-err_regulator:
-	dev_pm_opp_put_regulators(bus->opp_table);
-	bus->opp_table = NULL;
-
-	return ret;
 }
 
 static int exynos_bus_parse_of(struct device_node *np,
@@ -264,7 +246,7 @@ static int exynos_bus_parse_of(struct device_node *np,
 	}
 
 	/* Get the freq and voltage from OPP table to scale the bus freq */
-	ret = dev_pm_opp_of_add_table(dev);
+	ret = devm_pm_opp_of_add_table(dev);
 	if (ret < 0) {
 		dev_err(dev, "failed to get OPP table\n");
 		goto err_clk;
@@ -276,15 +258,13 @@ static int exynos_bus_parse_of(struct device_node *np,
 	if (IS_ERR(opp)) {
 		dev_err(dev, "failed to find dev_pm_opp\n");
 		ret = PTR_ERR(opp);
-		goto err_opp;
+		goto err_clk;
 	}
 	bus->curr_freq = dev_pm_opp_get_freq(opp);
 	dev_pm_opp_put(opp);
 
 	return 0;
 
-err_opp:
-	dev_pm_opp_of_remove_table(dev);
 err_clk:
 	clk_disable_unprepare(bus->clk);
 
@@ -425,7 +405,7 @@ static int exynos_bus_probe(struct platform_device *pdev)
 	/* Parse the device-tree to get the resource information */
 	ret = exynos_bus_parse_of(np, bus);
 	if (ret < 0)
-		goto err_reg;
+		return ret;
 
 	if (passive)
 		ret = exynos_bus_profile_init_passive(bus, profile);
@@ -456,11 +436,7 @@ static int exynos_bus_probe(struct platform_device *pdev)
 	return 0;
 
 err:
-	dev_pm_opp_of_remove_table(dev);
 	clk_disable_unprepare(bus->clk);
-err_reg:
-	dev_pm_opp_put_regulators(bus->opp_table);
-	bus->opp_table = NULL;
 
 	return ret;
 }
-- 
2.25.1


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

* [PATCH 30/31] PM / devfreq: exynos: convert to use devm_pm_opp_* API
@ 2021-01-03  3:56 ` Yangtao Li
  0 siblings, 0 replies; 4+ messages in thread
From: Yangtao Li @ 2021-01-03  3:56 UTC (permalink / raw)
  To: myungjoo.ham, kyungmin.park, cw00.choi, krzk, shawnguo, s.hauer,
	kernel, festevam, linux-imx, digetx, thierry.reding, jonathanh,
	yuq825, airlied, daniel, robdclark, sean, robh, tomeu.vizoso,
	steven.price, alyssa.rosenzweig, stanimir.varbanov, agross,
	bjorn.andersson, mchehab, lukasz.luba, adrian.hunter,
	ulf.hansson, vireshk, nm, sboyd, broonie, gregkh, jirislaby, rjw,
	jcrouse, hoegsberg, eric, tzimmermann, marijn.suijten,
	gustavoars, emil.velikov, jonathan, akhilpo, smasetty, airlied,
	masneyb, kalyan_t, tanmay, tiny.windzz, ddavenport, jsanka,
	rnayak, tongtiangen, miaoqinglang, khsieh, abhinavk, chandanu,
	groeck, varar, mka, harigovi, rikard.falkeborn, natechancellor,
	georgi.djakov, akashast, parashar, dianders
  Cc: linux-samsung-soc, lima, linux-pm, linux-arm-msm, linux-mmc,
	linux-kernel, dri-devel, linux-spi, linux-serial, linux-tegra,
	freedreno, linux-arm-kernel, linux-media

Use devm_pm_opp_* API to simplify code, and remove opp_table
from exynos_bus.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/devfreq/exynos-bus.c | 42 ++++++++----------------------------
 1 file changed, 9 insertions(+), 33 deletions(-)

diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
index e689101abc93..51752e5ce980 100644
--- a/drivers/devfreq/exynos-bus.c
+++ b/drivers/devfreq/exynos-bus.c
@@ -33,7 +33,6 @@ struct exynos_bus {
 
 	unsigned long curr_freq;
 
-	struct opp_table *opp_table;
 	struct clk *clk;
 	unsigned int ratio;
 };
@@ -159,10 +158,7 @@ static void exynos_bus_exit(struct device *dev)
 
 	platform_device_unregister(bus->icc_pdev);
 
-	dev_pm_opp_of_remove_table(dev);
 	clk_disable_unprepare(bus->clk);
-	dev_pm_opp_put_regulators(bus->opp_table);
-	bus->opp_table = NULL;
 }
 
 static void exynos_bus_passive_exit(struct device *dev)
@@ -171,7 +167,6 @@ static void exynos_bus_passive_exit(struct device *dev)
 
 	platform_device_unregister(bus->icc_pdev);
 
-	dev_pm_opp_of_remove_table(dev);
 	clk_disable_unprepare(bus->clk);
 }
 
@@ -183,15 +178,13 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
 	const char *vdd = "vdd";
 	int i, ret, count, size;
 
-	opp_table = dev_pm_opp_set_regulators(dev, &vdd, 1);
+	opp_table = devm_pm_opp_set_regulators(dev, &vdd, 1);
 	if (IS_ERR(opp_table)) {
 		ret = PTR_ERR(opp_table);
 		dev_err(dev, "failed to set regulators %d\n", ret);
 		return ret;
 	}
 
-	bus->opp_table = opp_table;
-
 	/*
 	 * Get the devfreq-event devices to get the current utilization of
 	 * buses. This raw data will be used in devfreq ondemand governor.
@@ -199,25 +192,20 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
 	count = devfreq_event_get_edev_count(dev, "devfreq-events");
 	if (count < 0) {
 		dev_err(dev, "failed to get the count of devfreq-event dev\n");
-		ret = count;
-		goto err_regulator;
+		return count;
 	}
 	bus->edev_count = count;
 
 	size = sizeof(*bus->edev) * count;
 	bus->edev = devm_kzalloc(dev, size, GFP_KERNEL);
-	if (!bus->edev) {
-		ret = -ENOMEM;
-		goto err_regulator;
-	}
+	if (!bus->edev)
+		return -ENOMEM;
 
 	for (i = 0; i < count; i++) {
 		bus->edev[i] = devfreq_event_get_edev_by_phandle(dev,
 							"devfreq-events", i);
-		if (IS_ERR(bus->edev[i])) {
-			ret = -EPROBE_DEFER;
-			goto err_regulator;
-		}
+		if (IS_ERR(bus->edev[i]))
+			return -EPROBE_DEFER;
 	}
 
 	/*
@@ -234,12 +222,6 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
 		bus->ratio = DEFAULT_SATURATION_RATIO;
 
 	return 0;
-
-err_regulator:
-	dev_pm_opp_put_regulators(bus->opp_table);
-	bus->opp_table = NULL;
-
-	return ret;
 }
 
 static int exynos_bus_parse_of(struct device_node *np,
@@ -264,7 +246,7 @@ static int exynos_bus_parse_of(struct device_node *np,
 	}
 
 	/* Get the freq and voltage from OPP table to scale the bus freq */
-	ret = dev_pm_opp_of_add_table(dev);
+	ret = devm_pm_opp_of_add_table(dev);
 	if (ret < 0) {
 		dev_err(dev, "failed to get OPP table\n");
 		goto err_clk;
@@ -276,15 +258,13 @@ static int exynos_bus_parse_of(struct device_node *np,
 	if (IS_ERR(opp)) {
 		dev_err(dev, "failed to find dev_pm_opp\n");
 		ret = PTR_ERR(opp);
-		goto err_opp;
+		goto err_clk;
 	}
 	bus->curr_freq = dev_pm_opp_get_freq(opp);
 	dev_pm_opp_put(opp);
 
 	return 0;
 
-err_opp:
-	dev_pm_opp_of_remove_table(dev);
 err_clk:
 	clk_disable_unprepare(bus->clk);
 
@@ -425,7 +405,7 @@ static int exynos_bus_probe(struct platform_device *pdev)
 	/* Parse the device-tree to get the resource information */
 	ret = exynos_bus_parse_of(np, bus);
 	if (ret < 0)
-		goto err_reg;
+		return ret;
 
 	if (passive)
 		ret = exynos_bus_profile_init_passive(bus, profile);
@@ -456,11 +436,7 @@ static int exynos_bus_probe(struct platform_device *pdev)
 	return 0;
 
 err:
-	dev_pm_opp_of_remove_table(dev);
 	clk_disable_unprepare(bus->clk);
-err_reg:
-	dev_pm_opp_put_regulators(bus->opp_table);
-	bus->opp_table = NULL;
 
 	return ret;
 }
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 30/31] PM / devfreq: exynos: convert to use devm_pm_opp_* API
  2021-01-03  3:56 ` Yangtao Li
@ 2021-01-05  4:35   ` Chanwoo Choi
  -1 siblings, 0 replies; 4+ messages in thread
From: Chanwoo Choi @ 2021-01-05  4:35 UTC (permalink / raw)
  To: Yangtao Li
  Cc: MyungJoo Ham, Kyungmin Park, Chanwoo Choi, Krzysztof Kozlowski,
	Shawn Guo, s.hauer, kernel, festevam, dl-linux-imx,
	Dmitry Osipenko, Thierry Reding, Jonathan Hunter, yuq825,
	David Airlie, daniel, robdclark, sean, Rob Herring, tomeu.vizoso,
	steven.price, alyssa.rosenzweig, stanimir.varbanov, agross,
	Bjorn Andersson, mchehab, Lukasz Luba, adrian.hunter,
	Ulf Hansson, Viresh Kumar, Nishanth Menon, Stephen Boyd,
	Mark Brown, Greg KH, jirislaby, Rafael J. Wysocki, jcrouse,
	hoegsberg, eric, tzimmermann, marijn.suijten, gustavoars,
	emil.velikov, jonathan, akhilpo, smasetty, airlied, masneyb,
	kalyan_t, tanmay, ddavenport, jsanka, rnayak, tongtiangen,
	miaoqinglang, khsieh, abhinavk, chandanu, Guenter Roeck, varar,
	Matthias Kaehlcke, harigovi, rikard.falkeborn, natechancellor,
	Georgi Djakov, akashast, parashar, Doug Anderson, Linux PM list,
	linux-kernel, linux-samsung-soc, linux-arm-kernel, linux-tegra,
	dri-devel, lima, linux-arm-msm, freedreno, linux-media,
	linux-mmc, linux-spi, linux-serial

On Sun, Jan 3, 2021 at 12:59 PM Yangtao Li <tiny.windzz@gmail.com> wrote:
>
> Use devm_pm_opp_* API to simplify code, and remove opp_table
> from exynos_bus.
>
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> ---
>  drivers/devfreq/exynos-bus.c | 42 ++++++++----------------------------
>  1 file changed, 9 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
> index e689101abc93..51752e5ce980 100644
> --- a/drivers/devfreq/exynos-bus.c
> +++ b/drivers/devfreq/exynos-bus.c
> @@ -33,7 +33,6 @@ struct exynos_bus {
>
>         unsigned long curr_freq;
>
> -       struct opp_table *opp_table;
>         struct clk *clk;
>         unsigned int ratio;
>  };
> @@ -159,10 +158,7 @@ static void exynos_bus_exit(struct device *dev)
>
>         platform_device_unregister(bus->icc_pdev);
>
> -       dev_pm_opp_of_remove_table(dev);
>         clk_disable_unprepare(bus->clk);
> -       dev_pm_opp_put_regulators(bus->opp_table);

OPP uses the clock and regulator. It means that there are dependency
between them and the sequence for resource free.

I think that OPP should be removed before clock and regulator.
Your patch always guarantee this dependency? If not, we have to
free the resource according to the dependency.

> -       bus->opp_table = NULL;
>  }
>
>  static void exynos_bus_passive_exit(struct device *dev)
> @@ -171,7 +167,6 @@ static void exynos_bus_passive_exit(struct device *dev)
>
>         platform_device_unregister(bus->icc_pdev);
>
> -       dev_pm_opp_of_remove_table(dev);
>         clk_disable_unprepare(bus->clk);
>  }
>
> @@ -183,15 +178,13 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
>         const char *vdd = "vdd";
>         int i, ret, count, size;
>
> -       opp_table = dev_pm_opp_set_regulators(dev, &vdd, 1);
> +       opp_table = devm_pm_opp_set_regulators(dev, &vdd, 1);
>         if (IS_ERR(opp_table)) {
>                 ret = PTR_ERR(opp_table);
>                 dev_err(dev, "failed to set regulators %d\n", ret);
>                 return ret;
>         }
>
> -       bus->opp_table = opp_table;
> -
>         /*
>          * Get the devfreq-event devices to get the current utilization of
>          * buses. This raw data will be used in devfreq ondemand governor.
> @@ -199,25 +192,20 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
>         count = devfreq_event_get_edev_count(dev, "devfreq-events");
>         if (count < 0) {
>                 dev_err(dev, "failed to get the count of devfreq-event dev\n");
> -               ret = count;
> -               goto err_regulator;
> +               return count;
>         }
>         bus->edev_count = count;
>
>         size = sizeof(*bus->edev) * count;
>         bus->edev = devm_kzalloc(dev, size, GFP_KERNEL);
> -       if (!bus->edev) {
> -               ret = -ENOMEM;
> -               goto err_regulator;
> -       }
> +       if (!bus->edev)
> +               return -ENOMEM;
>
>         for (i = 0; i < count; i++) {
>                 bus->edev[i] = devfreq_event_get_edev_by_phandle(dev,
>                                                         "devfreq-events", i);
> -               if (IS_ERR(bus->edev[i])) {
> -                       ret = -EPROBE_DEFER;
> -                       goto err_regulator;
> -               }
> +               if (IS_ERR(bus->edev[i]))
> +                       return -EPROBE_DEFER;
>         }
>
>         /*
> @@ -234,12 +222,6 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
>                 bus->ratio = DEFAULT_SATURATION_RATIO;
>
>         return 0;
> -
> -err_regulator:
> -       dev_pm_opp_put_regulators(bus->opp_table);
> -       bus->opp_table = NULL;
> -
> -       return ret;
>  }
>
>  static int exynos_bus_parse_of(struct device_node *np,
> @@ -264,7 +246,7 @@ static int exynos_bus_parse_of(struct device_node *np,
>         }
>
>         /* Get the freq and voltage from OPP table to scale the bus freq */
> -       ret = dev_pm_opp_of_add_table(dev);
> +       ret = devm_pm_opp_of_add_table(dev);
>         if (ret < 0) {
>                 dev_err(dev, "failed to get OPP table\n");
>                 goto err_clk;
> @@ -276,15 +258,13 @@ static int exynos_bus_parse_of(struct device_node *np,
>         if (IS_ERR(opp)) {
>                 dev_err(dev, "failed to find dev_pm_opp\n");
>                 ret = PTR_ERR(opp);
> -               goto err_opp;
> +               goto err_clk;
>         }
>         bus->curr_freq = dev_pm_opp_get_freq(opp);
>         dev_pm_opp_put(opp);
>
>         return 0;
>
> -err_opp:
> -       dev_pm_opp_of_remove_table(dev);
>  err_clk:
>         clk_disable_unprepare(bus->clk);
>
> @@ -425,7 +405,7 @@ static int exynos_bus_probe(struct platform_device *pdev)
>         /* Parse the device-tree to get the resource information */
>         ret = exynos_bus_parse_of(np, bus);
>         if (ret < 0)
> -               goto err_reg;
> +               return ret;
>
>         if (passive)
>                 ret = exynos_bus_profile_init_passive(bus, profile);
> @@ -456,11 +436,7 @@ static int exynos_bus_probe(struct platform_device *pdev)
>         return 0;
>
>  err:
> -       dev_pm_opp_of_remove_table(dev);
>         clk_disable_unprepare(bus->clk);
> -err_reg:
> -       dev_pm_opp_put_regulators(bus->opp_table);
> -       bus->opp_table = NULL;
>
>         return ret;
>  }
> --
> 2.25.1
>


-- 
Best Regards,
Chanwoo Choi

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

* Re: [PATCH 30/31] PM / devfreq: exynos: convert to use devm_pm_opp_* API
@ 2021-01-05  4:35   ` Chanwoo Choi
  0 siblings, 0 replies; 4+ messages in thread
From: Chanwoo Choi @ 2021-01-05  4:35 UTC (permalink / raw)
  To: Yangtao Li
  Cc: Nishanth Menon, Ulf Hansson, gustavoars, jirislaby, David Airlie,
	linux-mmc, stanimir.varbanov, tanmay, Bjorn Andersson,
	natechancellor, Thierry Reding, tongtiangen, Guenter Roeck,
	marijn.suijten, Dmitry Osipenko, steven.price, Matthias Kaehlcke,
	chandanu, emil.velikov, linux-samsung-soc, jonathan, harigovi,
	adrian.hunter, Viresh Kumar, Linux PM list, Kyungmin Park,
	Krzysztof Kozlowski, Jonathan Hunter, Chanwoo Choi, MyungJoo Ham,
	alyssa.rosenzweig, linux-serial, airlied, smasetty, dl-linux-imx,
	freedreno, kernel, tzimmermann, linux-arm-msm, s.hauer,
	linux-spi, linux-media, abhinavk, akhilpo, khsieh, lima,
	Mark Brown, rikard.falkeborn, kalyan_t, linux-tegra, varar,
	mchehab, sean, linux-arm-kernel, Doug Anderson, akashast, rnayak,
	parashar, tomeu.vizoso, Stephen Boyd, Greg KH, dri-devel,
	Rafael J. Wysocki, agross, linux-kernel, miaoqinglang, hoegsberg,
	yuq825, ddavenport, masneyb, Shawn Guo, Georgi Djakov,
	Lukasz Luba

On Sun, Jan 3, 2021 at 12:59 PM Yangtao Li <tiny.windzz@gmail.com> wrote:
>
> Use devm_pm_opp_* API to simplify code, and remove opp_table
> from exynos_bus.
>
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> ---
>  drivers/devfreq/exynos-bus.c | 42 ++++++++----------------------------
>  1 file changed, 9 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
> index e689101abc93..51752e5ce980 100644
> --- a/drivers/devfreq/exynos-bus.c
> +++ b/drivers/devfreq/exynos-bus.c
> @@ -33,7 +33,6 @@ struct exynos_bus {
>
>         unsigned long curr_freq;
>
> -       struct opp_table *opp_table;
>         struct clk *clk;
>         unsigned int ratio;
>  };
> @@ -159,10 +158,7 @@ static void exynos_bus_exit(struct device *dev)
>
>         platform_device_unregister(bus->icc_pdev);
>
> -       dev_pm_opp_of_remove_table(dev);
>         clk_disable_unprepare(bus->clk);
> -       dev_pm_opp_put_regulators(bus->opp_table);

OPP uses the clock and regulator. It means that there are dependency
between them and the sequence for resource free.

I think that OPP should be removed before clock and regulator.
Your patch always guarantee this dependency? If not, we have to
free the resource according to the dependency.

> -       bus->opp_table = NULL;
>  }
>
>  static void exynos_bus_passive_exit(struct device *dev)
> @@ -171,7 +167,6 @@ static void exynos_bus_passive_exit(struct device *dev)
>
>         platform_device_unregister(bus->icc_pdev);
>
> -       dev_pm_opp_of_remove_table(dev);
>         clk_disable_unprepare(bus->clk);
>  }
>
> @@ -183,15 +178,13 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
>         const char *vdd = "vdd";
>         int i, ret, count, size;
>
> -       opp_table = dev_pm_opp_set_regulators(dev, &vdd, 1);
> +       opp_table = devm_pm_opp_set_regulators(dev, &vdd, 1);
>         if (IS_ERR(opp_table)) {
>                 ret = PTR_ERR(opp_table);
>                 dev_err(dev, "failed to set regulators %d\n", ret);
>                 return ret;
>         }
>
> -       bus->opp_table = opp_table;
> -
>         /*
>          * Get the devfreq-event devices to get the current utilization of
>          * buses. This raw data will be used in devfreq ondemand governor.
> @@ -199,25 +192,20 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
>         count = devfreq_event_get_edev_count(dev, "devfreq-events");
>         if (count < 0) {
>                 dev_err(dev, "failed to get the count of devfreq-event dev\n");
> -               ret = count;
> -               goto err_regulator;
> +               return count;
>         }
>         bus->edev_count = count;
>
>         size = sizeof(*bus->edev) * count;
>         bus->edev = devm_kzalloc(dev, size, GFP_KERNEL);
> -       if (!bus->edev) {
> -               ret = -ENOMEM;
> -               goto err_regulator;
> -       }
> +       if (!bus->edev)
> +               return -ENOMEM;
>
>         for (i = 0; i < count; i++) {
>                 bus->edev[i] = devfreq_event_get_edev_by_phandle(dev,
>                                                         "devfreq-events", i);
> -               if (IS_ERR(bus->edev[i])) {
> -                       ret = -EPROBE_DEFER;
> -                       goto err_regulator;
> -               }
> +               if (IS_ERR(bus->edev[i]))
> +                       return -EPROBE_DEFER;
>         }
>
>         /*
> @@ -234,12 +222,6 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
>                 bus->ratio = DEFAULT_SATURATION_RATIO;
>
>         return 0;
> -
> -err_regulator:
> -       dev_pm_opp_put_regulators(bus->opp_table);
> -       bus->opp_table = NULL;
> -
> -       return ret;
>  }
>
>  static int exynos_bus_parse_of(struct device_node *np,
> @@ -264,7 +246,7 @@ static int exynos_bus_parse_of(struct device_node *np,
>         }
>
>         /* Get the freq and voltage from OPP table to scale the bus freq */
> -       ret = dev_pm_opp_of_add_table(dev);
> +       ret = devm_pm_opp_of_add_table(dev);
>         if (ret < 0) {
>                 dev_err(dev, "failed to get OPP table\n");
>                 goto err_clk;
> @@ -276,15 +258,13 @@ static int exynos_bus_parse_of(struct device_node *np,
>         if (IS_ERR(opp)) {
>                 dev_err(dev, "failed to find dev_pm_opp\n");
>                 ret = PTR_ERR(opp);
> -               goto err_opp;
> +               goto err_clk;
>         }
>         bus->curr_freq = dev_pm_opp_get_freq(opp);
>         dev_pm_opp_put(opp);
>
>         return 0;
>
> -err_opp:
> -       dev_pm_opp_of_remove_table(dev);
>  err_clk:
>         clk_disable_unprepare(bus->clk);
>
> @@ -425,7 +405,7 @@ static int exynos_bus_probe(struct platform_device *pdev)
>         /* Parse the device-tree to get the resource information */
>         ret = exynos_bus_parse_of(np, bus);
>         if (ret < 0)
> -               goto err_reg;
> +               return ret;
>
>         if (passive)
>                 ret = exynos_bus_profile_init_passive(bus, profile);
> @@ -456,11 +436,7 @@ static int exynos_bus_probe(struct platform_device *pdev)
>         return 0;
>
>  err:
> -       dev_pm_opp_of_remove_table(dev);
>         clk_disable_unprepare(bus->clk);
> -err_reg:
> -       dev_pm_opp_put_regulators(bus->opp_table);
> -       bus->opp_table = NULL;
>
>         return ret;
>  }
> --
> 2.25.1
>


-- 
Best Regards,
Chanwoo Choi
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2021-01-05  4:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-03  3:56 [PATCH 30/31] PM / devfreq: exynos: convert to use devm_pm_opp_* API Yangtao Li
2021-01-03  3:56 ` Yangtao Li
2021-01-05  4:35 ` Chanwoo Choi
2021-01-05  4:35   ` Chanwoo Choi

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.