Skip to content

Commit d441fe2

Browse files
committed
Merge branches 'pm-domains' and 'pm-cpufreq'
* pm-domains: PM / Domains: Fix bad of_node_put() in failure paths of genpd_dev_pm_attach() PM / Domains: Validate cases of a non-bound driver in genpd governor * pm-cpufreq: cpufreq: use last policy after online for drivers with ->setpolicy
3 parents 3e5050e + 265e2cf + 69030dd commit d441fe2

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

drivers/base/power/domain.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,10 +1775,10 @@ int genpd_dev_pm_attach(struct device *dev)
17751775
}
17761776

17771777
pd = of_genpd_get_from_provider(&pd_args);
1778+
of_node_put(pd_args.np);
17781779
if (IS_ERR(pd)) {
17791780
dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
17801781
__func__, PTR_ERR(pd));
1781-
of_node_put(dev->of_node);
17821782
return -EPROBE_DEFER;
17831783
}
17841784

@@ -1796,7 +1796,6 @@ int genpd_dev_pm_attach(struct device *dev)
17961796
if (ret < 0) {
17971797
dev_err(dev, "failed to add to PM domain %s: %d",
17981798
pd->name, ret);
1799-
of_node_put(dev->of_node);
18001799
goto out;
18011800
}
18021801

drivers/base/power/domain_governor.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ static bool default_power_down_ok(struct dev_pm_domain *pd)
160160
struct gpd_timing_data *td;
161161
s64 constraint_ns;
162162

163-
if (!pdd->dev->driver)
164-
continue;
165-
166163
/*
167164
* Check if the device is allowed to be off long enough for the
168165
* domain to turn off and on (that's how much time it will

drivers/cpufreq/cpufreq.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,10 +976,14 @@ static int cpufreq_init_policy(struct cpufreq_policy *policy)
976976

977977
new_policy.governor = gov;
978978

979-
/* Use the default policy if its valid. */
980-
if (cpufreq_driver->setpolicy)
981-
cpufreq_parse_governor(gov->name, &new_policy.policy, NULL);
982-
979+
/* Use the default policy if there is no last_policy. */
980+
if (cpufreq_driver->setpolicy) {
981+
if (policy->last_policy)
982+
new_policy.policy = policy->last_policy;
983+
else
984+
cpufreq_parse_governor(gov->name, &new_policy.policy,
985+
NULL);
986+
}
983987
/* set default policy */
984988
return cpufreq_set_policy(policy, &new_policy);
985989
}
@@ -1330,6 +1334,8 @@ static void cpufreq_offline_prepare(unsigned int cpu)
13301334
if (has_target())
13311335
strncpy(policy->last_governor, policy->governor->name,
13321336
CPUFREQ_NAME_LEN);
1337+
else
1338+
policy->last_policy = policy->policy;
13331339
} else if (cpu == policy->cpu) {
13341340
/* Nominate new CPU */
13351341
policy->cpu = cpumask_any(policy->cpus);

include/linux/cpufreq.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct cpufreq_policy {
7777
unsigned int suspend_freq; /* freq to set during suspend */
7878

7979
unsigned int policy; /* see above */
80+
unsigned int last_policy; /* policy before unplug */
8081
struct cpufreq_governor *governor; /* see below */
8182
void *governor_data;
8283
bool governor_enabled; /* governor start/stop flag */

0 commit comments

Comments
 (0)