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>
This commit is contained in:
parent
fa55b7dcdc
commit
006da96c84
|
@ -10,6 +10,7 @@
|
||||||
#include <linux/export.h>
|
#include <linux/export.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/pm_opp.h>
|
#include <linux/pm_opp.h>
|
||||||
|
#include <linux/pm_runtime.h>
|
||||||
|
|
||||||
#include <soc/tegra/common.h>
|
#include <soc/tegra/common.h>
|
||||||
#include <soc/tegra/fuse.h>
|
#include <soc/tegra/fuse.h>
|
||||||
|
@ -43,6 +44,7 @@ static int tegra_core_dev_init_opp_state(struct device *dev)
|
||||||
{
|
{
|
||||||
unsigned long rate;
|
unsigned long rate;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
|
bool rpm_enabled;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
clk = devm_clk_get(dev, NULL);
|
clk = devm_clk_get(dev, NULL);
|
||||||
|
@ -57,8 +59,31 @@ static int tegra_core_dev_init_opp_state(struct device *dev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Runtime PM of the device must be enabled in order to set up
|
||||||
|
* GENPD's performance properly because GENPD core checks whether
|
||||||
|
* device is suspended and this check doesn't work while RPM is
|
||||||
|
* disabled. This makes sure the OPP vote below gets cached in
|
||||||
|
* GENPD for the device. Instead, the vote is done the next time
|
||||||
|
* the device gets runtime resumed.
|
||||||
|
*/
|
||||||
|
rpm_enabled = pm_runtime_enabled(dev);
|
||||||
|
if (!rpm_enabled)
|
||||||
|
pm_runtime_enable(dev);
|
||||||
|
|
||||||
|
/* should never happen in practice */
|
||||||
|
if (!pm_runtime_enabled(dev)) {
|
||||||
|
dev_WARN(dev, "failed to enable runtime PM\n");
|
||||||
|
pm_runtime_disable(dev);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* first dummy rate-setting initializes voltage vote */
|
/* first dummy rate-setting initializes voltage vote */
|
||||||
err = dev_pm_opp_set_rate(dev, rate);
|
err = dev_pm_opp_set_rate(dev, rate);
|
||||||
|
|
||||||
|
if (!rpm_enabled)
|
||||||
|
pm_runtime_disable(dev);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(dev, "failed to initialize OPP clock: %d\n", err);
|
dev_err(dev, "failed to initialize OPP clock: %d\n", err);
|
||||||
return err;
|
return err;
|
||||||
|
|
Loading…
Reference in New Issue