* [PATCH 0/5] thermal: intel: int340x: New power slider interface
@ 2025-08-13 18:55 Srinivas Pandruvada
2025-08-13 18:55 ` [PATCH 1/5] thermal: intel: int340x: Add support for power slider Srinivas Pandruvada
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Srinivas Pandruvada @ 2025-08-13 18:55 UTC (permalink / raw)
To: rafael, daniel.lezcano, lukasz.luba
Cc: linux-pm, linux-kernel, Srinivas Pandruvada
Using the Linux platform-profile API, add support for system-wide energy
performance preferences. This feature is enabled for Panther Lake CPUs.
Srinivas Pandruvada (5):
thermal: intel: int340x: Add support for power slider
thermal: intel: int340x: Enable power slider interface
thermal: intel: int340x: Add module parameter for balanced Slider
thermal: intel: int340x: Add module parameter to change slider offset
thermal: intel: int340x: Add suspend and resume callbacks
drivers/thermal/intel/int340x_thermal/Kconfig | 1 +
.../thermal/intel/int340x_thermal/Makefile | 1 +
.../processor_thermal_device.c | 20 ++
.../processor_thermal_device.h | 6 +
.../processor_thermal_device_pci.c | 3 +-
.../processor_thermal_soc_slider.c | 268 ++++++++++++++++++
6 files changed, 298 insertions(+), 1 deletion(-)
create mode 100644 drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/5] thermal: intel: int340x: Add support for power slider
2025-08-13 18:55 [PATCH 0/5] thermal: intel: int340x: New power slider interface Srinivas Pandruvada
@ 2025-08-13 18:55 ` Srinivas Pandruvada
2025-08-22 12:43 ` Rafael J. Wysocki
2025-08-13 18:55 ` [PATCH 2/5] thermal: intel: int340x: Enable power slider interface Srinivas Pandruvada
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Srinivas Pandruvada @ 2025-08-13 18:55 UTC (permalink / raw)
To: rafael, daniel.lezcano, lukasz.luba
Cc: linux-pm, linux-kernel, Srinivas Pandruvada
Add support for system wide energy performance preference using a SoC
slider interface defined via processor thermal PCI device MMIO space.
Using Linux platform-profile class API, register a new platform profile.
Provide three platform power profile choices:
"performance", "balanced" and "low-power".
Profile sysfs is located at:
/sys/class/platform-profile/platform-profile-*
where attribute "name" is presented as "SoC Power Slider".
At boot by default the slider is set to balanced mode. This profile is
changed by user space based on user preference via power profile daemon
or directly writing to the "profile" sysfs attribute.
Add a CPU model specific processor thermal device feature
PROC_THERMAL_FEATURE_SOC_POWER_SLIDER. When enabled for a CPU model,
slider interface is registered.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/thermal/intel/int340x_thermal/Kconfig | 1 +
.../thermal/intel/int340x_thermal/Makefile | 1 +
.../processor_thermal_device.c | 10 +
.../processor_thermal_device.h | 4 +
.../processor_thermal_soc_slider.c | 171 ++++++++++++++++++
5 files changed, 187 insertions(+)
create mode 100644 drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
diff --git a/drivers/thermal/intel/int340x_thermal/Kconfig b/drivers/thermal/intel/int340x_thermal/Kconfig
index 4c699f0896b5..4ced7bdcd62c 100644
--- a/drivers/thermal/intel/int340x_thermal/Kconfig
+++ b/drivers/thermal/intel/int340x_thermal/Kconfig
@@ -12,6 +12,7 @@ config INT340X_THERMAL
select ACPI_THERMAL_LIB
select INTEL_SOC_DTS_IOSF_CORE
select INTEL_TCC
+ select ACPI_PLATFORM_PROFILE
select PROC_THERMAL_MMIO_RAPL if POWERCAP
help
Newer laptops and tablets that use ACPI may have thermal sensors and
diff --git a/drivers/thermal/intel/int340x_thermal/Makefile b/drivers/thermal/intel/int340x_thermal/Makefile
index 184318d1792b..436be34b21a9 100644
--- a/drivers/thermal/intel/int340x_thermal/Makefile
+++ b/drivers/thermal/intel/int340x_thermal/Makefile
@@ -14,5 +14,6 @@ obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_mbox.o
obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_wt_req.o
obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_wt_hint.o
obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_power_floor.o
+obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_soc_slider.o
obj-$(CONFIG_INT3406_THERMAL) += int3406_thermal.o
obj-$(CONFIG_ACPI_THERMAL_REL) += acpi_thermal_rel.o
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
index 29fcece48cad..4aea5c9baae9 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
@@ -432,8 +432,18 @@ int proc_thermal_mmio_add(struct pci_dev *pdev,
}
}
+ if (feature_mask & PROC_THERMAL_FEATURE_SOC_POWER_SLIDER) {
+ ret = proc_thermal_soc_power_slider_add(pdev, proc_priv);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to add soc power efficiency slider\n");
+ goto err_rem_wlt;
+ }
+ }
+
return 0;
+err_rem_wlt:
+ proc_thermal_wt_hint_remove(pdev);
err_rem_rfim:
proc_thermal_rfim_remove(pdev);
err_rem_ptc:
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
index 49398794124a..ba3f64742f2f 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
@@ -69,6 +69,7 @@ struct rapl_mmio_regs {
#define PROC_THERMAL_FEATURE_POWER_FLOOR 0x40
#define PROC_THERMAL_FEATURE_MSI_SUPPORT 0x80
#define PROC_THERMAL_FEATURE_PTC 0x100
+#define PROC_THERMAL_FEATURE_SOC_POWER_SLIDER 0x200
#if IS_ENABLED(CONFIG_PROC_THERMAL_MMIO_RAPL)
int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
@@ -127,4 +128,7 @@ int proc_thermal_mmio_add(struct pci_dev *pdev,
void proc_thermal_mmio_remove(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
int proc_thermal_ptc_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
void proc_thermal_ptc_remove(struct pci_dev *pdev);
+
+int proc_thermal_soc_power_slider_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
+
#endif
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
new file mode 100644
index 000000000000..c492ee937dc7
--- /dev/null
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
@@ -0,0 +1,171 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Processor Thermal Device Interface for Reading and Writing
+ * SoC Power Slider Values from User Space.
+ *
+ * Operation:
+ * The SOC_EFFICIENCY_SLIDER_0_0_0_MCHBAR register is accessed
+ * using the MMIO (Memory-Mapped I/O) interface with an MMIO offset of 0x5B38.
+ * Although this register is 64 bits wide, only bits 7:0 are used,
+ * and the other bits remain unchanged.
+ *
+ * Bit definitions
+ *
+ * Bits 2:0 (Slider value):
+ * The SoC optimizer slider value indicates the system wide energy performance
+ * hint. The slider has no specific units and ranges from 0 (highest
+ * performance) to 6 (highest energy efficiency). Value of 7 is reserved.
+ * Bits 3 : Reserved
+ * Bits 6:4 (Offset)
+ * Offset allows the SoC to automatically switch slider position in range
+ * [slider value (bits 2:0) + offset] to improve power efficiency based on
+ * internal SoC algorithms.
+ * Bit 7 (Enable):
+ * If this bit is set, the SoC Optimization sliders will be processed by the
+ * SoC firmware.
+ *
+ * Copyright (c) 2025, Intel Corporation.
+ */
+
+#include <linux/bitfield.h>
+#include <linux/pci.h>
+#include <linux/platform_profile.h>
+#include "processor_thermal_device.h"
+
+#define SOC_POWER_SLIDER_OFFSET 0x5B38
+
+enum power_slider_preference {
+ SOC_POWER_SLIDER_PERFORMANCE,
+ SOC_POWER_SLIDER_BALANCE,
+ SOC_POWER_SLIDER_POWERSAVE,
+};
+
+#define SOC_SLIDER_VALUE_MINIMUM 0x00
+#define SOC_SLIDER_VALUE_MAXIMUM 0x06
+#define SOC_SLIDER_VALUE_BALANCE 0x03
+
+static u8 slider_values[] = {
+ [SOC_POWER_SLIDER_PERFORMANCE] = SOC_SLIDER_VALUE_MINIMUM,
+ [SOC_POWER_SLIDER_BALANCE] = SOC_SLIDER_VALUE_BALANCE,
+ [SOC_POWER_SLIDER_POWERSAVE] = SOC_SLIDER_VALUE_MAXIMUM,
+};
+
+/* Convert from platform power profile option to SoC slider value */
+static int convert_profile_to_power_slider(enum platform_profile_option profile)
+{
+ switch (profile) {
+ case PLATFORM_PROFILE_LOW_POWER:
+ return slider_values[SOC_POWER_SLIDER_POWERSAVE];
+ case PLATFORM_PROFILE_BALANCED:
+ return slider_values[SOC_POWER_SLIDER_BALANCE];
+ case PLATFORM_PROFILE_PERFORMANCE:
+ return slider_values[SOC_POWER_SLIDER_PERFORMANCE];
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return -EOPNOTSUPP;
+}
+
+/* Convert to platform power profile option from SoC slider values */
+static int convert_power_slider_to_profile(u8 slider)
+{
+ if (slider == slider_values[SOC_POWER_SLIDER_PERFORMANCE])
+ return PLATFORM_PROFILE_PERFORMANCE;
+ if (slider == slider_values[SOC_POWER_SLIDER_BALANCE])
+ return PLATFORM_PROFILE_BALANCED;
+ if (slider == slider_values[SOC_POWER_SLIDER_POWERSAVE])
+ return PLATFORM_PROFILE_LOW_POWER;
+
+ return -EOPNOTSUPP;
+}
+
+#define SLIDER_MASK GENMASK_ULL(2, 0)
+#define SLIDER_ENABLE_BIT 7
+
+static void set_soc_power_profile(struct proc_thermal_device *proc_priv, int slider)
+{
+ u64 val;
+
+ val = readq(proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
+ val &= ~SLIDER_MASK;
+ val |= FIELD_PREP(SLIDER_MASK, slider);
+ val |= BIT(SLIDER_ENABLE_BIT);
+ writeq(val, proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
+}
+
+/* profile get/set callbacks are called with a profile lock, so no need for local locks */
+
+static int power_slider_platform_profile_set(struct device *dev,
+ enum platform_profile_option profile)
+{
+ struct proc_thermal_device *proc_priv;
+ int slider;
+
+ proc_priv = dev_get_drvdata(dev);
+ if (!proc_priv)
+ return -EOPNOTSUPP;
+
+ slider = convert_profile_to_power_slider(profile);
+ if (slider < 0)
+ return slider;
+
+ set_soc_power_profile(proc_priv, slider);
+
+ return 0;
+}
+
+static int power_slider_platform_profile_get(struct device *dev,
+ enum platform_profile_option *profile)
+{
+ struct proc_thermal_device *proc_priv;
+ int slider, ret;
+ u64 val;
+
+ proc_priv = dev_get_drvdata(dev);
+ if (!proc_priv)
+ return -EOPNOTSUPP;
+
+ val = readq(proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
+ slider = FIELD_GET(SLIDER_MASK, val);
+
+ ret = convert_power_slider_to_profile(slider);
+ if (ret < 0)
+ return ret;
+
+ *profile = ret;
+
+ return 0;
+}
+
+static int power_slider_platform_profile_probe(void *drvdata, unsigned long *choices)
+{
+ set_bit(PLATFORM_PROFILE_LOW_POWER, choices);
+ set_bit(PLATFORM_PROFILE_BALANCED, choices);
+ set_bit(PLATFORM_PROFILE_PERFORMANCE, choices);
+
+ return 0;
+}
+
+static const struct platform_profile_ops power_slider_platform_profile_ops = {
+ .probe = power_slider_platform_profile_probe,
+ .profile_get = power_slider_platform_profile_get,
+ .profile_set = power_slider_platform_profile_set,
+};
+
+int proc_thermal_soc_power_slider_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv)
+{
+ struct device *ppdev;
+
+ set_soc_power_profile(proc_priv, slider_values[SOC_POWER_SLIDER_BALANCE]);
+
+ ppdev = devm_platform_profile_register(&pdev->dev, "SoC Power Slider", proc_priv,
+ &power_slider_platform_profile_ops);
+
+ return PTR_ERR_OR_ZERO(ppdev);
+}
+EXPORT_SYMBOL_NS_GPL(proc_thermal_soc_power_slider_add, "INT340X_THERMAL");
+
+MODULE_IMPORT_NS("INT340X_THERMAL");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Processor Thermal Power Slider Interface");
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/5] thermal: intel: int340x: Enable power slider interface
2025-08-13 18:55 [PATCH 0/5] thermal: intel: int340x: New power slider interface Srinivas Pandruvada
2025-08-13 18:55 ` [PATCH 1/5] thermal: intel: int340x: Add support for power slider Srinivas Pandruvada
@ 2025-08-13 18:55 ` Srinivas Pandruvada
2025-08-22 12:47 ` Rafael J. Wysocki
2025-08-13 18:55 ` [PATCH 3/5] thermal: intel: int340x: Add module parameter for balanced Slider Srinivas Pandruvada
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Srinivas Pandruvada @ 2025-08-13 18:55 UTC (permalink / raw)
To: rafael, daniel.lezcano, lukasz.luba
Cc: linux-pm, linux-kernel, Srinivas Pandruvada
Enable power slider interface for Panther Lake.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
.../intel/int340x_thermal/processor_thermal_device_pci.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
index d4d7e8e147d2..e2471768d355 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
@@ -498,7 +498,8 @@ static const struct pci_device_id proc_thermal_pci_ids[] = {
{ PCI_DEVICE_DATA(INTEL, PTL_THERMAL, PROC_THERMAL_FEATURE_RAPL |
PROC_THERMAL_FEATURE_DLVR | PROC_THERMAL_FEATURE_DVFS |
PROC_THERMAL_FEATURE_MSI_SUPPORT | PROC_THERMAL_FEATURE_WT_HINT |
- PROC_THERMAL_FEATURE_POWER_FLOOR | PROC_THERMAL_FEATURE_PTC) },
+ PROC_THERMAL_FEATURE_POWER_FLOOR | PROC_THERMAL_FEATURE_PTC |
+ PROC_THERMAL_FEATURE_SOC_POWER_SLIDER) },
{ PCI_DEVICE_DATA(INTEL, WCL_THERMAL, PROC_THERMAL_FEATURE_MSI_SUPPORT |
PROC_THERMAL_FEATURE_RAPL | PROC_THERMAL_FEATURE_DLVR |
PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_WT_HINT |
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/5] thermal: intel: int340x: Add module parameter for balanced Slider
2025-08-13 18:55 [PATCH 0/5] thermal: intel: int340x: New power slider interface Srinivas Pandruvada
2025-08-13 18:55 ` [PATCH 1/5] thermal: intel: int340x: Add support for power slider Srinivas Pandruvada
2025-08-13 18:55 ` [PATCH 2/5] thermal: intel: int340x: Enable power slider interface Srinivas Pandruvada
@ 2025-08-13 18:55 ` Srinivas Pandruvada
2025-08-22 12:50 ` Rafael J. Wysocki
2025-08-13 18:55 ` [PATCH 4/5] thermal: intel: int340x: Add module parameter to change slider offset Srinivas Pandruvada
2025-08-13 18:55 ` [PATCH 5/5] thermal: intel: int340x: Add suspend and resume callbacks Srinivas Pandruvada
4 siblings, 1 reply; 11+ messages in thread
From: Srinivas Pandruvada @ 2025-08-13 18:55 UTC (permalink / raw)
To: rafael, daniel.lezcano, lukasz.luba
Cc: linux-pm, linux-kernel, Srinivas Pandruvada
By default, the SoC slider value for the "balanced" platform profile is
set to 3. A new module parameter is introduced to allow users to change
this default value. After modifying the module parameter, users must call
an update to the "profile" sysfs attribute for the change to take effect.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
.../processor_thermal_soc_slider.c | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
index c492ee937dc7..ffc538c9b9e3 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
@@ -50,6 +50,43 @@ static u8 slider_values[] = {
[SOC_POWER_SLIDER_POWERSAVE] = SOC_SLIDER_VALUE_MAXIMUM,
};
+/* Lock to protect module param updates */
+static DEFINE_MUTEX(slider_param_lock);
+
+static int slider_balanced_param = SOC_SLIDER_VALUE_BALANCE;
+
+static int slider_def_balance_set(const char *arg, const struct kernel_param *kp)
+{
+ u8 slider_val;
+ int ret;
+
+ guard(mutex)(&slider_param_lock);
+
+ ret = kstrtou8(arg, 16, &slider_val);
+ if (!ret) {
+ if (slider_val > SOC_SLIDER_VALUE_MAXIMUM)
+ return -EINVAL;
+
+ slider_balanced_param = slider_val;
+ }
+
+ return ret;
+}
+
+static int slider_def_balance_get(char *buf, const struct kernel_param *kp)
+{
+ guard(mutex)(&slider_param_lock);
+ return sysfs_emit(buf, "%02x\n", slider_values[SOC_POWER_SLIDER_BALANCE]);
+}
+
+static const struct kernel_param_ops slider_def_balance_ops = {
+ .set = slider_def_balance_set,
+ .get = slider_def_balance_get,
+};
+
+module_param_cb(slider_balance, &slider_def_balance_ops, NULL, 0644);
+MODULE_PARM_DESC(slider_balance, "Set slider default value for balance.");
+
/* Convert from platform power profile option to SoC slider value */
static int convert_profile_to_power_slider(enum platform_profile_option profile)
{
@@ -106,6 +143,10 @@ static int power_slider_platform_profile_set(struct device *dev,
if (!proc_priv)
return -EOPNOTSUPP;
+ guard(mutex)(&slider_param_lock);
+
+ slider_values[SOC_POWER_SLIDER_BALANCE] = slider_balanced_param;
+
slider = convert_profile_to_power_slider(profile);
if (slider < 0)
return slider;
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/5] thermal: intel: int340x: Add module parameter to change slider offset
2025-08-13 18:55 [PATCH 0/5] thermal: intel: int340x: New power slider interface Srinivas Pandruvada
` (2 preceding siblings ...)
2025-08-13 18:55 ` [PATCH 3/5] thermal: intel: int340x: Add module parameter for balanced Slider Srinivas Pandruvada
@ 2025-08-13 18:55 ` Srinivas Pandruvada
2025-08-22 13:00 ` Rafael J. Wysocki
2025-08-13 18:55 ` [PATCH 5/5] thermal: intel: int340x: Add suspend and resume callbacks Srinivas Pandruvada
4 siblings, 1 reply; 11+ messages in thread
From: Srinivas Pandruvada @ 2025-08-13 18:55 UTC (permalink / raw)
To: rafael, daniel.lezcano, lukasz.luba
Cc: linux-pm, linux-kernel, Srinivas Pandruvada
The slider offset value allows the SoC to automatically switch slider
positions in range [SOC_SLIDER … (SOC_SLIDER + slider offset)] based on
internal algorithms to improve power efficiency.
By default, the SoC slider offset is set to 0. This means that SoC is not
allowed to switch slider position.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
.../processor_thermal_soc_slider.c | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
index ffc538c9b9e3..bd4ff26a488b 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
@@ -87,6 +87,40 @@ static const struct kernel_param_ops slider_def_balance_ops = {
module_param_cb(slider_balance, &slider_def_balance_ops, NULL, 0644);
MODULE_PARM_DESC(slider_balance, "Set slider default value for balance.");
+static u8 slider_offset;
+
+static int slider_def_offset_set(const char *arg, const struct kernel_param *kp)
+{
+ u8 offset;
+ int ret;
+
+ guard(mutex)(&slider_param_lock);
+
+ ret = kstrtou8(arg, 16, &offset);
+ if (!ret) {
+ if (offset > SOC_SLIDER_VALUE_MAXIMUM)
+ return -EINVAL;
+
+ slider_offset = offset;
+ }
+
+ return ret;
+}
+
+static int slider_def_offset_get(char *buf, const struct kernel_param *kp)
+{
+ guard(mutex)(&slider_param_lock);
+ return sysfs_emit(buf, "%02x\n", slider_offset);
+}
+
+static const struct kernel_param_ops slider_offset_ops = {
+ .set = slider_def_offset_set,
+ .get = slider_def_offset_get,
+};
+
+module_param_cb(slider_offset, &slider_offset_ops, NULL, 0644);
+MODULE_PARM_DESC(slider_offset, "Set slider offset.");
+
/* Convert from platform power profile option to SoC slider value */
static int convert_profile_to_power_slider(enum platform_profile_option profile)
{
@@ -120,6 +154,8 @@ static int convert_power_slider_to_profile(u8 slider)
#define SLIDER_MASK GENMASK_ULL(2, 0)
#define SLIDER_ENABLE_BIT 7
+#define SLIDER_OFFSET_MASK GENMASK_ULL(6, 4)
+
static void set_soc_power_profile(struct proc_thermal_device *proc_priv, int slider)
{
u64 val;
@@ -128,6 +164,11 @@ static void set_soc_power_profile(struct proc_thermal_device *proc_priv, int sli
val &= ~SLIDER_MASK;
val |= FIELD_PREP(SLIDER_MASK, slider);
val |= BIT(SLIDER_ENABLE_BIT);
+
+ /* Set the slider offset from module params */
+ val &= ~SLIDER_OFFSET_MASK;
+ val |= FIELD_PREP(SLIDER_OFFSET_MASK, slider_offset);
+
writeq(val, proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/5] thermal: intel: int340x: Add suspend and resume callbacks
2025-08-13 18:55 [PATCH 0/5] thermal: intel: int340x: New power slider interface Srinivas Pandruvada
` (3 preceding siblings ...)
2025-08-13 18:55 ` [PATCH 4/5] thermal: intel: int340x: Add module parameter to change slider offset Srinivas Pandruvada
@ 2025-08-13 18:55 ` Srinivas Pandruvada
2025-08-22 13:02 ` Rafael J. Wysocki
4 siblings, 1 reply; 11+ messages in thread
From: Srinivas Pandruvada @ 2025-08-13 18:55 UTC (permalink / raw)
To: rafael, daniel.lezcano, lukasz.luba
Cc: linux-pm, linux-kernel, Srinivas Pandruvada
During system suspend callback save slider register and restore during
resume callback.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
.../int340x_thermal/processor_thermal_device.c | 10 ++++++++++
.../int340x_thermal/processor_thermal_device.h | 2 ++
.../processor_thermal_soc_slider.c | 15 +++++++++++++++
3 files changed, 27 insertions(+)
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
index 4aea5c9baae9..a772c187bedb 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
@@ -338,10 +338,17 @@ static int tcc_offset_save = -1;
int proc_thermal_suspend(struct device *dev)
{
+ struct proc_thermal_device *proc_dev;
+
tcc_offset_save = intel_tcc_get_offset(-1);
if (tcc_offset_save < 0)
dev_warn(dev, "failed to save offset (%d)\n", tcc_offset_save);
+ proc_dev = dev_get_drvdata(dev);
+
+ if (proc_dev->mmio_feature_mask & PROC_THERMAL_FEATURE_SOC_POWER_SLIDER)
+ proc_thermal_soc_power_slider_suspend(proc_dev);
+
return 0;
}
EXPORT_SYMBOL_GPL(proc_thermal_suspend);
@@ -357,6 +364,9 @@ int proc_thermal_resume(struct device *dev)
if (tcc_offset_save >= 0)
intel_tcc_set_offset(-1, tcc_offset_save);
+ if (proc_dev->mmio_feature_mask & PROC_THERMAL_FEATURE_SOC_POWER_SLIDER)
+ proc_thermal_soc_power_slider_resume(proc_dev);
+
return 0;
}
EXPORT_SYMBOL_GPL(proc_thermal_resume);
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
index ba3f64742f2f..30760475102f 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
@@ -130,5 +130,7 @@ int proc_thermal_ptc_add(struct pci_dev *pdev, struct proc_thermal_device *proc_
void proc_thermal_ptc_remove(struct pci_dev *pdev);
int proc_thermal_soc_power_slider_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
+void proc_thermal_soc_power_slider_suspend(struct proc_thermal_device *proc_priv);
+void proc_thermal_soc_power_slider_resume(struct proc_thermal_device *proc_priv);
#endif
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
index bd4ff26a488b..268bf9124d95 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
@@ -248,6 +248,21 @@ int proc_thermal_soc_power_slider_add(struct pci_dev *pdev, struct proc_thermal_
}
EXPORT_SYMBOL_NS_GPL(proc_thermal_soc_power_slider_add, "INT340X_THERMAL");
+static u64 soc_slider_save;
+
+void proc_thermal_soc_power_slider_suspend(struct proc_thermal_device *proc_priv)
+{
+ soc_slider_save = readq(proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
+
+}
+EXPORT_SYMBOL_NS_GPL(proc_thermal_soc_power_slider_suspend, "INT340X_THERMAL");
+
+void proc_thermal_soc_power_slider_resume(struct proc_thermal_device *proc_priv)
+{
+ writeq(soc_slider_save, proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
+}
+EXPORT_SYMBOL_NS_GPL(proc_thermal_soc_power_slider_resume, "INT340X_THERMAL");
+
MODULE_IMPORT_NS("INT340X_THERMAL");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Processor Thermal Power Slider Interface");
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/5] thermal: intel: int340x: Add support for power slider
2025-08-13 18:55 ` [PATCH 1/5] thermal: intel: int340x: Add support for power slider Srinivas Pandruvada
@ 2025-08-22 12:43 ` Rafael J. Wysocki
0 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2025-08-22 12:43 UTC (permalink / raw)
To: Srinivas Pandruvada
Cc: rafael, daniel.lezcano, lukasz.luba, linux-pm, linux-kernel
On Wed, Aug 13, 2025 at 8:55 PM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> Add support for system wide energy performance preference using a SoC
> slider interface defined via processor thermal PCI device MMIO space.
>
> Using Linux platform-profile class API, register a new platform profile.
> Provide three platform power profile choices:
> "performance", "balanced" and "low-power".
>
> Profile sysfs is located at:
> /sys/class/platform-profile/platform-profile-*
> where attribute "name" is presented as "SoC Power Slider".
>
> At boot by default the slider is set to balanced mode. This profile is
> changed by user space based on user preference via power profile daemon
> or directly writing to the "profile" sysfs attribute.
>
> Add a CPU model specific processor thermal device feature
> PROC_THERMAL_FEATURE_SOC_POWER_SLIDER. When enabled for a CPU model,
> slider interface is registered.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
LGTM overall, a few minor nits below.
> ---
> drivers/thermal/intel/int340x_thermal/Kconfig | 1 +
> .../thermal/intel/int340x_thermal/Makefile | 1 +
> .../processor_thermal_device.c | 10 +
> .../processor_thermal_device.h | 4 +
> .../processor_thermal_soc_slider.c | 171 ++++++++++++++++++
> 5 files changed, 187 insertions(+)
> create mode 100644 drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
>
> diff --git a/drivers/thermal/intel/int340x_thermal/Kconfig b/drivers/thermal/intel/int340x_thermal/Kconfig
> index 4c699f0896b5..4ced7bdcd62c 100644
> --- a/drivers/thermal/intel/int340x_thermal/Kconfig
> +++ b/drivers/thermal/intel/int340x_thermal/Kconfig
> @@ -12,6 +12,7 @@ config INT340X_THERMAL
> select ACPI_THERMAL_LIB
> select INTEL_SOC_DTS_IOSF_CORE
> select INTEL_TCC
> + select ACPI_PLATFORM_PROFILE
> select PROC_THERMAL_MMIO_RAPL if POWERCAP
> help
> Newer laptops and tablets that use ACPI may have thermal sensors and
> diff --git a/drivers/thermal/intel/int340x_thermal/Makefile b/drivers/thermal/intel/int340x_thermal/Makefile
> index 184318d1792b..436be34b21a9 100644
> --- a/drivers/thermal/intel/int340x_thermal/Makefile
> +++ b/drivers/thermal/intel/int340x_thermal/Makefile
> @@ -14,5 +14,6 @@ obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_mbox.o
> obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_wt_req.o
> obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_wt_hint.o
> obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_power_floor.o
> +obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_soc_slider.o
> obj-$(CONFIG_INT3406_THERMAL) += int3406_thermal.o
> obj-$(CONFIG_ACPI_THERMAL_REL) += acpi_thermal_rel.o
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> index 29fcece48cad..4aea5c9baae9 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> @@ -432,8 +432,18 @@ int proc_thermal_mmio_add(struct pci_dev *pdev,
> }
> }
>
> + if (feature_mask & PROC_THERMAL_FEATURE_SOC_POWER_SLIDER) {
> + ret = proc_thermal_soc_power_slider_add(pdev, proc_priv);
> + if (ret) {
> + dev_err(&pdev->dev, "failed to add soc power efficiency slider\n");
Maybe dev_info()? I'm not sure if this failure is serious enough for dev_err().
> + goto err_rem_wlt;
> + }
> + }
> +
> return 0;
>
> +err_rem_wlt:
> + proc_thermal_wt_hint_remove(pdev);
> err_rem_rfim:
> proc_thermal_rfim_remove(pdev);
> err_rem_ptc:
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
> index 49398794124a..ba3f64742f2f 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
> @@ -69,6 +69,7 @@ struct rapl_mmio_regs {
> #define PROC_THERMAL_FEATURE_POWER_FLOOR 0x40
> #define PROC_THERMAL_FEATURE_MSI_SUPPORT 0x80
> #define PROC_THERMAL_FEATURE_PTC 0x100
> +#define PROC_THERMAL_FEATURE_SOC_POWER_SLIDER 0x200
>
> #if IS_ENABLED(CONFIG_PROC_THERMAL_MMIO_RAPL)
> int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
> @@ -127,4 +128,7 @@ int proc_thermal_mmio_add(struct pci_dev *pdev,
> void proc_thermal_mmio_remove(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
> int proc_thermal_ptc_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
> void proc_thermal_ptc_remove(struct pci_dev *pdev);
> +
> +int proc_thermal_soc_power_slider_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
> +
> #endif
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
> new file mode 100644
> index 000000000000..c492ee937dc7
> --- /dev/null
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
> @@ -0,0 +1,171 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Processor Thermal Device Interface for Reading and Writing
> + * SoC Power Slider Values from User Space.
> + *
> + * Operation:
> + * The SOC_EFFICIENCY_SLIDER_0_0_0_MCHBAR register is accessed
> + * using the MMIO (Memory-Mapped I/O) interface with an MMIO offset of 0x5B38.
> + * Although this register is 64 bits wide, only bits 7:0 are used,
> + * and the other bits remain unchanged.
> + *
> + * Bit definitions
> + *
> + * Bits 2:0 (Slider value):
> + * The SoC optimizer slider value indicates the system wide energy performance
> + * hint. The slider has no specific units and ranges from 0 (highest
> + * performance) to 6 (highest energy efficiency). Value of 7 is reserved.
> + * Bits 3 : Reserved
> + * Bits 6:4 (Offset)
> + * Offset allows the SoC to automatically switch slider position in range
> + * [slider value (bits 2:0) + offset] to improve power efficiency based on
> + * internal SoC algorithms.
> + * Bit 7 (Enable):
> + * If this bit is set, the SoC Optimization sliders will be processed by the
> + * SoC firmware.
> + *
> + * Copyright (c) 2025, Intel Corporation.
> + */
> +
> +#include <linux/bitfield.h>
> +#include <linux/pci.h>
> +#include <linux/platform_profile.h>
> +#include "processor_thermal_device.h"
> +
> +#define SOC_POWER_SLIDER_OFFSET 0x5B38
> +
> +enum power_slider_preference {
> + SOC_POWER_SLIDER_PERFORMANCE,
> + SOC_POWER_SLIDER_BALANCE,
> + SOC_POWER_SLIDER_POWERSAVE,
> +};
> +
> +#define SOC_SLIDER_VALUE_MINIMUM 0x00
> +#define SOC_SLIDER_VALUE_MAXIMUM 0x06
> +#define SOC_SLIDER_VALUE_BALANCE 0x03
I would sort these by value, lowest to highest.
> +
> +static u8 slider_values[] = {
> + [SOC_POWER_SLIDER_PERFORMANCE] = SOC_SLIDER_VALUE_MINIMUM,
> + [SOC_POWER_SLIDER_BALANCE] = SOC_SLIDER_VALUE_BALANCE,
> + [SOC_POWER_SLIDER_POWERSAVE] = SOC_SLIDER_VALUE_MAXIMUM,
> +};
> +
> +/* Convert from platform power profile option to SoC slider value */
> +static int convert_profile_to_power_slider(enum platform_profile_option profile)
> +{
> + switch (profile) {
> + case PLATFORM_PROFILE_LOW_POWER:
> + return slider_values[SOC_POWER_SLIDER_POWERSAVE];
> + case PLATFORM_PROFILE_BALANCED:
> + return slider_values[SOC_POWER_SLIDER_BALANCE];
> + case PLATFORM_PROFILE_PERFORMANCE:
> + return slider_values[SOC_POWER_SLIDER_PERFORMANCE];
> + default:
> + return -EOPNOTSUPP;
I would use break here.
> + }
> +
> + return -EOPNOTSUPP;
> +}
> +
> +/* Convert to platform power profile option from SoC slider values */
> +static int convert_power_slider_to_profile(u8 slider)
> +{
> + if (slider == slider_values[SOC_POWER_SLIDER_PERFORMANCE])
> + return PLATFORM_PROFILE_PERFORMANCE;
> + if (slider == slider_values[SOC_POWER_SLIDER_BALANCE])
> + return PLATFORM_PROFILE_BALANCED;
> + if (slider == slider_values[SOC_POWER_SLIDER_POWERSAVE])
> + return PLATFORM_PROFILE_LOW_POWER;
> +
> + return -EOPNOTSUPP;
> +}
> +
> +#define SLIDER_MASK GENMASK_ULL(2, 0)
> +#define SLIDER_ENABLE_BIT 7
I'd move these up to where the other symbols are defined.
> +
> +static void set_soc_power_profile(struct proc_thermal_device *proc_priv, int slider)
> +{
> + u64 val;
> +
> + val = readq(proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
I would define a macro or static inline for the proc_priv->mmio_base +
SOC_POWER_SLIDER_OFFSET computation. It has enough characters and it
is used enough times to get a separate wrapper IMV.
> + val &= ~SLIDER_MASK;
> + val |= FIELD_PREP(SLIDER_MASK, slider);
> + val |= BIT(SLIDER_ENABLE_BIT);
The two statements above can be combined.
> + writeq(val, proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
> +}
> +
> +/* profile get/set callbacks are called with a profile lock, so no need for local locks */
> +
> +static int power_slider_platform_profile_set(struct device *dev,
> + enum platform_profile_option profile)
> +{
> + struct proc_thermal_device *proc_priv;
> + int slider;
> +
> + proc_priv = dev_get_drvdata(dev);
> + if (!proc_priv)
> + return -EOPNOTSUPP;
> +
> + slider = convert_profile_to_power_slider(profile);
> + if (slider < 0)
> + return slider;
> +
> + set_soc_power_profile(proc_priv, slider);
> +
> + return 0;
> +}
> +
> +static int power_slider_platform_profile_get(struct device *dev,
> + enum platform_profile_option *profile)
> +{
> + struct proc_thermal_device *proc_priv;
> + int slider, ret;
> + u64 val;
> +
> + proc_priv = dev_get_drvdata(dev);
> + if (!proc_priv)
> + return -EOPNOTSUPP;
> +
> + val = readq(proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
> + slider = FIELD_GET(SLIDER_MASK, val);
> +
> + ret = convert_power_slider_to_profile(slider);
> + if (ret < 0)
> + return ret;
> +
> + *profile = ret;
> +
> + return 0;
> +}
> +
> +static int power_slider_platform_profile_probe(void *drvdata, unsigned long *choices)
> +{
> + set_bit(PLATFORM_PROFILE_LOW_POWER, choices);
> + set_bit(PLATFORM_PROFILE_BALANCED, choices);
> + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices);
> +
> + return 0;
> +}
> +
> +static const struct platform_profile_ops power_slider_platform_profile_ops = {
> + .probe = power_slider_platform_profile_probe,
> + .profile_get = power_slider_platform_profile_get,
> + .profile_set = power_slider_platform_profile_set,
> +};
> +
> +int proc_thermal_soc_power_slider_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv)
> +{
> + struct device *ppdev;
> +
> + set_soc_power_profile(proc_priv, slider_values[SOC_POWER_SLIDER_BALANCE]);
> +
> + ppdev = devm_platform_profile_register(&pdev->dev, "SoC Power Slider", proc_priv,
> + &power_slider_platform_profile_ops);
> +
> + return PTR_ERR_OR_ZERO(ppdev);
> +}
> +EXPORT_SYMBOL_NS_GPL(proc_thermal_soc_power_slider_add, "INT340X_THERMAL");
> +
> +MODULE_IMPORT_NS("INT340X_THERMAL");
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("Processor Thermal Power Slider Interface");
> --
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] thermal: intel: int340x: Enable power slider interface
2025-08-13 18:55 ` [PATCH 2/5] thermal: intel: int340x: Enable power slider interface Srinivas Pandruvada
@ 2025-08-22 12:47 ` Rafael J. Wysocki
0 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2025-08-22 12:47 UTC (permalink / raw)
To: Srinivas Pandruvada
Cc: rafael, daniel.lezcano, lukasz.luba, linux-pm, linux-kernel
Please add "for Panther Lake" to the subject.
On Wed, Aug 13, 2025 at 8:55 PM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> Enable power slider interface for Panther Lake.
And I would say "Set the PROC_THERMAL_FEATURE_SOC_POWER_SLIDER feature
flag in proc_thermal_pci_ids[] for Panther Lake" here.
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> .../intel/int340x_thermal/processor_thermal_device_pci.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
> index d4d7e8e147d2..e2471768d355 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
> @@ -498,7 +498,8 @@ static const struct pci_device_id proc_thermal_pci_ids[] = {
> { PCI_DEVICE_DATA(INTEL, PTL_THERMAL, PROC_THERMAL_FEATURE_RAPL |
> PROC_THERMAL_FEATURE_DLVR | PROC_THERMAL_FEATURE_DVFS |
> PROC_THERMAL_FEATURE_MSI_SUPPORT | PROC_THERMAL_FEATURE_WT_HINT |
> - PROC_THERMAL_FEATURE_POWER_FLOOR | PROC_THERMAL_FEATURE_PTC) },
> + PROC_THERMAL_FEATURE_POWER_FLOOR | PROC_THERMAL_FEATURE_PTC |
> + PROC_THERMAL_FEATURE_SOC_POWER_SLIDER) },
> { PCI_DEVICE_DATA(INTEL, WCL_THERMAL, PROC_THERMAL_FEATURE_MSI_SUPPORT |
> PROC_THERMAL_FEATURE_RAPL | PROC_THERMAL_FEATURE_DLVR |
> PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_WT_HINT |
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/5] thermal: intel: int340x: Add module parameter for balanced Slider
2025-08-13 18:55 ` [PATCH 3/5] thermal: intel: int340x: Add module parameter for balanced Slider Srinivas Pandruvada
@ 2025-08-22 12:50 ` Rafael J. Wysocki
0 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2025-08-22 12:50 UTC (permalink / raw)
To: Srinivas Pandruvada
Cc: rafael, daniel.lezcano, lukasz.luba, linux-pm, linux-kernel
On Wed, Aug 13, 2025 at 8:55 PM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> By default, the SoC slider value for the "balanced" platform profile is
> set to 3. A new module parameter is introduced to allow users to change
> this default value. After modifying the module parameter, users must call
> an update to the "profile" sysfs attribute for the change to take effect.
This last bit is slightly confusing. What exactly do they need to do
for this purpose?
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> .../processor_thermal_soc_slider.c | 41 +++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
> index c492ee937dc7..ffc538c9b9e3 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
> @@ -50,6 +50,43 @@ static u8 slider_values[] = {
> [SOC_POWER_SLIDER_POWERSAVE] = SOC_SLIDER_VALUE_MAXIMUM,
> };
>
> +/* Lock to protect module param updates */
> +static DEFINE_MUTEX(slider_param_lock);
> +
> +static int slider_balanced_param = SOC_SLIDER_VALUE_BALANCE;
> +
> +static int slider_def_balance_set(const char *arg, const struct kernel_param *kp)
> +{
> + u8 slider_val;
> + int ret;
> +
> + guard(mutex)(&slider_param_lock);
> +
> + ret = kstrtou8(arg, 16, &slider_val);
> + if (!ret) {
> + if (slider_val > SOC_SLIDER_VALUE_MAXIMUM)
> + return -EINVAL;
> +
> + slider_balanced_param = slider_val;
> + }
> +
> + return ret;
> +}
> +
> +static int slider_def_balance_get(char *buf, const struct kernel_param *kp)
> +{
> + guard(mutex)(&slider_param_lock);
> + return sysfs_emit(buf, "%02x\n", slider_values[SOC_POWER_SLIDER_BALANCE]);
> +}
> +
> +static const struct kernel_param_ops slider_def_balance_ops = {
> + .set = slider_def_balance_set,
> + .get = slider_def_balance_get,
> +};
> +
> +module_param_cb(slider_balance, &slider_def_balance_ops, NULL, 0644);
> +MODULE_PARM_DESC(slider_balance, "Set slider default value for balance.");
> +
> /* Convert from platform power profile option to SoC slider value */
> static int convert_profile_to_power_slider(enum platform_profile_option profile)
> {
> @@ -106,6 +143,10 @@ static int power_slider_platform_profile_set(struct device *dev,
> if (!proc_priv)
> return -EOPNOTSUPP;
>
> + guard(mutex)(&slider_param_lock);
> +
> + slider_values[SOC_POWER_SLIDER_BALANCE] = slider_balanced_param;
> +
> slider = convert_profile_to_power_slider(profile);
> if (slider < 0)
> return slider;
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/5] thermal: intel: int340x: Add module parameter to change slider offset
2025-08-13 18:55 ` [PATCH 4/5] thermal: intel: int340x: Add module parameter to change slider offset Srinivas Pandruvada
@ 2025-08-22 13:00 ` Rafael J. Wysocki
0 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2025-08-22 13:00 UTC (permalink / raw)
To: Srinivas Pandruvada
Cc: rafael, daniel.lezcano, lukasz.luba, linux-pm, linux-kernel
On Wed, Aug 13, 2025 at 8:55 PM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> The slider offset value allows the SoC to automatically switch slider
> positions in range [SOC_SLIDER … (SOC_SLIDER + slider offset)] based on
> internal algorithms to improve power efficiency.
So SOC_SLIDER is the value set by the user (or the default value if
the user has not set it) and the "slider offset" allows the SoC to
adjust the slider value by setting it above SOC_SLIDER up to and
including SOC_SLIDER + slider offset?
If so, I would add a comment to this effect next to the slider_offset
module param definition.
> By default, the SoC slider offset is set to 0. This means that SoC is not
> allowed to switch slider position.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> .../processor_thermal_soc_slider.c | 41 +++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
> index ffc538c9b9e3..bd4ff26a488b 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
> @@ -87,6 +87,40 @@ static const struct kernel_param_ops slider_def_balance_ops = {
> module_param_cb(slider_balance, &slider_def_balance_ops, NULL, 0644);
> MODULE_PARM_DESC(slider_balance, "Set slider default value for balance.");
>
> +static u8 slider_offset;
> +
> +static int slider_def_offset_set(const char *arg, const struct kernel_param *kp)
> +{
> + u8 offset;
> + int ret;
> +
> + guard(mutex)(&slider_param_lock);
> +
> + ret = kstrtou8(arg, 16, &offset);
> + if (!ret) {
> + if (offset > SOC_SLIDER_VALUE_MAXIMUM)
> + return -EINVAL;
> +
> + slider_offset = offset;
> + }
> +
> + return ret;
> +}
> +
> +static int slider_def_offset_get(char *buf, const struct kernel_param *kp)
> +{
> + guard(mutex)(&slider_param_lock);
> + return sysfs_emit(buf, "%02x\n", slider_offset);
> +}
> +
> +static const struct kernel_param_ops slider_offset_ops = {
> + .set = slider_def_offset_set,
> + .get = slider_def_offset_get,
> +};
> +
> +module_param_cb(slider_offset, &slider_offset_ops, NULL, 0644);
> +MODULE_PARM_DESC(slider_offset, "Set slider offset.");
The _DESC is a bit short IMO. I would say something like "Maximum
offset by which the slider can be increased automatically above the
prescribed value".
> +
> /* Convert from platform power profile option to SoC slider value */
> static int convert_profile_to_power_slider(enum platform_profile_option profile)
> {
> @@ -120,6 +154,8 @@ static int convert_power_slider_to_profile(u8 slider)
> #define SLIDER_MASK GENMASK_ULL(2, 0)
> #define SLIDER_ENABLE_BIT 7
>
> +#define SLIDER_OFFSET_MASK GENMASK_ULL(6, 4)
> +
> static void set_soc_power_profile(struct proc_thermal_device *proc_priv, int slider)
> {
> u64 val;
> @@ -128,6 +164,11 @@ static void set_soc_power_profile(struct proc_thermal_device *proc_priv, int sli
> val &= ~SLIDER_MASK;
> val |= FIELD_PREP(SLIDER_MASK, slider);
> val |= BIT(SLIDER_ENABLE_BIT);
> +
> + /* Set the slider offset from module params */
> + val &= ~SLIDER_OFFSET_MASK;
> + val |= FIELD_PREP(SLIDER_OFFSET_MASK, slider_offset);
> +
> writeq(val, proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
> }
>
> --
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] thermal: intel: int340x: Add suspend and resume callbacks
2025-08-13 18:55 ` [PATCH 5/5] thermal: intel: int340x: Add suspend and resume callbacks Srinivas Pandruvada
@ 2025-08-22 13:02 ` Rafael J. Wysocki
0 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2025-08-22 13:02 UTC (permalink / raw)
To: Srinivas Pandruvada
Cc: rafael, daniel.lezcano, lukasz.luba, linux-pm, linux-kernel
On Wed, Aug 13, 2025 at 8:55 PM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> During system suspend callback save slider register and restore during
> resume callback.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
I would combine this with the first patch.
It doesn't add extra functionality, it's mandatory stuff.
> ---
> .../int340x_thermal/processor_thermal_device.c | 10 ++++++++++
> .../int340x_thermal/processor_thermal_device.h | 2 ++
> .../processor_thermal_soc_slider.c | 15 +++++++++++++++
> 3 files changed, 27 insertions(+)
>
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> index 4aea5c9baae9..a772c187bedb 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> @@ -338,10 +338,17 @@ static int tcc_offset_save = -1;
>
> int proc_thermal_suspend(struct device *dev)
> {
> + struct proc_thermal_device *proc_dev;
> +
> tcc_offset_save = intel_tcc_get_offset(-1);
> if (tcc_offset_save < 0)
> dev_warn(dev, "failed to save offset (%d)\n", tcc_offset_save);
>
> + proc_dev = dev_get_drvdata(dev);
> +
> + if (proc_dev->mmio_feature_mask & PROC_THERMAL_FEATURE_SOC_POWER_SLIDER)
> + proc_thermal_soc_power_slider_suspend(proc_dev);
> +
> return 0;
> }
> EXPORT_SYMBOL_GPL(proc_thermal_suspend);
> @@ -357,6 +364,9 @@ int proc_thermal_resume(struct device *dev)
> if (tcc_offset_save >= 0)
> intel_tcc_set_offset(-1, tcc_offset_save);
>
> + if (proc_dev->mmio_feature_mask & PROC_THERMAL_FEATURE_SOC_POWER_SLIDER)
> + proc_thermal_soc_power_slider_resume(proc_dev);
> +
> return 0;
> }
> EXPORT_SYMBOL_GPL(proc_thermal_resume);
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
> index ba3f64742f2f..30760475102f 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
> @@ -130,5 +130,7 @@ int proc_thermal_ptc_add(struct pci_dev *pdev, struct proc_thermal_device *proc_
> void proc_thermal_ptc_remove(struct pci_dev *pdev);
>
> int proc_thermal_soc_power_slider_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
> +void proc_thermal_soc_power_slider_suspend(struct proc_thermal_device *proc_priv);
> +void proc_thermal_soc_power_slider_resume(struct proc_thermal_device *proc_priv);
>
> #endif
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
> index bd4ff26a488b..268bf9124d95 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
> @@ -248,6 +248,21 @@ int proc_thermal_soc_power_slider_add(struct pci_dev *pdev, struct proc_thermal_
> }
> EXPORT_SYMBOL_NS_GPL(proc_thermal_soc_power_slider_add, "INT340X_THERMAL");
>
> +static u64 soc_slider_save;
> +
> +void proc_thermal_soc_power_slider_suspend(struct proc_thermal_device *proc_priv)
> +{
> + soc_slider_save = readq(proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
> +
> +}
> +EXPORT_SYMBOL_NS_GPL(proc_thermal_soc_power_slider_suspend, "INT340X_THERMAL");
> +
> +void proc_thermal_soc_power_slider_resume(struct proc_thermal_device *proc_priv)
> +{
> + writeq(soc_slider_save, proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET);
> +}
> +EXPORT_SYMBOL_NS_GPL(proc_thermal_soc_power_slider_resume, "INT340X_THERMAL");
> +
> MODULE_IMPORT_NS("INT340X_THERMAL");
> MODULE_LICENSE("GPL");
> MODULE_DESCRIPTION("Processor Thermal Power Slider Interface");
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-08-22 13:02 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 18:55 [PATCH 0/5] thermal: intel: int340x: New power slider interface Srinivas Pandruvada
2025-08-13 18:55 ` [PATCH 1/5] thermal: intel: int340x: Add support for power slider Srinivas Pandruvada
2025-08-22 12:43 ` Rafael J. Wysocki
2025-08-13 18:55 ` [PATCH 2/5] thermal: intel: int340x: Enable power slider interface Srinivas Pandruvada
2025-08-22 12:47 ` Rafael J. Wysocki
2025-08-13 18:55 ` [PATCH 3/5] thermal: intel: int340x: Add module parameter for balanced Slider Srinivas Pandruvada
2025-08-22 12:50 ` Rafael J. Wysocki
2025-08-13 18:55 ` [PATCH 4/5] thermal: intel: int340x: Add module parameter to change slider offset Srinivas Pandruvada
2025-08-22 13:00 ` Rafael J. Wysocki
2025-08-13 18:55 ` [PATCH 5/5] thermal: intel: int340x: Add suspend and resume callbacks Srinivas Pandruvada
2025-08-22 13:02 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).