Skip to content

Commit 0506158

Browse files
committed
Merge tag 'thermal-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull thermal control updates from Rafael Wysocki: "These add support for "slow" (long-term trend) workload type hints to the Intel int340x thermal driver and selftests (and enable it for Panther Lake), add support for MT8196 along with DT bindings and for MT7987 to the Mediatek LVTS thermal driver, add support for RZ/T2H and RZ/N2H along with DT bindings to the Renesas rzg3e thermal driver, add support for the Panther Lake, Wildcat Lake and Nova Lake processors to the intel_tcc_cooling driver, fix bugs, make some cosmetic changes including code cleanups and library function substitutions, and update documentation. Specifics: - 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) - Fix CFLAGS and LDFLAGS in the pkg-config libthermal template (Romain Gantois) - Support multiple temp to raw conversion functions in the Mediatek LVTS thermal driver and add MT8196 and MT6991 support to it (Laura Nao) - Add Mediatek LVTS driver support for MT7987 (Frank Wunderlich) - Use the existing HZ_PER_MHZ macro on STM32 (Andy Shevchenko) - Use the existing clamp() macro on BCM2835 (Thorsten Blum) - Make the reset line optional in order to support new Renesas SoCs where it is not available and add support for RZ/T2H and RZ/N2H to the rzg3e thermal driver (Cosmin Tanislav) - Document RZ/V2N TSU in the r9a09g047-tsu DT bindings (Ovidiu Panait) - Fix all kernel-doc warnings in the internal thermal core header file (Randy Dunlap) - Fix a device node reference leak in thermal_of_cm_lookup() (Felix Gu) - Replace some old-style library function calls with ones that are currently recommended in several places in the thermal core and debugfs code (Sumeet Pawnikar, Thorsten Blum) * tag 'thermal-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (34 commits) drivers: thermal: intel: tcc_cooling: Drop redundant local variable thermal/of: Fix reference leak in thermal_of_cm_lookup() thermal: core: thermal_core.h: fix all kernel-doc warnings thermal: intel: x86_pkg_temp_thermal: Handle invalid temperature thermal: renesas: rzg3e: add support for RZ/T2H and RZ/N2H dt-bindings: thermal: r9a09g047-tsu: document RZ/T2H and RZ/N2H thermal: renesas: rzg3e: make calibration value retrieval per-chip thermal: renesas: rzg3e: make min and max temperature per-chip thermal: renesas: rzg3e: make reset optional dt-bindings: thermal: r9a09g047-tsu: Document RZ/V2N TSU thermal/drivers/broadcom: Use clamp to simplify bcm2835_thermal_temp2adc thermal/drivers/stm32: Use predefined HZ_PER_MHZ instead of a custom one thermal/drivers/mediatek/lvts_thermal: Add mt7987 support dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT7987 dt-bindings: nvmem: mediatek: efuse: Add support for MT8196 thermal/drivers/mediatek/lvts_thermal: Add MT8196 support thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data thermal/drivers/mediatek/lvts: Add support for ATP mode thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant thermal/drivers/mediatek/lvts: Add platform ops to support alternative conversion logic ...
2 parents 9b1b3dc + 8035d70 commit 0506158

26 files changed

Lines changed: 651 additions & 165 deletions

Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ properties:
2828
- enum:
2929
- mediatek,mt8188-efuse
3030
- mediatek,mt8189-efuse
31+
- mediatek,mt8196-efuse
3132
- const: mediatek,mt8186-efuse
3233
- const: mediatek,mt8186-efuse
3334

Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ description: |
1818
properties:
1919
compatible:
2020
enum:
21+
- mediatek,mt7987-lvts-ap
2122
- mediatek,mt7988-lvts-ap
2223
- mediatek,mt8186-lvts
2324
- mediatek,mt8188-lvts-ap
@@ -26,6 +27,8 @@ properties:
2627
- mediatek,mt8192-lvts-mcu
2728
- mediatek,mt8195-lvts-ap
2829
- mediatek,mt8195-lvts-mcu
30+
- mediatek,mt8196-lvts-ap
31+
- mediatek,mt8196-lvts-mcu
2932

3033
reg:
3134
maxItems: 1

Documentation/devicetree/bindings/thermal/renesas,r9a09g047-tsu.yaml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ description:
1717
properties:
1818
compatible:
1919
oneOf:
20-
- const: renesas,r9a09g047-tsu # RZ/G3E
20+
- enum:
21+
- renesas,r9a09g047-tsu # RZ/G3E
22+
- renesas,r9a09g077-tsu # RZ/T2H
2123
- items:
22-
- const: renesas,r9a09g057-tsu # RZ/V2H
24+
- enum:
25+
- renesas,r9a09g056-tsu # RZ/V2N
26+
- renesas,r9a09g057-tsu # RZ/V2H
2327
- const: renesas,r9a09g047-tsu # RZ/G3E
28+
- items:
29+
- const: renesas,r9a09g087-tsu # RZ/N2H
30+
- const: renesas,r9a09g077-tsu # RZ/T2H
2431

2532
reg:
2633
maxItems: 1
@@ -63,12 +70,31 @@ required:
6370
- compatible
6471
- reg
6572
- clocks
66-
- resets
6773
- power-domains
6874
- interrupts
6975
- interrupt-names
7076
- "#thermal-sensor-cells"
71-
- renesas,tsu-trim
77+
78+
allOf:
79+
- if:
80+
properties:
81+
compatible:
82+
contains:
83+
const: renesas,r9a09g047-tsu
84+
then:
85+
required:
86+
- resets
87+
- renesas,tsu-trim
88+
89+
- if:
90+
properties:
91+
compatible:
92+
contains:
93+
const: renesas,r9a09g077-tsu
94+
then:
95+
properties:
96+
resets: false
97+
renesas,tsu-trim: false
7298

7399
additionalProperties: false
74100

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/broadcom/bcm2835_thermal.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/err.h>
1212
#include <linux/io.h>
1313
#include <linux/kernel.h>
14+
#include <linux/minmax.h>
1415
#include <linux/module.h>
1516
#include <linux/of.h>
1617
#include <linux/of_address.h>
@@ -80,12 +81,7 @@ static int bcm2835_thermal_temp2adc(int temp, int offset, int slope)
8081
temp -= offset;
8182
temp /= slope;
8283

83-
if (temp < 0)
84-
temp = 0;
85-
if (temp >= BIT(BCM2835_TS_TSENSSTAT_DATA_BITS))
86-
temp = BIT(BCM2835_TS_TSENSSTAT_DATA_BITS) - 1;
87-
88-
return temp;
84+
return clamp(temp, 0, (int)BIT(BCM2835_TS_TSENSSTAT_DATA_BITS) - 1);
8985
}
9086

9187
static int bcm2835_thermal_get_temp(struct thermal_zone_device *tz, int *temp)

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
}

0 commit comments

Comments
 (0)