Skip to content

Commit 966d0ab

Browse files
spandruvadarafaeljw
authored andcommitted
thermal: intel: powerclamp: Fix duration module parameter
After the switch to use the powercap/idle-inject framework in the Intel powerclamp driver, the idle duration unit is microsecond. However, the module parameter for idle duration is in milliseconds, so convert it to microseconds in the "set" callback and back to milliseconds in a new "get" callback. While here, also use mutex protection for setting and getting "duration". The other uses of "duration" are already protected by the mutex. Fixes: 8526eb7 ("thermal: intel: powerclamp: Use powercap idle-inject feature") Signed-off-by: Srinivas Pandruvada <[email protected]> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 6210849 commit 966d0ab

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

drivers/thermal/intel/intel_powerclamp.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static struct thermal_cooling_device *cooling_dev;
7474

7575
static DEFINE_MUTEX(powerclamp_lock);
7676

77+
/* This duration is in microseconds */
7778
static unsigned int duration;
7879
static unsigned int pkg_cstate_ratio_cur;
7980
static unsigned int window_size;
@@ -90,23 +91,34 @@ static int duration_set(const char *arg, const struct kernel_param *kp)
9091
pr_err("Out of recommended range %lu, between 6-25ms\n",
9192
new_duration);
9293
ret = -EINVAL;
94+
goto exit;
9395
}
9496

95-
duration = clamp(new_duration, 6ul, 25ul);
96-
smp_mb();
97-
97+
mutex_lock(&powerclamp_lock);
98+
duration = clamp(new_duration, 6ul, 25ul) * 1000;
99+
mutex_unlock(&powerclamp_lock);
98100
exit:
99101

100102
return ret;
101103
}
102104

105+
static int duration_get(char *buf, const struct kernel_param *kp)
106+
{
107+
int ret;
108+
109+
mutex_lock(&powerclamp_lock);
110+
ret = sysfs_emit(buf, "%d\n", duration / 1000);
111+
mutex_unlock(&powerclamp_lock);
112+
113+
return ret;
114+
}
115+
103116
static const struct kernel_param_ops duration_ops = {
104117
.set = duration_set,
105-
.get = param_get_int,
118+
.get = duration_get,
106119
};
107120

108-
109-
module_param_cb(duration, &duration_ops, &duration, 0644);
121+
module_param_cb(duration, &duration_ops, NULL, 0644);
110122
MODULE_PARM_DESC(duration, "forced idle time for each attempt in msec.");
111123

112124
struct powerclamp_calibration_data {

0 commit comments

Comments
 (0)