cpufreq.c (c6380ecd8e9bee7aba3d9a5a94b58168244c4a61) | cpufreq.c (92c99d159c38256e221ed8b50fd48953746a90e0) |
---|---|
1/* 2 * linux/drivers/cpufreq/cpufreq.c 3 * 4 * Copyright (C) 2001 Russell King 5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 6 * (C) 2013 Viresh Kumar <viresh.kumar@linaro.org> 7 * 8 * Oct 2005 - Ashok Raj <ashok.raj@intel.com> --- 164 unchanged lines hidden (view full) --- 173 * - validate & show freq table passed 174 * - set policies transition latency 175 * - policy->cpus with all possible CPUs 176 */ 177int cpufreq_generic_init(struct cpufreq_policy *policy, 178 struct cpufreq_frequency_table *table, 179 unsigned int transition_latency) 180{ | 1/* 2 * linux/drivers/cpufreq/cpufreq.c 3 * 4 * Copyright (C) 2001 Russell King 5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 6 * (C) 2013 Viresh Kumar <viresh.kumar@linaro.org> 7 * 8 * Oct 2005 - Ashok Raj <ashok.raj@intel.com> --- 164 unchanged lines hidden (view full) --- 173 * - validate & show freq table passed 174 * - set policies transition latency 175 * - policy->cpus with all possible CPUs 176 */ 177int cpufreq_generic_init(struct cpufreq_policy *policy, 178 struct cpufreq_frequency_table *table, 179 unsigned int transition_latency) 180{ |
181 int ret; 182 183 ret = cpufreq_table_validate_and_show(policy, table); 184 if (ret) { 185 pr_err("%s: invalid frequency table: %d\n", __func__, ret); 186 return ret; 187 } 188 | 181 policy->freq_table = table; |
189 policy->cpuinfo.transition_latency = transition_latency; 190 191 /* 192 * The driver only supports the SMP configuration where all processors 193 * share the clock and voltage and clock. 194 */ 195 cpumask_setall(policy->cpus); 196 --- 1017 unchanged lines hidden (view full) --- 1214 * to accept all calls to ->verify and ->setpolicy for this CPU 1215 */ 1216 ret = cpufreq_driver->init(policy); 1217 if (ret) { 1218 pr_debug("initialization failed\n"); 1219 goto out_free_policy; 1220 } 1221 | 182 policy->cpuinfo.transition_latency = transition_latency; 183 184 /* 185 * The driver only supports the SMP configuration where all processors 186 * share the clock and voltage and clock. 187 */ 188 cpumask_setall(policy->cpus); 189 --- 1017 unchanged lines hidden (view full) --- 1207 * to accept all calls to ->verify and ->setpolicy for this CPU 1208 */ 1209 ret = cpufreq_driver->init(policy); 1210 if (ret) { 1211 pr_debug("initialization failed\n"); 1212 goto out_free_policy; 1213 } 1214 |
1215 ret = cpufreq_table_validate_and_sort(policy); 1216 if (ret) 1217 goto out_exit_policy; 1218 |
|
1222 down_write(&policy->rwsem); 1223 1224 if (new_policy) { 1225 /* related_cpus should at least include policy->cpus. */ 1226 cpumask_copy(policy->related_cpus, policy->cpus); 1227 } 1228 1229 /* --- 14 unchanged lines hidden (view full) --- 1244 policy->min = policy->user_policy.min; 1245 policy->max = policy->user_policy.max; 1246 } 1247 1248 if (cpufreq_driver->get && !cpufreq_driver->setpolicy) { 1249 policy->cur = cpufreq_driver->get(policy->cpu); 1250 if (!policy->cur) { 1251 pr_err("%s: ->get() failed\n", __func__); | 1219 down_write(&policy->rwsem); 1220 1221 if (new_policy) { 1222 /* related_cpus should at least include policy->cpus. */ 1223 cpumask_copy(policy->related_cpus, policy->cpus); 1224 } 1225 1226 /* --- 14 unchanged lines hidden (view full) --- 1241 policy->min = policy->user_policy.min; 1242 policy->max = policy->user_policy.max; 1243 } 1244 1245 if (cpufreq_driver->get && !cpufreq_driver->setpolicy) { 1246 policy->cur = cpufreq_driver->get(policy->cpu); 1247 if (!policy->cur) { 1248 pr_err("%s: ->get() failed\n", __func__); |
1252 goto out_exit_policy; | 1249 goto out_destroy_policy; |
1253 } 1254 } 1255 1256 /* 1257 * Sometimes boot loaders set CPU frequency to a value outside of 1258 * frequency table present with cpufreq core. In such cases CPU might be 1259 * unstable if it has to run on that frequency for long duration of time 1260 * and so its better to set it to a frequency which is specified in --- 30 unchanged lines hidden (view full) --- 1291 pr_warn("%s: CPU%d: Unlisted initial frequency changed to: %u KHz\n", 1292 __func__, policy->cpu, policy->cur); 1293 } 1294 } 1295 1296 if (new_policy) { 1297 ret = cpufreq_add_dev_interface(policy); 1298 if (ret) | 1250 } 1251 } 1252 1253 /* 1254 * Sometimes boot loaders set CPU frequency to a value outside of 1255 * frequency table present with cpufreq core. In such cases CPU might be 1256 * unstable if it has to run on that frequency for long duration of time 1257 * and so its better to set it to a frequency which is specified in --- 30 unchanged lines hidden (view full) --- 1288 pr_warn("%s: CPU%d: Unlisted initial frequency changed to: %u KHz\n", 1289 __func__, policy->cpu, policy->cur); 1290 } 1291 } 1292 1293 if (new_policy) { 1294 ret = cpufreq_add_dev_interface(policy); 1295 if (ret) |
1299 goto out_exit_policy; | 1296 goto out_destroy_policy; |
1300 1301 cpufreq_stats_create_table(policy); 1302 1303 write_lock_irqsave(&cpufreq_driver_lock, flags); 1304 list_add(&policy->policy_list, &cpufreq_policy_list); 1305 write_unlock_irqrestore(&cpufreq_driver_lock, flags); 1306 } 1307 1308 ret = cpufreq_init_policy(policy); 1309 if (ret) { 1310 pr_err("%s: Failed to initialize policy for cpu: %d (%d)\n", 1311 __func__, cpu, ret); 1312 /* cpufreq_policy_free() will notify based on this */ 1313 new_policy = false; | 1297 1298 cpufreq_stats_create_table(policy); 1299 1300 write_lock_irqsave(&cpufreq_driver_lock, flags); 1301 list_add(&policy->policy_list, &cpufreq_policy_list); 1302 write_unlock_irqrestore(&cpufreq_driver_lock, flags); 1303 } 1304 1305 ret = cpufreq_init_policy(policy); 1306 if (ret) { 1307 pr_err("%s: Failed to initialize policy for cpu: %d (%d)\n", 1308 __func__, cpu, ret); 1309 /* cpufreq_policy_free() will notify based on this */ 1310 new_policy = false; |
1314 goto out_exit_policy; | 1311 goto out_destroy_policy; |
1315 } 1316 1317 up_write(&policy->rwsem); 1318 1319 kobject_uevent(&policy->kobj, KOBJ_ADD); 1320 1321 /* Callback for handling stuff after policy is ready */ 1322 if (cpufreq_driver->ready) 1323 cpufreq_driver->ready(policy); 1324 1325 pr_debug("initialization complete\n"); 1326 1327 return 0; 1328 | 1312 } 1313 1314 up_write(&policy->rwsem); 1315 1316 kobject_uevent(&policy->kobj, KOBJ_ADD); 1317 1318 /* Callback for handling stuff after policy is ready */ 1319 if (cpufreq_driver->ready) 1320 cpufreq_driver->ready(policy); 1321 1322 pr_debug("initialization complete\n"); 1323 1324 return 0; 1325 |
1329out_exit_policy: | 1326out_destroy_policy: 1327 for_each_cpu(j, policy->real_cpus) 1328 remove_cpu_dev_symlink(policy, get_cpu_device(j)); 1329 |
1330 up_write(&policy->rwsem); 1331 | 1330 up_write(&policy->rwsem); 1331 |
1332out_exit_policy: |
|
1332 if (cpufreq_driver->exit) 1333 cpufreq_driver->exit(policy); 1334 | 1333 if (cpufreq_driver->exit) 1334 cpufreq_driver->exit(policy); 1335 |
1335 for_each_cpu(j, policy->real_cpus) 1336 remove_cpu_dev_symlink(policy, get_cpu_device(j)); 1337 | |
1338out_free_policy: 1339 cpufreq_policy_free(policy); 1340 return ret; 1341} 1342 1343/** 1344 * cpufreq_add_dev - the cpufreq interface for a CPU device. 1345 * @dev: CPU device. --- 1267 unchanged lines hidden --- | 1336out_free_policy: 1337 cpufreq_policy_free(policy); 1338 return ret; 1339} 1340 1341/** 1342 * cpufreq_add_dev - the cpufreq interface for a CPU device. 1343 * @dev: CPU device. --- 1267 unchanged lines hidden --- |