Skip to content

Commit 7f2145b

Browse files
committed
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
Pull thermal updates from Zhang Rui: "The latest Thermal Management updates for v4.9-rc3: - Fix a regression introduced by commit b721ca0(thermal/powerclamp: remove cpu whitelist), that powerclamp driver checks cpu support in a wrong way. From: Eric Ernst. - Fix a problem that intel_pch_thermal driver misses passive trip point when the PCH thermal device has an ACPI companion device associated. From: Srinivas Pandruvada. - Add missing support for Haswell PCH thermal sensor. From: Srinivas Pandruvada" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: thermal/powerclamp: correct cpu support check thermal: intel_pch_thermal: Enable Haswell PCH thermal: intel_pch_thermal: Add an ACPI passive trip
2 parents 55bea71 + 3105f23 commit 7f2145b

2 files changed

Lines changed: 62 additions & 12 deletions

File tree

drivers/thermal/intel_pch_thermal.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020
#include <linux/types.h>
2121
#include <linux/init.h>
2222
#include <linux/pci.h>
23+
#include <linux/acpi.h>
2324
#include <linux/thermal.h>
2425
#include <linux/pm.h>
2526

2627
/* Intel PCH thermal Device IDs */
28+
#define PCH_THERMAL_DID_HSW_1 0x9C24 /* Haswell PCH */
29+
#define PCH_THERMAL_DID_HSW_2 0x8C24 /* Haswell PCH */
2730
#define PCH_THERMAL_DID_WPT 0x9CA4 /* Wildcat Point */
2831
#define PCH_THERMAL_DID_SKL 0x9D31 /* Skylake PCH */
2932

@@ -66,9 +69,53 @@ struct pch_thermal_device {
6669
unsigned long crt_temp;
6770
int hot_trip_id;
6871
unsigned long hot_temp;
72+
int psv_trip_id;
73+
unsigned long psv_temp;
6974
bool bios_enabled;
7075
};
7176

77+
#ifdef CONFIG_ACPI
78+
79+
/*
80+
* On some platforms, there is a companion ACPI device, which adds
81+
* passive trip temperature using _PSV method. There is no specific
82+
* passive temperature setting in MMIO interface of this PCI device.
83+
*/
84+
static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
85+
int *nr_trips)
86+
{
87+
struct acpi_device *adev;
88+
89+
ptd->psv_trip_id = -1;
90+
91+
adev = ACPI_COMPANION(&ptd->pdev->dev);
92+
if (adev) {
93+
unsigned long long r;
94+
acpi_status status;
95+
96+
status = acpi_evaluate_integer(adev->handle, "_PSV", NULL,
97+
&r);
98+
if (ACPI_SUCCESS(status)) {
99+
unsigned long trip_temp;
100+
101+
trip_temp = DECI_KELVIN_TO_MILLICELSIUS(r);
102+
if (trip_temp) {
103+
ptd->psv_temp = trip_temp;
104+
ptd->psv_trip_id = *nr_trips;
105+
++(*nr_trips);
106+
}
107+
}
108+
}
109+
}
110+
#else
111+
static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
112+
int *nr_trips)
113+
{
114+
ptd->psv_trip_id = -1;
115+
116+
}
117+
#endif
118+
72119
static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips)
73120
{
74121
u8 tsel;
@@ -119,6 +166,8 @@ static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips)
119166
++(*nr_trips);
120167
}
121168

169+
pch_wpt_add_acpi_psv_trip(ptd, nr_trips);
170+
122171
return 0;
123172
}
124173

@@ -194,6 +243,8 @@ static int pch_get_trip_type(struct thermal_zone_device *tzd, int trip,
194243
*type = THERMAL_TRIP_CRITICAL;
195244
else if (ptd->hot_trip_id == trip)
196245
*type = THERMAL_TRIP_HOT;
246+
else if (ptd->psv_trip_id == trip)
247+
*type = THERMAL_TRIP_PASSIVE;
197248
else
198249
return -EINVAL;
199250

@@ -208,6 +259,8 @@ static int pch_get_trip_temp(struct thermal_zone_device *tzd, int trip, int *tem
208259
*temp = ptd->crt_temp;
209260
else if (ptd->hot_trip_id == trip)
210261
*temp = ptd->hot_temp;
262+
else if (ptd->psv_trip_id == trip)
263+
*temp = ptd->psv_temp;
211264
else
212265
return -EINVAL;
213266

@@ -242,6 +295,11 @@ static int intel_pch_thermal_probe(struct pci_dev *pdev,
242295
ptd->ops = &pch_dev_ops_wpt;
243296
dev_name = "pch_skylake";
244297
break;
298+
case PCH_THERMAL_DID_HSW_1:
299+
case PCH_THERMAL_DID_HSW_2:
300+
ptd->ops = &pch_dev_ops_wpt;
301+
dev_name = "pch_haswell";
302+
break;
245303
default:
246304
dev_err(&pdev->dev, "unknown pch thermal device\n");
247305
return -ENODEV;
@@ -324,6 +382,8 @@ static int intel_pch_thermal_resume(struct device *device)
324382
static struct pci_device_id intel_pch_thermal_id[] = {
325383
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_WPT) },
326384
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_SKL) },
385+
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_HSW_1) },
386+
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_HSW_2) },
327387
{ 0, },
328388
};
329389
MODULE_DEVICE_TABLE(pci, intel_pch_thermal_id);

drivers/thermal/intel_powerclamp.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -669,20 +669,10 @@ static struct thermal_cooling_device_ops powerclamp_cooling_ops = {
669669
.set_cur_state = powerclamp_set_cur_state,
670670
};
671671

672-
static const struct x86_cpu_id intel_powerclamp_ids[] __initconst = {
673-
{ X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_MWAIT },
674-
{ X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_ARAT },
675-
{ X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_NONSTOP_TSC },
676-
{ X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_CONSTANT_TSC},
677-
{}
678-
};
679-
MODULE_DEVICE_TABLE(x86cpu, intel_powerclamp_ids);
680-
681672
static int __init powerclamp_probe(void)
682673
{
683-
if (!x86_match_cpu(intel_powerclamp_ids)) {
684-
pr_err("Intel powerclamp does not run on family %d model %d\n",
685-
boot_cpu_data.x86, boot_cpu_data.x86_model);
674+
if (!boot_cpu_has(X86_FEATURE_MWAIT)) {
675+
pr_err("CPU does not support MWAIT");
686676
return -ENODEV;
687677
}
688678

0 commit comments

Comments
 (0)