Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpu_cooling: Drop static-power related stuff

No one has used it for the last two and half years (since it was
introduced by commit c36cf0717631 (thermal: cpu_cooling: implement the
power cooling device API), get rid of it.

Acked-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Viresh Kumar and committed by
Rafael J. Wysocki
84fe2cab 3ebb62ff

+16 -103
+12 -94
drivers/thermal/cpu_cooling.c
··· 88 88 * @policy: cpufreq policy. 89 89 * @node: list_head to link all cpufreq_cooling_device together. 90 90 * @idle_time: idle time stats 91 - * @plat_get_static_power: callback to calculate the static power 92 91 * 93 92 * This structure is required for keeping information of each registered 94 93 * cpufreq_cooling_device. ··· 103 104 struct cpufreq_policy *policy; 104 105 struct list_head node; 105 106 struct time_in_idle *idle_time; 106 - get_static_t plat_get_static_power; 107 107 }; 108 108 109 109 static DEFINE_IDA(cpufreq_ida); ··· 317 319 } 318 320 319 321 /** 320 - * get_static_power() - calculate the static power consumed by the cpus 321 - * @cpufreq_cdev: struct &cpufreq_cooling_device for this cpu cdev 322 - * @tz: thermal zone device in which we're operating 323 - * @freq: frequency in KHz 324 - * @power: pointer in which to store the calculated static power 325 - * 326 - * Calculate the static power consumed by the cpus described by 327 - * @cpu_actor running at frequency @freq. This function relies on a 328 - * platform specific function that should have been provided when the 329 - * actor was registered. If it wasn't, the static power is assumed to 330 - * be negligible. The calculated static power is stored in @power. 331 - * 332 - * Return: 0 on success, -E* on failure. 333 - */ 334 - static int get_static_power(struct cpufreq_cooling_device *cpufreq_cdev, 335 - struct thermal_zone_device *tz, unsigned long freq, 336 - u32 *power) 337 - { 338 - struct dev_pm_opp *opp; 339 - unsigned long voltage; 340 - struct cpufreq_policy *policy = cpufreq_cdev->policy; 341 - struct cpumask *cpumask = policy->related_cpus; 342 - unsigned long freq_hz = freq * 1000; 343 - struct device *dev; 344 - 345 - if (!cpufreq_cdev->plat_get_static_power) { 346 - *power = 0; 347 - return 0; 348 - } 349 - 350 - dev = get_cpu_device(policy->cpu); 351 - WARN_ON(!dev); 352 - 353 - opp = dev_pm_opp_find_freq_exact(dev, freq_hz, true); 354 - if (IS_ERR(opp)) { 355 - dev_warn_ratelimited(dev, "Failed to find OPP for frequency %lu: %ld\n", 356 - freq_hz, PTR_ERR(opp)); 357 - return -EINVAL; 358 - } 359 - 360 - voltage = dev_pm_opp_get_voltage(opp); 361 - dev_pm_opp_put(opp); 362 - 363 - if (voltage == 0) { 364 - dev_err_ratelimited(dev, "Failed to get voltage for frequency %lu\n", 365 - freq_hz); 366 - return -EINVAL; 367 - } 368 - 369 - return cpufreq_cdev->plat_get_static_power(cpumask, tz->passive_delay, 370 - voltage, power); 371 - } 372 - 373 - /** 374 322 * get_dynamic_power() - calculate the dynamic power 375 323 * @cpufreq_cdev: &cpufreq_cooling_device for this cdev 376 324 * @freq: current frequency ··· 435 491 u32 *power) 436 492 { 437 493 unsigned long freq; 438 - int i = 0, cpu, ret; 439 - u32 static_power, dynamic_power, total_load = 0; 494 + int i = 0, cpu; 495 + u32 total_load = 0; 440 496 struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; 441 497 struct cpufreq_policy *policy = cpufreq_cdev->policy; 442 498 u32 *load_cpu = NULL; ··· 466 522 467 523 cpufreq_cdev->last_load = total_load; 468 524 469 - dynamic_power = get_dynamic_power(cpufreq_cdev, freq); 470 - ret = get_static_power(cpufreq_cdev, tz, freq, &static_power); 471 - if (ret) { 472 - kfree(load_cpu); 473 - return ret; 474 - } 525 + *power = get_dynamic_power(cpufreq_cdev, freq); 475 526 476 527 if (load_cpu) { 477 528 trace_thermal_power_cpu_get_power(policy->related_cpus, freq, 478 - load_cpu, i, dynamic_power, 479 - static_power); 529 + load_cpu, i, *power); 480 530 481 531 kfree(load_cpu); 482 532 } 483 533 484 - *power = static_power + dynamic_power; 485 534 return 0; 486 535 } 487 536 ··· 498 561 unsigned long state, u32 *power) 499 562 { 500 563 unsigned int freq, num_cpus; 501 - u32 static_power, dynamic_power; 502 - int ret; 503 564 struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; 504 565 505 566 /* Request state should be less than max_level */ ··· 507 572 num_cpus = cpumask_weight(cpufreq_cdev->policy->cpus); 508 573 509 574 freq = cpufreq_cdev->freq_table[state].frequency; 510 - dynamic_power = cpu_freq_to_power(cpufreq_cdev, freq) * num_cpus; 511 - ret = get_static_power(cpufreq_cdev, tz, freq, &static_power); 512 - if (ret) 513 - return ret; 575 + *power = cpu_freq_to_power(cpufreq_cdev, freq) * num_cpus; 514 576 515 - *power = static_power + dynamic_power; 516 - return ret; 577 + return 0; 517 578 } 518 579 519 580 /** ··· 537 606 unsigned long *state) 538 607 { 539 608 unsigned int cur_freq, target_freq; 540 - int ret; 541 - s32 dyn_power; 542 - u32 last_load, normalised_power, static_power; 609 + u32 last_load, normalised_power; 543 610 struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; 544 611 struct cpufreq_policy *policy = cpufreq_cdev->policy; 545 612 546 613 cur_freq = cpufreq_quick_get(policy->cpu); 547 - ret = get_static_power(cpufreq_cdev, tz, cur_freq, &static_power); 548 - if (ret) 549 - return ret; 550 - 551 - dyn_power = power - static_power; 552 - dyn_power = dyn_power > 0 ? dyn_power : 0; 614 + power = power > 0 ? power : 0; 553 615 last_load = cpufreq_cdev->last_load ?: 1; 554 - normalised_power = (dyn_power * 100) / last_load; 616 + normalised_power = (power * 100) / last_load; 555 617 target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power); 556 618 557 619 *state = get_level(cpufreq_cdev, target_freq); ··· 595 671 * @policy: cpufreq policy 596 672 * Normally this should be same as cpufreq policy->related_cpus. 597 673 * @capacitance: dynamic power coefficient for these cpus 598 - * @plat_static_func: function to calculate the static power consumed by these 599 - * cpus (optional) 600 674 * 601 675 * This interface function registers the cpufreq cooling device with the name 602 676 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq ··· 606 684 */ 607 685 static struct thermal_cooling_device * 608 686 __cpufreq_cooling_register(struct device_node *np, 609 - struct cpufreq_policy *policy, u32 capacitance, 610 - get_static_t plat_static_func) 687 + struct cpufreq_policy *policy, u32 capacitance) 611 688 { 612 689 struct thermal_cooling_device *cdev; 613 690 struct cpufreq_cooling_device *cpufreq_cdev; ··· 676 755 } 677 756 678 757 if (capacitance) { 679 - cpufreq_cdev->plat_get_static_power = plat_static_func; 680 - 681 758 ret = update_freq_table(cpufreq_cdev, capacitance); 682 759 if (ret) { 683 760 cdev = ERR_PTR(ret); ··· 732 813 struct thermal_cooling_device * 733 814 cpufreq_cooling_register(struct cpufreq_policy *policy) 734 815 { 735 - return __cpufreq_cooling_register(NULL, policy, 0, NULL); 816 + return __cpufreq_cooling_register(NULL, policy, 0); 736 817 } 737 818 EXPORT_SYMBOL_GPL(cpufreq_cooling_register); 738 819 ··· 772 853 of_property_read_u32(np, "dynamic-power-coefficient", 773 854 &capacitance); 774 855 775 - cdev = __cpufreq_cooling_register(np, policy, capacitance, 776 - NULL); 856 + cdev = __cpufreq_cooling_register(np, policy, capacitance); 777 857 if (IS_ERR(cdev)) { 778 858 pr_err("cpu_cooling: cpu%d is not running as cooling device: %ld\n", 779 859 policy->cpu, PTR_ERR(cdev));
-3
include/linux/cpu_cooling.h
··· 30 30 31 31 struct cpufreq_policy; 32 32 33 - typedef int (*get_static_t)(cpumask_t *cpumask, int interval, 34 - unsigned long voltage, u32 *power); 35 - 36 33 #ifdef CONFIG_CPU_THERMAL 37 34 /** 38 35 * cpufreq_cooling_register - function to create cpufreq cooling device.
+4 -6
include/trace/events/thermal.h
··· 94 94 #ifdef CONFIG_CPU_THERMAL 95 95 TRACE_EVENT(thermal_power_cpu_get_power, 96 96 TP_PROTO(const struct cpumask *cpus, unsigned long freq, u32 *load, 97 - size_t load_len, u32 dynamic_power, u32 static_power), 97 + size_t load_len, u32 dynamic_power), 98 98 99 - TP_ARGS(cpus, freq, load, load_len, dynamic_power, static_power), 99 + TP_ARGS(cpus, freq, load, load_len, dynamic_power), 100 100 101 101 TP_STRUCT__entry( 102 102 __bitmask(cpumask, num_possible_cpus()) ··· 104 104 __dynamic_array(u32, load, load_len) 105 105 __field(size_t, load_len ) 106 106 __field(u32, dynamic_power ) 107 - __field(u32, static_power ) 108 107 ), 109 108 110 109 TP_fast_assign( ··· 114 115 load_len * sizeof(*load)); 115 116 __entry->load_len = load_len; 116 117 __entry->dynamic_power = dynamic_power; 117 - __entry->static_power = static_power; 118 118 ), 119 119 120 - TP_printk("cpus=%s freq=%lu load={%s} dynamic_power=%d static_power=%d", 120 + TP_printk("cpus=%s freq=%lu load={%s} dynamic_power=%d", 121 121 __get_bitmask(cpumask), __entry->freq, 122 122 __print_array(__get_dynamic_array(load), __entry->load_len, 4), 123 - __entry->dynamic_power, __entry->static_power) 123 + __entry->dynamic_power) 124 124 ); 125 125 126 126 TRACE_EVENT(thermal_power_cpu_limit,