aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/thermal/cpu_cooling.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index e3fbc5a5d88f..6ceac4f2d4b2 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -377,26 +377,28 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_device,
377 * get_load() - get load for a cpu since last updated 377 * get_load() - get load for a cpu since last updated
378 * @cpufreq_device: &struct cpufreq_cooling_device for this cpu 378 * @cpufreq_device: &struct cpufreq_cooling_device for this cpu
379 * @cpu: cpu number 379 * @cpu: cpu number
380 * @cpu_idx: index of the cpu in cpufreq_device->allowed_cpus
380 * 381 *
381 * Return: The average load of cpu @cpu in percentage since this 382 * Return: The average load of cpu @cpu in percentage since this
382 * function was last called. 383 * function was last called.
383 */ 384 */
384static u32 get_load(struct cpufreq_cooling_device *cpufreq_device, int cpu) 385static u32 get_load(struct cpufreq_cooling_device *cpufreq_device, int cpu,
386 int cpu_idx)
385{ 387{
386 u32 load; 388 u32 load;
387 u64 now, now_idle, delta_time, delta_idle; 389 u64 now, now_idle, delta_time, delta_idle;
388 390
389 now_idle = get_cpu_idle_time(cpu, &now, 0); 391 now_idle = get_cpu_idle_time(cpu, &now, 0);
390 delta_idle = now_idle - cpufreq_device->time_in_idle[cpu]; 392 delta_idle = now_idle - cpufreq_device->time_in_idle[cpu_idx];
391 delta_time = now - cpufreq_device->time_in_idle_timestamp[cpu]; 393 delta_time = now - cpufreq_device->time_in_idle_timestamp[cpu_idx];
392 394
393 if (delta_time <= delta_idle) 395 if (delta_time <= delta_idle)
394 load = 0; 396 load = 0;
395 else 397 else
396 load = div64_u64(100 * (delta_time - delta_idle), delta_time); 398 load = div64_u64(100 * (delta_time - delta_idle), delta_time);
397 399
398 cpufreq_device->time_in_idle[cpu] = now_idle; 400 cpufreq_device->time_in_idle[cpu_idx] = now_idle;
399 cpufreq_device->time_in_idle_timestamp[cpu] = now; 401 cpufreq_device->time_in_idle_timestamp[cpu_idx] = now;
400 402
401 return load; 403 return load;
402} 404}
@@ -598,7 +600,7 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
598 u32 load; 600 u32 load;
599 601
600 if (cpu_online(cpu)) 602 if (cpu_online(cpu))
601 load = get_load(cpufreq_device, cpu); 603 load = get_load(cpufreq_device, cpu, i);
602 else 604 else
603 load = 0; 605 load = 0;
604 606