Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal: intel: int340x: Add module parameter to change slider offset

SoC slider value is set by the user (or the default when user has not
modified it). To enhance power efficiency dynamically, the firmware can
optionally auto-adjust the slider value based on the current workload.
This adjustment is governed by an additional parameter known as the
"slider offset". This offset permits the firmware to increase the slider
value up to and including "SoC slider + slider offset".

Add a module parameter to specify this "slier offset" value.

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>
Link: https://patch.msgid.link/20250825132315.75521-5-srinivas.pandruvada@linux.intel.com
[ rjw: Comment and module param description adjustments ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Srinivas Pandruvada and committed by
Rafael J. Wysocki
8306bcab 4a64a748

+48
+48
drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
··· 90 90 module_param_cb(slider_balance, &slider_def_balance_ops, NULL, 0644); 91 91 MODULE_PARM_DESC(slider_balance, "Set slider default value for balance"); 92 92 93 + static u8 slider_offset; 94 + 95 + static int slider_def_offset_set(const char *arg, const struct kernel_param *kp) 96 + { 97 + u8 offset; 98 + int ret; 99 + 100 + guard(mutex)(&slider_param_lock); 101 + 102 + ret = kstrtou8(arg, 16, &offset); 103 + if (!ret) { 104 + if (offset > SOC_SLIDER_VALUE_MAXIMUM) 105 + return -EINVAL; 106 + 107 + slider_offset = offset; 108 + } 109 + 110 + return ret; 111 + } 112 + 113 + static int slider_def_offset_get(char *buf, const struct kernel_param *kp) 114 + { 115 + guard(mutex)(&slider_param_lock); 116 + return sysfs_emit(buf, "%02x\n", slider_offset); 117 + } 118 + 119 + static const struct kernel_param_ops slider_offset_ops = { 120 + .set = slider_def_offset_set, 121 + .get = slider_def_offset_get, 122 + }; 123 + 124 + /* 125 + * To enhance power efficiency dynamically, the firmware can optionally 126 + * auto-adjust the slider value based on the current workload. This 127 + * adjustment is controlled by the "slider_offset" module parameter. 128 + * This offset permits the firmware to increase the slider value 129 + * up to and including "SoC slider + slider offset,". 130 + */ 131 + module_param_cb(slider_offset, &slider_offset_ops, NULL, 0644); 132 + MODULE_PARM_DESC(slider_offset, "Set slider offset"); 133 + 93 134 /* Convert from platform power profile option to SoC slider value */ 94 135 static int convert_profile_to_power_slider(enum platform_profile_option profile) 95 136 { ··· 171 130 writeq(val, proc_priv->mmio_base + SOC_POWER_SLIDER_OFFSET); 172 131 } 173 132 133 + #define SLIDER_OFFSET_MASK GENMASK_ULL(6, 4) 134 + 174 135 static void set_soc_power_profile(struct proc_thermal_device *proc_priv, int slider) 175 136 { 176 137 u64 val; ··· 180 137 val = read_soc_slider(proc_priv); 181 138 val &= ~SLIDER_MASK; 182 139 val |= FIELD_PREP(SLIDER_MASK, slider) | BIT(SLIDER_ENABLE_BIT); 140 + 141 + /* Set the slider offset from module params */ 142 + val &= ~SLIDER_OFFSET_MASK; 143 + val |= FIELD_PREP(SLIDER_OFFSET_MASK, slider_offset); 144 + 183 145 write_soc_slider(proc_priv, val); 184 146 } 185 147