Skip to content

Commit 8cbd0ee

Browse files
committed
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
Pull thermal management updates from Zhang Rui: "There are not too many changes this time, except two new platform thermal drivers, ti-soc-thermal driver and x86_pkg_temp_thermal driver, and a couple of small fixes. Highlights: - move the ti-soc-thermal driver out of the staging tree to the thermal tree. - introduce the x86_pkg_temp_thermal driver. This driver registers CPU digital temperature package level sensor as a thermal zone. - small fixes/cleanups including removing redundant use of platform_set_drvdata() and of_match_ptr for all platform thermal drivers" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: (34 commits) thermal: cpu_cooling: fix stub function thermal: ti-soc-thermal: use standard GPIO DT bindings thermal: MAINTAINERS: Add git tree path for SoC specific updates thermal: fix x86_pkg_temp_thermal.c build and Kconfig Thermal: Documentation for x86 package temperature thermal driver Thermal: CPU Package temperature thermal thermal: consider emul_temperature while computing trend thermal: ti-soc-thermal: add DT example for DRA752 chip thermal: ti-soc-thermal: add dra752 chip to device table thermal: ti-soc-thermal: add thermal data for DRA752 chips thermal: ti-soc-thermal: remove usage of IS_ERR_OR_NULL thermal: ti-soc-thermal: freeze FSM while computing trend thermal: ti-soc-thermal: remove external heat while extrapolating hotspot thermal: ti-soc-thermal: update DT reference for OMAP5430 x86, mcheck, therm_throt: Process package thresholds thermal: cpu_cooling: fix 'descend' check in get_property() Thermal: spear: Remove redundant use of of_match_ptr Thermal: kirkwood: Remove redundant use of of_match_ptr Thermal: dove: Remove redundant use of of_match_ptr Thermal: armada: Remove redundant use of of_match_ptr ...
2 parents 1466b77 + e8d3924 commit 8cbd0ee

32 files changed

Lines changed: 1627 additions & 83 deletions

drivers/staging/ti-soc-thermal/ti_soc_thermal.txt renamed to Documentation/devicetree/bindings/thermal/ti_soc_thermal.txt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ Required properties:
1717
- interrupts : this entry should indicate which interrupt line
1818
the talert signal is routed to;
1919
Specific:
20-
- ti,tshut-gpio : this entry should be used to inform which GPIO
21-
line the tshut signal is routed to;
20+
- gpios : this entry should be used to inform which GPIO
21+
line the tshut signal is routed to. The informed GPIO will
22+
be treated as an IRQ;
2223
- regs : this entry must also be specified and it is specific
2324
to each bandgap version, because the mapping may change from
2425
soc to soc, apart of depending on available features.
@@ -37,7 +38,7 @@ bandgap {
3738
0x4a002378 0x18>;
3839
compatible = "ti,omap4460-bandgap";
3940
interrupts = <0 126 4>; /* talert */
40-
ti,tshut-gpio = <86>;
41+
gpios = <&gpio3 22 0>; /* tshut */
4142
};
4243

4344
OMAP4470:
@@ -47,7 +48,7 @@ bandgap {
4748
0x4a002378 0x18>;
4849
compatible = "ti,omap4470-bandgap";
4950
interrupts = <0 126 4>; /* talert */
50-
ti,tshut-gpio = <86>;
51+
gpios = <&gpio3 22 0>; /* tshut */
5152
};
5253

5354
OMAP5430:
@@ -59,3 +60,15 @@ bandgap {
5960
compatible = "ti,omap5430-bandgap";
6061
interrupts = <0 126 4>; /* talert */
6162
};
63+
64+
DRA752:
65+
bandgap {
66+
reg = <0x4a0021e0 0xc
67+
0x4a00232c 0xc
68+
0x4a002380 0x2c
69+
0x4a0023C0 0x3c
70+
0x4a002564 0x8
71+
0x4a002574 0x50>;
72+
compatible = "ti,dra752-bandgap";
73+
interrupts = <0 126 4>; /* talert */
74+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Kernel driver: x86_pkg_temp_thermal
2+
===================
3+
4+
Supported chips:
5+
* x86: with package level thermal management
6+
(Verify using: CPUID.06H:EAX[bit 6] =1)
7+
8+
Authors: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
9+
10+
Reference
11+
---
12+
Intel® 64 and IA-32 Architectures Software Developer’s Manual (Jan, 2013):
13+
Chapter 14.6: PACKAGE LEVEL THERMAL MANAGEMENT
14+
15+
Description
16+
---------
17+
18+
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
20+
depends on the capability of the package. Once the trip point is violated,
21+
user mode can receive notification via thermal notification mechanism and can
22+
take any action to control temperature.
23+
24+
25+
Threshold management
26+
--------------------
27+
Each package will register as a thermal zone under /sys/class/thermal.
28+
Example:
29+
/sys/class/thermal/thermal_zone1
30+
31+
This contains two trip points:
32+
- trip_point_0_temp
33+
- trip_point_1_temp
34+
35+
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
37+
thermal sys-fs details.
38+
39+
Any value other than 0 in these trip points, can trigger thermal notifications.
40+
Setting 0, stops sending thermal notifications.
41+
42+
Thermal notifications: To get kobject-uevent notifications, set the thermal zone
43+
policy to "user_space". For example: echo -n "user_space" > policy
44+
45+
46+
47+

‎MAINTAINERS‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8159,6 +8159,7 @@ M: Zhang Rui <rui.zhang@intel.com>
81598159
M: Eduardo Valentin <eduardo.valentin@ti.com>
81608160
L: linux-pm@vger.kernel.org
81618161
T: git git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git
8162+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git
81628163
Q: https://patchwork.kernel.org/project/linux-pm/list/
81638164
S: Supported
81648165
F: drivers/thermal/
@@ -8183,8 +8184,8 @@ F: drivers/platform/x86/thinkpad_acpi.c
81838184
TI BANDGAP AND THERMAL DRIVER
81848185
M: Eduardo Valentin <eduardo.valentin@ti.com>
81858186
L: linux-pm@vger.kernel.org
8186-
S: Maintained
8187-
F: drivers/staging/omap-thermal/
8187+
S: Supported
8188+
F: drivers/thermal/ti-soc-thermal/
81888189

81898190
TI FLASH MEDIA INTERFACE DRIVER
81908191
M: Alex Dubov <oakad@yahoo.com>

‎arch/x86/include/asm/mce.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ void mce_log_therm_throt_event(__u64 status);
214214
/* Interrupt Handler for core thermal thresholds */
215215
extern int (*platform_thermal_notify)(__u64 msr_val);
216216

217+
/* Interrupt Handler for package thermal thresholds */
218+
extern int (*platform_thermal_package_notify)(__u64 msr_val);
219+
220+
/* Callback support of rate control, return true, if
221+
* callback has rate control */
222+
extern bool (*platform_thermal_package_rate_control)(void);
223+
217224
#ifdef CONFIG_X86_THERMAL_VECTOR
218225
extern void mcheck_intel_therm_init(void);
219226
#else

‎arch/x86/kernel/cpu/mcheck/therm_throt.c‎

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,24 @@ struct thermal_state {
5555
struct _thermal_state package_power_limit;
5656
struct _thermal_state core_thresh0;
5757
struct _thermal_state core_thresh1;
58+
struct _thermal_state pkg_thresh0;
59+
struct _thermal_state pkg_thresh1;
5860
};
5961

6062
/* Callback to handle core threshold interrupts */
6163
int (*platform_thermal_notify)(__u64 msr_val);
6264
EXPORT_SYMBOL(platform_thermal_notify);
6365

66+
/* Callback to handle core package threshold_interrupts */
67+
int (*platform_thermal_package_notify)(__u64 msr_val);
68+
EXPORT_SYMBOL_GPL(platform_thermal_package_notify);
69+
70+
/* Callback support of rate control, return true, if
71+
* callback has rate control */
72+
bool (*platform_thermal_package_rate_control)(void);
73+
EXPORT_SYMBOL_GPL(platform_thermal_package_rate_control);
74+
75+
6476
static DEFINE_PER_CPU(struct thermal_state, thermal_state);
6577

6678
static atomic_t therm_throt_en = ATOMIC_INIT(0);
@@ -195,19 +207,25 @@ static int therm_throt_process(bool new_event, int event, int level)
195207
return 0;
196208
}
197209

198-
static int thresh_event_valid(int event)
210+
static int thresh_event_valid(int level, int event)
199211
{
200212
struct _thermal_state *state;
201213
unsigned int this_cpu = smp_processor_id();
202214
struct thermal_state *pstate = &per_cpu(thermal_state, this_cpu);
203215
u64 now = get_jiffies_64();
204216

205-
state = (event == 0) ? &pstate->core_thresh0 : &pstate->core_thresh1;
217+
if (level == PACKAGE_LEVEL)
218+
state = (event == 0) ? &pstate->pkg_thresh0 :
219+
&pstate->pkg_thresh1;
220+
else
221+
state = (event == 0) ? &pstate->core_thresh0 :
222+
&pstate->core_thresh1;
206223

207224
if (time_before64(now, state->next_check))
208225
return 0;
209226

210227
state->next_check = now + CHECK_INTERVAL;
228+
211229
return 1;
212230
}
213231

@@ -322,6 +340,39 @@ device_initcall(thermal_throttle_init_device);
322340

323341
#endif /* CONFIG_SYSFS */
324342

343+
static void notify_package_thresholds(__u64 msr_val)
344+
{
345+
bool notify_thres_0 = false;
346+
bool notify_thres_1 = false;
347+
348+
if (!platform_thermal_package_notify)
349+
return;
350+
351+
/* lower threshold check */
352+
if (msr_val & THERM_LOG_THRESHOLD0)
353+
notify_thres_0 = true;
354+
/* higher threshold check */
355+
if (msr_val & THERM_LOG_THRESHOLD1)
356+
notify_thres_1 = true;
357+
358+
if (!notify_thres_0 && !notify_thres_1)
359+
return;
360+
361+
if (platform_thermal_package_rate_control &&
362+
platform_thermal_package_rate_control()) {
363+
/* Rate control is implemented in callback */
364+
platform_thermal_package_notify(msr_val);
365+
return;
366+
}
367+
368+
/* lower threshold reached */
369+
if (notify_thres_0 && thresh_event_valid(PACKAGE_LEVEL, 0))
370+
platform_thermal_package_notify(msr_val);
371+
/* higher threshold reached */
372+
if (notify_thres_1 && thresh_event_valid(PACKAGE_LEVEL, 1))
373+
platform_thermal_package_notify(msr_val);
374+
}
375+
325376
static void notify_thresholds(__u64 msr_val)
326377
{
327378
/* check whether the interrupt handler is defined;
@@ -331,10 +382,12 @@ static void notify_thresholds(__u64 msr_val)
331382
return;
332383

333384
/* lower threshold reached */
334-
if ((msr_val & THERM_LOG_THRESHOLD0) && thresh_event_valid(0))
385+
if ((msr_val & THERM_LOG_THRESHOLD0) &&
386+
thresh_event_valid(CORE_LEVEL, 0))
335387
platform_thermal_notify(msr_val);
336388
/* higher threshold reached */
337-
if ((msr_val & THERM_LOG_THRESHOLD1) && thresh_event_valid(1))
389+
if ((msr_val & THERM_LOG_THRESHOLD1) &&
390+
thresh_event_valid(CORE_LEVEL, 1))
338391
platform_thermal_notify(msr_val);
339392
}
340393

@@ -360,6 +413,8 @@ static void intel_thermal_interrupt(void)
360413

361414
if (this_cpu_has(X86_FEATURE_PTS)) {
362415
rdmsrl(MSR_IA32_PACKAGE_THERM_STATUS, msr_val);
416+
/* check violations of package thermal thresholds */
417+
notify_package_thresholds(msr_val);
363418
therm_throt_process(msr_val & PACKAGE_THERM_STATUS_PROCHOT,
364419
THERMAL_THROTTLING_EVENT,
365420
PACKAGE_LEVEL);

‎drivers/staging/Kconfig‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ source "drivers/staging/gdm72xx/Kconfig"
120120

121121
source "drivers/staging/csr/Kconfig"
122122

123-
source "drivers/staging/ti-soc-thermal/Kconfig"
124-
125123
source "drivers/staging/silicom/Kconfig"
126124

127125
source "drivers/staging/ced1401/Kconfig"

‎drivers/staging/Makefile‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ obj-$(CONFIG_ANDROID) += android/
5353
obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/
5454
obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/
5555
obj-$(CONFIG_CSR_WIFI) += csr/
56-
obj-$(CONFIG_TI_SOC_THERMAL) += ti-soc-thermal/
5756
obj-$(CONFIG_NET_VENDOR_SILICOM) += silicom/
5857
obj-$(CONFIG_CED1401) += ced1401/
5958
obj-$(CONFIG_DRM_IMX) += imx-drm/

‎drivers/thermal/Kconfig‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,19 @@ config INTEL_POWERCLAMP
169169
enforce idle time which results in more package C-state residency. The
170170
user interface is exposed via generic thermal framework.
171171

172+
config X86_PKG_TEMP_THERMAL
173+
tristate "X86 package temperature thermal driver"
174+
depends on X86_THERMAL_VECTOR
175+
select THERMAL_GOV_USER_SPACE
176+
default m
177+
help
178+
Enable this to register CPU digital sensor for package temperature as
179+
thermal zone. Each package will have its own thermal zone. There are
180+
two trip points which can be set by user to get notifications via thermal
181+
notification methods.
182+
183+
menu "Texas Instruments thermal drivers"
184+
source "drivers/thermal/ti-soc-thermal/Kconfig"
185+
endmenu
186+
172187
endif

‎drivers/thermal/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ obj-$(CONFIG_DB8500_THERMAL) += db8500_thermal.o
2323
obj-$(CONFIG_ARMADA_THERMAL) += armada_thermal.o
2424
obj-$(CONFIG_DB8500_CPUFREQ_COOLING) += db8500_cpufreq_cooling.o
2525
obj-$(CONFIG_INTEL_POWERCLAMP) += intel_powerclamp.o
26-
26+
obj-$(CONFIG_X86_PKG_TEMP_THERMAL) += x86_pkg_temp_thermal.o
27+
obj-$(CONFIG_TI_SOC_THERMAL) += ti-soc-thermal/

‎drivers/thermal/armada_thermal.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ static int armada_thermal_exit(struct platform_device *pdev)
200200
platform_get_drvdata(pdev);
201201

202202
thermal_zone_device_unregister(armada_thermal);
203-
platform_set_drvdata(pdev, NULL);
204203

205204
return 0;
206205
}
@@ -211,7 +210,7 @@ static struct platform_driver armada_thermal_driver = {
211210
.driver = {
212211
.name = "armada_thermal",
213212
.owner = THIS_MODULE,
214-
.of_match_table = of_match_ptr(armada_thermal_id_table),
213+
.of_match_table = armada_thermal_id_table,
215214
},
216215
};
217216

0 commit comments

Comments
 (0)