diff options
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/at32ap-cpufreq.c | 2 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 104 | ||||
-rw-r--r-- | drivers/cpufreq/exynos4210-cpufreq.c | 1 | ||||
-rw-r--r-- | drivers/cpufreq/exynos4x12-cpufreq.c | 1 | ||||
-rw-r--r-- | drivers/cpufreq/exynos5250-cpufreq.c | 1 | ||||
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 8 | ||||
-rw-r--r-- | drivers/cpufreq/tegra-cpufreq.c | 4 |
7 files changed, 68 insertions, 53 deletions
diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c index 856ad80418ae..7c03dd84f66a 100644 --- a/drivers/cpufreq/at32ap-cpufreq.c +++ b/drivers/cpufreq/at32ap-cpufreq.c | |||
@@ -58,7 +58,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index) | |||
58 | return 0; | 58 | return 0; |
59 | } | 59 | } |
60 | 60 | ||
61 | static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy) | 61 | static int at32_cpufreq_driver_init(struct cpufreq_policy *policy) |
62 | { | 62 | { |
63 | unsigned int frequency, rate, min_freq; | 63 | unsigned int frequency, rate, min_freq; |
64 | int retval, steps, i; | 64 | int retval, steps, i; |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 02d534da22dd..8d19f7c06010 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -828,14 +828,17 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy) | |||
828 | int ret = 0; | 828 | int ret = 0; |
829 | 829 | ||
830 | memcpy(&new_policy, policy, sizeof(*policy)); | 830 | memcpy(&new_policy, policy, sizeof(*policy)); |
831 | |||
832 | /* Use the default policy if its valid. */ | ||
833 | if (cpufreq_driver->setpolicy) | ||
834 | cpufreq_parse_governor(policy->governor->name, | ||
835 | &new_policy.policy, NULL); | ||
836 | |||
831 | /* assure that the starting sequence is run in cpufreq_set_policy */ | 837 | /* assure that the starting sequence is run in cpufreq_set_policy */ |
832 | policy->governor = NULL; | 838 | policy->governor = NULL; |
833 | 839 | ||
834 | /* set default policy */ | 840 | /* set default policy */ |
835 | ret = cpufreq_set_policy(policy, &new_policy); | 841 | ret = cpufreq_set_policy(policy, &new_policy); |
836 | policy->user_policy.policy = policy->policy; | ||
837 | policy->user_policy.governor = policy->governor; | ||
838 | |||
839 | if (ret) { | 842 | if (ret) { |
840 | pr_debug("setting policy failed\n"); | 843 | pr_debug("setting policy failed\n"); |
841 | if (cpufreq_driver->exit) | 844 | if (cpufreq_driver->exit) |
@@ -845,8 +848,7 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy) | |||
845 | 848 | ||
846 | #ifdef CONFIG_HOTPLUG_CPU | 849 | #ifdef CONFIG_HOTPLUG_CPU |
847 | static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, | 850 | static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, |
848 | unsigned int cpu, struct device *dev, | 851 | unsigned int cpu, struct device *dev) |
849 | bool frozen) | ||
850 | { | 852 | { |
851 | int ret = 0; | 853 | int ret = 0; |
852 | unsigned long flags; | 854 | unsigned long flags; |
@@ -877,11 +879,7 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, | |||
877 | } | 879 | } |
878 | } | 880 | } |
879 | 881 | ||
880 | /* Don't touch sysfs links during light-weight init */ | 882 | return sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); |
881 | if (!frozen) | ||
882 | ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); | ||
883 | |||
884 | return ret; | ||
885 | } | 883 | } |
886 | #endif | 884 | #endif |
887 | 885 | ||
@@ -926,6 +924,27 @@ err_free_policy: | |||
926 | return NULL; | 924 | return NULL; |
927 | } | 925 | } |
928 | 926 | ||
927 | static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy) | ||
928 | { | ||
929 | struct kobject *kobj; | ||
930 | struct completion *cmp; | ||
931 | |||
932 | down_read(&policy->rwsem); | ||
933 | kobj = &policy->kobj; | ||
934 | cmp = &policy->kobj_unregister; | ||
935 | up_read(&policy->rwsem); | ||
936 | kobject_put(kobj); | ||
937 | |||
938 | /* | ||
939 | * We need to make sure that the underlying kobj is | ||
940 | * actually not referenced anymore by anybody before we | ||
941 | * proceed with unloading. | ||
942 | */ | ||
943 | pr_debug("waiting for dropping of refcount\n"); | ||
944 | wait_for_completion(cmp); | ||
945 | pr_debug("wait complete\n"); | ||
946 | } | ||
947 | |||
929 | static void cpufreq_policy_free(struct cpufreq_policy *policy) | 948 | static void cpufreq_policy_free(struct cpufreq_policy *policy) |
930 | { | 949 | { |
931 | free_cpumask_var(policy->related_cpus); | 950 | free_cpumask_var(policy->related_cpus); |
@@ -986,7 +1005,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
986 | list_for_each_entry(tpolicy, &cpufreq_policy_list, policy_list) { | 1005 | list_for_each_entry(tpolicy, &cpufreq_policy_list, policy_list) { |
987 | if (cpumask_test_cpu(cpu, tpolicy->related_cpus)) { | 1006 | if (cpumask_test_cpu(cpu, tpolicy->related_cpus)) { |
988 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1007 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
989 | ret = cpufreq_add_policy_cpu(tpolicy, cpu, dev, frozen); | 1008 | ret = cpufreq_add_policy_cpu(tpolicy, cpu, dev); |
990 | up_read(&cpufreq_rwsem); | 1009 | up_read(&cpufreq_rwsem); |
991 | return ret; | 1010 | return ret; |
992 | } | 1011 | } |
@@ -994,15 +1013,17 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
994 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1013 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
995 | #endif | 1014 | #endif |
996 | 1015 | ||
997 | if (frozen) | 1016 | /* |
998 | /* Restore the saved policy when doing light-weight init */ | 1017 | * Restore the saved policy when doing light-weight init and fall back |
999 | policy = cpufreq_policy_restore(cpu); | 1018 | * to the full init if that fails. |
1000 | else | 1019 | */ |
1020 | policy = frozen ? cpufreq_policy_restore(cpu) : NULL; | ||
1021 | if (!policy) { | ||
1022 | frozen = false; | ||
1001 | policy = cpufreq_policy_alloc(); | 1023 | policy = cpufreq_policy_alloc(); |
1002 | 1024 | if (!policy) | |
1003 | if (!policy) | 1025 | goto nomem_out; |
1004 | goto nomem_out; | 1026 | } |
1005 | |||
1006 | 1027 | ||
1007 | /* | 1028 | /* |
1008 | * In the resume path, since we restore a saved policy, the assignment | 1029 | * In the resume path, since we restore a saved policy, the assignment |
@@ -1047,8 +1068,10 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
1047 | */ | 1068 | */ |
1048 | cpumask_and(policy->cpus, policy->cpus, cpu_online_mask); | 1069 | cpumask_and(policy->cpus, policy->cpus, cpu_online_mask); |
1049 | 1070 | ||
1050 | policy->user_policy.min = policy->min; | 1071 | if (!frozen) { |
1051 | policy->user_policy.max = policy->max; | 1072 | policy->user_policy.min = policy->min; |
1073 | policy->user_policy.max = policy->max; | ||
1074 | } | ||
1052 | 1075 | ||
1053 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 1076 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1054 | CPUFREQ_START, policy); | 1077 | CPUFREQ_START, policy); |
@@ -1079,6 +1102,11 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
1079 | 1102 | ||
1080 | cpufreq_init_policy(policy); | 1103 | cpufreq_init_policy(policy); |
1081 | 1104 | ||
1105 | if (!frozen) { | ||
1106 | policy->user_policy.policy = policy->policy; | ||
1107 | policy->user_policy.governor = policy->governor; | ||
1108 | } | ||
1109 | |||
1082 | kobject_uevent(&policy->kobj, KOBJ_ADD); | 1110 | kobject_uevent(&policy->kobj, KOBJ_ADD); |
1083 | up_read(&cpufreq_rwsem); | 1111 | up_read(&cpufreq_rwsem); |
1084 | 1112 | ||
@@ -1096,7 +1124,13 @@ err_get_freq: | |||
1096 | if (cpufreq_driver->exit) | 1124 | if (cpufreq_driver->exit) |
1097 | cpufreq_driver->exit(policy); | 1125 | cpufreq_driver->exit(policy); |
1098 | err_set_policy_cpu: | 1126 | err_set_policy_cpu: |
1127 | if (frozen) { | ||
1128 | /* Do not leave stale fallback data behind. */ | ||
1129 | per_cpu(cpufreq_cpu_data_fallback, cpu) = NULL; | ||
1130 | cpufreq_policy_put_kobj(policy); | ||
1131 | } | ||
1099 | cpufreq_policy_free(policy); | 1132 | cpufreq_policy_free(policy); |
1133 | |||
1100 | nomem_out: | 1134 | nomem_out: |
1101 | up_read(&cpufreq_rwsem); | 1135 | up_read(&cpufreq_rwsem); |
1102 | 1136 | ||
@@ -1118,7 +1152,7 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) | |||
1118 | } | 1152 | } |
1119 | 1153 | ||
1120 | static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, | 1154 | static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, |
1121 | unsigned int old_cpu, bool frozen) | 1155 | unsigned int old_cpu) |
1122 | { | 1156 | { |
1123 | struct device *cpu_dev; | 1157 | struct device *cpu_dev; |
1124 | int ret; | 1158 | int ret; |
@@ -1126,10 +1160,6 @@ static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, | |||
1126 | /* first sibling now owns the new sysfs dir */ | 1160 | /* first sibling now owns the new sysfs dir */ |
1127 | cpu_dev = get_cpu_device(cpumask_any_but(policy->cpus, old_cpu)); | 1161 | cpu_dev = get_cpu_device(cpumask_any_but(policy->cpus, old_cpu)); |
1128 | 1162 | ||
1129 | /* Don't touch sysfs files during light-weight tear-down */ | ||
1130 | if (frozen) | ||
1131 | return cpu_dev->id; | ||
1132 | |||
1133 | sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); | 1163 | sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); |
1134 | ret = kobject_move(&policy->kobj, &cpu_dev->kobj); | 1164 | ret = kobject_move(&policy->kobj, &cpu_dev->kobj); |
1135 | if (ret) { | 1165 | if (ret) { |
@@ -1196,7 +1226,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, | |||
1196 | if (!frozen) | 1226 | if (!frozen) |
1197 | sysfs_remove_link(&dev->kobj, "cpufreq"); | 1227 | sysfs_remove_link(&dev->kobj, "cpufreq"); |
1198 | } else if (cpus > 1) { | 1228 | } else if (cpus > 1) { |
1199 | new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen); | 1229 | new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu); |
1200 | if (new_cpu >= 0) { | 1230 | if (new_cpu >= 0) { |
1201 | update_policy_cpu(policy, new_cpu); | 1231 | update_policy_cpu(policy, new_cpu); |
1202 | 1232 | ||
@@ -1218,8 +1248,6 @@ static int __cpufreq_remove_dev_finish(struct device *dev, | |||
1218 | int ret; | 1248 | int ret; |
1219 | unsigned long flags; | 1249 | unsigned long flags; |
1220 | struct cpufreq_policy *policy; | 1250 | struct cpufreq_policy *policy; |
1221 | struct kobject *kobj; | ||
1222 | struct completion *cmp; | ||
1223 | 1251 | ||
1224 | read_lock_irqsave(&cpufreq_driver_lock, flags); | 1252 | read_lock_irqsave(&cpufreq_driver_lock, flags); |
1225 | policy = per_cpu(cpufreq_cpu_data, cpu); | 1253 | policy = per_cpu(cpufreq_cpu_data, cpu); |
@@ -1249,22 +1277,8 @@ static int __cpufreq_remove_dev_finish(struct device *dev, | |||
1249 | } | 1277 | } |
1250 | } | 1278 | } |
1251 | 1279 | ||
1252 | if (!frozen) { | 1280 | if (!frozen) |
1253 | down_read(&policy->rwsem); | 1281 | cpufreq_policy_put_kobj(policy); |
1254 | kobj = &policy->kobj; | ||
1255 | cmp = &policy->kobj_unregister; | ||
1256 | up_read(&policy->rwsem); | ||
1257 | kobject_put(kobj); | ||
1258 | |||
1259 | /* | ||
1260 | * We need to make sure that the underlying kobj is | ||
1261 | * actually not referenced anymore by anybody before we | ||
1262 | * proceed with unloading. | ||
1263 | */ | ||
1264 | pr_debug("waiting for dropping of refcount\n"); | ||
1265 | wait_for_completion(cmp); | ||
1266 | pr_debug("wait complete\n"); | ||
1267 | } | ||
1268 | 1282 | ||
1269 | /* | 1283 | /* |
1270 | * Perform the ->exit() even during light-weight tear-down, | 1284 | * Perform the ->exit() even during light-weight tear-down, |
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c index f2c75065ce19..dfd1643b0b2f 100644 --- a/drivers/cpufreq/exynos4210-cpufreq.c +++ b/drivers/cpufreq/exynos4210-cpufreq.c | |||
@@ -157,4 +157,3 @@ err_moutcore: | |||
157 | pr_debug("%s: failed initialization\n", __func__); | 157 | pr_debug("%s: failed initialization\n", __func__); |
158 | return -EINVAL; | 158 | return -EINVAL; |
159 | } | 159 | } |
160 | EXPORT_SYMBOL(exynos4210_cpufreq_init); | ||
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c index 8683304ce62c..efad5e657f6f 100644 --- a/drivers/cpufreq/exynos4x12-cpufreq.c +++ b/drivers/cpufreq/exynos4x12-cpufreq.c | |||
@@ -211,4 +211,3 @@ err_moutcore: | |||
211 | pr_debug("%s: failed initialization\n", __func__); | 211 | pr_debug("%s: failed initialization\n", __func__); |
212 | return -EINVAL; | 212 | return -EINVAL; |
213 | } | 213 | } |
214 | EXPORT_SYMBOL(exynos4x12_cpufreq_init); | ||
diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c index 9fae466d7746..8feda86fe42c 100644 --- a/drivers/cpufreq/exynos5250-cpufreq.c +++ b/drivers/cpufreq/exynos5250-cpufreq.c | |||
@@ -236,4 +236,3 @@ err_moutcore: | |||
236 | pr_err("%s: failed initialization\n", __func__); | 236 | pr_err("%s: failed initialization\n", __func__); |
237 | return -EINVAL; | 237 | return -EINVAL; |
238 | } | 238 | } |
239 | EXPORT_SYMBOL(exynos5250_cpufreq_init); | ||
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 5f1cbae36961..d51f17ed691e 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -581,7 +581,8 @@ static void intel_pstate_timer_func(unsigned long __data) | |||
581 | } | 581 | } |
582 | 582 | ||
583 | #define ICPU(model, policy) \ | 583 | #define ICPU(model, policy) \ |
584 | { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (unsigned long)&policy } | 584 | { X86_VENDOR_INTEL, 6, model, X86_FEATURE_APERFMPERF,\ |
585 | (unsigned long)&policy } | ||
585 | 586 | ||
586 | static const struct x86_cpu_id intel_pstate_cpu_ids[] = { | 587 | static const struct x86_cpu_id intel_pstate_cpu_ids[] = { |
587 | ICPU(0x2a, core_params), | 588 | ICPU(0x2a, core_params), |
@@ -614,6 +615,11 @@ static int intel_pstate_init_cpu(unsigned int cpunum) | |||
614 | cpu = all_cpu_data[cpunum]; | 615 | cpu = all_cpu_data[cpunum]; |
615 | 616 | ||
616 | intel_pstate_get_cpu_pstates(cpu); | 617 | intel_pstate_get_cpu_pstates(cpu); |
618 | if (!cpu->pstate.current_pstate) { | ||
619 | all_cpu_data[cpunum] = NULL; | ||
620 | kfree(cpu); | ||
621 | return -ENODATA; | ||
622 | } | ||
617 | 623 | ||
618 | cpu->cpu = cpunum; | 624 | cpu->cpu = cpunum; |
619 | 625 | ||
diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c index f42df7ec03c5..b7309c37033d 100644 --- a/drivers/cpufreq/tegra-cpufreq.c +++ b/drivers/cpufreq/tegra-cpufreq.c | |||
@@ -142,10 +142,8 @@ static int tegra_target(struct cpufreq_policy *policy, unsigned int index) | |||
142 | 142 | ||
143 | mutex_lock(&tegra_cpu_lock); | 143 | mutex_lock(&tegra_cpu_lock); |
144 | 144 | ||
145 | if (is_suspended) { | 145 | if (is_suspended) |
146 | ret = -EBUSY; | ||
147 | goto out; | 146 | goto out; |
148 | } | ||
149 | 147 | ||
150 | freq = freq_table[index].frequency; | 148 | freq = freq_table[index].frequency; |
151 | 149 | ||