[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGTfZH3Rb8qsT6ZtT9QWb_oU_Nt9z+UaiyWkExo1uzSDKz6g8A@mail.gmail.com>
Date: Tue, 5 Jan 2021 13:35:15 +0900
From: Chanwoo Choi <cwchoi00@...il.com>
To: Yangtao Li <tiny.windzz@...il.com>
Cc: MyungJoo Ham <myungjoo.ham@...sung.com>,
Kyungmin Park <kyungmin.park@...sung.com>,
Chanwoo Choi <cw00.choi@...sung.com>,
Krzysztof Kozlowski <krzk@...nel.org>,
Shawn Guo <shawnguo@...nel.org>, s.hauer@...gutronix.de,
kernel@...gutronix.de, festevam@...il.com,
dl-linux-imx <linux-imx@....com>,
Dmitry Osipenko <digetx@...il.com>,
Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>, yuq825@...il.com,
David Airlie <airlied@...ux.ie>, daniel@...ll.ch,
robdclark@...il.com, sean@...rly.run,
Rob Herring <robh@...nel.org>, tomeu.vizoso@...labora.com,
steven.price@....com, alyssa.rosenzweig@...labora.com,
stanimir.varbanov@...aro.org, agross@...nel.org,
Bjorn Andersson <bjorn.andersson@...aro.org>,
mchehab@...nel.org, Lukasz Luba <lukasz.luba@....com>,
adrian.hunter@...el.com, Ulf Hansson <ulf.hansson@...aro.org>,
Viresh Kumar <vireshk@...nel.org>, Nishanth Menon <nm@...com>,
Stephen Boyd <sboyd@...nel.org>,
Mark Brown <broonie@...nel.org>,
Greg KH <gregkh@...uxfoundation.org>, jirislaby@...nel.org,
"Rafael J. Wysocki" <rjw@...ysocki.net>, jcrouse@...eaurora.org,
hoegsberg@...gle.com, eric@...olt.net, tzimmermann@...e.de,
marijn.suijten@...ainline.org, gustavoars@...nel.org,
emil.velikov@...labora.com, jonathan@...ek.ca,
akhilpo@...eaurora.org, smasetty@...eaurora.org,
airlied@...hat.com, masneyb@...tation.org, kalyan_t@...eaurora.org,
tanmay@...eaurora.org, ddavenport@...omium.org,
jsanka@...eaurora.org, rnayak@...eaurora.org,
tongtiangen@...wei.com, miaoqinglang@...wei.com,
khsieh@...eaurora.org, abhinavk@...eaurora.org,
chandanu@...eaurora.org, Guenter Roeck <groeck@...omium.org>,
varar@...eaurora.org, Matthias Kaehlcke <mka@...omium.org>,
harigovi@...eaurora.org, rikard.falkeborn@...il.com,
natechancellor@...il.com, Georgi Djakov <georgi.djakov@...aro.org>,
akashast@...eaurora.org, parashar@...eaurora.org,
Doug Anderson <dianders@...omium.org>,
Linux PM list <linux-pm@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
linux-samsung-soc <linux-samsung-soc@...r.kernel.org>,
linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
linux-tegra@...r.kernel.org,
dri-devel <dri-devel@...ts.freedesktop.org>,
lima@...ts.freedesktop.org, linux-arm-msm@...r.kernel.org,
freedreno@...ts.freedesktop.org, linux-media@...r.kernel.org,
linux-mmc@...r.kernel.org, linux-spi@...r.kernel.org,
linux-serial@...r.kernel.org
Subject: Re: [PATCH 30/31] PM / devfreq: exynos: convert to use devm_pm_opp_* API
On Sun, Jan 3, 2021 at 12:59 PM Yangtao Li <tiny.windzz@...il.com> wrote:
>
> Use devm_pm_opp_* API to simplify code, and remove opp_table
> from exynos_bus.
>
> Signed-off-by: Yangtao Li <tiny.windzz@...il.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
Powered by blists - more mailing lists