Skip to content

Commit a499c24

Browse files
spandruvadarafaeljw
authored andcommitted
thermal: int340x: processor_thermal: Enable slow workload type hints
On processors starting from Panther Lake, additional workload type hints are provided. The hardware analyzes workload residencies over an extended period to determine whether the workload classification tends toward idle/battery life states or sustained/performance states. Based on this long-term analysis, it classifies: Power Classification: If the workload exhibits more idle or battery life residencies, it is classified as "power". This is indicated by setting bit 4 of the current workload type. Performance Classification: If the workload exhibits more sustained or performance residencies, it is classified as "performance". This is indicated by clearing bit 4 of the current workload type. This approach enables applications to ignore short-term workload fluctuations and instead respond to longer-term power vs. performance trends. Hints of this type are called slow workload hints. To get notifications for slow workload hints, bit 22 in the thermal mailbox can be used for configuring workload interrupts. It is possible to exclusively enable slow workload hints or enable them in addition to the current workload hints. To enable slow workload hints, a new sysfs attribute is added to the existing workload hint attributes: workload_slow_hint_enable (RW): Write 1 to enable, 0 to disable. Reading this attribute shows the current state. This attribute is not present on any previous generation of processors. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> [ rjw: Dropped redundant local variables, changelog edits ] Link: https://patch.msgid.link/20251218222559.4110027-2-srinivas.pandruvada@linux.intel.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 3e08735 commit a499c24

2 files changed

Lines changed: 52 additions & 8 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_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
/*

0 commit comments

Comments
 (0)