Skip to content

Commit 4a64a74

Browse files
spandruvadarafaeljw
authored andcommitted
thermal: intel: int340x: Add module parameter for balanced Slider
By default, the SoC slider value for the "balanced" platform profile is set to 3. This update introduces a new module parameter, allowing users to modify this default value. The module parameter can be specified during load time to set a custom slider value for the "balanced" profile. If the module parameter is not specified at load time and is updated later, the new value will only take effect after the next write of "balanced" to the sysfs "profile" attribute. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/20250825132315.75521-4-srinivas.pandruvada@linux.intel.com [ rjw: Minor adjustments of module param description ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 018d046 commit 4a64a74

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,43 @@ static u8 slider_values[] = {
5353
[SOC_POWER_SLIDER_POWERSAVE] = SOC_SLIDER_VALUE_MAXIMUM,
5454
};
5555

56+
/* Lock to protect module param updates */
57+
static DEFINE_MUTEX(slider_param_lock);
58+
59+
static int slider_balanced_param = SOC_SLIDER_VALUE_BALANCE;
60+
61+
static int slider_def_balance_set(const char *arg, const struct kernel_param *kp)
62+
{
63+
u8 slider_val;
64+
int ret;
65+
66+
guard(mutex)(&slider_param_lock);
67+
68+
ret = kstrtou8(arg, 16, &slider_val);
69+
if (!ret) {
70+
if (slider_val > SOC_SLIDER_VALUE_MAXIMUM)
71+
return -EINVAL;
72+
73+
slider_balanced_param = slider_val;
74+
}
75+
76+
return ret;
77+
}
78+
79+
static int slider_def_balance_get(char *buf, const struct kernel_param *kp)
80+
{
81+
guard(mutex)(&slider_param_lock);
82+
return sysfs_emit(buf, "%02x\n", slider_values[SOC_POWER_SLIDER_BALANCE]);
83+
}
84+
85+
static const struct kernel_param_ops slider_def_balance_ops = {
86+
.set = slider_def_balance_set,
87+
.get = slider_def_balance_get,
88+
};
89+
90+
module_param_cb(slider_balance, &slider_def_balance_ops, NULL, 0644);
91+
MODULE_PARM_DESC(slider_balance, "Set slider default value for balance");
92+
5693
/* Convert from platform power profile option to SoC slider value */
5794
static int convert_profile_to_power_slider(enum platform_profile_option profile)
5895
{
@@ -115,6 +152,10 @@ static int power_slider_platform_profile_set(struct device *dev,
115152
if (!proc_priv)
116153
return -EOPNOTSUPP;
117154

155+
guard(mutex)(&slider_param_lock);
156+
157+
slider_values[SOC_POWER_SLIDER_BALANCE] = slider_balanced_param;
158+
118159
slider = convert_profile_to_power_slider(profile);
119160
if (slider < 0)
120161
return slider;

0 commit comments

Comments
 (0)