aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-05-25 18:29:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-25 18:29:21 -0400
commit877c057d2b3cdac9f44c0fbe48e4208375395bf0 (patch)
treed9be4f9087e5717cb58b547b502d4d0a74f81c5a
parentecc5fbd5ef472a4c659dc56a5739b3f041c0530c (diff)
parent4c2628cd7580bc4f4a4994925cf366185ecc37a5 (diff)
Merge tag 'pm-4.7-rc1-more' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull more power management updates from Rafael Wysocki: "These are two stable-candidate fixes (PM core, cpuidle) and a bunch of cpufreq cleanups. Specifics: - Stable-candidate cpuidle fix to make it check the right variable when deciding whether or not to enable interrupts on the local CPU so as to avoid enabling iterrupts too early in some cases if the system has both coupled and per-core idle states (Daniel Lezcano). - Stable-candidate PM core fix to make it handle failures at the "late suspend" stage of device suspend consistently for all devices regardless of whether or not async suspend/resume is enabled for them (Rafael Wysocki). - Cleanups in the cpufreq core, the schedutil governor and the intel_pstate driver (Rafael Wysocki, Pankaj Gupta, Viresh Kumar)" * tag 'pm-4.7-rc1-more' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: PM / sleep: Handle failures in device_suspend_late() consistently cpufreq: schedutil: Improve prints messages with pr_fmt cpuidle: Fix cpuidle_state_is_coupled() argument in cpuidle_enter() cpufreq: simplified goto out in cpufreq_register_driver() cpufreq: governor: CPUFREQ_GOV_STOP never fails cpufreq: governor: CPUFREQ_GOV_POLICY_EXIT never fails intel_pstate: Simplify conditional in intel_pstate_set_policy()
-rw-r--r--drivers/base/power/main.c5
-rw-r--r--drivers/cpufreq/cpufreq.c84
-rw-r--r--drivers/cpufreq/intel_pstate.c11
-rw-r--r--drivers/cpuidle/cpuidle.c2
-rw-r--r--kernel/sched/cpufreq_schedutil.c4
5 files changed, 39 insertions, 67 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index c81667d4bb60..e44944f4be77 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1267,14 +1267,15 @@ int dpm_suspend_late(pm_message_t state)
1267 error = device_suspend_late(dev); 1267 error = device_suspend_late(dev);
1268 1268
1269 mutex_lock(&dpm_list_mtx); 1269 mutex_lock(&dpm_list_mtx);
1270 if (!list_empty(&dev->power.entry))
1271 list_move(&dev->power.entry, &dpm_late_early_list);
1272
1270 if (error) { 1273 if (error) {
1271 pm_dev_err(dev, state, " late", error); 1274 pm_dev_err(dev, state, " late", error);
1272 dpm_save_failed_dev(dev_name(dev)); 1275 dpm_save_failed_dev(dev_name(dev));
1273 put_device(dev); 1276 put_device(dev);
1274 break; 1277 break;
1275 } 1278 }
1276 if (!list_empty(&dev->power.entry))
1277 list_move(&dev->power.entry, &dpm_late_early_list);
1278 put_device(dev); 1279 put_device(dev);
1279 1280
1280 if (async_error) 1281 if (async_error)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 035513b012ee..36bc11a106aa 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -78,9 +78,14 @@ static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event);
78static unsigned int __cpufreq_get(struct cpufreq_policy *policy); 78static unsigned int __cpufreq_get(struct cpufreq_policy *policy);
79static int cpufreq_start_governor(struct cpufreq_policy *policy); 79static int cpufreq_start_governor(struct cpufreq_policy *policy);
80 80
81static inline int cpufreq_exit_governor(struct cpufreq_policy *policy) 81static inline void cpufreq_exit_governor(struct cpufreq_policy *policy)
82{ 82{
83 return cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); 83 (void)cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
84}
85
86static inline void cpufreq_stop_governor(struct cpufreq_policy *policy)
87{
88 (void)cpufreq_governor(policy, CPUFREQ_GOV_STOP);
84} 89}
85 90
86/** 91/**
@@ -1026,13 +1031,8 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp
1026 return 0; 1031 return 0;
1027 1032
1028 down_write(&policy->rwsem); 1033 down_write(&policy->rwsem);
1029 if (has_target()) { 1034 if (has_target())
1030 ret = cpufreq_governor(policy, CPUFREQ_GOV_STOP); 1035 cpufreq_stop_governor(policy);
1031 if (ret) {
1032 pr_err("%s: Failed to stop governor\n", __func__);
1033 goto unlock;
1034 }
1035 }
1036 1036
1037 cpumask_set_cpu(cpu, policy->cpus); 1037 cpumask_set_cpu(cpu, policy->cpus);
1038 1038
@@ -1041,8 +1041,6 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp
1041 if (ret) 1041 if (ret)
1042 pr_err("%s: Failed to start governor\n", __func__); 1042 pr_err("%s: Failed to start governor\n", __func__);
1043 } 1043 }
1044
1045unlock:
1046 up_write(&policy->rwsem); 1044 up_write(&policy->rwsem);
1047 return ret; 1045 return ret;
1048} 1046}
@@ -1354,11 +1352,8 @@ static void cpufreq_offline(unsigned int cpu)
1354 } 1352 }
1355 1353
1356 down_write(&policy->rwsem); 1354 down_write(&policy->rwsem);
1357 if (has_target()) { 1355 if (has_target())
1358 ret = cpufreq_governor(policy, CPUFREQ_GOV_STOP); 1356 cpufreq_stop_governor(policy);
1359 if (ret)
1360 pr_err("%s: Failed to stop governor\n", __func__);
1361 }
1362 1357
1363 cpumask_clear_cpu(cpu, policy->cpus); 1358 cpumask_clear_cpu(cpu, policy->cpus);
1364 1359
@@ -1387,12 +1382,8 @@ static void cpufreq_offline(unsigned int cpu)
1387 if (cpufreq_driver->stop_cpu) 1382 if (cpufreq_driver->stop_cpu)
1388 cpufreq_driver->stop_cpu(policy); 1383 cpufreq_driver->stop_cpu(policy);
1389 1384
1390 /* If cpu is last user of policy, free policy */ 1385 if (has_target())
1391 if (has_target()) { 1386 cpufreq_exit_governor(policy);
1392 ret = cpufreq_exit_governor(policy);
1393 if (ret)
1394 pr_err("%s: Failed to exit governor\n", __func__);
1395 }
1396 1387
1397 /* 1388 /*
1398 * Perform the ->exit() even during light-weight tear-down, 1389 * Perform the ->exit() even during light-weight tear-down,
@@ -1626,7 +1617,6 @@ EXPORT_SYMBOL(cpufreq_generic_suspend);
1626void cpufreq_suspend(void) 1617void cpufreq_suspend(void)
1627{ 1618{
1628 struct cpufreq_policy *policy; 1619 struct cpufreq_policy *policy;
1629 int ret;
1630 1620
1631 if (!cpufreq_driver) 1621 if (!cpufreq_driver)
1632 return; 1622 return;
@@ -1639,14 +1629,8 @@ void cpufreq_suspend(void)
1639 for_each_active_policy(policy) { 1629 for_each_active_policy(policy) {
1640 if (has_target()) { 1630 if (has_target()) {
1641 down_write(&policy->rwsem); 1631 down_write(&policy->rwsem);
1642 ret = cpufreq_governor(policy, CPUFREQ_GOV_STOP); 1632 cpufreq_stop_governor(policy);
1643 up_write(&policy->rwsem); 1633 up_write(&policy->rwsem);
1644
1645 if (ret) {
1646 pr_err("%s: Failed to stop governor for policy: %p\n",
1647 __func__, policy);
1648 continue;
1649 }
1650 } 1634 }
1651 1635
1652 if (cpufreq_driver->suspend && cpufreq_driver->suspend(policy)) 1636 if (cpufreq_driver->suspend && cpufreq_driver->suspend(policy))
@@ -2049,16 +2033,15 @@ static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)
2049 2033
2050 ret = policy->governor->governor(policy, event); 2034 ret = policy->governor->governor(policy, event);
2051 2035
2052 if (!ret) { 2036 if (event == CPUFREQ_GOV_POLICY_INIT) {
2053 if (event == CPUFREQ_GOV_POLICY_INIT) 2037 if (ret)
2038 module_put(policy->governor->owner);
2039 else
2054 policy->governor->initialized++; 2040 policy->governor->initialized++;
2055 else if (event == CPUFREQ_GOV_POLICY_EXIT) 2041 } else if (event == CPUFREQ_GOV_POLICY_EXIT) {
2056 policy->governor->initialized--; 2042 policy->governor->initialized--;
2057 }
2058
2059 if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) ||
2060 ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret))
2061 module_put(policy->governor->owner); 2043 module_put(policy->governor->owner);
2044 }
2062 2045
2063 return ret; 2046 return ret;
2064} 2047}
@@ -2221,20 +2204,8 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
2221 old_gov = policy->governor; 2204 old_gov = policy->governor;
2222 /* end old governor */ 2205 /* end old governor */
2223 if (old_gov) { 2206 if (old_gov) {
2224 ret = cpufreq_governor(policy, CPUFREQ_GOV_STOP); 2207 cpufreq_stop_governor(policy);
2225 if (ret) { 2208 cpufreq_exit_governor(policy);
2226 /* This can happen due to race with other operations */
2227 pr_debug("%s: Failed to Stop Governor: %s (%d)\n",
2228 __func__, old_gov->name, ret);
2229 return ret;
2230 }
2231
2232 ret = cpufreq_exit_governor(policy);
2233 if (ret) {
2234 pr_err("%s: Failed to Exit Governor: %s (%d)\n",
2235 __func__, old_gov->name, ret);
2236 return ret;
2237 }
2238 } 2209 }
2239 2210
2240 /* start new governor */ 2211 /* start new governor */
@@ -2495,10 +2466,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
2495 2466
2496 register_hotcpu_notifier(&cpufreq_cpu_notifier); 2467 register_hotcpu_notifier(&cpufreq_cpu_notifier);
2497 pr_debug("driver %s up and running\n", driver_data->name); 2468 pr_debug("driver %s up and running\n", driver_data->name);
2498 2469 goto out;
2499out:
2500 put_online_cpus();
2501 return ret;
2502 2470
2503err_if_unreg: 2471err_if_unreg:
2504 subsys_interface_unregister(&cpufreq_interface); 2472 subsys_interface_unregister(&cpufreq_interface);
@@ -2508,7 +2476,9 @@ err_null_driver:
2508 write_lock_irqsave(&cpufreq_driver_lock, flags); 2476 write_lock_irqsave(&cpufreq_driver_lock, flags);
2509 cpufreq_driver = NULL; 2477 cpufreq_driver = NULL;
2510 write_unlock_irqrestore(&cpufreq_driver_lock, flags); 2478 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
2511 goto out; 2479out:
2480 put_online_cpus();
2481 return ret;
2512} 2482}
2513EXPORT_SYMBOL_GPL(cpufreq_register_driver); 2483EXPORT_SYMBOL_GPL(cpufreq_register_driver);
2514 2484
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index b76a98dd9988..3a9c4325d6e2 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1461,12 +1461,11 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
1461 intel_pstate_clear_update_util_hook(policy->cpu); 1461 intel_pstate_clear_update_util_hook(policy->cpu);
1462 1462
1463 cpu = all_cpu_data[0]; 1463 cpu = all_cpu_data[0];
1464 if (cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate) { 1464 if (cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate &&
1465 if (policy->max < policy->cpuinfo.max_freq && 1465 policy->max < policy->cpuinfo.max_freq &&
1466 policy->max > cpu->pstate.max_pstate * cpu->pstate.scaling) { 1466 policy->max > cpu->pstate.max_pstate * cpu->pstate.scaling) {
1467 pr_debug("policy->max > max non turbo frequency\n"); 1467 pr_debug("policy->max > max non turbo frequency\n");
1468 policy->max = policy->cpuinfo.max_freq; 1468 policy->max = policy->cpuinfo.max_freq;
1469 }
1470 } 1469 }
1471 1470
1472 if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { 1471 if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) {
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 2b8e6ce62e81..a4d0059e232c 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -214,7 +214,7 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
214 tick_broadcast_exit(); 214 tick_broadcast_exit();
215 } 215 }
216 216
217 if (!cpuidle_state_is_coupled(drv, entered_state)) 217 if (!cpuidle_state_is_coupled(drv, index))
218 local_irq_enable(); 218 local_irq_enable();
219 219
220 /* 220 /*
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 154ae3a51e86..14c4aa25cc45 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -9,6 +9,8 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/cpufreq.h> 14#include <linux/cpufreq.h>
13#include <linux/module.h> 15#include <linux/module.h>
14#include <linux/slab.h> 16#include <linux/slab.h>
@@ -388,7 +390,7 @@ static int sugov_init(struct cpufreq_policy *policy)
388 mutex_unlock(&global_tunables_lock); 390 mutex_unlock(&global_tunables_lock);
389 391
390 sugov_policy_free(sg_policy); 392 sugov_policy_free(sg_policy);
391 pr_err("cpufreq: schedutil governor initialization failed (error %d)\n", ret); 393 pr_err("initialization failed (error %d)\n", ret);
392 return ret; 394 return ret;
393} 395}
394 396