cpu-cooling-api.rst 3.9 KB

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