diff options
author | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-06-18 17:05:28 -0400 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2019-06-27 09:22:15 -0400 |
commit | 6bbe6f5732faeabb4bb583726ec2d7f9739532bd (patch) | |
tree | 18a6fd0f79ec2f7363376cb88eaec3d4500221b8 | |
parent | 57c5b2ec905933da84fe77b2b54619567ac21297 (diff) |
docs: thermal: convert to ReST
Rename the thermal documentation files to ReST, add an
index for them and adjust in order to produce a nice html
output via the Sphinx build system.
At its new index.rst, let's add a :orphan: while this is not linked to
the main index.rst file, in order to avoid build warnings.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r-- | Documentation/thermal/cpu-cooling-api.rst (renamed from Documentation/thermal/cpu-cooling-api.txt) | 39 | ||||
-rw-r--r-- | Documentation/thermal/exynos_thermal.rst (renamed from Documentation/thermal/exynos_thermal) | 47 | ||||
-rw-r--r-- | Documentation/thermal/exynos_thermal_emulation | 53 | ||||
-rw-r--r-- | Documentation/thermal/exynos_thermal_emulation.rst | 61 | ||||
-rw-r--r-- | Documentation/thermal/index.rst | 18 | ||||
-rw-r--r-- | Documentation/thermal/intel_powerclamp.rst (renamed from Documentation/thermal/intel_powerclamp.txt) | 183 | ||||
-rw-r--r-- | Documentation/thermal/nouveau_thermal.rst (renamed from Documentation/thermal/nouveau_thermal) | 54 | ||||
-rw-r--r-- | Documentation/thermal/power_allocator.rst (renamed from Documentation/thermal/power_allocator.txt) | 144 | ||||
-rw-r--r-- | Documentation/thermal/sysfs-api.rst (renamed from Documentation/thermal/sysfs-api.txt) | 488 | ||||
-rw-r--r-- | Documentation/thermal/x86_pkg_temperature_thermal.rst (renamed from Documentation/thermal/x86_pkg_temperature_thermal) | 28 | ||||
-rw-r--r-- | MAINTAINERS | 2 | ||||
-rw-r--r-- | include/linux/thermal.h | 4 |
12 files changed, 693 insertions, 428 deletions
diff --git a/Documentation/thermal/cpu-cooling-api.txt b/Documentation/thermal/cpu-cooling-api.rst index 7df567eaea1a..645d914c45a6 100644 --- a/Documentation/thermal/cpu-cooling-api.txt +++ b/Documentation/thermal/cpu-cooling-api.rst | |||
@@ -1,5 +1,6 @@ | |||
1 | ======================= | ||
1 | CPU cooling APIs How To | 2 | CPU cooling APIs How To |
2 | =================================== | 3 | ======================= |
3 | 4 | ||
4 | Written by Amit Daniel Kachhap <amit.kachhap@linaro.org> | 5 | Written by Amit Daniel Kachhap <amit.kachhap@linaro.org> |
5 | 6 | ||
@@ -8,40 +9,54 @@ Updated: 6 Jan 2015 | |||
8 | Copyright (c) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com) | 9 | Copyright (c) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com) |
9 | 10 | ||
10 | 0. Introduction | 11 | 0. Introduction |
12 | =============== | ||
11 | 13 | ||
12 | The generic cpu cooling(freq clipping) provides registration/unregistration APIs | 14 | 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 | 15 | 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. | 16 | the user. The registration APIs returns the cooling device pointer. |
15 | 17 | ||
16 | 1. cpu cooling APIs | 18 | 1. cpu cooling APIs |
19 | =================== | ||
17 | 20 | ||
18 | 1.1 cpufreq registration/unregistration APIs | 21 | 1.1 cpufreq registration/unregistration APIs |
19 | 1.1.1 struct thermal_cooling_device *cpufreq_cooling_register( | 22 | -------------------------------------------- |
20 | struct cpumask *clip_cpus) | 23 | |
24 | :: | ||
25 | |||
26 | struct thermal_cooling_device | ||
27 | *cpufreq_cooling_register(struct cpumask *clip_cpus) | ||
21 | 28 | ||
22 | This interface function registers the cpufreq cooling device with the name | 29 | This interface function registers the cpufreq cooling device with the name |
23 | "thermal-cpufreq-%x". This api can support multiple instances of cpufreq | 30 | "thermal-cpufreq-%x". This api can support multiple instances of cpufreq |
24 | cooling devices. | 31 | cooling devices. |
25 | 32 | ||
26 | clip_cpus: cpumask of cpus where the frequency constraints will happen. | 33 | clip_cpus: |
34 | cpumask of cpus where the frequency constraints will happen. | ||
35 | |||
36 | :: | ||
27 | 37 | ||
28 | 1.1.2 struct thermal_cooling_device *of_cpufreq_cooling_register( | 38 | struct thermal_cooling_device |
29 | struct cpufreq_policy *policy) | 39 | *of_cpufreq_cooling_register(struct cpufreq_policy *policy) |
30 | 40 | ||
31 | This interface function registers the cpufreq cooling device with | 41 | This interface function registers the cpufreq cooling device with |
32 | the name "thermal-cpufreq-%x" linking it with a device tree node, in | 42 | 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 | 43 | order to bind it via the thermal DT code. This api can support multiple |
34 | instances of cpufreq cooling devices. | 44 | instances of cpufreq cooling devices. |
35 | 45 | ||
36 | policy: CPUFreq policy. | 46 | policy: |
47 | CPUFreq policy. | ||
48 | |||
49 | |||
50 | :: | ||
37 | 51 | ||
38 | 1.1.3 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) | 52 | void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) |
39 | 53 | ||
40 | This interface function unregisters the "thermal-cpufreq-%x" cooling device. | 54 | This interface function unregisters the "thermal-cpufreq-%x" cooling device. |
41 | 55 | ||
42 | cdev: Cooling device pointer which has to be unregistered. | 56 | cdev: Cooling device pointer which has to be unregistered. |
43 | 57 | ||
44 | 2. Power models | 58 | 2. Power models |
59 | =============== | ||
45 | 60 | ||
46 | The power API registration functions provide a simple power model for | 61 | The power API registration functions provide a simple power model for |
47 | CPUs. The current power is calculated as dynamic power (static power isn't | 62 | CPUs. The current power is calculated as dynamic power (static power isn't |
@@ -65,9 +80,9 @@ For a given processor implementation the primary factors are: | |||
65 | variation. In pathological cases this variation can be significant, | 80 | variation. In pathological cases this variation can be significant, |
66 | but typically it is of a much lesser impact than the factors above. | 81 | but typically it is of a much lesser impact than the factors above. |
67 | 82 | ||
68 | A high level dynamic power consumption model may then be represented as: | 83 | A high level dynamic power consumption model may then be represented as:: |
69 | 84 | ||
70 | Pdyn = f(run) * Voltage^2 * Frequency * Utilisation | 85 | Pdyn = f(run) * Voltage^2 * Frequency * Utilisation |
71 | 86 | ||
72 | f(run) here represents the described execution behaviour and its | 87 | f(run) here represents the described execution behaviour and its |
73 | result has a units of Watts/Hz/Volt^2 (this often expressed in | 88 | result has a units of Watts/Hz/Volt^2 (this often expressed in |
@@ -80,9 +95,9 @@ factors. Therefore, in initial implementation that contribution is | |||
80 | represented as a constant coefficient. This is a simplification | 95 | represented as a constant coefficient. This is a simplification |
81 | consistent with the relative contribution to overall power variation. | 96 | consistent with the relative contribution to overall power variation. |
82 | 97 | ||
83 | In this simplified representation our model becomes: | 98 | In this simplified representation our model becomes:: |
84 | 99 | ||
85 | Pdyn = Capacitance * Voltage^2 * Frequency * Utilisation | 100 | Pdyn = Capacitance * Voltage^2 * Frequency * Utilisation |
86 | 101 | ||
87 | Where `capacitance` is a constant that represents an indicative | 102 | Where `capacitance` is a constant that represents an indicative |
88 | running time dynamic power coefficient in fundamental units of | 103 | running time dynamic power coefficient in fundamental units of |
diff --git a/Documentation/thermal/exynos_thermal b/Documentation/thermal/exynos_thermal.rst index 9010c4416967..5bd556566c70 100644 --- a/Documentation/thermal/exynos_thermal +++ b/Documentation/thermal/exynos_thermal.rst | |||
@@ -1,8 +1,11 @@ | |||
1 | ======================== | ||
1 | Kernel driver exynos_tmu | 2 | Kernel driver exynos_tmu |
2 | ================= | 3 | ======================== |
3 | 4 | ||
4 | Supported chips: | 5 | Supported chips: |
6 | |||
5 | * ARM SAMSUNG EXYNOS4, EXYNOS5 series of SoC | 7 | * ARM SAMSUNG EXYNOS4, EXYNOS5 series of SoC |
8 | |||
6 | Datasheet: Not publicly available | 9 | Datasheet: Not publicly available |
7 | 10 | ||
8 | Authors: Donggeun Kim <dg77.kim@samsung.com> | 11 | Authors: Donggeun Kim <dg77.kim@samsung.com> |
@@ -19,32 +22,39 @@ Temperature can be taken from the temperature code. | |||
19 | There are three equations converting from temperature to temperature code. | 22 | There are three equations converting from temperature to temperature code. |
20 | 23 | ||
21 | The three equations are: | 24 | The three equations are: |
22 | 1. Two point trimming | 25 | 1. Two point trimming:: |
26 | |||
23 | Tc = (T - 25) * (TI2 - TI1) / (85 - 25) + TI1 | 27 | Tc = (T - 25) * (TI2 - TI1) / (85 - 25) + TI1 |
24 | 28 | ||
25 | 2. One point trimming | 29 | 2. One point trimming:: |
30 | |||
26 | Tc = T + TI1 - 25 | 31 | Tc = T + TI1 - 25 |
27 | 32 | ||
28 | 3. No trimming | 33 | 3. No trimming:: |
34 | |||
29 | Tc = T + 50 | 35 | Tc = T + 50 |
30 | 36 | ||
31 | Tc: Temperature code, T: Temperature, | 37 | Tc: |
32 | TI1: Trimming info for 25 degree Celsius (stored at TRIMINFO register) | 38 | Temperature code, T: Temperature, |
39 | TI1: | ||
40 | Trimming info for 25 degree Celsius (stored at TRIMINFO register) | ||
33 | Temperature code measured at 25 degree Celsius which is unchanged | 41 | Temperature code measured at 25 degree Celsius which is unchanged |
34 | TI2: Trimming info for 85 degree Celsius (stored at TRIMINFO register) | 42 | TI2: |
43 | Trimming info for 85 degree Celsius (stored at TRIMINFO register) | ||
35 | Temperature code measured at 85 degree Celsius which is unchanged | 44 | Temperature code measured at 85 degree Celsius which is unchanged |
36 | 45 | ||
37 | TMU(Thermal Management Unit) in EXYNOS4/5 generates interrupt | 46 | TMU(Thermal Management Unit) in EXYNOS4/5 generates interrupt |
38 | when temperature exceeds pre-defined levels. | 47 | when temperature exceeds pre-defined levels. |
39 | The maximum number of configurable threshold is five. | 48 | The maximum number of configurable threshold is five. |
40 | The threshold levels are defined as follows: | 49 | The threshold levels are defined as follows:: |
50 | |||
41 | Level_0: current temperature > trigger_level_0 + threshold | 51 | Level_0: current temperature > trigger_level_0 + threshold |
42 | Level_1: current temperature > trigger_level_1 + threshold | 52 | Level_1: current temperature > trigger_level_1 + threshold |
43 | Level_2: current temperature > trigger_level_2 + threshold | 53 | Level_2: current temperature > trigger_level_2 + threshold |
44 | Level_3: current temperature > trigger_level_3 + threshold | 54 | Level_3: current temperature > trigger_level_3 + threshold |
45 | 55 | ||
46 | The threshold and each trigger_level are set | 56 | The threshold and each trigger_level are set |
47 | through the corresponding registers. | 57 | through the corresponding registers. |
48 | 58 | ||
49 | When an interrupt occurs, this driver notify kernel thermal framework | 59 | When an interrupt occurs, this driver notify kernel thermal framework |
50 | with the function exynos_report_trigger. | 60 | with the function exynos_report_trigger. |
@@ -54,24 +64,27 @@ it can be used to synchronize the cooling action. | |||
54 | TMU driver description: | 64 | TMU driver description: |
55 | ----------------------- | 65 | ----------------------- |
56 | 66 | ||
57 | The exynos thermal driver is structured as, | 67 | The exynos thermal driver is structured as:: |
58 | 68 | ||
59 | Kernel Core thermal framework | 69 | Kernel Core thermal framework |
60 | (thermal_core.c, step_wise.c, cpu_cooling.c) | 70 | (thermal_core.c, step_wise.c, cpu_cooling.c) |
61 | ^ | 71 | ^ |
62 | | | 72 | | |
63 | | | 73 | | |
64 | TMU configuration data -------> TMU Driver <------> Exynos Core thermal wrapper | 74 | TMU configuration data -----> TMU Driver <----> Exynos Core thermal wrapper |
65 | (exynos_tmu_data.c) (exynos_tmu.c) (exynos_thermal_common.c) | 75 | (exynos_tmu_data.c) (exynos_tmu.c) (exynos_thermal_common.c) |
66 | (exynos_tmu_data.h) (exynos_tmu.h) (exynos_thermal_common.h) | 76 | (exynos_tmu_data.h) (exynos_tmu.h) (exynos_thermal_common.h) |
67 | 77 | ||
68 | a) TMU configuration data: This consist of TMU register offsets/bitfields | 78 | a) TMU configuration data: |
79 | This consist of TMU register offsets/bitfields | ||
69 | described through structure exynos_tmu_registers. Also several | 80 | described through structure exynos_tmu_registers. Also several |
70 | other platform data (struct exynos_tmu_platform_data) members | 81 | other platform data (struct exynos_tmu_platform_data) members |
71 | are used to configure the TMU. | 82 | are used to configure the TMU. |
72 | b) TMU driver: This component initialises the TMU controller and sets different | 83 | b) TMU driver: |
84 | This component initialises the TMU controller and sets different | ||
73 | thresholds. It invokes core thermal implementation with the call | 85 | thresholds. It invokes core thermal implementation with the call |
74 | exynos_report_trigger. | 86 | exynos_report_trigger. |
75 | c) Exynos Core thermal wrapper: This provides 3 wrapper function to use the | 87 | c) Exynos Core thermal wrapper: |
88 | This provides 3 wrapper function to use the | ||
76 | Kernel core thermal framework. They are exynos_unregister_thermal, | 89 | Kernel core thermal framework. They are exynos_unregister_thermal, |
77 | exynos_register_thermal and exynos_report_trigger. | 90 | exynos_register_thermal and exynos_report_trigger. |
diff --git a/Documentation/thermal/exynos_thermal_emulation b/Documentation/thermal/exynos_thermal_emulation deleted file mode 100644 index b15efec6ca28..000000000000 --- a/Documentation/thermal/exynos_thermal_emulation +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | EXYNOS EMULATION MODE | ||
2 | ======================== | ||
3 | |||
4 | Copyright (C) 2012 Samsung Electronics | ||
5 | |||
6 | Written by Jonghwa Lee <jonghwa3.lee@samsung.com> | ||
7 | |||
8 | Description | ||
9 | ----------- | ||
10 | |||
11 | Exynos 4x12 (4212, 4412) and 5 series provide emulation mode for thermal management unit. | ||
12 | Thermal emulation mode supports software debug for TMU's operation. User can set temperature | ||
13 | manually with software code and TMU will read current temperature from user value not from | ||
14 | sensor's value. | ||
15 | |||
16 | Enabling CONFIG_THERMAL_EMULATION option will make this support available. | ||
17 | When it's enabled, sysfs node will be created as | ||
18 | /sys/devices/virtual/thermal/thermal_zone'zone id'/emul_temp. | ||
19 | |||
20 | The sysfs node, 'emul_node', will contain value 0 for the initial state. When you input any | ||
21 | temperature you want to update to sysfs node, it automatically enable emulation mode and | ||
22 | current temperature will be changed into it. | ||
23 | (Exynos also supports user changeable delay time which would be used to delay of | ||
24 | changing temperature. However, this node only uses same delay of real sensing time, 938us.) | ||
25 | |||
26 | Exynos emulation mode requires synchronous of value changing and enabling. It means when you | ||
27 | want to update the any value of delay or next temperature, then you have to enable emulation | ||
28 | mode at the same time. (Or you have to keep the mode enabling.) If you don't, it fails to | ||
29 | change the value to updated one and just use last succeessful value repeatedly. That's why | ||
30 | this node gives users the right to change termerpature only. Just one interface makes it more | ||
31 | simply to use. | ||
32 | |||
33 | Disabling emulation mode only requires writing value 0 to sysfs node. | ||
34 | |||
35 | |||
36 | TEMP 120 | | ||
37 | | | ||
38 | 100 | | ||
39 | | | ||
40 | 80 | | ||
41 | | +----------- | ||
42 | 60 | | | | ||
43 | | +-------------| | | ||
44 | 40 | | | | | ||
45 | | | | | | ||
46 | 20 | | | +---------- | ||
47 | | | | | | | ||
48 | 0 |______________|_____________|__________|__________|_________ | ||
49 | A A A A TIME | ||
50 | |<----->| |<----->| |<----->| | | ||
51 | | 938us | | | | | | | ||
52 | emulation : 0 50 | 70 | 20 | 0 | ||
53 | current temp : sensor 50 70 20 sensor | ||
diff --git a/Documentation/thermal/exynos_thermal_emulation.rst b/Documentation/thermal/exynos_thermal_emulation.rst new file mode 100644 index 000000000000..c21d10838bc5 --- /dev/null +++ b/Documentation/thermal/exynos_thermal_emulation.rst | |||
@@ -0,0 +1,61 @@ | |||
1 | ===================== | ||
2 | Exynos Emulation Mode | ||
3 | ===================== | ||
4 | |||
5 | Copyright (C) 2012 Samsung Electronics | ||
6 | |||
7 | Written by Jonghwa Lee <jonghwa3.lee@samsung.com> | ||
8 | |||
9 | Description | ||
10 | ----------- | ||
11 | |||
12 | Exynos 4x12 (4212, 4412) and 5 series provide emulation mode for thermal | ||
13 | management unit. Thermal emulation mode supports software debug for | ||
14 | TMU's operation. User can set temperature manually with software code | ||
15 | and TMU will read current temperature from user value not from sensor's | ||
16 | value. | ||
17 | |||
18 | Enabling CONFIG_THERMAL_EMULATION option will make this support | ||
19 | available. When it's enabled, sysfs node will be created as | ||
20 | /sys/devices/virtual/thermal/thermal_zone'zone id'/emul_temp. | ||
21 | |||
22 | The sysfs node, 'emul_node', will contain value 0 for the initial state. | ||
23 | When you input any temperature you want to update to sysfs node, it | ||
24 | automatically enable emulation mode and current temperature will be | ||
25 | changed into it. | ||
26 | |||
27 | (Exynos also supports user changeable delay time which would be used to | ||
28 | delay of changing temperature. However, this node only uses same delay | ||
29 | of real sensing time, 938us.) | ||
30 | |||
31 | Exynos emulation mode requires synchronous of value changing and | ||
32 | enabling. It means when you want to update the any value of delay or | ||
33 | next temperature, then you have to enable emulation mode at the same | ||
34 | time. (Or you have to keep the mode enabling.) If you don't, it fails to | ||
35 | change the value to updated one and just use last succeessful value | ||
36 | repeatedly. That's why this node gives users the right to change | ||
37 | termerpature only. Just one interface makes it more simply to use. | ||
38 | |||
39 | Disabling emulation mode only requires writing value 0 to sysfs node. | ||
40 | |||
41 | :: | ||
42 | |||
43 | |||
44 | TEMP 120 | | ||
45 | | | ||
46 | 100 | | ||
47 | | | ||
48 | 80 | | ||
49 | | +----------- | ||
50 | 60 | | | | ||
51 | | +-------------| | | ||
52 | 40 | | | | | ||
53 | | | | | | ||
54 | 20 | | | +---------- | ||
55 | | | | | | | ||
56 | 0 |______________|_____________|__________|__________|_________ | ||
57 | A A A A TIME | ||
58 | |<----->| |<----->| |<----->| | | ||
59 | | 938us | | | | | | | ||
60 | emulation : 0 50 | 70 | 20 | 0 | ||
61 | current temp: sensor 50 70 20 sensor | ||
diff --git a/Documentation/thermal/index.rst b/Documentation/thermal/index.rst new file mode 100644 index 000000000000..8c1c00146cad --- /dev/null +++ b/Documentation/thermal/index.rst | |||
@@ -0,0 +1,18 @@ | |||
1 | :orphan: | ||
2 | |||
3 | ======= | ||
4 | Thermal | ||
5 | ======= | ||
6 | |||
7 | .. toctree:: | ||
8 | :maxdepth: 1 | ||
9 | |||
10 | cpu-cooling-api | ||
11 | sysfs-api | ||
12 | power_allocator | ||
13 | |||
14 | exynos_thermal | ||
15 | exynos_thermal_emulation | ||
16 | intel_powerclamp | ||
17 | nouveau_thermal | ||
18 | x86_pkg_temperature_thermal | ||
diff --git a/Documentation/thermal/intel_powerclamp.txt b/Documentation/thermal/intel_powerclamp.rst index b5df21168fbc..3f6dfb0b3ea6 100644 --- a/Documentation/thermal/intel_powerclamp.txt +++ b/Documentation/thermal/intel_powerclamp.rst | |||
@@ -1,10 +1,13 @@ | |||
1 | ======================= | 1 | ======================= |
2 | INTEL POWERCLAMP DRIVER | 2 | Intel Powerclamp Driver |
3 | ======================= | 3 | ======================= |
4 | By: Arjan van de Ven <arjan@linux.intel.com> | 4 | |
5 | Jacob Pan <jacob.jun.pan@linux.intel.com> | 5 | By: |
6 | - Arjan van de Ven <arjan@linux.intel.com> | ||
7 | - Jacob Pan <jacob.jun.pan@linux.intel.com> | ||
8 | |||
9 | .. Contents: | ||
6 | 10 | ||
7 | Contents: | ||
8 | (*) Introduction | 11 | (*) Introduction |
9 | - Goals and Objectives | 12 | - Goals and Objectives |
10 | 13 | ||
@@ -23,7 +26,6 @@ Contents: | |||
23 | - Generic Thermal Layer (sysfs) | 26 | - Generic Thermal Layer (sysfs) |
24 | - Kernel APIs (TBD) | 27 | - Kernel APIs (TBD) |
25 | 28 | ||
26 | ============ | ||
27 | INTRODUCTION | 29 | INTRODUCTION |
28 | ============ | 30 | ============ |
29 | 31 | ||
@@ -47,7 +49,6 @@ scalability, and user experience. In many cases, clear advantage is | |||
47 | shown over taking the CPU offline or modulating the CPU clock. | 49 | shown over taking the CPU offline or modulating the CPU clock. |
48 | 50 | ||
49 | 51 | ||
50 | =================== | ||
51 | THEORY OF OPERATION | 52 | THEORY OF OPERATION |
52 | =================== | 53 | =================== |
53 | 54 | ||
@@ -57,11 +58,12 @@ Idle Injection | |||
57 | On modern Intel processors (Nehalem or later), package level C-state | 58 | On modern Intel processors (Nehalem or later), package level C-state |
58 | residency is available in MSRs, thus also available to the kernel. | 59 | residency is available in MSRs, thus also available to the kernel. |
59 | 60 | ||
60 | These MSRs are: | 61 | These MSRs are:: |
61 | #define MSR_PKG_C2_RESIDENCY 0x60D | 62 | |
62 | #define MSR_PKG_C3_RESIDENCY 0x3F8 | 63 | #define MSR_PKG_C2_RESIDENCY 0x60D |
63 | #define MSR_PKG_C6_RESIDENCY 0x3F9 | 64 | #define MSR_PKG_C3_RESIDENCY 0x3F8 |
64 | #define MSR_PKG_C7_RESIDENCY 0x3FA | 65 | #define MSR_PKG_C6_RESIDENCY 0x3F9 |
66 | #define MSR_PKG_C7_RESIDENCY 0x3FA | ||
65 | 67 | ||
66 | If the kernel can also inject idle time to the system, then a | 68 | If the kernel can also inject idle time to the system, then a |
67 | closed-loop control system can be established that manages package | 69 | closed-loop control system can be established that manages package |
@@ -96,19 +98,21 @@ are not masked. Tests show that the extra wakeups from scheduler tick | |||
96 | have a dramatic impact on the effectiveness of the powerclamp driver | 98 | have a dramatic impact on the effectiveness of the powerclamp driver |
97 | on large scale systems (Westmere system with 80 processors). | 99 | on large scale systems (Westmere system with 80 processors). |
98 | 100 | ||
99 | CPU0 | 101 | :: |
100 | ____________ ____________ | 102 | |
101 | kidle_inject/0 | sleep | mwait | sleep | | 103 | CPU0 |
102 | _________| |________| |_______ | 104 | ____________ ____________ |
103 | duration | 105 | kidle_inject/0 | sleep | mwait | sleep | |
104 | CPU1 | 106 | _________| |________| |_______ |
105 | ____________ ____________ | 107 | duration |
106 | kidle_inject/1 | sleep | mwait | sleep | | 108 | CPU1 |
107 | _________| |________| |_______ | 109 | ____________ ____________ |
108 | ^ | 110 | kidle_inject/1 | sleep | mwait | sleep | |
109 | | | 111 | _________| |________| |_______ |
110 | | | 112 | ^ |
111 | roundup(jiffies, interval) | 113 | | |
114 | | | ||
115 | roundup(jiffies, interval) | ||
112 | 116 | ||
113 | Only one CPU is allowed to collect statistics and update global | 117 | Only one CPU is allowed to collect statistics and update global |
114 | control parameters. This CPU is referred to as the controlling CPU in | 118 | control parameters. This CPU is referred to as the controlling CPU in |
@@ -148,7 +152,7 @@ b) determine the amount of compensation needed at each target ratio | |||
148 | 152 | ||
149 | Compensation to each target ratio consists of two parts: | 153 | Compensation to each target ratio consists of two parts: |
150 | 154 | ||
151 | a) steady state error compensation | 155 | a) steady state error compensation |
152 | This is to offset the error occurring when the system can | 156 | This is to offset the error occurring when the system can |
153 | enter idle without extra wakeups (such as external interrupts). | 157 | enter idle without extra wakeups (such as external interrupts). |
154 | 158 | ||
@@ -158,41 +162,42 @@ Compensation to each target ratio consists of two parts: | |||
158 | slowing down CPU activities. | 162 | slowing down CPU activities. |
159 | 163 | ||
160 | A debugfs file is provided for the user to examine compensation | 164 | A debugfs file is provided for the user to examine compensation |
161 | progress and results, such as on a Westmere system. | 165 | progress and results, such as on a Westmere system:: |
162 | [jacob@nex01 ~]$ cat | 166 | |
163 | /sys/kernel/debug/intel_powerclamp/powerclamp_calib | 167 | [jacob@nex01 ~]$ cat |
164 | controlling cpu: 0 | 168 | /sys/kernel/debug/intel_powerclamp/powerclamp_calib |
165 | pct confidence steady dynamic (compensation) | 169 | controlling cpu: 0 |
166 | 0 0 0 0 | 170 | pct confidence steady dynamic (compensation) |
167 | 1 1 0 0 | 171 | 0 0 0 0 |
168 | 2 1 1 0 | 172 | 1 1 0 0 |
169 | 3 3 1 0 | 173 | 2 1 1 0 |
170 | 4 3 1 0 | 174 | 3 3 1 0 |
171 | 5 3 1 0 | 175 | 4 3 1 0 |
172 | 6 3 1 0 | 176 | 5 3 1 0 |
173 | 7 3 1 0 | 177 | 6 3 1 0 |
174 | 8 3 1 0 | 178 | 7 3 1 0 |
175 | ... | 179 | 8 3 1 0 |
176 | 30 3 2 0 | 180 | ... |
177 | 31 3 2 0 | 181 | 30 3 2 0 |
178 | 32 3 1 0 | 182 | 31 3 2 0 |
179 | 33 3 2 0 | 183 | 32 3 1 0 |
180 | 34 3 1 0 | 184 | 33 3 2 0 |
181 | 35 3 2 0 | 185 | 34 3 1 0 |
182 | 36 3 1 0 | 186 | 35 3 2 0 |
183 | 37 3 2 0 | 187 | 36 3 1 0 |
184 | 38 3 1 0 | 188 | 37 3 2 0 |
185 | 39 3 2 0 | 189 | 38 3 1 0 |
186 | 40 3 3 0 | 190 | 39 3 2 0 |
187 | 41 3 1 0 | 191 | 40 3 3 0 |
188 | 42 3 2 0 | 192 | 41 3 1 0 |
189 | 43 3 1 0 | 193 | 42 3 2 0 |
190 | 44 3 1 0 | 194 | 43 3 1 0 |
191 | 45 3 2 0 | 195 | 44 3 1 0 |
192 | 46 3 3 0 | 196 | 45 3 2 0 |
193 | 47 3 0 0 | 197 | 46 3 3 0 |
194 | 48 3 2 0 | 198 | 47 3 0 0 |
195 | 49 3 3 0 | 199 | 48 3 2 0 |
200 | 49 3 3 0 | ||
196 | 201 | ||
197 | Calibration occurs during runtime. No offline method is available. | 202 | Calibration occurs during runtime. No offline method is available. |
198 | Steady state compensation is used only when confidence levels of all | 203 | Steady state compensation is used only when confidence levels of all |
@@ -217,9 +222,8 @@ keeps track of clamping kernel threads, even after they are migrated | |||
217 | to other CPUs, after a CPU offline event. | 222 | to other CPUs, after a CPU offline event. |
218 | 223 | ||
219 | 224 | ||
220 | ===================== | ||
221 | Performance Analysis | 225 | Performance Analysis |
222 | ===================== | 226 | ==================== |
223 | This section describes the general performance data collected on | 227 | This section describes the general performance data collected on |
224 | multiple systems, including Westmere (80P) and Ivy Bridge (4P, 8P). | 228 | multiple systems, including Westmere (80P) and Ivy Bridge (4P, 8P). |
225 | 229 | ||
@@ -257,16 +261,15 @@ achieve up to 40% better performance per watt. (measured by a spin | |||
257 | counter summed over per CPU counting threads spawned for all running | 261 | counter summed over per CPU counting threads spawned for all running |
258 | CPUs). | 262 | CPUs). |
259 | 263 | ||
260 | ==================== | ||
261 | Usage and Interfaces | 264 | Usage and Interfaces |
262 | ==================== | 265 | ==================== |
263 | The powerclamp driver is registered to the generic thermal layer as a | 266 | The powerclamp driver is registered to the generic thermal layer as a |
264 | cooling device. Currently, it’s not bound to any thermal zones. | 267 | cooling device. Currently, it’s not bound to any thermal zones:: |
265 | 268 | ||
266 | jacob@chromoly:/sys/class/thermal/cooling_device14$ grep . * | 269 | jacob@chromoly:/sys/class/thermal/cooling_device14$ grep . * |
267 | cur_state:0 | 270 | cur_state:0 |
268 | max_state:50 | 271 | max_state:50 |
269 | type:intel_powerclamp | 272 | type:intel_powerclamp |
270 | 273 | ||
271 | cur_state allows user to set the desired idle percentage. Writing 0 to | 274 | cur_state allows user to set the desired idle percentage. Writing 0 to |
272 | cur_state will stop idle injection. Writing a value between 1 and | 275 | cur_state will stop idle injection. Writing a value between 1 and |
@@ -278,9 +281,9 @@ cur_state returns value -1 instead of 0 which is to avoid confusing | |||
278 | 100% busy state with the disabled state. | 281 | 100% busy state with the disabled state. |
279 | 282 | ||
280 | Example usage: | 283 | Example usage: |
281 | - To inject 25% idle time | 284 | - To inject 25% idle time:: |
282 | $ sudo sh -c "echo 25 > /sys/class/thermal/cooling_device80/cur_state | 285 | |
283 | " | 286 | $ sudo sh -c "echo 25 > /sys/class/thermal/cooling_device80/cur_state |
284 | 287 | ||
285 | If the system is not busy and has more than 25% idle time already, | 288 | If the system is not busy and has more than 25% idle time already, |
286 | then the powerclamp driver will not start idle injection. Using Top | 289 | then the powerclamp driver will not start idle injection. Using Top |
@@ -292,23 +295,23 @@ idle time is accounted as normal idle in that common code path is | |||
292 | taken as the idle task. | 295 | taken as the idle task. |
293 | 296 | ||
294 | In this example, 24.1% idle is shown. This helps the system admin or | 297 | In this example, 24.1% idle is shown. This helps the system admin or |
295 | user determine the cause of slowdown, when a powerclamp driver is in action. | 298 | user determine the cause of slowdown, when a powerclamp driver is in action:: |
296 | 299 | ||
297 | 300 | ||
298 | Tasks: 197 total, 1 running, 196 sleeping, 0 stopped, 0 zombie | 301 | Tasks: 197 total, 1 running, 196 sleeping, 0 stopped, 0 zombie |
299 | Cpu(s): 71.2%us, 4.7%sy, 0.0%ni, 24.1%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st | 302 | Cpu(s): 71.2%us, 4.7%sy, 0.0%ni, 24.1%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st |
300 | Mem: 3943228k total, 1689632k used, 2253596k free, 74960k buffers | 303 | Mem: 3943228k total, 1689632k used, 2253596k free, 74960k buffers |
301 | Swap: 4087804k total, 0k used, 4087804k free, 945336k cached | 304 | Swap: 4087804k total, 0k used, 4087804k free, 945336k cached |
302 | 305 | ||
303 | PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND | 306 | PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND |
304 | 3352 jacob 20 0 262m 644 428 S 286 0.0 0:17.16 spin | 307 | 3352 jacob 20 0 262m 644 428 S 286 0.0 0:17.16 spin |
305 | 3341 root -51 0 0 0 0 D 25 0.0 0:01.62 kidle_inject/0 | 308 | 3341 root -51 0 0 0 0 D 25 0.0 0:01.62 kidle_inject/0 |
306 | 3344 root -51 0 0 0 0 D 25 0.0 0:01.60 kidle_inject/3 | 309 | 3344 root -51 0 0 0 0 D 25 0.0 0:01.60 kidle_inject/3 |
307 | 3342 root -51 0 0 0 0 D 25 0.0 0:01.61 kidle_inject/1 | 310 | 3342 root -51 0 0 0 0 D 25 0.0 0:01.61 kidle_inject/1 |
308 | 3343 root -51 0 0 0 0 D 25 0.0 0:01.60 kidle_inject/2 | 311 | 3343 root -51 0 0 0 0 D 25 0.0 0:01.60 kidle_inject/2 |
309 | 2935 jacob 20 0 696m 125m 35m S 5 3.3 0:31.11 firefox | 312 | 2935 jacob 20 0 696m 125m 35m S 5 3.3 0:31.11 firefox |
310 | 1546 root 20 0 158m 20m 6640 S 3 0.5 0:26.97 Xorg | 313 | 1546 root 20 0 158m 20m 6640 S 3 0.5 0:26.97 Xorg |
311 | 2100 jacob 20 0 1223m 88m 30m S 3 2.3 0:23.68 compiz | 314 | 2100 jacob 20 0 1223m 88m 30m S 3 2.3 0:23.68 compiz |
312 | 315 | ||
313 | Tests have shown that by using the powerclamp driver as a cooling | 316 | Tests have shown that by using the powerclamp driver as a cooling |
314 | device, a PID based userspace thermal controller can manage to | 317 | device, a PID based userspace thermal controller can manage to |
diff --git a/Documentation/thermal/nouveau_thermal b/Documentation/thermal/nouveau_thermal.rst index 6e17a11efcb0..37255fd6735d 100644 --- a/Documentation/thermal/nouveau_thermal +++ b/Documentation/thermal/nouveau_thermal.rst | |||
@@ -1,13 +1,15 @@ | |||
1 | ===================== | ||
1 | Kernel driver nouveau | 2 | Kernel driver nouveau |
2 | =================== | 3 | ===================== |
3 | 4 | ||
4 | Supported chips: | 5 | Supported chips: |
6 | |||
5 | * NV43+ | 7 | * NV43+ |
6 | 8 | ||
7 | Authors: Martin Peres (mupuf) <martin.peres@free.fr> | 9 | Authors: Martin Peres (mupuf) <martin.peres@free.fr> |
8 | 10 | ||
9 | Description | 11 | Description |
10 | --------- | 12 | ----------- |
11 | 13 | ||
12 | This driver allows to read the GPU core temperature, drive the GPU fan and | 14 | This driver allows to read the GPU core temperature, drive the GPU fan and |
13 | set temperature alarms. | 15 | set temperature alarms. |
@@ -19,20 +21,25 @@ interface is likely not to work. This document may then not cover your situation | |||
19 | entirely. | 21 | entirely. |
20 | 22 | ||
21 | Temperature management | 23 | Temperature management |
22 | -------------------- | 24 | ---------------------- |
23 | 25 | ||
24 | Temperature is exposed under as a read-only HWMON attribute temp1_input. | 26 | Temperature is exposed under as a read-only HWMON attribute temp1_input. |
25 | 27 | ||
26 | In order to protect the GPU from overheating, Nouveau supports 4 configurable | 28 | In order to protect the GPU from overheating, Nouveau supports 4 configurable |
27 | temperature thresholds: | 29 | temperature thresholds: |
28 | 30 | ||
29 | * Fan_boost: Fan speed is set to 100% when reaching this temperature; | 31 | * Fan_boost: |
30 | * Downclock: The GPU will be downclocked to reduce its power dissipation; | 32 | Fan speed is set to 100% when reaching this temperature; |
31 | * Critical: The GPU is put on hold to further lower power dissipation; | 33 | * Downclock: |
32 | * Shutdown: Shut the computer down to protect your GPU. | 34 | The GPU will be downclocked to reduce its power dissipation; |
35 | * Critical: | ||
36 | The GPU is put on hold to further lower power dissipation; | ||
37 | * Shutdown: | ||
38 | Shut the computer down to protect your GPU. | ||
33 | 39 | ||
34 | WARNING: Some of these thresholds may not be used by Nouveau depending | 40 | WARNING: |
35 | on your chipset. | 41 | Some of these thresholds may not be used by Nouveau depending |
42 | on your chipset. | ||
36 | 43 | ||
37 | The default value for these thresholds comes from the GPU's vbios. These | 44 | The default value for these thresholds comes from the GPU's vbios. These |
38 | thresholds can be configured thanks to the following HWMON attributes: | 45 | thresholds can be configured thanks to the following HWMON attributes: |
@@ -46,19 +53,24 @@ NOTE: Remember that the values are stored as milli degrees Celsius. Don't forget | |||
46 | to multiply! | 53 | to multiply! |
47 | 54 | ||
48 | Fan management | 55 | Fan management |
49 | ------------ | 56 | -------------- |
50 | 57 | ||
51 | Not all cards have a drivable fan. If you do, then the following HWMON | 58 | Not all cards have a drivable fan. If you do, then the following HWMON |
52 | attributes should be available: | 59 | attributes should be available: |
53 | 60 | ||
54 | * pwm1_enable: Current fan management mode (NONE, MANUAL or AUTO); | 61 | * pwm1_enable: |
55 | * pwm1: Current PWM value (power percentage); | 62 | Current fan management mode (NONE, MANUAL or AUTO); |
56 | * pwm1_min: The minimum PWM speed allowed; | 63 | * pwm1: |
57 | * pwm1_max: The maximum PWM speed allowed (bypassed when hitting Fan_boost); | 64 | Current PWM value (power percentage); |
65 | * pwm1_min: | ||
66 | The minimum PWM speed allowed; | ||
67 | * pwm1_max: | ||
68 | The maximum PWM speed allowed (bypassed when hitting Fan_boost); | ||
58 | 69 | ||
59 | You may also have the following attribute: | 70 | You may also have the following attribute: |
60 | 71 | ||
61 | * fan1_input: Speed in RPM of your fan. | 72 | * fan1_input: |
73 | Speed in RPM of your fan. | ||
62 | 74 | ||
63 | Your fan can be driven in different modes: | 75 | Your fan can be driven in different modes: |
64 | 76 | ||
@@ -66,14 +78,16 @@ Your fan can be driven in different modes: | |||
66 | * 1: The fan can be driven in manual (use pwm1 to change the speed); | 78 | * 1: The fan can be driven in manual (use pwm1 to change the speed); |
67 | * 2; The fan is driven automatically depending on the temperature. | 79 | * 2; The fan is driven automatically depending on the temperature. |
68 | 80 | ||
69 | NOTE: Be sure to use the manual mode if you want to drive the fan speed manually | 81 | NOTE: |
82 | Be sure to use the manual mode if you want to drive the fan speed manually | ||
70 | 83 | ||
71 | NOTE2: When operating in manual mode outside the vbios-defined | 84 | NOTE2: |
72 | [PWM_min, PWM_max] range, the reported fan speed (RPM) may not be accurate | 85 | When operating in manual mode outside the vbios-defined |
73 | depending on your hardware. | 86 | [PWM_min, PWM_max] range, the reported fan speed (RPM) may not be accurate |
87 | depending on your hardware. | ||
74 | 88 | ||
75 | Bug reports | 89 | Bug reports |
76 | --------- | 90 | ----------- |
77 | 91 | ||
78 | Thermal management on Nouveau is new and may not work on all cards. If you have | 92 | Thermal management on Nouveau is new and may not work on all cards. If you have |
79 | inquiries, please ping mupuf on IRC (#nouveau, freenode). | 93 | inquiries, please ping mupuf on IRC (#nouveau, freenode). |
diff --git a/Documentation/thermal/power_allocator.txt b/Documentation/thermal/power_allocator.rst index 9fb0ff06dca9..67b6a3297238 100644 --- a/Documentation/thermal/power_allocator.txt +++ b/Documentation/thermal/power_allocator.rst | |||
@@ -1,3 +1,4 @@ | |||
1 | ================================= | ||
1 | Power allocator governor tunables | 2 | Power allocator governor tunables |
2 | ================================= | 3 | ================================= |
3 | 4 | ||
@@ -25,36 +26,36 @@ temperature as the control input and power as the controlled output: | |||
25 | P_max = k_p * e + k_i * err_integral + k_d * diff_err + sustainable_power | 26 | P_max = k_p * e + k_i * err_integral + k_d * diff_err + sustainable_power |
26 | 27 | ||
27 | where | 28 | where |
28 | e = desired_temperature - current_temperature | 29 | - e = desired_temperature - current_temperature |
29 | err_integral is the sum of previous errors | 30 | - err_integral is the sum of previous errors |
30 | diff_err = e - previous_error | 31 | - diff_err = e - previous_error |
31 | 32 | ||
32 | It is similar to the one depicted below: | 33 | It is similar to the one depicted below:: |
33 | 34 | ||
34 | k_d | 35 | k_d |
35 | | | 36 | | |
36 | current_temp | | 37 | current_temp | |
37 | | v | 38 | | v |
38 | | +----------+ +---+ | 39 | | +----------+ +---+ |
39 | | +----->| diff_err |-->| X |------+ | 40 | | +----->| diff_err |-->| X |------+ |
40 | | | +----------+ +---+ | | 41 | | | +----------+ +---+ | |
41 | | | | tdp actor | 42 | | | | tdp actor |
42 | | | k_i | | get_requested_power() | 43 | | | k_i | | get_requested_power() |
43 | | | | | | | | | 44 | | | | | | | | |
44 | | | | | | | | ... | 45 | | | | | | | | ... |
45 | v | v v v v v | 46 | v | v v v v v |
46 | +---+ | +-------+ +---+ +---+ +---+ +----------+ | 47 | +---+ | +-------+ +---+ +---+ +---+ +----------+ |
47 | | S |-------+----->| sum e |----->| X |--->| S |-->| S |-->|power | | 48 | | S |-----+----->| sum e |----->| X |--->| S |-->| S |-->|power | |
48 | +---+ | +-------+ +---+ +---+ +---+ |allocation| | 49 | +---+ | +-------+ +---+ +---+ +---+ |allocation| |
49 | ^ | ^ +----------+ | 50 | ^ | ^ +----------+ |
50 | | | | | | | 51 | | | | | | |
51 | | | +---+ | | | | 52 | | | +---+ | | | |
52 | | +------->| X |-------------------+ v v | 53 | | +------->| X |-------------------+ v v |
53 | | +---+ granted performance | 54 | | +---+ granted performance |
54 | desired_temperature ^ | 55 | desired_temperature ^ |
55 | | | 56 | | |
56 | | | 57 | | |
57 | k_po/k_pu | 58 | k_po/k_pu |
58 | 59 | ||
59 | Sustainable power | 60 | Sustainable power |
60 | ----------------- | 61 | ----------------- |
@@ -73,7 +74,7 @@ is typically 2000mW, while on a 10" tablet is around 4500mW (may vary | |||
73 | depending on screen size). | 74 | depending on screen size). |
74 | 75 | ||
75 | If you are using device tree, do add it as a property of the | 76 | If you are using device tree, do add it as a property of the |
76 | thermal-zone. For example: | 77 | thermal-zone. For example:: |
77 | 78 | ||
78 | thermal-zones { | 79 | thermal-zones { |
79 | soc_thermal { | 80 | soc_thermal { |
@@ -85,7 +86,7 @@ thermal-zone. For example: | |||
85 | Instead, if the thermal zone is registered from the platform code, pass a | 86 | Instead, if the thermal zone is registered from the platform code, pass a |
86 | `thermal_zone_params` that has a `sustainable_power`. If no | 87 | `thermal_zone_params` that has a `sustainable_power`. If no |
87 | `thermal_zone_params` were being passed, then something like below | 88 | `thermal_zone_params` were being passed, then something like below |
88 | will suffice: | 89 | will suffice:: |
89 | 90 | ||
90 | static const struct thermal_zone_params tz_params = { | 91 | static const struct thermal_zone_params tz_params = { |
91 | .sustainable_power = 3500, | 92 | .sustainable_power = 3500, |
@@ -112,18 +113,18 @@ available capacity at a low temperature. On the other hand, a high | |||
112 | value of `k_pu` will result in the governor granting very high power | 113 | value of `k_pu` will result in the governor granting very high power |
113 | while temperature is low, and may lead to temperature overshooting. | 114 | while temperature is low, and may lead to temperature overshooting. |
114 | 115 | ||
115 | The default value for `k_pu` is: | 116 | The default value for `k_pu` is:: |
116 | 117 | ||
117 | 2 * sustainable_power / (desired_temperature - switch_on_temp) | 118 | 2 * sustainable_power / (desired_temperature - switch_on_temp) |
118 | 119 | ||
119 | This means that at `switch_on_temp` the output of the controller's | 120 | This means that at `switch_on_temp` the output of the controller's |
120 | proportional term will be 2 * `sustainable_power`. The default value | 121 | proportional term will be 2 * `sustainable_power`. The default value |
121 | for `k_po` is: | 122 | for `k_po` is:: |
122 | 123 | ||
123 | sustainable_power / (desired_temperature - switch_on_temp) | 124 | sustainable_power / (desired_temperature - switch_on_temp) |
124 | 125 | ||
125 | Focusing on the proportional and feed forward values of the PID | 126 | Focusing on the proportional and feed forward values of the PID |
126 | controller equation we have: | 127 | controller equation we have:: |
127 | 128 | ||
128 | P_max = k_p * e + sustainable_power | 129 | P_max = k_p * e + sustainable_power |
129 | 130 | ||
@@ -134,21 +135,23 @@ is the desired one, then the proportional component is zero and | |||
134 | thermal equilibrium under constant load. `sustainable_power` is only | 135 | thermal equilibrium under constant load. `sustainable_power` is only |
135 | an estimate, which is the reason for closed-loop control such as this. | 136 | an estimate, which is the reason for closed-loop control such as this. |
136 | 137 | ||
137 | Expanding `k_pu` we get: | 138 | Expanding `k_pu` we get:: |
139 | |||
138 | P_max = 2 * sustainable_power * (T_set - T) / (T_set - T_on) + | 140 | P_max = 2 * sustainable_power * (T_set - T) / (T_set - T_on) + |
139 | sustainable_power | 141 | sustainable_power |
140 | 142 | ||
141 | where | 143 | where: |
142 | T_set is the desired temperature | 144 | |
143 | T is the current temperature | 145 | - T_set is the desired temperature |
144 | T_on is the switch on temperature | 146 | - T is the current temperature |
147 | - T_on is the switch on temperature | ||
145 | 148 | ||
146 | When the current temperature is the switch_on temperature, the above | 149 | When the current temperature is the switch_on temperature, the above |
147 | formula becomes: | 150 | formula becomes:: |
148 | 151 | ||
149 | P_max = 2 * sustainable_power * (T_set - T_on) / (T_set - T_on) + | 152 | P_max = 2 * sustainable_power * (T_set - T_on) / (T_set - T_on) + |
150 | sustainable_power = 2 * sustainable_power + sustainable_power = | 153 | sustainable_power = 2 * sustainable_power + sustainable_power = |
151 | 3 * sustainable_power | 154 | 3 * sustainable_power |
152 | 155 | ||
153 | Therefore, the proportional term alone linearly decreases power from | 156 | Therefore, the proportional term alone linearly decreases power from |
154 | 3 * `sustainable_power` to `sustainable_power` as the temperature | 157 | 3 * `sustainable_power` to `sustainable_power` as the temperature |
@@ -178,11 +181,18 @@ Cooling device power API | |||
178 | Cooling devices controlled by this governor must supply the additional | 181 | Cooling devices controlled by this governor must supply the additional |
179 | "power" API in their `cooling_device_ops`. It consists on three ops: | 182 | "power" API in their `cooling_device_ops`. It consists on three ops: |
180 | 183 | ||
181 | 1. int get_requested_power(struct thermal_cooling_device *cdev, | 184 | 1. :: |
182 | struct thermal_zone_device *tz, u32 *power); | 185 | |
183 | @cdev: The `struct thermal_cooling_device` pointer | 186 | int get_requested_power(struct thermal_cooling_device *cdev, |
184 | @tz: thermal zone in which we are currently operating | 187 | struct thermal_zone_device *tz, u32 *power); |
185 | @power: pointer in which to store the calculated power | 188 | |
189 | |||
190 | @cdev: | ||
191 | The `struct thermal_cooling_device` pointer | ||
192 | @tz: | ||
193 | thermal zone in which we are currently operating | ||
194 | @power: | ||
195 | pointer in which to store the calculated power | ||
186 | 196 | ||
187 | `get_requested_power()` calculates the power requested by the device | 197 | `get_requested_power()` calculates the power requested by the device |
188 | in milliwatts and stores it in @power . It should return 0 on | 198 | in milliwatts and stores it in @power . It should return 0 on |
@@ -190,23 +200,37 @@ success, -E* on failure. This is currently used by the power | |||
190 | allocator governor to calculate how much power to give to each cooling | 200 | allocator governor to calculate how much power to give to each cooling |
191 | device. | 201 | device. |
192 | 202 | ||
193 | 2. int state2power(struct thermal_cooling_device *cdev, struct | 203 | 2. :: |
194 | thermal_zone_device *tz, unsigned long state, u32 *power); | 204 | |
195 | @cdev: The `struct thermal_cooling_device` pointer | 205 | int state2power(struct thermal_cooling_device *cdev, struct |
196 | @tz: thermal zone in which we are currently operating | 206 | thermal_zone_device *tz, unsigned long state, |
197 | @state: A cooling device state | 207 | u32 *power); |
198 | @power: pointer in which to store the equivalent power | 208 | |
209 | @cdev: | ||
210 | The `struct thermal_cooling_device` pointer | ||
211 | @tz: | ||
212 | thermal zone in which we are currently operating | ||
213 | @state: | ||
214 | A cooling device state | ||
215 | @power: | ||
216 | pointer in which to store the equivalent power | ||
199 | 217 | ||
200 | Convert cooling device state @state into power consumption in | 218 | Convert cooling device state @state into power consumption in |
201 | milliwatts and store it in @power. It should return 0 on success, -E* | 219 | milliwatts and store it in @power. It should return 0 on success, -E* |
202 | on failure. This is currently used by thermal core to calculate the | 220 | on failure. This is currently used by thermal core to calculate the |
203 | maximum power that an actor can consume. | 221 | maximum power that an actor can consume. |
204 | 222 | ||
205 | 3. int power2state(struct thermal_cooling_device *cdev, u32 power, | 223 | 3. :: |
206 | unsigned long *state); | 224 | |
207 | @cdev: The `struct thermal_cooling_device` pointer | 225 | int power2state(struct thermal_cooling_device *cdev, u32 power, |
208 | @power: power in milliwatts | 226 | unsigned long *state); |
209 | @state: pointer in which to store the resulting state | 227 | |
228 | @cdev: | ||
229 | The `struct thermal_cooling_device` pointer | ||
230 | @power: | ||
231 | power in milliwatts | ||
232 | @state: | ||
233 | pointer in which to store the resulting state | ||
210 | 234 | ||
211 | Calculate a cooling device state that would make the device consume at | 235 | Calculate a cooling device state that would make the device consume at |
212 | most @power mW and store it in @state. It should return 0 on success, | 236 | most @power mW and store it in @state. It should return 0 on success, |
diff --git a/Documentation/thermal/sysfs-api.txt b/Documentation/thermal/sysfs-api.rst index c3fa500df92c..e4930761d3e5 100644 --- a/Documentation/thermal/sysfs-api.txt +++ b/Documentation/thermal/sysfs-api.rst | |||
@@ -1,3 +1,4 @@ | |||
1 | =================================== | ||
1 | Generic Thermal Sysfs driver How To | 2 | Generic Thermal Sysfs driver How To |
2 | =================================== | 3 | =================================== |
3 | 4 | ||
@@ -9,6 +10,7 @@ Copyright (c) 2008 Intel Corporation | |||
9 | 10 | ||
10 | 11 | ||
11 | 0. Introduction | 12 | 0. Introduction |
13 | =============== | ||
12 | 14 | ||
13 | The generic thermal sysfs provides a set of interfaces for thermal zone | 15 | The generic thermal sysfs provides a set of interfaces for thermal zone |
14 | devices (sensors) and thermal cooling devices (fan, processor...) to register | 16 | devices (sensors) and thermal cooling devices (fan, processor...) to register |
@@ -25,59 +27,90 @@ An intelligent thermal management application can make decisions based on | |||
25 | inputs from thermal zone attributes (the current temperature and trip point | 27 | inputs from thermal zone attributes (the current temperature and trip point |
26 | temperature) and throttle appropriate devices. | 28 | temperature) and throttle appropriate devices. |
27 | 29 | ||
28 | [0-*] denotes any positive number starting from 0 | 30 | - `[0-*]` denotes any positive number starting from 0 |
29 | [1-*] denotes any positive number starting from 1 | 31 | - `[1-*]` denotes any positive number starting from 1 |
30 | 32 | ||
31 | 1. thermal sysfs driver interface functions | 33 | 1. thermal sysfs driver interface functions |
34 | =========================================== | ||
32 | 35 | ||
33 | 1.1 thermal zone device interface | 36 | 1.1 thermal zone device interface |
34 | 1.1.1 struct thermal_zone_device *thermal_zone_device_register(char *type, | 37 | --------------------------------- |
35 | int trips, int mask, void *devdata, | 38 | |
36 | struct thermal_zone_device_ops *ops, | 39 | :: |
37 | const struct thermal_zone_params *tzp, | 40 | |
38 | int passive_delay, int polling_delay)) | 41 | struct thermal_zone_device |
42 | *thermal_zone_device_register(char *type, | ||
43 | int trips, int mask, void *devdata, | ||
44 | struct thermal_zone_device_ops *ops, | ||
45 | const struct thermal_zone_params *tzp, | ||
46 | int passive_delay, int polling_delay)) | ||
39 | 47 | ||
40 | This interface function adds a new thermal zone device (sensor) to | 48 | This interface function adds a new thermal zone device (sensor) to |
41 | /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the | 49 | /sys/class/thermal folder as `thermal_zone[0-*]`. It tries to bind all the |
42 | thermal cooling devices registered at the same time. | 50 | thermal cooling devices registered at the same time. |
43 | 51 | ||
44 | type: the thermal zone type. | 52 | type: |
45 | trips: the total number of trip points this thermal zone supports. | 53 | the thermal zone type. |
46 | mask: Bit string: If 'n'th bit is set, then trip point 'n' is writeable. | 54 | trips: |
47 | devdata: device private data | 55 | the total number of trip points this thermal zone supports. |
48 | ops: thermal zone device call-backs. | 56 | mask: |
49 | .bind: bind the thermal zone device with a thermal cooling device. | 57 | Bit string: If 'n'th bit is set, then trip point 'n' is writeable. |
50 | .unbind: unbind the thermal zone device with a thermal cooling device. | 58 | devdata: |
51 | .get_temp: get the current temperature of the thermal zone. | 59 | device private data |
52 | .set_trips: set the trip points window. Whenever the current temperature | 60 | ops: |
61 | thermal zone device call-backs. | ||
62 | |||
63 | .bind: | ||
64 | bind the thermal zone device with a thermal cooling device. | ||
65 | .unbind: | ||
66 | unbind the thermal zone device with a thermal cooling device. | ||
67 | .get_temp: | ||
68 | get the current temperature of the thermal zone. | ||
69 | .set_trips: | ||
70 | set the trip points window. Whenever the current temperature | ||
53 | is updated, the trip points immediately below and above the | 71 | is updated, the trip points immediately below and above the |
54 | current temperature are found. | 72 | current temperature are found. |
55 | .get_mode: get the current mode (enabled/disabled) of the thermal zone. | 73 | .get_mode: |
56 | - "enabled" means the kernel thermal management is enabled. | 74 | get the current mode (enabled/disabled) of the thermal zone. |
57 | - "disabled" will prevent kernel thermal driver action upon trip points | 75 | |
58 | so that user applications can take charge of thermal management. | 76 | - "enabled" means the kernel thermal management is |
59 | .set_mode: set the mode (enabled/disabled) of the thermal zone. | 77 | enabled. |
60 | .get_trip_type: get the type of certain trip point. | 78 | - "disabled" will prevent kernel thermal driver action |
61 | .get_trip_temp: get the temperature above which the certain trip point | 79 | upon trip points so that user applications can take |
80 | charge of thermal management. | ||
81 | .set_mode: | ||
82 | set the mode (enabled/disabled) of the thermal zone. | ||
83 | .get_trip_type: | ||
84 | get the type of certain trip point. | ||
85 | .get_trip_temp: | ||
86 | get the temperature above which the certain trip point | ||
62 | will be fired. | 87 | will be fired. |
63 | .set_emul_temp: set the emulation temperature which helps in debugging | 88 | .set_emul_temp: |
89 | set the emulation temperature which helps in debugging | ||
64 | different threshold temperature points. | 90 | different threshold temperature points. |
65 | tzp: thermal zone platform parameters. | 91 | tzp: |
66 | passive_delay: number of milliseconds to wait between polls when | 92 | thermal zone platform parameters. |
93 | passive_delay: | ||
94 | number of milliseconds to wait between polls when | ||
67 | performing passive cooling. | 95 | performing passive cooling. |
68 | polling_delay: number of milliseconds to wait between polls when checking | 96 | polling_delay: |
97 | number of milliseconds to wait between polls when checking | ||
69 | whether trip points have been crossed (0 for interrupt driven systems). | 98 | whether trip points have been crossed (0 for interrupt driven systems). |
70 | 99 | ||
100 | :: | ||
71 | 101 | ||
72 | 1.1.2 void thermal_zone_device_unregister(struct thermal_zone_device *tz) | 102 | void thermal_zone_device_unregister(struct thermal_zone_device *tz) |
73 | 103 | ||
74 | This interface function removes the thermal zone device. | 104 | This interface function removes the thermal zone device. |
75 | It deletes the corresponding entry from /sys/class/thermal folder and | 105 | It deletes the corresponding entry from /sys/class/thermal folder and |
76 | unbinds all the thermal cooling devices it uses. | 106 | unbinds all the thermal cooling devices it uses. |
77 | 107 | ||
78 | 1.1.3 struct thermal_zone_device *thermal_zone_of_sensor_register( | 108 | :: |
79 | struct device *dev, int sensor_id, void *data, | 109 | |
80 | const struct thermal_zone_of_device_ops *ops) | 110 | struct thermal_zone_device |
111 | *thermal_zone_of_sensor_register(struct device *dev, int sensor_id, | ||
112 | void *data, | ||
113 | const struct thermal_zone_of_device_ops *ops) | ||
81 | 114 | ||
82 | This interface adds a new sensor to a DT thermal zone. | 115 | This interface adds a new sensor to a DT thermal zone. |
83 | This function will search the list of thermal zones described in | 116 | This function will search the list of thermal zones described in |
@@ -87,25 +120,33 @@ temperature) and throttle appropriate devices. | |||
87 | thermal zone device. | 120 | thermal zone device. |
88 | 121 | ||
89 | The parameters for this interface are: | 122 | The parameters for this interface are: |
90 | dev: Device node of sensor containing valid node pointer in | 123 | |
124 | dev: | ||
125 | Device node of sensor containing valid node pointer in | ||
91 | dev->of_node. | 126 | dev->of_node. |
92 | sensor_id: a sensor identifier, in case the sensor IP has more | 127 | sensor_id: |
128 | a sensor identifier, in case the sensor IP has more | ||
93 | than one sensors | 129 | than one sensors |
94 | data: a private pointer (owned by the caller) that will be | 130 | data: |
131 | a private pointer (owned by the caller) that will be | ||
95 | passed back, when a temperature reading is needed. | 132 | passed back, when a temperature reading is needed. |
96 | ops: struct thermal_zone_of_device_ops *. | 133 | ops: |
134 | `struct thermal_zone_of_device_ops *`. | ||
97 | 135 | ||
98 | get_temp: a pointer to a function that reads the | 136 | ============== ======================================= |
137 | get_temp a pointer to a function that reads the | ||
99 | sensor temperature. This is mandatory | 138 | sensor temperature. This is mandatory |
100 | callback provided by sensor driver. | 139 | callback provided by sensor driver. |
101 | set_trips: a pointer to a function that sets a | 140 | set_trips a pointer to a function that sets a |
102 | temperature window. When this window is | 141 | temperature window. When this window is |
103 | left the driver must inform the thermal | 142 | left the driver must inform the thermal |
104 | core via thermal_zone_device_update. | 143 | core via thermal_zone_device_update. |
105 | get_trend: a pointer to a function that reads the | 144 | get_trend a pointer to a function that reads the |
106 | sensor temperature trend. | 145 | sensor temperature trend. |
107 | set_emul_temp: a pointer to a function that sets | 146 | set_emul_temp a pointer to a function that sets |
108 | sensor emulated temperature. | 147 | sensor emulated temperature. |
148 | ============== ======================================= | ||
149 | |||
109 | The thermal zone temperature is provided by the get_temp() function | 150 | The thermal zone temperature is provided by the get_temp() function |
110 | pointer of thermal_zone_of_device_ops. When called, it will | 151 | pointer of thermal_zone_of_device_ops. When called, it will |
111 | have the private pointer @data back. | 152 | have the private pointer @data back. |
@@ -114,8 +155,10 @@ temperature) and throttle appropriate devices. | |||
114 | handle. Caller should check the return handle with IS_ERR() for finding | 155 | handle. Caller should check the return handle with IS_ERR() for finding |
115 | whether success or not. | 156 | whether success or not. |
116 | 157 | ||
117 | 1.1.4 void thermal_zone_of_sensor_unregister(struct device *dev, | 158 | :: |
118 | struct thermal_zone_device *tzd) | 159 | |
160 | void thermal_zone_of_sensor_unregister(struct device *dev, | ||
161 | struct thermal_zone_device *tzd) | ||
119 | 162 | ||
120 | This interface unregisters a sensor from a DT thermal zone which was | 163 | This interface unregisters a sensor from a DT thermal zone which was |
121 | successfully added by interface thermal_zone_of_sensor_register(). | 164 | successfully added by interface thermal_zone_of_sensor_register(). |
@@ -124,21 +167,29 @@ temperature) and throttle appropriate devices. | |||
124 | interface. It will also silent the zone by remove the .get_temp() and | 167 | interface. It will also silent the zone by remove the .get_temp() and |
125 | get_trend() thermal zone device callbacks. | 168 | get_trend() thermal zone device callbacks. |
126 | 169 | ||
127 | 1.1.5 struct thermal_zone_device *devm_thermal_zone_of_sensor_register( | 170 | :: |
128 | struct device *dev, int sensor_id, | 171 | |
129 | void *data, const struct thermal_zone_of_device_ops *ops) | 172 | struct thermal_zone_device |
173 | *devm_thermal_zone_of_sensor_register(struct device *dev, | ||
174 | int sensor_id, | ||
175 | void *data, | ||
176 | const struct thermal_zone_of_device_ops *ops) | ||
130 | 177 | ||
131 | This interface is resource managed version of | 178 | This interface is resource managed version of |
132 | thermal_zone_of_sensor_register(). | 179 | thermal_zone_of_sensor_register(). |
180 | |||
133 | All details of thermal_zone_of_sensor_register() described in | 181 | All details of thermal_zone_of_sensor_register() described in |
134 | section 1.1.3 is applicable here. | 182 | section 1.1.3 is applicable here. |
183 | |||
135 | The benefit of using this interface to register sensor is that it | 184 | The benefit of using this interface to register sensor is that it |
136 | is not require to explicitly call thermal_zone_of_sensor_unregister() | 185 | is not require to explicitly call thermal_zone_of_sensor_unregister() |
137 | in error path or during driver unbinding as this is done by driver | 186 | in error path or during driver unbinding as this is done by driver |
138 | resource manager. | 187 | resource manager. |
139 | 188 | ||
140 | 1.1.6 void devm_thermal_zone_of_sensor_unregister(struct device *dev, | 189 | :: |
141 | struct thermal_zone_device *tzd) | 190 | |
191 | void devm_thermal_zone_of_sensor_unregister(struct device *dev, | ||
192 | struct thermal_zone_device *tzd) | ||
142 | 193 | ||
143 | This interface is resource managed version of | 194 | This interface is resource managed version of |
144 | thermal_zone_of_sensor_unregister(). | 195 | thermal_zone_of_sensor_unregister(). |
@@ -147,123 +198,186 @@ temperature) and throttle appropriate devices. | |||
147 | Normally this function will not need to be called and the resource | 198 | Normally this function will not need to be called and the resource |
148 | management code will ensure that the resource is freed. | 199 | management code will ensure that the resource is freed. |
149 | 200 | ||
150 | 1.1.7 int thermal_zone_get_slope(struct thermal_zone_device *tz) | 201 | :: |
202 | |||
203 | int thermal_zone_get_slope(struct thermal_zone_device *tz) | ||
151 | 204 | ||
152 | This interface is used to read the slope attribute value | 205 | This interface is used to read the slope attribute value |
153 | for the thermal zone device, which might be useful for platform | 206 | for the thermal zone device, which might be useful for platform |
154 | drivers for temperature calculations. | 207 | drivers for temperature calculations. |
155 | 208 | ||
156 | 1.1.8 int thermal_zone_get_offset(struct thermal_zone_device *tz) | 209 | :: |
210 | |||
211 | int thermal_zone_get_offset(struct thermal_zone_device *tz) | ||
157 | 212 | ||
158 | This interface is used to read the offset attribute value | 213 | This interface is used to read the offset attribute value |
159 | for the thermal zone device, which might be useful for platform | 214 | for the thermal zone device, which might be useful for platform |
160 | drivers for temperature calculations. | 215 | drivers for temperature calculations. |
161 | 216 | ||
162 | 1.2 thermal cooling device interface | 217 | 1.2 thermal cooling device interface |
163 | 1.2.1 struct thermal_cooling_device *thermal_cooling_device_register(char *name, | 218 | ------------------------------------ |
164 | void *devdata, struct thermal_cooling_device_ops *) | 219 | |
220 | |||
221 | :: | ||
222 | |||
223 | struct thermal_cooling_device | ||
224 | *thermal_cooling_device_register(char *name, | ||
225 | void *devdata, struct thermal_cooling_device_ops *) | ||
165 | 226 | ||
166 | This interface function adds a new thermal cooling device (fan/processor/...) | 227 | This interface function adds a new thermal cooling device (fan/processor/...) |
167 | to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself | 228 | to /sys/class/thermal/ folder as `cooling_device[0-*]`. It tries to bind itself |
168 | to all the thermal zone devices registered at the same time. | 229 | to all the thermal zone devices registered at the same time. |
169 | name: the cooling device name. | ||
170 | devdata: device private data. | ||
171 | ops: thermal cooling devices call-backs. | ||
172 | .get_max_state: get the Maximum throttle state of the cooling device. | ||
173 | .get_cur_state: get the Currently requested throttle state of the cooling device. | ||
174 | .set_cur_state: set the Current throttle state of the cooling device. | ||
175 | 230 | ||
176 | 1.2.2 void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) | 231 | name: |
232 | the cooling device name. | ||
233 | devdata: | ||
234 | device private data. | ||
235 | ops: | ||
236 | thermal cooling devices call-backs. | ||
237 | |||
238 | .get_max_state: | ||
239 | get the Maximum throttle state of the cooling device. | ||
240 | .get_cur_state: | ||
241 | get the Currently requested throttle state of the | ||
242 | cooling device. | ||
243 | .set_cur_state: | ||
244 | set the Current throttle state of the cooling device. | ||
245 | |||
246 | :: | ||
247 | |||
248 | void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) | ||
177 | 249 | ||
178 | This interface function removes the thermal cooling device. | 250 | This interface function removes the thermal cooling device. |
179 | It deletes the corresponding entry from /sys/class/thermal folder and | 251 | It deletes the corresponding entry from /sys/class/thermal folder and |
180 | unbinds itself from all the thermal zone devices using it. | 252 | unbinds itself from all the thermal zone devices using it. |
181 | 253 | ||
182 | 1.3 interface for binding a thermal zone device with a thermal cooling device | 254 | 1.3 interface for binding a thermal zone device with a thermal cooling device |
183 | 1.3.1 int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, | 255 | ----------------------------------------------------------------------------- |
184 | int trip, struct thermal_cooling_device *cdev, | 256 | |
185 | unsigned long upper, unsigned long lower, unsigned int weight); | 257 | :: |
258 | |||
259 | int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, | ||
260 | int trip, struct thermal_cooling_device *cdev, | ||
261 | unsigned long upper, unsigned long lower, unsigned int weight); | ||
186 | 262 | ||
187 | This interface function binds a thermal cooling device to a particular trip | 263 | This interface function binds a thermal cooling device to a particular trip |
188 | point of a thermal zone device. | 264 | point of a thermal zone device. |
265 | |||
189 | This function is usually called in the thermal zone device .bind callback. | 266 | This function is usually called in the thermal zone device .bind callback. |
190 | tz: the thermal zone device | 267 | |
191 | cdev: thermal cooling device | 268 | tz: |
192 | trip: indicates which trip point in this thermal zone the cooling device | 269 | the thermal zone device |
193 | is associated with. | 270 | cdev: |
194 | upper:the Maximum cooling state for this trip point. | 271 | thermal cooling device |
195 | THERMAL_NO_LIMIT means no upper limit, | 272 | trip: |
273 | indicates which trip point in this thermal zone the cooling device | ||
274 | is associated with. | ||
275 | upper: | ||
276 | the Maximum cooling state for this trip point. | ||
277 | THERMAL_NO_LIMIT means no upper limit, | ||
196 | and the cooling device can be in max_state. | 278 | and the cooling device can be in max_state. |
197 | lower:the Minimum cooling state can be used for this trip point. | 279 | lower: |
198 | THERMAL_NO_LIMIT means no lower limit, | 280 | the Minimum cooling state can be used for this trip point. |
281 | THERMAL_NO_LIMIT means no lower limit, | ||
199 | and the cooling device can be in cooling state 0. | 282 | and the cooling device can be in cooling state 0. |
200 | weight: the influence of this cooling device in this thermal | 283 | weight: |
201 | zone. See 1.4.1 below for more information. | 284 | the influence of this cooling device in this thermal |
285 | zone. See 1.4.1 below for more information. | ||
202 | 286 | ||
203 | 1.3.2 int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, | 287 | :: |
204 | int trip, struct thermal_cooling_device *cdev); | 288 | |
289 | int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, | ||
290 | int trip, struct thermal_cooling_device *cdev); | ||
205 | 291 | ||
206 | This interface function unbinds a thermal cooling device from a particular | 292 | This interface function unbinds a thermal cooling device from a particular |
207 | trip point of a thermal zone device. This function is usually called in | 293 | trip point of a thermal zone device. This function is usually called in |
208 | the thermal zone device .unbind callback. | 294 | the thermal zone device .unbind callback. |
209 | tz: the thermal zone device | 295 | |
210 | cdev: thermal cooling device | 296 | tz: |
211 | trip: indicates which trip point in this thermal zone the cooling device | 297 | the thermal zone device |
212 | is associated with. | 298 | cdev: |
299 | thermal cooling device | ||
300 | trip: | ||
301 | indicates which trip point in this thermal zone the cooling device | ||
302 | is associated with. | ||
213 | 303 | ||
214 | 1.4 Thermal Zone Parameters | 304 | 1.4 Thermal Zone Parameters |
215 | 1.4.1 struct thermal_bind_params | 305 | --------------------------- |
306 | |||
307 | :: | ||
308 | |||
309 | struct thermal_bind_params | ||
310 | |||
216 | This structure defines the following parameters that are used to bind | 311 | This structure defines the following parameters that are used to bind |
217 | a zone with a cooling device for a particular trip point. | 312 | a zone with a cooling device for a particular trip point. |
218 | .cdev: The cooling device pointer | 313 | |
219 | .weight: The 'influence' of a particular cooling device on this | 314 | .cdev: |
220 | zone. This is relative to the rest of the cooling | 315 | The cooling device pointer |
221 | devices. For example, if all cooling devices have a | 316 | .weight: |
222 | weight of 1, then they all contribute the same. You can | 317 | The 'influence' of a particular cooling device on this |
223 | use percentages if you want, but it's not mandatory. A | 318 | zone. This is relative to the rest of the cooling |
224 | weight of 0 means that this cooling device doesn't | 319 | devices. For example, if all cooling devices have a |
225 | contribute to the cooling of this zone unless all cooling | 320 | weight of 1, then they all contribute the same. You can |
226 | devices have a weight of 0. If all weights are 0, then | 321 | use percentages if you want, but it's not mandatory. A |
227 | they all contribute the same. | 322 | weight of 0 means that this cooling device doesn't |
228 | .trip_mask:This is a bit mask that gives the binding relation between | 323 | contribute to the cooling of this zone unless all cooling |
229 | this thermal zone and cdev, for a particular trip point. | 324 | devices have a weight of 0. If all weights are 0, then |
230 | If nth bit is set, then the cdev and thermal zone are bound | 325 | they all contribute the same. |
231 | for trip point n. | 326 | .trip_mask: |
232 | .binding_limits: This is an array of cooling state limits. Must have | 327 | This is a bit mask that gives the binding relation between |
233 | exactly 2 * thermal_zone.number_of_trip_points. It is an | 328 | this thermal zone and cdev, for a particular trip point. |
234 | array consisting of tuples <lower-state upper-state> of | 329 | If nth bit is set, then the cdev and thermal zone are bound |
235 | state limits. Each trip will be associated with one state | 330 | for trip point n. |
236 | limit tuple when binding. A NULL pointer means | 331 | .binding_limits: |
237 | <THERMAL_NO_LIMITS THERMAL_NO_LIMITS> on all trips. | 332 | This is an array of cooling state limits. Must have |
238 | These limits are used when binding a cdev to a trip point. | 333 | exactly 2 * thermal_zone.number_of_trip_points. It is an |
239 | .match: This call back returns success(0) if the 'tz and cdev' need to | 334 | array consisting of tuples <lower-state upper-state> of |
335 | state limits. Each trip will be associated with one state | ||
336 | limit tuple when binding. A NULL pointer means | ||
337 | <THERMAL_NO_LIMITS THERMAL_NO_LIMITS> on all trips. | ||
338 | These limits are used when binding a cdev to a trip point. | ||
339 | .match: | ||
340 | This call back returns success(0) if the 'tz and cdev' need to | ||
240 | be bound, as per platform data. | 341 | be bound, as per platform data. |
241 | 1.4.2 struct thermal_zone_params | 342 | |
343 | :: | ||
344 | |||
345 | struct thermal_zone_params | ||
346 | |||
242 | This structure defines the platform level parameters for a thermal zone. | 347 | This structure defines the platform level parameters for a thermal zone. |
243 | This data, for each thermal zone should come from the platform layer. | 348 | This data, for each thermal zone should come from the platform layer. |
244 | This is an optional feature where some platforms can choose not to | 349 | This is an optional feature where some platforms can choose not to |
245 | provide this data. | 350 | provide this data. |
246 | .governor_name: Name of the thermal governor used for this zone | 351 | |
247 | .no_hwmon: a boolean to indicate if the thermal to hwmon sysfs interface | 352 | .governor_name: |
248 | is required. when no_hwmon == false, a hwmon sysfs interface | 353 | Name of the thermal governor used for this zone |
249 | will be created. when no_hwmon == true, nothing will be done. | 354 | .no_hwmon: |
250 | In case the thermal_zone_params is NULL, the hwmon interface | 355 | a boolean to indicate if the thermal to hwmon sysfs interface |
251 | will be created (for backward compatibility). | 356 | is required. when no_hwmon == false, a hwmon sysfs interface |
252 | .num_tbps: Number of thermal_bind_params entries for this zone | 357 | will be created. when no_hwmon == true, nothing will be done. |
253 | .tbp: thermal_bind_params entries | 358 | In case the thermal_zone_params is NULL, the hwmon interface |
359 | will be created (for backward compatibility). | ||
360 | .num_tbps: | ||
361 | Number of thermal_bind_params entries for this zone | ||
362 | .tbp: | ||
363 | thermal_bind_params entries | ||
254 | 364 | ||
255 | 2. sysfs attributes structure | 365 | 2. sysfs attributes structure |
366 | ============================= | ||
256 | 367 | ||
368 | == ================ | ||
257 | RO read only value | 369 | RO read only value |
258 | WO write only value | 370 | WO write only value |
259 | RW read/write value | 371 | RW read/write value |
372 | == ================ | ||
260 | 373 | ||
261 | Thermal sysfs attributes will be represented under /sys/class/thermal. | 374 | Thermal sysfs attributes will be represented under /sys/class/thermal. |
262 | Hwmon sysfs I/F extension is also available under /sys/class/hwmon | 375 | Hwmon sysfs I/F extension is also available under /sys/class/hwmon |
263 | if hwmon is compiled in or built as a module. | 376 | if hwmon is compiled in or built as a module. |
264 | 377 | ||
265 | Thermal zone device sys I/F, created once it's registered: | 378 | Thermal zone device sys I/F, created once it's registered:: |
266 | /sys/class/thermal/thermal_zone[0-*]: | 379 | |
380 | /sys/class/thermal/thermal_zone[0-*]: | ||
267 | |---type: Type of the thermal zone | 381 | |---type: Type of the thermal zone |
268 | |---temp: Current temperature | 382 | |---temp: Current temperature |
269 | |---mode: Working mode of the thermal zone | 383 | |---mode: Working mode of the thermal zone |
@@ -282,8 +396,9 @@ Thermal zone device sys I/F, created once it's registered: | |||
282 | |---slope: Slope constant applied as linear extrapolation | 396 | |---slope: Slope constant applied as linear extrapolation |
283 | |---offset: Offset constant applied as linear extrapolation | 397 | |---offset: Offset constant applied as linear extrapolation |
284 | 398 | ||
285 | Thermal cooling device sys I/F, created once it's registered: | 399 | Thermal cooling device sys I/F, created once it's registered:: |
286 | /sys/class/thermal/cooling_device[0-*]: | 400 | |
401 | /sys/class/thermal/cooling_device[0-*]: | ||
287 | |---type: Type of the cooling device(processor/fan/...) | 402 | |---type: Type of the cooling device(processor/fan/...) |
288 | |---max_state: Maximum cooling state of the cooling device | 403 | |---max_state: Maximum cooling state of the cooling device |
289 | |---cur_state: Current cooling state of the cooling device | 404 | |---cur_state: Current cooling state of the cooling device |
@@ -299,11 +414,13 @@ the relationship between a thermal zone and its associated cooling device. | |||
299 | They are created/removed for each successful execution of | 414 | They are created/removed for each successful execution of |
300 | thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device. | 415 | thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device. |
301 | 416 | ||
302 | /sys/class/thermal/thermal_zone[0-*]: | 417 | :: |
418 | |||
419 | /sys/class/thermal/thermal_zone[0-*]: | ||
303 | |---cdev[0-*]: [0-*]th cooling device in current thermal zone | 420 | |---cdev[0-*]: [0-*]th cooling device in current thermal zone |
304 | |---cdev[0-*]_trip_point: Trip point that cdev[0-*] is associated with | 421 | |---cdev[0-*]_trip_point: Trip point that cdev[0-*] is associated with |
305 | |---cdev[0-*]_weight: Influence of the cooling device in | 422 | |---cdev[0-*]_weight: Influence of the cooling device in |
306 | this thermal zone | 423 | this thermal zone |
307 | 424 | ||
308 | Besides the thermal zone device sysfs I/F and cooling device sysfs I/F, | 425 | Besides the thermal zone device sysfs I/F and cooling device sysfs I/F, |
309 | the generic thermal driver also creates a hwmon sysfs I/F for each _type_ | 426 | the generic thermal driver also creates a hwmon sysfs I/F for each _type_ |
@@ -311,16 +428,17 @@ of thermal zone device. E.g. the generic thermal driver registers one hwmon | |||
311 | class device and build the associated hwmon sysfs I/F for all the registered | 428 | class device and build the associated hwmon sysfs I/F for all the registered |
312 | ACPI thermal zones. | 429 | ACPI thermal zones. |
313 | 430 | ||
314 | /sys/class/hwmon/hwmon[0-*]: | 431 | :: |
432 | |||
433 | /sys/class/hwmon/hwmon[0-*]: | ||
315 | |---name: The type of the thermal zone devices | 434 | |---name: The type of the thermal zone devices |
316 | |---temp[1-*]_input: The current temperature of thermal zone [1-*] | 435 | |---temp[1-*]_input: The current temperature of thermal zone [1-*] |
317 | |---temp[1-*]_critical: The critical trip point of thermal zone [1-*] | 436 | |---temp[1-*]_critical: The critical trip point of thermal zone [1-*] |
318 | 437 | ||
319 | Please read Documentation/hwmon/sysfs-interface.rst for additional information. | 438 | Please read Documentation/hwmon/sysfs-interface.rst for additional information. |
320 | 439 | ||
321 | *************************** | 440 | Thermal zone attributes |
322 | * Thermal zone attributes * | 441 | ----------------------- |
323 | *************************** | ||
324 | 442 | ||
325 | type | 443 | type |
326 | Strings which represent the thermal zone type. | 444 | Strings which represent the thermal zone type. |
@@ -340,54 +458,67 @@ mode | |||
340 | This file gives information about the algorithm that is currently | 458 | This file gives information about the algorithm that is currently |
341 | managing the thermal zone. It can be either default kernel based | 459 | managing the thermal zone. It can be either default kernel based |
342 | algorithm or user space application. | 460 | algorithm or user space application. |
343 | enabled = enable Kernel Thermal management. | 461 | |
344 | disabled = Preventing kernel thermal zone driver actions upon | 462 | enabled |
463 | enable Kernel Thermal management. | ||
464 | disabled | ||
465 | Preventing kernel thermal zone driver actions upon | ||
345 | trip points so that user application can take full | 466 | trip points so that user application can take full |
346 | charge of the thermal management. | 467 | charge of the thermal management. |
468 | |||
347 | RW, Optional | 469 | RW, Optional |
348 | 470 | ||
349 | policy | 471 | policy |
350 | One of the various thermal governors used for a particular zone. | 472 | One of the various thermal governors used for a particular zone. |
473 | |||
351 | RW, Required | 474 | RW, Required |
352 | 475 | ||
353 | available_policies | 476 | available_policies |
354 | Available thermal governors which can be used for a particular zone. | 477 | Available thermal governors which can be used for a particular zone. |
478 | |||
355 | RO, Required | 479 | RO, Required |
356 | 480 | ||
357 | trip_point_[0-*]_temp | 481 | `trip_point_[0-*]_temp` |
358 | The temperature above which trip point will be fired. | 482 | The temperature above which trip point will be fired. |
483 | |||
359 | Unit: millidegree Celsius | 484 | Unit: millidegree Celsius |
485 | |||
360 | RO, Optional | 486 | RO, Optional |
361 | 487 | ||
362 | trip_point_[0-*]_type | 488 | `trip_point_[0-*]_type` |
363 | Strings which indicate the type of the trip point. | 489 | Strings which indicate the type of the trip point. |
364 | E.g. it can be one of critical, hot, passive, active[0-*] for ACPI | 490 | |
491 | E.g. it can be one of critical, hot, passive, `active[0-*]` for ACPI | ||
365 | thermal zone. | 492 | thermal zone. |
493 | |||
366 | RO, Optional | 494 | RO, Optional |
367 | 495 | ||
368 | trip_point_[0-*]_hyst | 496 | `trip_point_[0-*]_hyst` |
369 | The hysteresis value for a trip point, represented as an integer | 497 | The hysteresis value for a trip point, represented as an integer |
370 | Unit: Celsius | 498 | Unit: Celsius |
371 | RW, Optional | 499 | RW, Optional |
372 | 500 | ||
373 | cdev[0-*] | 501 | `cdev[0-*]` |
374 | Sysfs link to the thermal cooling device node where the sys I/F | 502 | Sysfs link to the thermal cooling device node where the sys I/F |
375 | for cooling device throttling control represents. | 503 | for cooling device throttling control represents. |
504 | |||
376 | RO, Optional | 505 | RO, Optional |
377 | 506 | ||
378 | cdev[0-*]_trip_point | 507 | `cdev[0-*]_trip_point` |
379 | The trip point in this thermal zone which cdev[0-*] is associated | 508 | The trip point in this thermal zone which `cdev[0-*]` is associated |
380 | with; -1 means the cooling device is not associated with any trip | 509 | with; -1 means the cooling device is not associated with any trip |
381 | point. | 510 | point. |
511 | |||
382 | RO, Optional | 512 | RO, Optional |
383 | 513 | ||
384 | cdev[0-*]_weight | 514 | `cdev[0-*]_weight` |
385 | The influence of cdev[0-*] in this thermal zone. This value | 515 | The influence of `cdev[0-*]` in this thermal zone. This value |
386 | is relative to the rest of cooling devices in the thermal | 516 | is relative to the rest of cooling devices in the thermal |
387 | zone. For example, if a cooling device has a weight double | 517 | zone. For example, if a cooling device has a weight double |
388 | than that of other, it's twice as effective in cooling the | 518 | than that of other, it's twice as effective in cooling the |
389 | thermal zone. | 519 | thermal zone. |
390 | RW, Optional | 520 | |
521 | RW, Optional | ||
391 | 522 | ||
392 | passive | 523 | passive |
393 | Attribute is only present for zones in which the passive cooling | 524 | Attribute is only present for zones in which the passive cooling |
@@ -395,8 +526,11 @@ passive | |||
395 | and can be set to a temperature (in millidegrees) to enable a | 526 | and can be set to a temperature (in millidegrees) to enable a |
396 | passive trip point for the zone. Activation is done by polling with | 527 | passive trip point for the zone. Activation is done by polling with |
397 | an interval of 1 second. | 528 | an interval of 1 second. |
529 | |||
398 | Unit: millidegrees Celsius | 530 | Unit: millidegrees Celsius |
531 | |||
399 | Valid values: 0 (disabled) or greater than 1000 | 532 | Valid values: 0 (disabled) or greater than 1000 |
533 | |||
400 | RW, Optional | 534 | RW, Optional |
401 | 535 | ||
402 | emul_temp | 536 | emul_temp |
@@ -407,17 +541,21 @@ emul_temp | |||
407 | threshold and its associated cooling action. This is write only node | 541 | threshold and its associated cooling action. This is write only node |
408 | and writing 0 on this node should disable emulation. | 542 | and writing 0 on this node should disable emulation. |
409 | Unit: millidegree Celsius | 543 | Unit: millidegree Celsius |
544 | |||
410 | WO, Optional | 545 | WO, Optional |
411 | 546 | ||
412 | WARNING: Be careful while enabling this option on production systems, | 547 | WARNING: |
413 | because userland can easily disable the thermal policy by simply | 548 | Be careful while enabling this option on production systems, |
414 | flooding this sysfs node with low temperature values. | 549 | because userland can easily disable the thermal policy by simply |
550 | flooding this sysfs node with low temperature values. | ||
415 | 551 | ||
416 | sustainable_power | 552 | sustainable_power |
417 | An estimate of the sustained power that can be dissipated by | 553 | An estimate of the sustained power that can be dissipated by |
418 | the thermal zone. Used by the power allocator governor. For | 554 | the thermal zone. Used by the power allocator governor. For |
419 | more information see Documentation/thermal/power_allocator.txt | 555 | more information see Documentation/thermal/power_allocator.rst |
556 | |||
420 | Unit: milliwatts | 557 | Unit: milliwatts |
558 | |||
421 | RW, Optional | 559 | RW, Optional |
422 | 560 | ||
423 | k_po | 561 | k_po |
@@ -425,7 +563,8 @@ k_po | |||
425 | controller during temperature overshoot. Temperature overshoot | 563 | controller during temperature overshoot. Temperature overshoot |
426 | is when the current temperature is above the "desired | 564 | is when the current temperature is above the "desired |
427 | temperature" trip point. For more information see | 565 | temperature" trip point. For more information see |
428 | Documentation/thermal/power_allocator.txt | 566 | Documentation/thermal/power_allocator.rst |
567 | |||
429 | RW, Optional | 568 | RW, Optional |
430 | 569 | ||
431 | k_pu | 570 | k_pu |
@@ -433,20 +572,23 @@ k_pu | |||
433 | controller during temperature undershoot. Temperature undershoot | 572 | controller during temperature undershoot. Temperature undershoot |
434 | is when the current temperature is below the "desired | 573 | is when the current temperature is below the "desired |
435 | temperature" trip point. For more information see | 574 | temperature" trip point. For more information see |
436 | Documentation/thermal/power_allocator.txt | 575 | Documentation/thermal/power_allocator.rst |
576 | |||
437 | RW, Optional | 577 | RW, Optional |
438 | 578 | ||
439 | k_i | 579 | k_i |
440 | The integral term of the power allocator governor's PID | 580 | The integral term of the power allocator governor's PID |
441 | controller. This term allows the PID controller to compensate | 581 | controller. This term allows the PID controller to compensate |
442 | for long term drift. For more information see | 582 | for long term drift. For more information see |
443 | Documentation/thermal/power_allocator.txt | 583 | Documentation/thermal/power_allocator.rst |
584 | |||
444 | RW, Optional | 585 | RW, Optional |
445 | 586 | ||
446 | k_d | 587 | k_d |
447 | The derivative term of the power allocator governor's PID | 588 | The derivative term of the power allocator governor's PID |
448 | controller. For more information see | 589 | controller. For more information see |
449 | Documentation/thermal/power_allocator.txt | 590 | Documentation/thermal/power_allocator.rst |
591 | |||
450 | RW, Optional | 592 | RW, Optional |
451 | 593 | ||
452 | integral_cutoff | 594 | integral_cutoff |
@@ -456,8 +598,10 @@ integral_cutoff | |||
456 | example, if integral_cutoff is 0, then the integral term only | 598 | example, if integral_cutoff is 0, then the integral term only |
457 | accumulates error when temperature is above the desired | 599 | accumulates error when temperature is above the desired |
458 | temperature trip point. For more information see | 600 | temperature trip point. For more information see |
459 | Documentation/thermal/power_allocator.txt | 601 | Documentation/thermal/power_allocator.rst |
602 | |||
460 | Unit: millidegree Celsius | 603 | Unit: millidegree Celsius |
604 | |||
461 | RW, Optional | 605 | RW, Optional |
462 | 606 | ||
463 | slope | 607 | slope |
@@ -465,6 +609,7 @@ slope | |||
465 | to determine a hotspot temperature based off the sensor's | 609 | to determine a hotspot temperature based off the sensor's |
466 | raw readings. It is up to the device driver to determine | 610 | raw readings. It is up to the device driver to determine |
467 | the usage of these values. | 611 | the usage of these values. |
612 | |||
468 | RW, Optional | 613 | RW, Optional |
469 | 614 | ||
470 | offset | 615 | offset |
@@ -472,28 +617,33 @@ offset | |||
472 | to determine a hotspot temperature based off the sensor's | 617 | to determine a hotspot temperature based off the sensor's |
473 | raw readings. It is up to the device driver to determine | 618 | raw readings. It is up to the device driver to determine |
474 | the usage of these values. | 619 | the usage of these values. |
620 | |||
475 | RW, Optional | 621 | RW, Optional |
476 | 622 | ||
477 | ***************************** | 623 | Cooling device attributes |
478 | * Cooling device attributes * | 624 | ------------------------- |
479 | ***************************** | ||
480 | 625 | ||
481 | type | 626 | type |
482 | String which represents the type of device, e.g: | 627 | String which represents the type of device, e.g: |
628 | |||
483 | - for generic ACPI: should be "Fan", "Processor" or "LCD" | 629 | - for generic ACPI: should be "Fan", "Processor" or "LCD" |
484 | - for memory controller device on intel_menlow platform: | 630 | - for memory controller device on intel_menlow platform: |
485 | should be "Memory controller". | 631 | should be "Memory controller". |
632 | |||
486 | RO, Required | 633 | RO, Required |
487 | 634 | ||
488 | max_state | 635 | max_state |
489 | The maximum permissible cooling state of this cooling device. | 636 | The maximum permissible cooling state of this cooling device. |
637 | |||
490 | RO, Required | 638 | RO, Required |
491 | 639 | ||
492 | cur_state | 640 | cur_state |
493 | The current cooling state of this cooling device. | 641 | The current cooling state of this cooling device. |
494 | The value can any integer numbers between 0 and max_state: | 642 | The value can any integer numbers between 0 and max_state: |
643 | |||
495 | - cur_state == 0 means no cooling | 644 | - cur_state == 0 means no cooling |
496 | - cur_state == max_state means the maximum cooling. | 645 | - cur_state == max_state means the maximum cooling. |
646 | |||
497 | RW, Required | 647 | RW, Required |
498 | 648 | ||
499 | stats/reset | 649 | stats/reset |
@@ -508,9 +658,11 @@ stats/time_in_state_ms: | |||
508 | units here is 10mS (similar to other time exported in /proc). | 658 | units here is 10mS (similar to other time exported in /proc). |
509 | RO, Required | 659 | RO, Required |
510 | 660 | ||
661 | |||
511 | stats/total_trans: | 662 | stats/total_trans: |
512 | A single positive value showing the total number of times the state of a | 663 | A single positive value showing the total number of times the state of a |
513 | cooling device is changed. | 664 | cooling device is changed. |
665 | |||
514 | RO, Required | 666 | RO, Required |
515 | 667 | ||
516 | stats/trans_table: | 668 | stats/trans_table: |
@@ -522,6 +674,7 @@ stats/trans_table: | |||
522 | RO, Required | 674 | RO, Required |
523 | 675 | ||
524 | 3. A simple implementation | 676 | 3. A simple implementation |
677 | ========================== | ||
525 | 678 | ||
526 | ACPI thermal zone may support multiple trip points like critical, hot, | 679 | ACPI thermal zone may support multiple trip points like critical, hot, |
527 | passive, active. If an ACPI thermal zone supports critical, passive, | 680 | passive, active. If an ACPI thermal zone supports critical, passive, |
@@ -532,11 +685,10 @@ thermal_cooling_device. Both are considered to have the same | |||
532 | effectiveness in cooling the thermal zone. | 685 | effectiveness in cooling the thermal zone. |
533 | 686 | ||
534 | If the processor is listed in _PSL method, and the fan is listed in _AL0 | 687 | If the processor is listed in _PSL method, and the fan is listed in _AL0 |
535 | method, the sys I/F structure will be built like this: | 688 | method, the sys I/F structure will be built like this:: |
536 | 689 | ||
537 | /sys/class/thermal: | 690 | /sys/class/thermal: |
538 | 691 | |thermal_zone1: | |
539 | |thermal_zone1: | ||
540 | |---type: acpitz | 692 | |---type: acpitz |
541 | |---temp: 37000 | 693 | |---temp: 37000 |
542 | |---mode: enabled | 694 | |---mode: enabled |
@@ -557,24 +709,24 @@ method, the sys I/F structure will be built like this: | |||
557 | |---cdev1_trip_point: 2 /* cdev1 can be used for active[0]*/ | 709 | |---cdev1_trip_point: 2 /* cdev1 can be used for active[0]*/ |
558 | |---cdev1_weight: 1024 | 710 | |---cdev1_weight: 1024 |
559 | 711 | ||
560 | |cooling_device0: | 712 | |cooling_device0: |
561 | |---type: Processor | 713 | |---type: Processor |
562 | |---max_state: 8 | 714 | |---max_state: 8 |
563 | |---cur_state: 0 | 715 | |---cur_state: 0 |
564 | 716 | ||
565 | |cooling_device3: | 717 | |cooling_device3: |
566 | |---type: Fan | 718 | |---type: Fan |
567 | |---max_state: 2 | 719 | |---max_state: 2 |
568 | |---cur_state: 0 | 720 | |---cur_state: 0 |
569 | 721 | ||
570 | /sys/class/hwmon: | 722 | /sys/class/hwmon: |
571 | 723 | |hwmon0: | |
572 | |hwmon0: | ||
573 | |---name: acpitz | 724 | |---name: acpitz |
574 | |---temp1_input: 37000 | 725 | |---temp1_input: 37000 |
575 | |---temp1_crit: 100000 | 726 | |---temp1_crit: 100000 |
576 | 727 | ||
577 | 4. Event Notification | 728 | 4. Event Notification |
729 | ===================== | ||
578 | 730 | ||
579 | The framework includes a simple notification mechanism, in the form of a | 731 | The framework includes a simple notification mechanism, in the form of a |
580 | netlink event. Netlink socket initialization is done during the _init_ | 732 | netlink event. Netlink socket initialization is done during the _init_ |
@@ -587,21 +739,28 @@ event will be one of:{THERMAL_AUX0, THERMAL_AUX1, THERMAL_CRITICAL, | |||
587 | THERMAL_DEV_FAULT}. Notification can be sent when the current temperature | 739 | THERMAL_DEV_FAULT}. Notification can be sent when the current temperature |
588 | crosses any of the configured thresholds. | 740 | crosses any of the configured thresholds. |
589 | 741 | ||
590 | 5. Export Symbol APIs: | 742 | 5. Export Symbol APIs |
743 | ===================== | ||
744 | |||
745 | 5.1. get_tz_trend | ||
746 | ----------------- | ||
591 | 747 | ||
592 | 5.1: get_tz_trend: | ||
593 | This function returns the trend of a thermal zone, i.e the rate of change | 748 | This function returns the trend of a thermal zone, i.e the rate of change |
594 | of temperature of the thermal zone. Ideally, the thermal sensor drivers | 749 | of temperature of the thermal zone. Ideally, the thermal sensor drivers |
595 | are supposed to implement the callback. If they don't, the thermal | 750 | are supposed to implement the callback. If they don't, the thermal |
596 | framework calculated the trend by comparing the previous and the current | 751 | framework calculated the trend by comparing the previous and the current |
597 | temperature values. | 752 | temperature values. |
598 | 753 | ||
599 | 5.2:get_thermal_instance: | 754 | 5.2. get_thermal_instance |
755 | ------------------------- | ||
756 | |||
600 | This function returns the thermal_instance corresponding to a given | 757 | This function returns the thermal_instance corresponding to a given |
601 | {thermal_zone, cooling_device, trip_point} combination. Returns NULL | 758 | {thermal_zone, cooling_device, trip_point} combination. Returns NULL |
602 | if such an instance does not exist. | 759 | if such an instance does not exist. |
603 | 760 | ||
604 | 5.3:thermal_notify_framework: | 761 | 5.3. thermal_notify_framework |
762 | ----------------------------- | ||
763 | |||
605 | This function handles the trip events from sensor drivers. It starts | 764 | This function handles the trip events from sensor drivers. It starts |
606 | throttling the cooling devices according to the policy configured. | 765 | throttling the cooling devices according to the policy configured. |
607 | For CRITICAL and HOT trip points, this notifies the respective drivers, | 766 | For CRITICAL and HOT trip points, this notifies the respective drivers, |
@@ -609,12 +768,15 @@ and does actual throttling for other trip points i.e ACTIVE and PASSIVE. | |||
609 | The throttling policy is based on the configured platform data; if no | 768 | The throttling policy is based on the configured platform data; if no |
610 | platform data is provided, this uses the step_wise throttling policy. | 769 | platform data is provided, this uses the step_wise throttling policy. |
611 | 770 | ||
612 | 5.4:thermal_cdev_update: | 771 | 5.4. thermal_cdev_update |
772 | ------------------------ | ||
773 | |||
613 | This function serves as an arbitrator to set the state of a cooling | 774 | This function serves as an arbitrator to set the state of a cooling |
614 | device. It sets the cooling device to the deepest cooling state if | 775 | device. It sets the cooling device to the deepest cooling state if |
615 | possible. | 776 | possible. |
616 | 777 | ||
617 | 6. thermal_emergency_poweroff: | 778 | 6. thermal_emergency_poweroff |
779 | ============================= | ||
618 | 780 | ||
619 | On an event of critical trip temperature crossing. Thermal framework | 781 | On an event of critical trip temperature crossing. Thermal framework |
620 | allows the system to shutdown gracefully by calling orderly_poweroff(). | 782 | allows the system to shutdown gracefully by calling orderly_poweroff(). |
diff --git a/Documentation/thermal/x86_pkg_temperature_thermal b/Documentation/thermal/x86_pkg_temperature_thermal.rst index 17a3a4c0a0ca..f134dbd3f5a9 100644 --- a/Documentation/thermal/x86_pkg_temperature_thermal +++ b/Documentation/thermal/x86_pkg_temperature_thermal.rst | |||
@@ -1,19 +1,23 @@ | |||
1 | =================================== | ||
1 | Kernel driver: x86_pkg_temp_thermal | 2 | Kernel driver: x86_pkg_temp_thermal |
2 | =================== | 3 | =================================== |
3 | 4 | ||
4 | Supported chips: | 5 | Supported chips: |
6 | |||
5 | * x86: with package level thermal management | 7 | * x86: with package level thermal management |
8 | |||
6 | (Verify using: CPUID.06H:EAX[bit 6] =1) | 9 | (Verify using: CPUID.06H:EAX[bit 6] =1) |
7 | 10 | ||
8 | Authors: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 11 | Authors: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> |
9 | 12 | ||
10 | Reference | 13 | Reference |
11 | --- | 14 | --------- |
15 | |||
12 | Intel® 64 and IA-32 Architectures Software Developer’s Manual (Jan, 2013): | 16 | Intel® 64 and IA-32 Architectures Software Developer’s Manual (Jan, 2013): |
13 | Chapter 14.6: PACKAGE LEVEL THERMAL MANAGEMENT | 17 | Chapter 14.6: PACKAGE LEVEL THERMAL MANAGEMENT |
14 | 18 | ||
15 | Description | 19 | Description |
16 | --------- | 20 | ----------- |
17 | 21 | ||
18 | This driver register CPU digital temperature package level sensor as a thermal | 22 | This driver register CPU digital temperature package level sensor as a thermal |
19 | zone with maximum two user mode configurable trip points. Number of trip points | 23 | zone with maximum two user mode configurable trip points. Number of trip points |
@@ -25,23 +29,27 @@ take any action to control temperature. | |||
25 | Threshold management | 29 | Threshold management |
26 | -------------------- | 30 | -------------------- |
27 | Each package will register as a thermal zone under /sys/class/thermal. | 31 | Each package will register as a thermal zone under /sys/class/thermal. |
28 | Example: | 32 | |
29 | /sys/class/thermal/thermal_zone1 | 33 | Example:: |
34 | |||
35 | /sys/class/thermal/thermal_zone1 | ||
30 | 36 | ||
31 | This contains two trip points: | 37 | This contains two trip points: |
38 | |||
32 | - trip_point_0_temp | 39 | - trip_point_0_temp |
33 | - trip_point_1_temp | 40 | - trip_point_1_temp |
34 | 41 | ||
35 | User can set any temperature between 0 to TJ-Max temperature. Temperature units | 42 | User can set any temperature between 0 to TJ-Max temperature. Temperature units |
36 | are in milli-degree Celsius. Refer to "Documentation/thermal/sysfs-api.txt" for | 43 | are in milli-degree Celsius. Refer to "Documentation/thermal/sysfs-api.rst" for |
37 | thermal sys-fs details. | 44 | thermal sys-fs details. |
38 | 45 | ||
39 | Any value other than 0 in these trip points, can trigger thermal notifications. | 46 | Any value other than 0 in these trip points, can trigger thermal notifications. |
40 | Setting 0, stops sending thermal notifications. | 47 | Setting 0, stops sending thermal notifications. |
41 | 48 | ||
42 | Thermal notifications: To get kobject-uevent notifications, set the thermal zone | 49 | Thermal notifications: |
43 | policy to "user_space". For example: echo -n "user_space" > policy | 50 | To get kobject-uevent notifications, set the thermal zone |
44 | 51 | policy to "user_space". | |
45 | |||
46 | 52 | ||
53 | For example:: | ||
47 | 54 | ||
55 | echo -n "user_space" > policy | ||
diff --git a/MAINTAINERS b/MAINTAINERS index d0ed735994a5..693f2aebbc83 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -15618,7 +15618,7 @@ M: Viresh Kumar <viresh.kumar@linaro.org> | |||
15618 | M: Javi Merino <javi.merino@kernel.org> | 15618 | M: Javi Merino <javi.merino@kernel.org> |
15619 | L: linux-pm@vger.kernel.org | 15619 | L: linux-pm@vger.kernel.org |
15620 | S: Supported | 15620 | S: Supported |
15621 | F: Documentation/thermal/cpu-cooling-api.txt | 15621 | F: Documentation/thermal/cpu-cooling-api.rst |
15622 | F: drivers/thermal/cpu_cooling.c | 15622 | F: drivers/thermal/cpu_cooling.c |
15623 | F: include/linux/cpu_cooling.h | 15623 | F: include/linux/cpu_cooling.h |
15624 | 15624 | ||
diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 15a4ca5d7099..681047f8cc05 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h | |||
@@ -251,7 +251,7 @@ struct thermal_bind_params { | |||
251 | * platform characterization. This value is relative to the | 251 | * platform characterization. This value is relative to the |
252 | * rest of the weights so a cooling device whose weight is | 252 | * rest of the weights so a cooling device whose weight is |
253 | * double that of another cooling device is twice as | 253 | * double that of another cooling device is twice as |
254 | * effective. See Documentation/thermal/sysfs-api.txt for more | 254 | * effective. See Documentation/thermal/sysfs-api.rst for more |
255 | * information. | 255 | * information. |
256 | */ | 256 | */ |
257 | int weight; | 257 | int weight; |
@@ -259,7 +259,7 @@ struct thermal_bind_params { | |||
259 | /* | 259 | /* |
260 | * This is a bit mask that gives the binding relation between this | 260 | * This is a bit mask that gives the binding relation between this |
261 | * thermal zone and cdev, for a particular trip point. | 261 | * thermal zone and cdev, for a particular trip point. |
262 | * See Documentation/thermal/sysfs-api.txt for more information. | 262 | * See Documentation/thermal/sysfs-api.rst for more information. |
263 | */ | 263 | */ |
264 | int trip_mask; | 264 | int trip_mask; |
265 | 265 | ||