diff options
| author | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2012-03-13 19:18:39 -0400 |
|---|---|---|
| committer | Dave Jones <davej@redhat.com> | 2012-03-14 14:45:03 -0400 |
| commit | a7b422cda5084db7265c3b23310a959b43b47529 (patch) | |
| tree | 32cb3e1dbde6b23814cc4e9c432db92754e89679 | |
| parent | 562a6cbe1cf2edf0a87a659eb26095400322430e (diff) | |
provide disable_cpufreq() function to disable the API.
useful for disabling cpufreq altogether. The cpu frequency
scaling drivers and cpu frequency governors will fail to register.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Dave Jones <davej@redhat.com>
| -rw-r--r-- | drivers/cpufreq/cpufreq.c | 24 | ||||
| -rw-r--r-- | include/linux/cpufreq.h | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 622013fb7890..7f2f149ae40f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
| @@ -126,6 +126,15 @@ static int __init init_cpufreq_transition_notifier_list(void) | |||
| 126 | } | 126 | } |
| 127 | pure_initcall(init_cpufreq_transition_notifier_list); | 127 | pure_initcall(init_cpufreq_transition_notifier_list); |
| 128 | 128 | ||
| 129 | static int off __read_mostly; | ||
| 130 | int cpufreq_disabled(void) | ||
| 131 | { | ||
| 132 | return off; | ||
| 133 | } | ||
| 134 | void disable_cpufreq(void) | ||
| 135 | { | ||
| 136 | off = 1; | ||
| 137 | } | ||
| 129 | static LIST_HEAD(cpufreq_governor_list); | 138 | static LIST_HEAD(cpufreq_governor_list); |
| 130 | static DEFINE_MUTEX(cpufreq_governor_mutex); | 139 | static DEFINE_MUTEX(cpufreq_governor_mutex); |
| 131 | 140 | ||
| @@ -1441,6 +1450,9 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, | |||
| 1441 | { | 1450 | { |
| 1442 | int retval = -EINVAL; | 1451 | int retval = -EINVAL; |
| 1443 | 1452 | ||
| 1453 | if (cpufreq_disabled()) | ||
| 1454 | return -ENODEV; | ||
| 1455 | |||
| 1444 | pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu, | 1456 | pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu, |
| 1445 | target_freq, relation); | 1457 | target_freq, relation); |
| 1446 | if (cpu_online(policy->cpu) && cpufreq_driver->target) | 1458 | if (cpu_online(policy->cpu) && cpufreq_driver->target) |
| @@ -1549,6 +1561,9 @@ int cpufreq_register_governor(struct cpufreq_governor *governor) | |||
| 1549 | if (!governor) | 1561 | if (!governor) |
| 1550 | return -EINVAL; | 1562 | return -EINVAL; |
| 1551 | 1563 | ||
| 1564 | if (cpufreq_disabled()) | ||
| 1565 | return -ENODEV; | ||
| 1566 | |||
| 1552 | mutex_lock(&cpufreq_governor_mutex); | 1567 | mutex_lock(&cpufreq_governor_mutex); |
| 1553 | 1568 | ||
| 1554 | err = -EBUSY; | 1569 | err = -EBUSY; |
| @@ -1572,6 +1587,9 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor) | |||
| 1572 | if (!governor) | 1587 | if (!governor) |
| 1573 | return; | 1588 | return; |
| 1574 | 1589 | ||
| 1590 | if (cpufreq_disabled()) | ||
| 1591 | return; | ||
| 1592 | |||
| 1575 | #ifdef CONFIG_HOTPLUG_CPU | 1593 | #ifdef CONFIG_HOTPLUG_CPU |
| 1576 | for_each_present_cpu(cpu) { | 1594 | for_each_present_cpu(cpu) { |
| 1577 | if (cpu_online(cpu)) | 1595 | if (cpu_online(cpu)) |
| @@ -1814,6 +1832,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
| 1814 | unsigned long flags; | 1832 | unsigned long flags; |
| 1815 | int ret; | 1833 | int ret; |
| 1816 | 1834 | ||
| 1835 | if (cpufreq_disabled()) | ||
| 1836 | return -ENODEV; | ||
| 1837 | |||
| 1817 | if (!driver_data || !driver_data->verify || !driver_data->init || | 1838 | if (!driver_data || !driver_data->verify || !driver_data->init || |
| 1818 | ((!driver_data->setpolicy) && (!driver_data->target))) | 1839 | ((!driver_data->setpolicy) && (!driver_data->target))) |
| 1819 | return -EINVAL; | 1840 | return -EINVAL; |
| @@ -1901,6 +1922,9 @@ static int __init cpufreq_core_init(void) | |||
| 1901 | { | 1922 | { |
| 1902 | int cpu; | 1923 | int cpu; |
| 1903 | 1924 | ||
| 1925 | if (cpufreq_disabled()) | ||
| 1926 | return -ENODEV; | ||
| 1927 | |||
| 1904 | for_each_possible_cpu(cpu) { | 1928 | for_each_possible_cpu(cpu) { |
| 1905 | per_cpu(cpufreq_policy_cpu, cpu) = -1; | 1929 | per_cpu(cpufreq_policy_cpu, cpu) = -1; |
| 1906 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); | 1930 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); |
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 6216115c7789..8ff442753c75 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | #ifdef CONFIG_CPU_FREQ | 35 | #ifdef CONFIG_CPU_FREQ |
| 36 | int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list); | 36 | int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list); |
| 37 | int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list); | 37 | int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list); |
| 38 | extern void disable_cpufreq(void); | ||
| 38 | #else /* CONFIG_CPU_FREQ */ | 39 | #else /* CONFIG_CPU_FREQ */ |
| 39 | static inline int cpufreq_register_notifier(struct notifier_block *nb, | 40 | static inline int cpufreq_register_notifier(struct notifier_block *nb, |
| 40 | unsigned int list) | 41 | unsigned int list) |
| @@ -46,6 +47,7 @@ static inline int cpufreq_unregister_notifier(struct notifier_block *nb, | |||
| 46 | { | 47 | { |
| 47 | return 0; | 48 | return 0; |
| 48 | } | 49 | } |
| 50 | static inline void disable_cpufreq(void) { } | ||
| 49 | #endif /* CONFIG_CPU_FREQ */ | 51 | #endif /* CONFIG_CPU_FREQ */ |
| 50 | 52 | ||
| 51 | /* if (cpufreq_driver->target) exists, the ->governor decides what frequency | 53 | /* if (cpufreq_driver->target) exists, the ->governor decides what frequency |
