diff options
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 71 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 137 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 3 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 1 | ||||
-rw-r--r-- | drivers/cpufreq/freq_table.c | 12 |
5 files changed, 178 insertions, 46 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index ff57c40e9b8b..75d293eeb3ee 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -64,14 +64,14 @@ static DEFINE_SPINLOCK(cpufreq_driver_lock); | |||
64 | * - Lock should not be held across | 64 | * - Lock should not be held across |
65 | * __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 65 | * __cpufreq_governor(data, CPUFREQ_GOV_STOP); |
66 | */ | 66 | */ |
67 | static DEFINE_PER_CPU(int, policy_cpu); | 67 | static DEFINE_PER_CPU(int, cpufreq_policy_cpu); |
68 | static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem); | 68 | static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem); |
69 | 69 | ||
70 | #define lock_policy_rwsem(mode, cpu) \ | 70 | #define lock_policy_rwsem(mode, cpu) \ |
71 | int lock_policy_rwsem_##mode \ | 71 | int lock_policy_rwsem_##mode \ |
72 | (int cpu) \ | 72 | (int cpu) \ |
73 | { \ | 73 | { \ |
74 | int policy_cpu = per_cpu(policy_cpu, cpu); \ | 74 | int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); \ |
75 | BUG_ON(policy_cpu == -1); \ | 75 | BUG_ON(policy_cpu == -1); \ |
76 | down_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \ | 76 | down_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \ |
77 | if (unlikely(!cpu_online(cpu))) { \ | 77 | if (unlikely(!cpu_online(cpu))) { \ |
@@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(lock_policy_rwsem_write); | |||
90 | 90 | ||
91 | void unlock_policy_rwsem_read(int cpu) | 91 | void unlock_policy_rwsem_read(int cpu) |
92 | { | 92 | { |
93 | int policy_cpu = per_cpu(policy_cpu, cpu); | 93 | int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); |
94 | BUG_ON(policy_cpu == -1); | 94 | BUG_ON(policy_cpu == -1); |
95 | up_read(&per_cpu(cpu_policy_rwsem, policy_cpu)); | 95 | up_read(&per_cpu(cpu_policy_rwsem, policy_cpu)); |
96 | } | 96 | } |
@@ -98,7 +98,7 @@ EXPORT_SYMBOL_GPL(unlock_policy_rwsem_read); | |||
98 | 98 | ||
99 | void unlock_policy_rwsem_write(int cpu) | 99 | void unlock_policy_rwsem_write(int cpu) |
100 | { | 100 | { |
101 | int policy_cpu = per_cpu(policy_cpu, cpu); | 101 | int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); |
102 | BUG_ON(policy_cpu == -1); | 102 | BUG_ON(policy_cpu == -1); |
103 | up_write(&per_cpu(cpu_policy_rwsem, policy_cpu)); | 103 | up_write(&per_cpu(cpu_policy_rwsem, policy_cpu)); |
104 | } | 104 | } |
@@ -647,6 +647,21 @@ static ssize_t show_scaling_setspeed(struct cpufreq_policy *policy, char *buf) | |||
647 | return policy->governor->show_setspeed(policy, buf); | 647 | return policy->governor->show_setspeed(policy, buf); |
648 | } | 648 | } |
649 | 649 | ||
650 | /** | ||
651 | * show_scaling_driver - show the current cpufreq HW/BIOS limitation | ||
652 | */ | ||
653 | static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf) | ||
654 | { | ||
655 | unsigned int limit; | ||
656 | int ret; | ||
657 | if (cpufreq_driver->bios_limit) { | ||
658 | ret = cpufreq_driver->bios_limit(policy->cpu, &limit); | ||
659 | if (!ret) | ||
660 | return sprintf(buf, "%u\n", limit); | ||
661 | } | ||
662 | return sprintf(buf, "%u\n", policy->cpuinfo.max_freq); | ||
663 | } | ||
664 | |||
650 | #define define_one_ro(_name) \ | 665 | #define define_one_ro(_name) \ |
651 | static struct freq_attr _name = \ | 666 | static struct freq_attr _name = \ |
652 | __ATTR(_name, 0444, show_##_name, NULL) | 667 | __ATTR(_name, 0444, show_##_name, NULL) |
@@ -666,6 +681,7 @@ define_one_ro(cpuinfo_transition_latency); | |||
666 | define_one_ro(scaling_available_governors); | 681 | define_one_ro(scaling_available_governors); |
667 | define_one_ro(scaling_driver); | 682 | define_one_ro(scaling_driver); |
668 | define_one_ro(scaling_cur_freq); | 683 | define_one_ro(scaling_cur_freq); |
684 | define_one_ro(bios_limit); | ||
669 | define_one_ro(related_cpus); | 685 | define_one_ro(related_cpus); |
670 | define_one_ro(affected_cpus); | 686 | define_one_ro(affected_cpus); |
671 | define_one_rw(scaling_min_freq); | 687 | define_one_rw(scaling_min_freq); |
@@ -750,7 +766,7 @@ static void cpufreq_sysfs_release(struct kobject *kobj) | |||
750 | complete(&policy->kobj_unregister); | 766 | complete(&policy->kobj_unregister); |
751 | } | 767 | } |
752 | 768 | ||
753 | static struct sysfs_ops sysfs_ops = { | 769 | static const struct sysfs_ops sysfs_ops = { |
754 | .show = show, | 770 | .show = show, |
755 | .store = store, | 771 | .store = store, |
756 | }; | 772 | }; |
@@ -767,8 +783,9 @@ static struct kobj_type ktype_cpufreq = { | |||
767 | * 0: Success | 783 | * 0: Success |
768 | * Positive: When we have a managed CPU and the sysfs got symlinked | 784 | * Positive: When we have a managed CPU and the sysfs got symlinked |
769 | */ | 785 | */ |
770 | int cpufreq_add_dev_policy(unsigned int cpu, struct cpufreq_policy *policy, | 786 | static int cpufreq_add_dev_policy(unsigned int cpu, |
771 | struct sys_device *sys_dev) | 787 | struct cpufreq_policy *policy, |
788 | struct sys_device *sys_dev) | ||
772 | { | 789 | { |
773 | int ret = 0; | 790 | int ret = 0; |
774 | #ifdef CONFIG_SMP | 791 | #ifdef CONFIG_SMP |
@@ -801,7 +818,7 @@ int cpufreq_add_dev_policy(unsigned int cpu, struct cpufreq_policy *policy, | |||
801 | 818 | ||
802 | /* Set proper policy_cpu */ | 819 | /* Set proper policy_cpu */ |
803 | unlock_policy_rwsem_write(cpu); | 820 | unlock_policy_rwsem_write(cpu); |
804 | per_cpu(policy_cpu, cpu) = managed_policy->cpu; | 821 | per_cpu(cpufreq_policy_cpu, cpu) = managed_policy->cpu; |
805 | 822 | ||
806 | if (lock_policy_rwsem_write(cpu) < 0) { | 823 | if (lock_policy_rwsem_write(cpu) < 0) { |
807 | /* Should not go through policy unlock path */ | 824 | /* Should not go through policy unlock path */ |
@@ -842,7 +859,8 @@ int cpufreq_add_dev_policy(unsigned int cpu, struct cpufreq_policy *policy, | |||
842 | 859 | ||
843 | 860 | ||
844 | /* symlink affected CPUs */ | 861 | /* symlink affected CPUs */ |
845 | int cpufreq_add_dev_symlink(unsigned int cpu, struct cpufreq_policy *policy) | 862 | static int cpufreq_add_dev_symlink(unsigned int cpu, |
863 | struct cpufreq_policy *policy) | ||
846 | { | 864 | { |
847 | unsigned int j; | 865 | unsigned int j; |
848 | int ret = 0; | 866 | int ret = 0; |
@@ -869,8 +887,9 @@ int cpufreq_add_dev_symlink(unsigned int cpu, struct cpufreq_policy *policy) | |||
869 | return ret; | 887 | return ret; |
870 | } | 888 | } |
871 | 889 | ||
872 | int cpufreq_add_dev_interface(unsigned int cpu, struct cpufreq_policy *policy, | 890 | static int cpufreq_add_dev_interface(unsigned int cpu, |
873 | struct sys_device *sys_dev) | 891 | struct cpufreq_policy *policy, |
892 | struct sys_device *sys_dev) | ||
874 | { | 893 | { |
875 | struct cpufreq_policy new_policy; | 894 | struct cpufreq_policy new_policy; |
876 | struct freq_attr **drv_attr; | 895 | struct freq_attr **drv_attr; |
@@ -902,13 +921,18 @@ int cpufreq_add_dev_interface(unsigned int cpu, struct cpufreq_policy *policy, | |||
902 | if (ret) | 921 | if (ret) |
903 | goto err_out_kobj_put; | 922 | goto err_out_kobj_put; |
904 | } | 923 | } |
924 | if (cpufreq_driver->bios_limit) { | ||
925 | ret = sysfs_create_file(&policy->kobj, &bios_limit.attr); | ||
926 | if (ret) | ||
927 | goto err_out_kobj_put; | ||
928 | } | ||
905 | 929 | ||
906 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 930 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
907 | for_each_cpu(j, policy->cpus) { | 931 | for_each_cpu(j, policy->cpus) { |
908 | if (!cpu_online(j)) | 932 | if (!cpu_online(j)) |
909 | continue; | 933 | continue; |
910 | per_cpu(cpufreq_cpu_data, j) = policy; | 934 | per_cpu(cpufreq_cpu_data, j) = policy; |
911 | per_cpu(policy_cpu, j) = policy->cpu; | 935 | per_cpu(cpufreq_policy_cpu, j) = policy->cpu; |
912 | } | 936 | } |
913 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 937 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
914 | 938 | ||
@@ -996,7 +1020,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) | |||
996 | cpumask_copy(policy->cpus, cpumask_of(cpu)); | 1020 | cpumask_copy(policy->cpus, cpumask_of(cpu)); |
997 | 1021 | ||
998 | /* Initially set CPU itself as the policy_cpu */ | 1022 | /* Initially set CPU itself as the policy_cpu */ |
999 | per_cpu(policy_cpu, cpu) = cpu; | 1023 | per_cpu(cpufreq_policy_cpu, cpu) = cpu; |
1000 | ret = (lock_policy_rwsem_write(cpu) < 0); | 1024 | ret = (lock_policy_rwsem_write(cpu) < 0); |
1001 | WARN_ON(ret); | 1025 | WARN_ON(ret); |
1002 | 1026 | ||
@@ -1089,6 +1113,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1089 | unsigned int cpu = sys_dev->id; | 1113 | unsigned int cpu = sys_dev->id; |
1090 | unsigned long flags; | 1114 | unsigned long flags; |
1091 | struct cpufreq_policy *data; | 1115 | struct cpufreq_policy *data; |
1116 | struct kobject *kobj; | ||
1117 | struct completion *cmp; | ||
1092 | #ifdef CONFIG_SMP | 1118 | #ifdef CONFIG_SMP |
1093 | struct sys_device *cpu_sys_dev; | 1119 | struct sys_device *cpu_sys_dev; |
1094 | unsigned int j; | 1120 | unsigned int j; |
@@ -1117,10 +1143,11 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1117 | dprintk("removing link\n"); | 1143 | dprintk("removing link\n"); |
1118 | cpumask_clear_cpu(cpu, data->cpus); | 1144 | cpumask_clear_cpu(cpu, data->cpus); |
1119 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1145 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1120 | sysfs_remove_link(&sys_dev->kobj, "cpufreq"); | 1146 | kobj = &sys_dev->kobj; |
1121 | cpufreq_cpu_put(data); | 1147 | cpufreq_cpu_put(data); |
1122 | cpufreq_debug_enable_ratelimit(); | 1148 | cpufreq_debug_enable_ratelimit(); |
1123 | unlock_policy_rwsem_write(cpu); | 1149 | unlock_policy_rwsem_write(cpu); |
1150 | sysfs_remove_link(kobj, "cpufreq"); | ||
1124 | return 0; | 1151 | return 0; |
1125 | } | 1152 | } |
1126 | #endif | 1153 | #endif |
@@ -1157,7 +1184,10 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1157 | data->governor->name, CPUFREQ_NAME_LEN); | 1184 | data->governor->name, CPUFREQ_NAME_LEN); |
1158 | #endif | 1185 | #endif |
1159 | cpu_sys_dev = get_cpu_sysdev(j); | 1186 | cpu_sys_dev = get_cpu_sysdev(j); |
1160 | sysfs_remove_link(&cpu_sys_dev->kobj, "cpufreq"); | 1187 | kobj = &cpu_sys_dev->kobj; |
1188 | unlock_policy_rwsem_write(cpu); | ||
1189 | sysfs_remove_link(kobj, "cpufreq"); | ||
1190 | lock_policy_rwsem_write(cpu); | ||
1161 | cpufreq_cpu_put(data); | 1191 | cpufreq_cpu_put(data); |
1162 | } | 1192 | } |
1163 | } | 1193 | } |
@@ -1168,19 +1198,22 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1168 | if (cpufreq_driver->target) | 1198 | if (cpufreq_driver->target) |
1169 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 1199 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); |
1170 | 1200 | ||
1171 | kobject_put(&data->kobj); | 1201 | kobj = &data->kobj; |
1202 | cmp = &data->kobj_unregister; | ||
1203 | unlock_policy_rwsem_write(cpu); | ||
1204 | kobject_put(kobj); | ||
1172 | 1205 | ||
1173 | /* we need to make sure that the underlying kobj is actually | 1206 | /* we need to make sure that the underlying kobj is actually |
1174 | * not referenced anymore by anybody before we proceed with | 1207 | * not referenced anymore by anybody before we proceed with |
1175 | * unloading. | 1208 | * unloading. |
1176 | */ | 1209 | */ |
1177 | dprintk("waiting for dropping of refcount\n"); | 1210 | dprintk("waiting for dropping of refcount\n"); |
1178 | wait_for_completion(&data->kobj_unregister); | 1211 | wait_for_completion(cmp); |
1179 | dprintk("wait complete\n"); | 1212 | dprintk("wait complete\n"); |
1180 | 1213 | ||
1214 | lock_policy_rwsem_write(cpu); | ||
1181 | if (cpufreq_driver->exit) | 1215 | if (cpufreq_driver->exit) |
1182 | cpufreq_driver->exit(data); | 1216 | cpufreq_driver->exit(data); |
1183 | |||
1184 | unlock_policy_rwsem_write(cpu); | 1217 | unlock_policy_rwsem_write(cpu); |
1185 | 1218 | ||
1186 | free_cpumask_var(data->related_cpus); | 1219 | free_cpumask_var(data->related_cpus); |
@@ -1978,7 +2011,7 @@ static int __init cpufreq_core_init(void) | |||
1978 | int cpu; | 2011 | int cpu; |
1979 | 2012 | ||
1980 | for_each_possible_cpu(cpu) { | 2013 | for_each_possible_cpu(cpu) { |
1981 | per_cpu(policy_cpu, cpu) = -1; | 2014 | per_cpu(cpufreq_policy_cpu, cpu) = -1; |
1982 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); | 2015 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); |
1983 | } | 2016 | } |
1984 | 2017 | ||
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index c7b081b839ff..3a147874a465 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -164,20 +164,22 @@ static struct notifier_block dbs_cpufreq_notifier_block = { | |||
164 | }; | 164 | }; |
165 | 165 | ||
166 | /************************** sysfs interface ************************/ | 166 | /************************** sysfs interface ************************/ |
167 | static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) | 167 | static ssize_t show_sampling_rate_max(struct kobject *kobj, |
168 | struct attribute *attr, char *buf) | ||
168 | { | 169 | { |
169 | printk_once(KERN_INFO "CPUFREQ: conservative sampling_rate_max " | 170 | printk_once(KERN_INFO "CPUFREQ: conservative sampling_rate_max " |
170 | "sysfs file is deprecated - used by: %s\n", current->comm); | 171 | "sysfs file is deprecated - used by: %s\n", current->comm); |
171 | return sprintf(buf, "%u\n", -1U); | 172 | return sprintf(buf, "%u\n", -1U); |
172 | } | 173 | } |
173 | 174 | ||
174 | static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) | 175 | static ssize_t show_sampling_rate_min(struct kobject *kobj, |
176 | struct attribute *attr, char *buf) | ||
175 | { | 177 | { |
176 | return sprintf(buf, "%u\n", min_sampling_rate); | 178 | return sprintf(buf, "%u\n", min_sampling_rate); |
177 | } | 179 | } |
178 | 180 | ||
179 | #define define_one_ro(_name) \ | 181 | #define define_one_ro(_name) \ |
180 | static struct freq_attr _name = \ | 182 | static struct global_attr _name = \ |
181 | __ATTR(_name, 0444, show_##_name, NULL) | 183 | __ATTR(_name, 0444, show_##_name, NULL) |
182 | 184 | ||
183 | define_one_ro(sampling_rate_max); | 185 | define_one_ro(sampling_rate_max); |
@@ -186,7 +188,7 @@ define_one_ro(sampling_rate_min); | |||
186 | /* cpufreq_conservative Governor Tunables */ | 188 | /* cpufreq_conservative Governor Tunables */ |
187 | #define show_one(file_name, object) \ | 189 | #define show_one(file_name, object) \ |
188 | static ssize_t show_##file_name \ | 190 | static ssize_t show_##file_name \ |
189 | (struct cpufreq_policy *unused, char *buf) \ | 191 | (struct kobject *kobj, struct attribute *attr, char *buf) \ |
190 | { \ | 192 | { \ |
191 | return sprintf(buf, "%u\n", dbs_tuners_ins.object); \ | 193 | return sprintf(buf, "%u\n", dbs_tuners_ins.object); \ |
192 | } | 194 | } |
@@ -197,8 +199,40 @@ show_one(down_threshold, down_threshold); | |||
197 | show_one(ignore_nice_load, ignore_nice); | 199 | show_one(ignore_nice_load, ignore_nice); |
198 | show_one(freq_step, freq_step); | 200 | show_one(freq_step, freq_step); |
199 | 201 | ||
200 | static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, | 202 | /*** delete after deprecation time ***/ |
201 | const char *buf, size_t count) | 203 | #define DEPRECATION_MSG(file_name) \ |
204 | printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \ | ||
205 | "interface is deprecated - " #file_name "\n"); | ||
206 | |||
207 | #define show_one_old(file_name) \ | ||
208 | static ssize_t show_##file_name##_old \ | ||
209 | (struct cpufreq_policy *unused, char *buf) \ | ||
210 | { \ | ||
211 | printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \ | ||
212 | "interface is deprecated - " #file_name "\n"); \ | ||
213 | return show_##file_name(NULL, NULL, buf); \ | ||
214 | } | ||
215 | show_one_old(sampling_rate); | ||
216 | show_one_old(sampling_down_factor); | ||
217 | show_one_old(up_threshold); | ||
218 | show_one_old(down_threshold); | ||
219 | show_one_old(ignore_nice_load); | ||
220 | show_one_old(freq_step); | ||
221 | show_one_old(sampling_rate_min); | ||
222 | show_one_old(sampling_rate_max); | ||
223 | |||
224 | #define define_one_ro_old(object, _name) \ | ||
225 | static struct freq_attr object = \ | ||
226 | __ATTR(_name, 0444, show_##_name##_old, NULL) | ||
227 | |||
228 | define_one_ro_old(sampling_rate_min_old, sampling_rate_min); | ||
229 | define_one_ro_old(sampling_rate_max_old, sampling_rate_max); | ||
230 | |||
231 | /*** delete after deprecation time ***/ | ||
232 | |||
233 | static ssize_t store_sampling_down_factor(struct kobject *a, | ||
234 | struct attribute *b, | ||
235 | const char *buf, size_t count) | ||
202 | { | 236 | { |
203 | unsigned int input; | 237 | unsigned int input; |
204 | int ret; | 238 | int ret; |
@@ -214,8 +248,8 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, | |||
214 | return count; | 248 | return count; |
215 | } | 249 | } |
216 | 250 | ||
217 | static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | 251 | static ssize_t store_sampling_rate(struct kobject *a, struct attribute *b, |
218 | const char *buf, size_t count) | 252 | const char *buf, size_t count) |
219 | { | 253 | { |
220 | unsigned int input; | 254 | unsigned int input; |
221 | int ret; | 255 | int ret; |
@@ -231,8 +265,8 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | |||
231 | return count; | 265 | return count; |
232 | } | 266 | } |
233 | 267 | ||
234 | static ssize_t store_up_threshold(struct cpufreq_policy *unused, | 268 | static ssize_t store_up_threshold(struct kobject *a, struct attribute *b, |
235 | const char *buf, size_t count) | 269 | const char *buf, size_t count) |
236 | { | 270 | { |
237 | unsigned int input; | 271 | unsigned int input; |
238 | int ret; | 272 | int ret; |
@@ -251,8 +285,8 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused, | |||
251 | return count; | 285 | return count; |
252 | } | 286 | } |
253 | 287 | ||
254 | static ssize_t store_down_threshold(struct cpufreq_policy *unused, | 288 | static ssize_t store_down_threshold(struct kobject *a, struct attribute *b, |
255 | const char *buf, size_t count) | 289 | const char *buf, size_t count) |
256 | { | 290 | { |
257 | unsigned int input; | 291 | unsigned int input; |
258 | int ret; | 292 | int ret; |
@@ -272,8 +306,8 @@ static ssize_t store_down_threshold(struct cpufreq_policy *unused, | |||
272 | return count; | 306 | return count; |
273 | } | 307 | } |
274 | 308 | ||
275 | static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, | 309 | static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, |
276 | const char *buf, size_t count) | 310 | const char *buf, size_t count) |
277 | { | 311 | { |
278 | unsigned int input; | 312 | unsigned int input; |
279 | int ret; | 313 | int ret; |
@@ -308,8 +342,8 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, | |||
308 | return count; | 342 | return count; |
309 | } | 343 | } |
310 | 344 | ||
311 | static ssize_t store_freq_step(struct cpufreq_policy *policy, | 345 | static ssize_t store_freq_step(struct kobject *a, struct attribute *b, |
312 | const char *buf, size_t count) | 346 | const char *buf, size_t count) |
313 | { | 347 | { |
314 | unsigned int input; | 348 | unsigned int input; |
315 | int ret; | 349 | int ret; |
@@ -331,7 +365,7 @@ static ssize_t store_freq_step(struct cpufreq_policy *policy, | |||
331 | } | 365 | } |
332 | 366 | ||
333 | #define define_one_rw(_name) \ | 367 | #define define_one_rw(_name) \ |
334 | static struct freq_attr _name = \ | 368 | static struct global_attr _name = \ |
335 | __ATTR(_name, 0644, show_##_name, store_##_name) | 369 | __ATTR(_name, 0644, show_##_name, store_##_name) |
336 | 370 | ||
337 | define_one_rw(sampling_rate); | 371 | define_one_rw(sampling_rate); |
@@ -358,11 +392,59 @@ static struct attribute_group dbs_attr_group = { | |||
358 | .name = "conservative", | 392 | .name = "conservative", |
359 | }; | 393 | }; |
360 | 394 | ||
395 | /*** delete after deprecation time ***/ | ||
396 | |||
397 | #define write_one_old(file_name) \ | ||
398 | static ssize_t store_##file_name##_old \ | ||
399 | (struct cpufreq_policy *unused, const char *buf, size_t count) \ | ||
400 | { \ | ||
401 | printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \ | ||
402 | "interface is deprecated - " #file_name "\n"); \ | ||
403 | return store_##file_name(NULL, NULL, buf, count); \ | ||
404 | } | ||
405 | write_one_old(sampling_rate); | ||
406 | write_one_old(sampling_down_factor); | ||
407 | write_one_old(up_threshold); | ||
408 | write_one_old(down_threshold); | ||
409 | write_one_old(ignore_nice_load); | ||
410 | write_one_old(freq_step); | ||
411 | |||
412 | #define define_one_rw_old(object, _name) \ | ||
413 | static struct freq_attr object = \ | ||
414 | __ATTR(_name, 0644, show_##_name##_old, store_##_name##_old) | ||
415 | |||
416 | define_one_rw_old(sampling_rate_old, sampling_rate); | ||
417 | define_one_rw_old(sampling_down_factor_old, sampling_down_factor); | ||
418 | define_one_rw_old(up_threshold_old, up_threshold); | ||
419 | define_one_rw_old(down_threshold_old, down_threshold); | ||
420 | define_one_rw_old(ignore_nice_load_old, ignore_nice_load); | ||
421 | define_one_rw_old(freq_step_old, freq_step); | ||
422 | |||
423 | static struct attribute *dbs_attributes_old[] = { | ||
424 | &sampling_rate_max_old.attr, | ||
425 | &sampling_rate_min_old.attr, | ||
426 | &sampling_rate_old.attr, | ||
427 | &sampling_down_factor_old.attr, | ||
428 | &up_threshold_old.attr, | ||
429 | &down_threshold_old.attr, | ||
430 | &ignore_nice_load_old.attr, | ||
431 | &freq_step_old.attr, | ||
432 | NULL | ||
433 | }; | ||
434 | |||
435 | static struct attribute_group dbs_attr_group_old = { | ||
436 | .attrs = dbs_attributes_old, | ||
437 | .name = "conservative", | ||
438 | }; | ||
439 | |||
440 | /*** delete after deprecation time ***/ | ||
441 | |||
361 | /************************** sysfs end ************************/ | 442 | /************************** sysfs end ************************/ |
362 | 443 | ||
363 | static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | 444 | static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) |
364 | { | 445 | { |
365 | unsigned int load = 0; | 446 | unsigned int load = 0; |
447 | unsigned int max_load = 0; | ||
366 | unsigned int freq_target; | 448 | unsigned int freq_target; |
367 | 449 | ||
368 | struct cpufreq_policy *policy; | 450 | struct cpufreq_policy *policy; |
@@ -420,6 +502,9 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
420 | continue; | 502 | continue; |
421 | 503 | ||
422 | load = 100 * (wall_time - idle_time) / wall_time; | 504 | load = 100 * (wall_time - idle_time) / wall_time; |
505 | |||
506 | if (load > max_load) | ||
507 | max_load = load; | ||
423 | } | 508 | } |
424 | 509 | ||
425 | /* | 510 | /* |
@@ -430,7 +515,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
430 | return; | 515 | return; |
431 | 516 | ||
432 | /* Check for frequency increase */ | 517 | /* Check for frequency increase */ |
433 | if (load > dbs_tuners_ins.up_threshold) { | 518 | if (max_load > dbs_tuners_ins.up_threshold) { |
434 | this_dbs_info->down_skip = 0; | 519 | this_dbs_info->down_skip = 0; |
435 | 520 | ||
436 | /* if we are already at full speed then break out early */ | 521 | /* if we are already at full speed then break out early */ |
@@ -457,7 +542,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
457 | * can support the current CPU usage without triggering the up | 542 | * can support the current CPU usage without triggering the up |
458 | * policy. To be safe, we focus 10 points under the threshold. | 543 | * policy. To be safe, we focus 10 points under the threshold. |
459 | */ | 544 | */ |
460 | if (load < (dbs_tuners_ins.down_threshold - 10)) { | 545 | if (max_load < (dbs_tuners_ins.down_threshold - 10)) { |
461 | freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100; | 546 | freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100; |
462 | 547 | ||
463 | this_dbs_info->requested_freq -= freq_target; | 548 | this_dbs_info->requested_freq -= freq_target; |
@@ -530,7 +615,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
530 | 615 | ||
531 | mutex_lock(&dbs_mutex); | 616 | mutex_lock(&dbs_mutex); |
532 | 617 | ||
533 | rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); | 618 | rc = sysfs_create_group(&policy->kobj, &dbs_attr_group_old); |
534 | if (rc) { | 619 | if (rc) { |
535 | mutex_unlock(&dbs_mutex); | 620 | mutex_unlock(&dbs_mutex); |
536 | return rc; | 621 | return rc; |
@@ -564,6 +649,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
564 | if (latency == 0) | 649 | if (latency == 0) |
565 | latency = 1; | 650 | latency = 1; |
566 | 651 | ||
652 | rc = sysfs_create_group(cpufreq_global_kobject, | ||
653 | &dbs_attr_group); | ||
654 | if (rc) { | ||
655 | mutex_unlock(&dbs_mutex); | ||
656 | return rc; | ||
657 | } | ||
658 | |||
567 | /* | 659 | /* |
568 | * conservative does not implement micro like ondemand | 660 | * conservative does not implement micro like ondemand |
569 | * governor, thus we are bound to jiffes/HZ | 661 | * governor, thus we are bound to jiffes/HZ |
@@ -591,7 +683,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
591 | dbs_timer_exit(this_dbs_info); | 683 | dbs_timer_exit(this_dbs_info); |
592 | 684 | ||
593 | mutex_lock(&dbs_mutex); | 685 | mutex_lock(&dbs_mutex); |
594 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); | 686 | sysfs_remove_group(&policy->kobj, &dbs_attr_group_old); |
595 | dbs_enable--; | 687 | dbs_enable--; |
596 | mutex_destroy(&this_dbs_info->timer_mutex); | 688 | mutex_destroy(&this_dbs_info->timer_mutex); |
597 | 689 | ||
@@ -605,6 +697,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
605 | CPUFREQ_TRANSITION_NOTIFIER); | 697 | CPUFREQ_TRANSITION_NOTIFIER); |
606 | 698 | ||
607 | mutex_unlock(&dbs_mutex); | 699 | mutex_unlock(&dbs_mutex); |
700 | if (!dbs_enable) | ||
701 | sysfs_remove_group(cpufreq_global_kobject, | ||
702 | &dbs_attr_group); | ||
608 | 703 | ||
609 | break; | 704 | break; |
610 | 705 | ||
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 4b34ade2332b..bd444dc93cf2 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -554,6 +554,9 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
554 | (dbs_tuners_ins.up_threshold - | 554 | (dbs_tuners_ins.up_threshold - |
555 | dbs_tuners_ins.down_differential); | 555 | dbs_tuners_ins.down_differential); |
556 | 556 | ||
557 | if (freq_next < policy->min) | ||
558 | freq_next = policy->min; | ||
559 | |||
557 | if (!dbs_tuners_ins.powersave_bias) { | 560 | if (!dbs_tuners_ins.powersave_bias) { |
558 | __cpufreq_driver_target(policy, freq_next, | 561 | __cpufreq_driver_target(policy, freq_next, |
559 | CPUFREQ_RELATION_L); | 562 | CPUFREQ_RELATION_L); |
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 5a62d678dd19..00d73fc8e4e2 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/slab.h> | ||
13 | #include <linux/sysdev.h> | 14 | #include <linux/sysdev.h> |
14 | #include <linux/cpu.h> | 15 | #include <linux/cpu.h> |
15 | #include <linux/sysfs.h> | 16 | #include <linux/sysfs.h> |
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index a9bd3a05a684..05432216e224 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
@@ -174,7 +174,7 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
174 | } | 174 | } |
175 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target); | 175 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target); |
176 | 176 | ||
177 | static DEFINE_PER_CPU(struct cpufreq_frequency_table *, show_table); | 177 | static DEFINE_PER_CPU(struct cpufreq_frequency_table *, cpufreq_show_table); |
178 | /** | 178 | /** |
179 | * show_available_freqs - show available frequencies for the specified CPU | 179 | * show_available_freqs - show available frequencies for the specified CPU |
180 | */ | 180 | */ |
@@ -185,10 +185,10 @@ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf) | |||
185 | ssize_t count = 0; | 185 | ssize_t count = 0; |
186 | struct cpufreq_frequency_table *table; | 186 | struct cpufreq_frequency_table *table; |
187 | 187 | ||
188 | if (!per_cpu(show_table, cpu)) | 188 | if (!per_cpu(cpufreq_show_table, cpu)) |
189 | return -ENODEV; | 189 | return -ENODEV; |
190 | 190 | ||
191 | table = per_cpu(show_table, cpu); | 191 | table = per_cpu(cpufreq_show_table, cpu); |
192 | 192 | ||
193 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { | 193 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { |
194 | if (table[i].frequency == CPUFREQ_ENTRY_INVALID) | 194 | if (table[i].frequency == CPUFREQ_ENTRY_INVALID) |
@@ -217,20 +217,20 @@ void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, | |||
217 | unsigned int cpu) | 217 | unsigned int cpu) |
218 | { | 218 | { |
219 | dprintk("setting show_table for cpu %u to %p\n", cpu, table); | 219 | dprintk("setting show_table for cpu %u to %p\n", cpu, table); |
220 | per_cpu(show_table, cpu) = table; | 220 | per_cpu(cpufreq_show_table, cpu) = table; |
221 | } | 221 | } |
222 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr); | 222 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr); |
223 | 223 | ||
224 | void cpufreq_frequency_table_put_attr(unsigned int cpu) | 224 | void cpufreq_frequency_table_put_attr(unsigned int cpu) |
225 | { | 225 | { |
226 | dprintk("clearing show_table for cpu %u\n", cpu); | 226 | dprintk("clearing show_table for cpu %u\n", cpu); |
227 | per_cpu(show_table, cpu) = NULL; | 227 | per_cpu(cpufreq_show_table, cpu) = NULL; |
228 | } | 228 | } |
229 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr); | 229 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr); |
230 | 230 | ||
231 | struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) | 231 | struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) |
232 | { | 232 | { |
233 | return per_cpu(show_table, cpu); | 233 | return per_cpu(cpufreq_show_table, cpu); |
234 | } | 234 | } |
235 | EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); | 235 | EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); |
236 | 236 | ||