Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 1 | CPU cooling APIs How To |
| 2 | =================================== |
| 3 | |
| 4 | Written by Amit Daniel Kachhap <amit.kachhap@linaro.org> |
| 5 | |
Javi Merino | 9477e18 | 2015-01-06 18:14:25 +0000 | [diff] [blame] | 6 | Updated: 6 Jan 2015 |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 7 | |
| 8 | Copyright (c) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com) |
| 9 | |
| 10 | 0. Introduction |
| 11 | |
| 12 | The generic cpu cooling(freq clipping) provides registration/unregistration APIs |
| 13 | to the caller. The binding of the cooling devices to the trip point is left for |
| 14 | the user. The registration APIs returns the cooling device pointer. |
| 15 | |
| 16 | 1. cpu cooling APIs |
| 17 | |
| 18 | 1.1 cpufreq registration/unregistration APIs |
| 19 | 1.1.1 struct thermal_cooling_device *cpufreq_cooling_register( |
| 20 | struct cpumask *clip_cpus) |
| 21 | |
| 22 | This interface function registers the cpufreq cooling device with the name |
| 23 | "thermal-cpufreq-%x". This api can support multiple instances of cpufreq |
| 24 | cooling devices. |
| 25 | |
| 26 | clip_cpus: cpumask of cpus where the frequency constraints will happen. |
| 27 | |
Javi Merino | 9477e18 | 2015-01-06 18:14:25 +0000 | [diff] [blame] | 28 | 1.1.2 struct thermal_cooling_device *of_cpufreq_cooling_register( |
Viresh Kumar | 3ebb62f | 2017-12-05 11:02:45 +0530 | [diff] [blame] | 29 | struct cpufreq_policy *policy) |
Javi Merino | 9477e18 | 2015-01-06 18:14:25 +0000 | [diff] [blame] | 30 | |
| 31 | This interface function registers the cpufreq cooling device with |
| 32 | the name "thermal-cpufreq-%x" linking it with a device tree node, in |
| 33 | order to bind it via the thermal DT code. This api can support multiple |
| 34 | instances of cpufreq cooling devices. |
| 35 | |
Viresh Kumar | 3ebb62f | 2017-12-05 11:02:45 +0530 | [diff] [blame] | 36 | policy: CPUFreq policy. |
Javi Merino | 9477e18 | 2015-01-06 18:14:25 +0000 | [diff] [blame] | 37 | |
Viresh Kumar | 3ebb62f | 2017-12-05 11:02:45 +0530 | [diff] [blame] | 38 | 1.1.3 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 39 | |
| 40 | This interface function unregisters the "thermal-cpufreq-%x" cooling device. |
| 41 | |
| 42 | cdev: Cooling device pointer which has to be unregistered. |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 43 | |
| 44 | 2. Power models |
| 45 | |
| 46 | The power API registration functions provide a simple power model for |
Viresh Kumar | ac89c40 | 2018-01-02 10:51:34 +0530 | [diff] [blame] | 47 | CPUs. The current power is calculated as dynamic power (static power isn't |
| 48 | supported currently). This power model requires that the operating-points of |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 49 | the CPUs are registered using the kernel's opp library and the |
| 50 | `cpufreq_frequency_table` is assigned to the `struct device` of the |
| 51 | cpu. If you are using CONFIG_CPUFREQ_DT then the |
| 52 | `cpufreq_frequency_table` should already be assigned to the cpu |
| 53 | device. |
| 54 | |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 55 | The dynamic power consumption of a processor depends on many factors. |
| 56 | For a given processor implementation the primary factors are: |
| 57 | |
| 58 | - The time the processor spends running, consuming dynamic power, as |
| 59 | compared to the time in idle states where dynamic consumption is |
| 60 | negligible. Herein we refer to this as 'utilisation'. |
| 61 | - The voltage and frequency levels as a result of DVFS. The DVFS |
| 62 | level is a dominant factor governing power consumption. |
| 63 | - In running time the 'execution' behaviour (instruction types, memory |
| 64 | access patterns and so forth) causes, in most cases, a second order |
| 65 | variation. In pathological cases this variation can be significant, |
| 66 | but typically it is of a much lesser impact than the factors above. |
| 67 | |
| 68 | A high level dynamic power consumption model may then be represented as: |
| 69 | |
| 70 | Pdyn = f(run) * Voltage^2 * Frequency * Utilisation |
| 71 | |
| 72 | f(run) here represents the described execution behaviour and its |
| 73 | result has a units of Watts/Hz/Volt^2 (this often expressed in |
| 74 | mW/MHz/uVolt^2) |
| 75 | |
| 76 | The detailed behaviour for f(run) could be modelled on-line. However, |
| 77 | in practice, such an on-line model has dependencies on a number of |
| 78 | implementation specific processor support and characterisation |
| 79 | factors. Therefore, in initial implementation that contribution is |
| 80 | represented as a constant coefficient. This is a simplification |
| 81 | consistent with the relative contribution to overall power variation. |
| 82 | |
| 83 | In this simplified representation our model becomes: |
| 84 | |
| 85 | Pdyn = Capacitance * Voltage^2 * Frequency * Utilisation |
| 86 | |
| 87 | Where `capacitance` is a constant that represents an indicative |
| 88 | running time dynamic power coefficient in fundamental units of |
| 89 | mW/MHz/uVolt^2. Typical values for mobile CPUs might lie in range |
| 90 | from 100 to 500. For reference, the approximate values for the SoC in |
| 91 | ARM's Juno Development Platform are 530 for the Cortex-A57 cluster and |
| 92 | 140 for the Cortex-A53 cluster. |