Commit cd7ea582 authored by Rajendra Nayak's avatar Rajendra Nayak Committed by Viresh Kumar

opp: Make dev_pm_opp_set_rate() handle freq = 0 to drop performance votes

For devices with performance state, we use dev_pm_opp_set_rate() to set
the appropriate clk rate and the performance state.

We do need a way to remove the performance state vote when we idle the
device and turn the clocks off. Use dev_pm_opp_set_rate() with freq = 0
to achieve this.
Signed-off-by: default avatarRajendra Nayak <rnayak@codeaurora.org>
Signed-off-by: default avatarStephen Boyd <swboyd@chromium.org>
[ Viresh: Updated _set_required_opps() to handle the !opp case ]
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent b3e3759e
...@@ -711,7 +711,7 @@ static int _set_required_opps(struct device *dev, ...@@ -711,7 +711,7 @@ static int _set_required_opps(struct device *dev,
/* Single genpd case */ /* Single genpd case */
if (!genpd_virt_devs) { if (!genpd_virt_devs) {
pstate = opp->required_opps[0]->pstate; pstate = likely(opp) ? opp->required_opps[0]->pstate : 0;
ret = dev_pm_genpd_set_performance_state(dev, pstate); ret = dev_pm_genpd_set_performance_state(dev, pstate);
if (ret) { if (ret) {
dev_err(dev, "Failed to set performance state of %s: %d (%d)\n", dev_err(dev, "Failed to set performance state of %s: %d (%d)\n",
...@@ -729,7 +729,7 @@ static int _set_required_opps(struct device *dev, ...@@ -729,7 +729,7 @@ static int _set_required_opps(struct device *dev,
mutex_lock(&opp_table->genpd_virt_dev_lock); mutex_lock(&opp_table->genpd_virt_dev_lock);
for (i = 0; i < opp_table->required_opp_count; i++) { for (i = 0; i < opp_table->required_opp_count; i++) {
pstate = opp->required_opps[i]->pstate; pstate = likely(opp) ? opp->required_opps[i]->pstate : 0;
if (!genpd_virt_devs[i]) if (!genpd_virt_devs[i])
continue; continue;
...@@ -765,18 +765,23 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) ...@@ -765,18 +765,23 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
struct clk *clk; struct clk *clk;
int ret; int ret;
if (unlikely(!target_freq)) {
dev_err(dev, "%s: Invalid target frequency %lu\n", __func__,
target_freq);
return -EINVAL;
}
opp_table = _find_opp_table(dev); opp_table = _find_opp_table(dev);
if (IS_ERR(opp_table)) { if (IS_ERR(opp_table)) {
dev_err(dev, "%s: device opp doesn't exist\n", __func__); dev_err(dev, "%s: device opp doesn't exist\n", __func__);
return PTR_ERR(opp_table); return PTR_ERR(opp_table);
} }
if (unlikely(!target_freq)) {
if (opp_table->required_opp_tables) {
ret = _set_required_opps(dev, opp_table, NULL);
} else {
dev_err(dev, "target frequency can't be 0\n");
ret = -EINVAL;
}
goto put_opp_table;
}
clk = opp_table->clk; clk = opp_table->clk;
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
dev_err(dev, "%s: No clock available for the device\n", dev_err(dev, "%s: No clock available for the device\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment