drm/lima: Convert to use resource-managed OPP API

Use resource-managed OPP API to simplify code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
Yangtao Li
2021-03-14 19:34:05 +03:00
committed by Viresh Kumar
parent 411281d24b
commit 864a270189
2 changed files with 11 additions and 39 deletions

View File

@@ -99,20 +99,12 @@ void lima_devfreq_fini(struct lima_device *ldev)
devm_devfreq_remove_device(ldev->dev, devfreq->devfreq); devm_devfreq_remove_device(ldev->dev, devfreq->devfreq);
devfreq->devfreq = NULL; devfreq->devfreq = NULL;
} }
dev_pm_opp_of_remove_table(ldev->dev);
dev_pm_opp_put_regulators(devfreq->regulators_opp_table);
dev_pm_opp_put_clkname(devfreq->clkname_opp_table);
devfreq->regulators_opp_table = NULL;
devfreq->clkname_opp_table = NULL;
} }
int lima_devfreq_init(struct lima_device *ldev) int lima_devfreq_init(struct lima_device *ldev)
{ {
struct thermal_cooling_device *cooling; struct thermal_cooling_device *cooling;
struct device *dev = ldev->dev; struct device *dev = ldev->dev;
struct opp_table *opp_table;
struct devfreq *devfreq; struct devfreq *devfreq;
struct lima_devfreq *ldevfreq = &ldev->devfreq; struct lima_devfreq *ldevfreq = &ldev->devfreq;
struct dev_pm_opp *opp; struct dev_pm_opp *opp;
@@ -125,40 +117,28 @@ int lima_devfreq_init(struct lima_device *ldev)
spin_lock_init(&ldevfreq->lock); spin_lock_init(&ldevfreq->lock);
opp_table = dev_pm_opp_set_clkname(dev, "core"); ret = devm_pm_opp_set_clkname(dev, "core");
if (IS_ERR(opp_table)) { if (ret)
ret = PTR_ERR(opp_table); return ret;
goto err_fini;
}
ldevfreq->clkname_opp_table = opp_table;
opp_table = dev_pm_opp_set_regulators(dev,
(const char *[]){ "mali" },
1);
if (IS_ERR(opp_table)) {
ret = PTR_ERR(opp_table);
ret = devm_pm_opp_set_regulators(dev, (const char *[]){ "mali" }, 1);
if (ret) {
/* Continue if the optional regulator is missing */ /* Continue if the optional regulator is missing */
if (ret != -ENODEV) if (ret != -ENODEV)
goto err_fini; return ret;
} else {
ldevfreq->regulators_opp_table = opp_table;
} }
ret = dev_pm_opp_of_add_table(dev); ret = devm_pm_opp_of_add_table(dev);
if (ret) if (ret)
goto err_fini; return ret;
lima_devfreq_reset(ldevfreq); lima_devfreq_reset(ldevfreq);
cur_freq = clk_get_rate(ldev->clk_gpu); cur_freq = clk_get_rate(ldev->clk_gpu);
opp = devfreq_recommended_opp(dev, &cur_freq, 0); opp = devfreq_recommended_opp(dev, &cur_freq, 0);
if (IS_ERR(opp)) { if (IS_ERR(opp))
ret = PTR_ERR(opp); return PTR_ERR(opp);
goto err_fini;
}
lima_devfreq_profile.initial_freq = cur_freq; lima_devfreq_profile.initial_freq = cur_freq;
dev_pm_opp_put(opp); dev_pm_opp_put(opp);
@@ -167,8 +147,7 @@ int lima_devfreq_init(struct lima_device *ldev)
DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL); DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
if (IS_ERR(devfreq)) { if (IS_ERR(devfreq)) {
dev_err(dev, "Couldn't initialize GPU devfreq\n"); dev_err(dev, "Couldn't initialize GPU devfreq\n");
ret = PTR_ERR(devfreq); return PTR_ERR(devfreq);
goto err_fini;
} }
ldevfreq->devfreq = devfreq; ldevfreq->devfreq = devfreq;
@@ -180,10 +159,6 @@ int lima_devfreq_init(struct lima_device *ldev)
ldevfreq->cooling = cooling; ldevfreq->cooling = cooling;
return 0; return 0;
err_fini:
lima_devfreq_fini(ldev);
return ret;
} }
void lima_devfreq_record_busy(struct lima_devfreq *devfreq) void lima_devfreq_record_busy(struct lima_devfreq *devfreq)

View File

@@ -8,15 +8,12 @@
#include <linux/ktime.h> #include <linux/ktime.h>
struct devfreq; struct devfreq;
struct opp_table;
struct thermal_cooling_device; struct thermal_cooling_device;
struct lima_device; struct lima_device;
struct lima_devfreq { struct lima_devfreq {
struct devfreq *devfreq; struct devfreq *devfreq;
struct opp_table *clkname_opp_table;
struct opp_table *regulators_opp_table;
struct thermal_cooling_device *cooling; struct thermal_cooling_device *cooling;
ktime_t busy_time; ktime_t busy_time;