summaryrefslogtreecommitdiffstats
path: root/drivers/devfreq
diff options
context:
space:
mode:
authorDmitry Osipenko <digetx@gmail.com>2019-05-02 02:38:03 +0300
committerMyungJoo Ham <myungjoo.ham@samsung.com>2019-08-24 20:11:12 +0900
commit30af44fae8bdccfb21a45dfb4029f954f618d2e3 (patch)
tree4653b44e81bbf89304bb673a4a0525d81438015a /drivers/devfreq
parented2a8dd22a752af60282af38a47d26b227f772a7 (diff)
downloadlinux-stable-30af44fae8bdccfb21a45dfb4029f954f618d2e3.tar.gz
linux-stable-30af44fae8bdccfb21a45dfb4029f954f618d2e3.tar.bz2
linux-stable-30af44fae8bdccfb21a45dfb4029f954f618d2e3.zip
PM / devfreq: tegra: Don't ignore clk errors
The clk_set_min_rate() could fail and in this case clk_set_rate() sets rate to 0, which may drop EMC rate to minimum and make machine very difficult to use. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Diffstat (limited to 'drivers/devfreq')
-rw-r--r--drivers/devfreq/tegra-devfreq.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
index 986f3dfbcab9..325443f67725 100644
--- a/drivers/devfreq/tegra-devfreq.c
+++ b/drivers/devfreq/tegra-devfreq.c
@@ -472,8 +472,10 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,
u32 flags)
{
struct tegra_devfreq *tegra = dev_get_drvdata(dev);
+ struct devfreq *devfreq = tegra->devfreq;
struct dev_pm_opp *opp;
unsigned long rate;
+ int err;
opp = devfreq_recommended_opp(dev, freq, flags);
if (IS_ERR(opp)) {
@@ -483,10 +485,20 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,
rate = dev_pm_opp_get_freq(opp);
dev_pm_opp_put(opp);
- clk_set_min_rate(tegra->emc_clock, rate);
- clk_set_rate(tegra->emc_clock, 0);
+ err = clk_set_min_rate(tegra->emc_clock, rate);
+ if (err)
+ return err;
+
+ err = clk_set_rate(tegra->emc_clock, 0);
+ if (err)
+ goto restore_min_rate;
return 0;
+
+restore_min_rate:
+ clk_set_min_rate(tegra->emc_clock, devfreq->previous_freq);
+
+ return err;
}
static int tegra_devfreq_get_dev_status(struct device *dev,