Skip to content

Commit 8035d70

Browse files
committed
Merge branch 'thermal-intel'
Merge updates of Intel thermal drivers for 6.20/7.0: - Add Panther Lake, Wildcat Lake and Nova Lake processor IDs to the list of supported processors in the intel_tcc_cooling thermal driver (Srinivas Pandruvada) - Drop unnecessary explicit driver data clearing on removal from the intel_pch_thermal driver (Kaushlendra Kumar) - Add support for "slow" workload type hints to the int340x processor_thermal driver and enable it on the Panther Lake platform (Srinivas Pandruvada) - Use sysfs_emit{_at}() in sysfs show functions in Intel thermal drivers (Thorsten Blum) - Update the x86_pkg_temp_thermal driver to handle THERMAL_TEMP_INVALID that can be passed to it via sysfs as expected (Rafael Wysocki) - Drop a redundant local variable from the intel_tcc_cooling thermal driver and fix a kerneldoc comment typo in the TCC library (Sumeet Pawnikar) * thermal-intel: drivers: thermal: intel: tcc_cooling: Drop redundant local variable thermal: intel: x86_pkg_temp_thermal: Handle invalid temperature thermal: intel: Use sysfs_emit() in a sysfs show function thermal: intel: fix typo "nagative" in comment for cpu argument thermal: intel: int340x: Use sysfs_emit{_at}() in sysfs show functions thermal: intel: selftests: workload_hint: Support slow workload hints thermal: int340x: processor_thermal: Enable slow workload type hints thermal: intel: intel_pch_thermal: Drop explicit driver data clearing thermal: intel: intel_tcc_cooling: Add CPU models in the support list
2 parents 74dd4d1 + 9eb9c35 commit 8035d70

11 files changed

Lines changed: 133 additions & 52 deletions

File tree

Documentation/driver-api/thermal/intel_dptf.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ based on the processor generation.
375375
``workload_hint_enable`` (RW)
376376
Enable firmware to send workload type hints to user space.
377377

378+
``workload_slow_hint_enable`` (RW)
379+
Enable firmware to send slow workload type hints to user space.
380+
378381
``notification_delay_ms`` (RW)
379382
Minimum delay in milliseconds before firmware will notify OS. This is
380383
for the rate control of notifications. This delay is between changing

drivers/thermal/intel/int340x_thermal/processor_thermal_device.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/kernel.h>
99
#include <linux/module.h>
1010
#include <linux/pci.h>
11+
#include <linux/sysfs.h>
1112
#include <linux/thermal.h>
1213
#include <asm/msr.h>
1314
#include "int340x_thermal_zone.h"
@@ -23,7 +24,7 @@ static ssize_t power_limit_##index##_##suffix##_show(struct device *dev, \
2324
{ \
2425
struct proc_thermal_device *proc_dev = dev_get_drvdata(dev); \
2526
\
26-
return sprintf(buf, "%lu\n",\
27+
return sysfs_emit(buf, "%lu\n",\
2728
(unsigned long)proc_dev->power_limits[index].suffix * 1000); \
2829
}
2930

@@ -143,7 +144,7 @@ static ssize_t tcc_offset_degree_celsius_show(struct device *dev,
143144
if (offset < 0)
144145
return offset;
145146

146-
return sprintf(buf, "%d\n", offset);
147+
return sysfs_emit(buf, "%d\n", offset);
147148
}
148149

149150
static ssize_t tcc_offset_degree_celsius_store(struct device *dev,

drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/kernel.h>
88
#include <linux/module.h>
99
#include <linux/pci.h>
10+
#include <linux/sysfs.h>
1011
#include "processor_thermal_device.h"
1112

1213
MODULE_IMPORT_NS("INT340X_THERMAL");
@@ -211,9 +212,9 @@ static ssize_t suffix##_show(struct device *dev,\
211212
ret = (reg_val >> mmio_regs[ret].shift) & mmio_regs[ret].mask;\
212213
err = get_mapped_string(mapping, attr->attr.name, ret, &str);\
213214
if (!err)\
214-
return sprintf(buf, "%s\n", str);\
215+
return sysfs_emit(buf, "%s\n", str);\
215216
if (err == -EOPNOTSUPP)\
216-
return sprintf(buf, "%u\n", ret);\
217+
return sysfs_emit(buf, "%u\n", ret);\
217218
return err;\
218219
}
219220

@@ -398,7 +399,7 @@ static ssize_t rfi_restriction_show(struct device *dev,
398399
if (ret)
399400
return ret;
400401

401-
return sprintf(buf, "%llu\n", resp);
402+
return sysfs_emit(buf, "%llu\n", resp);
402403
}
403404

404405
static ssize_t ddr_data_rate_show(struct device *dev,
@@ -413,7 +414,7 @@ static ssize_t ddr_data_rate_show(struct device *dev,
413414
if (ret)
414415
return ret;
415416

416-
return sprintf(buf, "%llu\n", resp);
417+
return sysfs_emit(buf, "%llu\n", resp);
417418
}
418419

419420
static DEVICE_ATTR_RW(rfi_restriction);

drivers/thermal/intel/int340x_thermal/processor_thermal_wt_hint.c

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#define SOC_WT GENMASK_ULL(47, 40)
3636

37+
#define SOC_WT_SLOW_PREDICTION_INT_ENABLE_BIT 22
3738
#define SOC_WT_PREDICTION_INT_ENABLE_BIT 23
3839

3940
#define SOC_WT_PREDICTION_INT_ACTIVE BIT(2)
@@ -47,6 +48,7 @@ static u16 notify_delay_ms = 1024;
4748

4849
static DEFINE_MUTEX(wt_lock);
4950
static u8 wt_enable;
51+
static u8 wt_slow_enable;
5052

5153
/* Show current predicted workload type index */
5254
static ssize_t workload_type_index_show(struct device *dev,
@@ -59,7 +61,7 @@ static ssize_t workload_type_index_show(struct device *dev,
5961
int wt;
6062

6163
mutex_lock(&wt_lock);
62-
if (!wt_enable) {
64+
if (!wt_enable && !wt_slow_enable) {
6365
mutex_unlock(&wt_lock);
6466
return -ENODATA;
6567
}
@@ -84,9 +86,9 @@ static ssize_t workload_hint_enable_show(struct device *dev,
8486
return sysfs_emit(buf, "%d\n", wt_enable);
8587
}
8688

87-
static ssize_t workload_hint_enable_store(struct device *dev,
88-
struct device_attribute *attr,
89-
const char *buf, size_t size)
89+
static ssize_t workload_hint_enable(struct device *dev, u8 enable_bit, u8 *status,
90+
struct device_attribute *attr,
91+
const char *buf, size_t size)
9092
{
9193
struct pci_dev *pdev = to_pci_dev(dev);
9294
u8 mode;
@@ -99,26 +101,46 @@ static ssize_t workload_hint_enable_store(struct device *dev,
99101

100102
if (mode)
101103
ret = processor_thermal_mbox_interrupt_config(pdev, true,
102-
SOC_WT_PREDICTION_INT_ENABLE_BIT,
104+
enable_bit,
103105
notify_delay);
104106
else
105107
ret = processor_thermal_mbox_interrupt_config(pdev, false,
106-
SOC_WT_PREDICTION_INT_ENABLE_BIT, 0);
108+
enable_bit, 0);
107109

108110
if (ret)
109111
goto ret_enable_store;
110112

111113
ret = size;
112-
wt_enable = mode;
114+
*status = mode;
113115

114116
ret_enable_store:
115117
mutex_unlock(&wt_lock);
116118

117119
return ret;
118120
}
119121

122+
static ssize_t workload_hint_enable_store(struct device *dev, struct device_attribute *attr,
123+
const char *buf, size_t size)
124+
{
125+
return workload_hint_enable(dev, SOC_WT_PREDICTION_INT_ENABLE_BIT, &wt_enable,
126+
attr, buf, size);
127+
}
120128
static DEVICE_ATTR_RW(workload_hint_enable);
121129

130+
static ssize_t workload_slow_hint_enable_show(struct device *dev, struct device_attribute *attr,
131+
char *buf)
132+
{
133+
return sysfs_emit(buf, "%d\n", wt_slow_enable);
134+
}
135+
136+
static ssize_t workload_slow_hint_enable_store(struct device *dev, struct device_attribute *attr,
137+
const char *buf, size_t size)
138+
{
139+
return workload_hint_enable(dev, SOC_WT_SLOW_PREDICTION_INT_ENABLE_BIT, &wt_slow_enable,
140+
attr, buf, size);
141+
}
142+
static DEVICE_ATTR_RW(workload_slow_hint_enable);
143+
122144
static ssize_t notification_delay_ms_show(struct device *dev,
123145
struct device_attribute *attr,
124146
char *buf)
@@ -178,16 +200,35 @@ static ssize_t notification_delay_ms_store(struct device *dev,
178200

179201
static DEVICE_ATTR_RW(notification_delay_ms);
180202

203+
static umode_t workload_hint_attr_visible(struct kobject *kobj, struct attribute *attr, int unused)
204+
{
205+
if (attr != &dev_attr_workload_slow_hint_enable.attr)
206+
return attr->mode;
207+
208+
switch (to_pci_dev(kobj_to_dev(kobj))->device) {
209+
case PCI_DEVICE_ID_INTEL_LNLM_THERMAL:
210+
case PCI_DEVICE_ID_INTEL_MTLP_THERMAL:
211+
case PCI_DEVICE_ID_INTEL_ARL_S_THERMAL:
212+
return 0;
213+
default:
214+
break;
215+
}
216+
217+
return attr->mode;
218+
}
219+
181220
static struct attribute *workload_hint_attrs[] = {
182221
&dev_attr_workload_type_index.attr,
183222
&dev_attr_workload_hint_enable.attr,
223+
&dev_attr_workload_slow_hint_enable.attr,
184224
&dev_attr_notification_delay_ms.attr,
185225
NULL
186226
};
187227

188228
static const struct attribute_group workload_hint_attribute_group = {
189229
.attrs = workload_hint_attrs,
190-
.name = "workload_hint"
230+
.name = "workload_hint",
231+
.is_visible = workload_hint_attr_visible
191232
};
192233

193234
/*

drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include <linux/pci.h>
10+
#include <linux/sysfs.h>
1011
#include "processor_thermal_device.h"
1112

1213
/* List of workload types */
@@ -28,9 +29,9 @@ static ssize_t workload_available_types_show(struct device *dev,
2829
int ret = 0;
2930

3031
while (workload_types[i] != NULL)
31-
ret += sprintf(&buf[ret], "%s ", workload_types[i++]);
32+
ret += sysfs_emit_at(buf, ret, "%s ", workload_types[i++]);
3233

33-
ret += sprintf(&buf[ret], "\n");
34+
ret += sysfs_emit_at(buf, ret, "\n");
3435

3536
return ret;
3637
}
@@ -85,7 +86,7 @@ static ssize_t workload_type_show(struct device *dev,
8586
if (cmd_resp > ARRAY_SIZE(workload_types) - 1)
8687
return -EINVAL;
8788

88-
return sprintf(buf, "%s\n", workload_types[cmd_resp]);
89+
return sysfs_emit(buf, "%s\n", workload_types[cmd_resp]);
8990
}
9091

9192
static DEVICE_ATTR_RW(workload_type);

drivers/thermal/intel/intel_pch_thermal.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ static void intel_pch_thermal_remove(struct pci_dev *pdev)
269269

270270
thermal_zone_device_unregister(ptd->tzd);
271271
iounmap(ptd->hw_base);
272-
pci_set_drvdata(pdev, NULL);
273272
pci_release_regions(pdev);
274273
pci_disable_device(pdev);
275274
}

drivers/thermal/intel/intel_tcc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static u32 get_temp_mask(bool pkg)
172172

173173
/**
174174
* intel_tcc_get_tjmax() - returns the default TCC activation Temperature
175-
* @cpu: cpu that the MSR should be run on, nagative value means any cpu.
175+
* @cpu: cpu that the MSR should be run on, negative value means any cpu.
176176
*
177177
* Get the TjMax value, which is the default thermal throttling or TCC
178178
* activation temperature in degrees C.
@@ -199,7 +199,7 @@ EXPORT_SYMBOL_NS_GPL(intel_tcc_get_tjmax, "INTEL_TCC");
199199

200200
/**
201201
* intel_tcc_get_offset() - returns the TCC Offset value to Tjmax
202-
* @cpu: cpu that the MSR should be run on, nagative value means any cpu.
202+
* @cpu: cpu that the MSR should be run on, negative value means any cpu.
203203
*
204204
* Get the TCC offset value to Tjmax. The effective thermal throttling or TCC
205205
* activation temperature equals "Tjmax" - "TCC Offset", in degrees C.
@@ -224,7 +224,7 @@ EXPORT_SYMBOL_NS_GPL(intel_tcc_get_offset, "INTEL_TCC");
224224

225225
/**
226226
* intel_tcc_set_offset() - set the TCC offset value to Tjmax
227-
* @cpu: cpu that the MSR should be run on, nagative value means any cpu.
227+
* @cpu: cpu that the MSR should be run on, negative value means any cpu.
228228
* @offset: TCC offset value in degree C
229229
*
230230
* Set the TCC Offset value to Tjmax. The effective thermal throttling or TCC
@@ -267,7 +267,7 @@ EXPORT_SYMBOL_NS_GPL(intel_tcc_set_offset, "INTEL_TCC");
267267

268268
/**
269269
* intel_tcc_get_temp() - returns the current temperature
270-
* @cpu: cpu that the MSR should be run on, nagative value means any cpu.
270+
* @cpu: cpu that the MSR should be run on, negative value means any cpu.
271271
* @temp: pointer to the memory for saving cpu temperature.
272272
* @pkg: true: Package Thermal Sensor. false: Core Thermal Sensor.
273273
*

drivers/thermal/intel/intel_tcc_cooling.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,19 @@ static const struct x86_cpu_id tcc_ids[] __initconst = {
6565
X86_MATCH_VFM(INTEL_RAPTORLAKE, NULL),
6666
X86_MATCH_VFM(INTEL_RAPTORLAKE_P, NULL),
6767
X86_MATCH_VFM(INTEL_RAPTORLAKE_S, NULL),
68+
X86_MATCH_VFM(INTEL_PANTHERLAKE_L, NULL),
69+
X86_MATCH_VFM(INTEL_WILDCATLAKE_L, NULL),
70+
X86_MATCH_VFM(INTEL_NOVALAKE, NULL),
71+
X86_MATCH_VFM(INTEL_NOVALAKE_L, NULL),
6872
{}
6973
};
7074

7175
MODULE_DEVICE_TABLE(x86cpu, tcc_ids);
7276

7377
static int __init tcc_cooling_init(void)
7478
{
75-
int ret;
7679
u64 val;
7780
const struct x86_cpu_id *id;
78-
7981
int err;
8082

8183
id = x86_match_cpu(tcc_ids);
@@ -103,10 +105,9 @@ static int __init tcc_cooling_init(void)
103105
tcc_cdev =
104106
thermal_cooling_device_register("TCC Offset", NULL,
105107
&tcc_cooling_ops);
106-
if (IS_ERR(tcc_cdev)) {
107-
ret = PTR_ERR(tcc_cdev);
108-
return ret;
109-
}
108+
if (IS_ERR(tcc_cdev))
109+
return PTR_ERR(tcc_cdev);
110+
110111
return 0;
111112
}
112113

drivers/thermal/intel/therm_throt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/types.h>
2424
#include <linux/init.h>
2525
#include <linux/smp.h>
26+
#include <linux/sysfs.h>
2627
#include <linux/cpu.h>
2728

2829
#include <asm/processor.h>
@@ -144,8 +145,8 @@ static ssize_t therm_throt_device_show_##event##_##name( \
144145
\
145146
preempt_disable(); /* CPU hotplug */ \
146147
if (cpu_online(cpu)) { \
147-
ret = sprintf(buf, "%lu\n", \
148-
per_cpu(thermal_state, cpu).event.name); \
148+
ret = sysfs_emit(buf, "%lu\n", \
149+
per_cpu(thermal_state, cpu).event.name); \
149150
} else \
150151
ret = 0; \
151152
preempt_enable(); \

drivers/thermal/intel/x86_pkg_temp_thermal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ sys_set_trip_temp(struct thermal_zone_device *tzd,
128128
u32 l, h, mask, shift, intr;
129129
int tj_max, val, ret;
130130

131+
if (temp == THERMAL_TEMP_INVALID)
132+
temp = 0;
133+
131134
tj_max = intel_tcc_get_tjmax(zonedev->cpu);
132135
if (tj_max < 0)
133136
return tj_max;

0 commit comments

Comments
 (0)