Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc/tegra: Enable runtime PM during OPP state-syncing

GENPD core now can set up domain's performance state properly while device
is RPM-suspended. Runtime PM of a device must be enabled during setup
because GENPD checks whether device is suspended and check doesn't work
while RPM is disabled. Instead of replicating the boilerplate RPM-enable
code around OPP helper for each driver, let's make OPP helper to take care
of enabling it.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Dmitry Osipenko and committed by
Thierry Reding
006da96c fa55b7dc

+25
+25
drivers/soc/tegra/common.c
··· 10 10 #include <linux/export.h> 11 11 #include <linux/of.h> 12 12 #include <linux/pm_opp.h> 13 + #include <linux/pm_runtime.h> 13 14 14 15 #include <soc/tegra/common.h> 15 16 #include <soc/tegra/fuse.h> ··· 44 43 { 45 44 unsigned long rate; 46 45 struct clk *clk; 46 + bool rpm_enabled; 47 47 int err; 48 48 49 49 clk = devm_clk_get(dev, NULL); ··· 59 57 return -EINVAL; 60 58 } 61 59 60 + /* 61 + * Runtime PM of the device must be enabled in order to set up 62 + * GENPD's performance properly because GENPD core checks whether 63 + * device is suspended and this check doesn't work while RPM is 64 + * disabled. This makes sure the OPP vote below gets cached in 65 + * GENPD for the device. Instead, the vote is done the next time 66 + * the device gets runtime resumed. 67 + */ 68 + rpm_enabled = pm_runtime_enabled(dev); 69 + if (!rpm_enabled) 70 + pm_runtime_enable(dev); 71 + 72 + /* should never happen in practice */ 73 + if (!pm_runtime_enabled(dev)) { 74 + dev_WARN(dev, "failed to enable runtime PM\n"); 75 + pm_runtime_disable(dev); 76 + return -EINVAL; 77 + } 78 + 62 79 /* first dummy rate-setting initializes voltage vote */ 63 80 err = dev_pm_opp_set_rate(dev, rate); 81 + 82 + if (!rpm_enabled) 83 + pm_runtime_disable(dev); 84 + 64 85 if (err) { 65 86 dev_err(dev, "failed to initialize OPP clock: %d\n", err); 66 87 return err;