summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/arch_topology.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 5728e2fbb765..9e4d2107f4fa 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -95,14 +95,21 @@ subsys_initcall(register_cpu_capacity_sysctl);
95 95
96static u32 capacity_scale; 96static u32 capacity_scale;
97static u32 *raw_capacity; 97static u32 *raw_capacity;
98static bool cap_parsing_failed; 98
99static int __init free_raw_capacity(void)
100{
101 kfree(raw_capacity);
102 raw_capacity = NULL;
103
104 return 0;
105}
99 106
100void topology_normalize_cpu_scale(void) 107void topology_normalize_cpu_scale(void)
101{ 108{
102 u64 capacity; 109 u64 capacity;
103 int cpu; 110 int cpu;
104 111
105 if (!raw_capacity || cap_parsing_failed) 112 if (!raw_capacity)
106 return; 113 return;
107 114
108 pr_debug("cpu_capacity: capacity_scale=%u\n", capacity_scale); 115 pr_debug("cpu_capacity: capacity_scale=%u\n", capacity_scale);
@@ -121,6 +128,7 @@ void topology_normalize_cpu_scale(void)
121 128
122bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) 129bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
123{ 130{
131 static bool cap_parsing_failed;
124 int ret; 132 int ret;
125 u32 cpu_capacity; 133 u32 cpu_capacity;
126 134
@@ -151,7 +159,7 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
151 pr_err("cpu_capacity: partial information: fallback to 1024 for all CPUs\n"); 159 pr_err("cpu_capacity: partial information: fallback to 1024 for all CPUs\n");
152 } 160 }
153 cap_parsing_failed = true; 161 cap_parsing_failed = true;
154 kfree(raw_capacity); 162 free_raw_capacity();
155 } 163 }
156 164
157 return !ret; 165 return !ret;
@@ -171,7 +179,7 @@ init_cpu_capacity_callback(struct notifier_block *nb,
171 struct cpufreq_policy *policy = data; 179 struct cpufreq_policy *policy = data;
172 int cpu; 180 int cpu;
173 181
174 if (cap_parsing_failed || cap_parsing_done) 182 if (!raw_capacity || cap_parsing_done)
175 return 0; 183 return 0;
176 184
177 if (val != CPUFREQ_NOTIFY) 185 if (val != CPUFREQ_NOTIFY)
@@ -191,7 +199,7 @@ init_cpu_capacity_callback(struct notifier_block *nb,
191 199
192 if (cpumask_empty(cpus_to_visit)) { 200 if (cpumask_empty(cpus_to_visit)) {
193 topology_normalize_cpu_scale(); 201 topology_normalize_cpu_scale();
194 kfree(raw_capacity); 202 free_raw_capacity();
195 pr_debug("cpu_capacity: parsing done\n"); 203 pr_debug("cpu_capacity: parsing done\n");
196 cap_parsing_done = true; 204 cap_parsing_done = true;
197 schedule_work(&parsing_done_work); 205 schedule_work(&parsing_done_work);
@@ -233,11 +241,5 @@ static void parsing_done_workfn(struct work_struct *work)
233} 241}
234 242
235#else 243#else
236static int __init free_raw_capacity(void)
237{
238 kfree(raw_capacity);
239
240 return 0;
241}
242core_initcall(free_raw_capacity); 244core_initcall(free_raw_capacity);
243#endif 245#endif