diff options
| -rw-r--r-- | drivers/cpufreq/cpufreq.c | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index cb003a6b72c8..cf485d928903 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
| @@ -1109,6 +1109,21 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
| 1109 | goto err_set_policy_cpu; | 1109 | goto err_set_policy_cpu; |
| 1110 | } | 1110 | } |
| 1111 | 1111 | ||
| 1112 | /* related cpus should atleast have policy->cpus */ | ||
| 1113 | cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus); | ||
| 1114 | |||
| 1115 | /* | ||
| 1116 | * affected cpus must always be the one, which are online. We aren't | ||
| 1117 | * managing offline cpus here. | ||
| 1118 | */ | ||
| 1119 | cpumask_and(policy->cpus, policy->cpus, cpu_online_mask); | ||
| 1120 | |||
| 1121 | if (!frozen) { | ||
| 1122 | policy->user_policy.min = policy->min; | ||
| 1123 | policy->user_policy.max = policy->max; | ||
| 1124 | } | ||
| 1125 | |||
| 1126 | down_write(&policy->rwsem); | ||
| 1112 | write_lock_irqsave(&cpufreq_driver_lock, flags); | 1127 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
| 1113 | for_each_cpu(j, policy->cpus) | 1128 | for_each_cpu(j, policy->cpus) |
| 1114 | per_cpu(cpufreq_cpu_data, j) = policy; | 1129 | per_cpu(cpufreq_cpu_data, j) = policy; |
| @@ -1162,20 +1177,6 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
| 1162 | } | 1177 | } |
| 1163 | } | 1178 | } |
| 1164 | 1179 | ||
| 1165 | /* related cpus should atleast have policy->cpus */ | ||
| 1166 | cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus); | ||
| 1167 | |||
| 1168 | /* | ||
| 1169 | * affected cpus must always be the one, which are online. We aren't | ||
| 1170 | * managing offline cpus here. | ||
| 1171 | */ | ||
| 1172 | cpumask_and(policy->cpus, policy->cpus, cpu_online_mask); | ||
| 1173 | |||
| 1174 | if (!frozen) { | ||
| 1175 | policy->user_policy.min = policy->min; | ||
| 1176 | policy->user_policy.max = policy->max; | ||
| 1177 | } | ||
| 1178 | |||
| 1179 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 1180 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
| 1180 | CPUFREQ_START, policy); | 1181 | CPUFREQ_START, policy); |
| 1181 | 1182 | ||
| @@ -1206,6 +1207,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
| 1206 | policy->user_policy.policy = policy->policy; | 1207 | policy->user_policy.policy = policy->policy; |
| 1207 | policy->user_policy.governor = policy->governor; | 1208 | policy->user_policy.governor = policy->governor; |
| 1208 | } | 1209 | } |
| 1210 | up_write(&policy->rwsem); | ||
| 1209 | 1211 | ||
| 1210 | kobject_uevent(&policy->kobj, KOBJ_ADD); | 1212 | kobject_uevent(&policy->kobj, KOBJ_ADD); |
| 1211 | up_read(&cpufreq_rwsem); | 1213 | up_read(&cpufreq_rwsem); |
| @@ -1546,23 +1548,16 @@ static unsigned int __cpufreq_get(unsigned int cpu) | |||
| 1546 | */ | 1548 | */ |
| 1547 | unsigned int cpufreq_get(unsigned int cpu) | 1549 | unsigned int cpufreq_get(unsigned int cpu) |
| 1548 | { | 1550 | { |
| 1549 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); | 1551 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); |
| 1550 | unsigned int ret_freq = 0; | 1552 | unsigned int ret_freq = 0; |
| 1551 | 1553 | ||
| 1552 | if (cpufreq_disabled() || !cpufreq_driver) | 1554 | if (policy) { |
| 1553 | return -ENOENT; | 1555 | down_read(&policy->rwsem); |
| 1554 | 1556 | ret_freq = __cpufreq_get(cpu); | |
| 1555 | BUG_ON(!policy); | 1557 | up_read(&policy->rwsem); |
| 1556 | |||
| 1557 | if (!down_read_trylock(&cpufreq_rwsem)) | ||
| 1558 | return 0; | ||
| 1559 | |||
| 1560 | down_read(&policy->rwsem); | ||
| 1561 | |||
| 1562 | ret_freq = __cpufreq_get(cpu); | ||
| 1563 | 1558 | ||
| 1564 | up_read(&policy->rwsem); | 1559 | cpufreq_cpu_put(policy); |
| 1565 | up_read(&cpufreq_rwsem); | 1560 | } |
| 1566 | 1561 | ||
| 1567 | return ret_freq; | 1562 | return ret_freq; |
| 1568 | } | 1563 | } |
