mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: rafael@kernel.org, daniel.lezcano@linaro.org, lukasz.luba@arm.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [PATCH v2 3/4] thermal: intel: int340x: Add module parameter for balanced Slider
Date: Mon, 25 Aug 2025 06:23:14 -0700	[thread overview]
Message-ID: <20250825132315.75521-4-srinivas.pandruvada@linux.intel.com> (raw)
In-Reply-To: <20250825132315.75521-1-srinivas.pandruvada@linux.intel.com>

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>
---
v2:
- Edit description to be more clear

 .../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 3225cb38588c..393ce5246447 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
@@ -53,6 +53,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)
 {
@@ -115,6 +152,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


  parent reply	other threads:[~2025-08-25 13:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-25 13:23 [PATCH v2 0/4] thermal: intel: int340x: New power slider interface Srinivas Pandruvada
2025-08-25 13:23 ` [PATCH v2 1/4] thermal: intel: int340x: Add support for power slider Srinivas Pandruvada
2025-08-25 13:23 ` [PATCH v2 2/4] thermal: intel: int340x: Enable power slider interface for Panther Lake Srinivas Pandruvada
2025-08-25 13:23 ` Srinivas Pandruvada [this message]
2025-08-25 13:23 ` [PATCH v2 4/4] thermal: intel: int340x: Add module parameter to change slider offset Srinivas Pandruvada
2025-08-25 13:47 ` [PATCH v2 0/4] thermal: intel: int340x: New power slider interface Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250825132315.75521-4-srinivas.pandruvada@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®