Skip to content

Commit

Permalink
Merge branch 'opp/linux-next' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/git/vireshk/pm

Pull OPP (Operating Performance Points) framework updates for v5.13
from Viresh Kumar:

"This adds devm variants for OPP APIs and updates few of the users
 as well (Yangtao Li and Dmitry Osipenko)."

* 'opp/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm:
  memory: samsung: exynos5422-dmc: Convert to use resource-managed OPP API
  drm/panfrost: Convert to use resource-managed OPP API
  drm/lima: Convert to use resource-managed OPP API
  mmc: sdhci-msm: Convert to use resource-managed OPP API
  spi: spi-qcom-qspi: Convert to use resource-managed OPP API
  spi: spi-geni-qcom: Convert to use resource-managed OPP API
  serial: qcom_geni_serial: Convert to use resource-managed OPP API
  opp: Change return type of devm_pm_opp_attach_genpd()
  opp: Change return type of devm_pm_opp_register_set_opp_helper()
  opp: Add devres wrapper for dev_pm_opp_of_add_table
  opp: Add devres wrapper for dev_pm_opp_set_supported_hw
  opp: Add devres wrapper for dev_pm_opp_set_regulators
  opp: Add devres wrapper for dev_pm_opp_set_clkname
  • Loading branch information
Rafael J. Wysocki committed Apr 12, 2021
2 parents e49d033 + a8bb0e8 commit eed7a17
Show file tree
Hide file tree
Showing 13 changed files with 217 additions and 165 deletions.
47 changes: 11 additions & 36 deletions drivers/gpu/drm/lima/lima_devfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,12 @@ void lima_devfreq_fini(struct lima_device *ldev)
devm_devfreq_remove_device(ldev->dev, devfreq->devfreq);
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)
{
struct thermal_cooling_device *cooling;
struct device *dev = ldev->dev;
struct opp_table *opp_table;
struct devfreq *devfreq;
struct lima_devfreq *ldevfreq = &ldev->devfreq;
struct dev_pm_opp *opp;
Expand All @@ -125,40 +117,28 @@ int lima_devfreq_init(struct lima_device *ldev)

spin_lock_init(&ldevfreq->lock);

opp_table = dev_pm_opp_set_clkname(dev, "core");
if (IS_ERR(opp_table)) {
ret = PTR_ERR(opp_table);
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_clkname(dev, "core");
if (ret)
return ret;

ret = devm_pm_opp_set_regulators(dev, (const char *[]){ "mali" }, 1);
if (ret) {
/* Continue if the optional regulator is missing */
if (ret != -ENODEV)
goto err_fini;
} else {
ldevfreq->regulators_opp_table = opp_table;
return ret;
}

ret = dev_pm_opp_of_add_table(dev);
ret = devm_pm_opp_of_add_table(dev);
if (ret)
goto err_fini;
return ret;

lima_devfreq_reset(ldevfreq);

cur_freq = clk_get_rate(ldev->clk_gpu);

opp = devfreq_recommended_opp(dev, &cur_freq, 0);
if (IS_ERR(opp)) {
ret = PTR_ERR(opp);
goto err_fini;
}
if (IS_ERR(opp))
return PTR_ERR(opp);

lima_devfreq_profile.initial_freq = cur_freq;
dev_pm_opp_put(opp);
Expand All @@ -167,8 +147,7 @@ int lima_devfreq_init(struct lima_device *ldev)
DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
if (IS_ERR(devfreq)) {
dev_err(dev, "Couldn't initialize GPU devfreq\n");
ret = PTR_ERR(devfreq);
goto err_fini;
return PTR_ERR(devfreq);
}

ldevfreq->devfreq = devfreq;
Expand All @@ -180,10 +159,6 @@ int lima_devfreq_init(struct lima_device *ldev)
ldevfreq->cooling = cooling;

return 0;

err_fini:
lima_devfreq_fini(ldev);
return ret;
}

void lima_devfreq_record_busy(struct lima_devfreq *devfreq)
Expand Down
3 changes: 0 additions & 3 deletions drivers/gpu/drm/lima/lima_devfreq.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
#include <linux/ktime.h>

struct devfreq;
struct opp_table;
struct thermal_cooling_device;

struct lima_device;

struct lima_devfreq {
struct devfreq *devfreq;
struct opp_table *clkname_opp_table;
struct opp_table *regulators_opp_table;
struct thermal_cooling_device *cooling;

ktime_t busy_time;
Expand Down
37 changes: 9 additions & 28 deletions drivers/gpu/drm/panfrost/panfrost_devfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,25 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
unsigned long cur_freq;
struct device *dev = &pfdev->pdev->dev;
struct devfreq *devfreq;
struct opp_table *opp_table;
struct thermal_cooling_device *cooling;
struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq;

opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names,
pfdev->comp->num_supplies);
if (IS_ERR(opp_table)) {
ret = PTR_ERR(opp_table);
ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names,
pfdev->comp->num_supplies);
if (ret) {
/* Continue if the optional regulator is missing */
if (ret != -ENODEV) {
DRM_DEV_ERROR(dev, "Couldn't set OPP regulators\n");
goto err_fini;
return ret;
}
} else {
pfdevfreq->regulators_opp_table = opp_table;
}

ret = dev_pm_opp_of_add_table(dev);
ret = devm_pm_opp_of_add_table(dev);
if (ret) {
/* Optional, continue without devfreq */
if (ret == -ENODEV)
ret = 0;
goto err_fini;
return ret;
}
pfdevfreq->opp_of_table_added = true;

Expand All @@ -122,10 +118,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
cur_freq = clk_get_rate(pfdev->clock);

opp = devfreq_recommended_opp(dev, &cur_freq, 0);
if (IS_ERR(opp)) {
ret = PTR_ERR(opp);
goto err_fini;
}
if (IS_ERR(opp))
return PTR_ERR(opp);

panfrost_devfreq_profile.initial_freq = cur_freq;
dev_pm_opp_put(opp);
Expand All @@ -134,8 +128,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
if (IS_ERR(devfreq)) {
DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n");
ret = PTR_ERR(devfreq);
goto err_fini;
return PTR_ERR(devfreq);
}
pfdevfreq->devfreq = devfreq;

Expand All @@ -146,10 +139,6 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
pfdevfreq->cooling = cooling;

return 0;

err_fini:
panfrost_devfreq_fini(pfdev);
return ret;
}

void panfrost_devfreq_fini(struct panfrost_device *pfdev)
Expand All @@ -160,14 +149,6 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev)
devfreq_cooling_unregister(pfdevfreq->cooling);
pfdevfreq->cooling = NULL;
}

if (pfdevfreq->opp_of_table_added) {
dev_pm_opp_of_remove_table(&pfdev->pdev->dev);
pfdevfreq->opp_of_table_added = false;
}

dev_pm_opp_put_regulators(pfdevfreq->regulators_opp_table);
pfdevfreq->regulators_opp_table = NULL;
}

void panfrost_devfreq_resume(struct panfrost_device *pfdev)
Expand Down
2 changes: 0 additions & 2 deletions drivers/gpu/drm/panfrost/panfrost_devfreq.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
#include <linux/ktime.h>

struct devfreq;
struct opp_table;
struct thermal_cooling_device;

struct panfrost_device;

struct panfrost_devfreq {
struct devfreq *devfreq;
struct opp_table *regulators_opp_table;
struct thermal_cooling_device *cooling;
bool opp_of_table_added;

Expand Down
13 changes: 3 additions & 10 deletions drivers/memory/samsung/exynos5422-dmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static int exynos5_init_freq_table(struct exynos5_dmc *dmc,
int idx;
unsigned long freq;

ret = dev_pm_opp_of_add_table(dmc->dev);
ret = devm_pm_opp_of_add_table(dmc->dev);
if (ret < 0) {
dev_err(dmc->dev, "Failed to get OPP table\n");
return ret;
Expand All @@ -354,15 +354,15 @@ static int exynos5_init_freq_table(struct exynos5_dmc *dmc,
dmc->opp = devm_kmalloc_array(dmc->dev, dmc->opp_count,
sizeof(struct dmc_opp_table), GFP_KERNEL);
if (!dmc->opp)
goto err_opp;
return -ENOMEM;

idx = dmc->opp_count - 1;
for (i = 0, freq = ULONG_MAX; i < dmc->opp_count; i++, freq--) {
struct dev_pm_opp *opp;

opp = dev_pm_opp_find_freq_floor(dmc->dev, &freq);
if (IS_ERR(opp))
goto err_opp;
return PTR_ERR(opp);

dmc->opp[idx - i].freq_hz = freq;
dmc->opp[idx - i].volt_uv = dev_pm_opp_get_voltage(opp);
Expand All @@ -371,11 +371,6 @@ static int exynos5_init_freq_table(struct exynos5_dmc *dmc,
}

return 0;

err_opp:
dev_pm_opp_of_remove_table(dmc->dev);

return -EINVAL;
}

/**
Expand Down Expand Up @@ -1567,8 +1562,6 @@ static int exynos5_dmc_remove(struct platform_device *pdev)
clk_disable_unprepare(dmc->mout_bpll);
clk_disable_unprepare(dmc->fout_bpll);

dev_pm_opp_remove_table(dmc->dev);

return 0;
}

Expand Down
19 changes: 5 additions & 14 deletions drivers/mmc/host/sdhci-msm.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ struct sdhci_msm_host {
struct clk_bulk_data bulk_clks[5];
unsigned long clk_rate;
struct mmc_host *mmc;
struct opp_table *opp_table;
bool use_14lpp_dll_reset;
bool tuning_done;
bool calibration_done;
Expand Down Expand Up @@ -2551,17 +2550,15 @@ static int sdhci_msm_probe(struct platform_device *pdev)
if (ret)
goto bus_clk_disable;

msm_host->opp_table = dev_pm_opp_set_clkname(&pdev->dev, "core");
if (IS_ERR(msm_host->opp_table)) {
ret = PTR_ERR(msm_host->opp_table);
ret = devm_pm_opp_set_clkname(&pdev->dev, "core");
if (ret)
goto bus_clk_disable;
}

/* OPP table is optional */
ret = dev_pm_opp_of_add_table(&pdev->dev);
ret = devm_pm_opp_of_add_table(&pdev->dev);
if (ret && ret != -ENODEV) {
dev_err(&pdev->dev, "Invalid OPP table in Device tree\n");
goto opp_put_clkname;
goto bus_clk_disable;
}

/* Vote for maximum clock rate for maximum performance */
Expand All @@ -2587,7 +2584,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
ret = clk_bulk_prepare_enable(ARRAY_SIZE(msm_host->bulk_clks),
msm_host->bulk_clks);
if (ret)
goto opp_cleanup;
goto bus_clk_disable;

/*
* xo clock is needed for FLL feature of cm_dll.
Expand Down Expand Up @@ -2732,10 +2729,6 @@ static int sdhci_msm_probe(struct platform_device *pdev)
clk_disable:
clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks),
msm_host->bulk_clks);
opp_cleanup:
dev_pm_opp_of_remove_table(&pdev->dev);
opp_put_clkname:
dev_pm_opp_put_clkname(msm_host->opp_table);
bus_clk_disable:
if (!IS_ERR(msm_host->bus_clk))
clk_disable_unprepare(msm_host->bus_clk);
Expand All @@ -2754,8 +2747,6 @@ static int sdhci_msm_remove(struct platform_device *pdev)

sdhci_remove_host(host, dead);

dev_pm_opp_of_remove_table(&pdev->dev);
dev_pm_opp_put_clkname(msm_host->opp_table);
pm_runtime_get_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
pm_runtime_put_noidle(&pdev->dev);
Expand Down
Loading

0 comments on commit eed7a17

Please sign in to comment.