Skip to content

Commit 885c429

Browse files
committed
Merge branches 'pm-devfreq' and 'pm-tools'
Merge devfreq changes and power management tools changes for 6.6-rc1: - Fix memory leak in devfreq_dev_release() (Boris Brezillon). - Rewrite devfreq_monitor_start() kerneldoc comment (Manivannan Sadhasivam). - Explicitly include correct DT includes in devfreq (Rob Herring). - Add turbo-boost support to cpupower (Wyes Karny). - Add support for amd_pstate mode change to cpupower (Wyes Karny). - Fix 'cpupower idle_set' command to accept only numeric values of arguments (Likhitha Korrapati). * pm-devfreq: PM / devfreq: Fix leak in devfreq_dev_release() PM / devfreq: Reword the kernel-doc comment for devfreq_monitor_start() API PM / devfreq: Explicitly include correct DT includes * pm-tools: cpupower: Fix cpuidle_set to accept only numeric values for idle-set operation. cpupower: Add turbo-boost support in cpupower cpupower: Add support for amd_pstate mode change cpupower: Add EPP value change support cpupower: Add is_valid_path API cpupower: Recognise amd-pstate active mode driver cpupower: Bump soname version
3 parents 6a0b211 + 1c073f8 + 91b156f commit 885c429

File tree

12 files changed

+155
-21
lines changed

12 files changed

+155
-21
lines changed

drivers/devfreq/devfreq.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,11 @@ static void devfreq_monitor(struct work_struct *work)
472472
* devfreq_monitor_start() - Start load monitoring of devfreq instance
473473
* @devfreq: the devfreq instance.
474474
*
475-
* Helper function for starting devfreq device load monitoring. By
476-
* default delayed work based monitoring is supported. Function
477-
* to be called from governor in response to DEVFREQ_GOV_START
478-
* event when device is added to devfreq framework.
475+
* Helper function for starting devfreq device load monitoring. By default,
476+
* deferrable timer is used for load monitoring. But the users can change this
477+
* behavior using the "timer" type in devfreq_dev_profile. This function will be
478+
* called by devfreq governor in response to the DEVFREQ_GOV_START event
479+
* generated while adding a device to the devfreq framework.
479480
*/
480481
void devfreq_monitor_start(struct devfreq *devfreq)
481482
{
@@ -763,6 +764,7 @@ static void devfreq_dev_release(struct device *dev)
763764
dev_pm_opp_put_opp_table(devfreq->opp_table);
764765

765766
mutex_destroy(&devfreq->lock);
767+
srcu_cleanup_notifier_head(&devfreq->transition_notifier_list);
766768
kfree(devfreq);
767769
}
768770

drivers/devfreq/imx-bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <linux/devfreq.h>
88
#include <linux/device.h>
99
#include <linux/module.h>
10-
#include <linux/of_device.h>
10+
#include <linux/of.h>
1111
#include <linux/pm_opp.h>
1212
#include <linux/platform_device.h>
1313
#include <linux/slab.h>

drivers/devfreq/imx8m-ddrc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* Copyright 2019 NXP
44
*/
55

6+
#include <linux/mod_devicetable.h>
67
#include <linux/module.h>
78
#include <linux/device.h>
8-
#include <linux/of_device.h>
99
#include <linux/platform_device.h>
1010
#include <linux/devfreq.h>
1111
#include <linux/pm_opp.h>

drivers/devfreq/mtk-cci-devfreq.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <linux/minmax.h>
99
#include <linux/module.h>
1010
#include <linux/of.h>
11-
#include <linux/of_device.h>
1211
#include <linux/platform_device.h>
1312
#include <linux/pm_opp.h>
1413
#include <linux/regulator/consumer.h>

drivers/devfreq/tegra30-devfreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <linux/io.h>
1414
#include <linux/irq.h>
1515
#include <linux/module.h>
16-
#include <linux/of_device.h>
16+
#include <linux/of.h>
1717
#include <linux/platform_device.h>
1818
#include <linux/pm_opp.h>
1919
#include <linux/reset.h>

tools/power/cpupower/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ DESTDIR ?=
5353

5454
VERSION:= $(shell ./utils/version-gen.sh)
5555
LIB_MAJ= 0.0.1
56-
LIB_MIN= 0
56+
LIB_MIN= 1
5757

5858
PACKAGE = cpupower
5959
PACKAGE_BUGREPORT = linux-pm@vger.kernel.org

tools/power/cpupower/lib/cpupower.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
#include "cpupower.h"
1515
#include "cpupower_intern.h"
1616

17+
int is_valid_path(const char *path)
18+
{
19+
if (access(path, F_OK) == -1)
20+
return 0;
21+
return 1;
22+
}
23+
1724
unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen)
1825
{
1926
ssize_t numread;

tools/power/cpupower/lib/cpupower_intern.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77

88
#define SYSFS_PATH_MAX 255
99

10+
int is_valid_path(const char *path);
1011
unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen);
1112
unsigned int cpupower_write_sysfs(const char *path, char *buf, size_t buflen);

tools/power/cpupower/utils/cpuidle-set.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,20 @@ int cmd_idle_set(int argc, char **argv)
4141
cont = 0;
4242
break;
4343
case 'd':
44-
if (param) {
45-
param = -1;
46-
cont = 0;
47-
break;
48-
}
49-
param = ret;
50-
idlestate = atoi(optarg);
51-
break;
5244
case 'e':
5345
if (param) {
5446
param = -1;
5547
cont = 0;
5648
break;
5749
}
5850
param = ret;
59-
idlestate = atoi(optarg);
51+
strtol(optarg, &endptr, 10);
52+
if (*endptr != '\0') {
53+
printf(_("Bad value: %s, Integer expected\n"), optarg);
54+
exit(EXIT_FAILURE);
55+
} else {
56+
idlestate = atoi(optarg);
57+
}
6058
break;
6159
case 'D':
6260
if (param) {

tools/power/cpupower/utils/cpupower-set.c

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
static struct option set_opts[] = {
2020
{"perf-bias", required_argument, NULL, 'b'},
21+
{"epp", required_argument, NULL, 'e'},
22+
{"amd-pstate-mode", required_argument, NULL, 'm'},
23+
{"turbo-boost", required_argument, NULL, 't'},
2124
{ },
2225
};
2326

@@ -37,11 +40,15 @@ int cmd_set(int argc, char **argv)
3740
union {
3841
struct {
3942
int perf_bias:1;
43+
int epp:1;
44+
int mode:1;
45+
int turbo_boost:1;
4046
};
4147
int params;
4248
} params;
43-
int perf_bias = 0;
49+
int perf_bias = 0, turbo_boost = 1;
4450
int ret = 0;
51+
char epp[30], mode[20];
4552

4653
ret = uname(&uts);
4754
if (!ret && (!strcmp(uts.machine, "ppc64le") ||
@@ -55,7 +62,7 @@ int cmd_set(int argc, char **argv)
5562

5663
params.params = 0;
5764
/* parameter parsing */
58-
while ((ret = getopt_long(argc, argv, "b:",
65+
while ((ret = getopt_long(argc, argv, "b:e:m:",
5966
set_opts, NULL)) != -1) {
6067
switch (ret) {
6168
case 'b':
@@ -69,6 +76,38 @@ int cmd_set(int argc, char **argv)
6976
}
7077
params.perf_bias = 1;
7178
break;
79+
case 'e':
80+
if (params.epp)
81+
print_wrong_arg_exit();
82+
if (sscanf(optarg, "%29s", epp) != 1) {
83+
print_wrong_arg_exit();
84+
return -EINVAL;
85+
}
86+
params.epp = 1;
87+
break;
88+
case 'm':
89+
if (cpupower_cpu_info.vendor != X86_VENDOR_AMD)
90+
print_wrong_arg_exit();
91+
if (params.mode)
92+
print_wrong_arg_exit();
93+
if (sscanf(optarg, "%19s", mode) != 1) {
94+
print_wrong_arg_exit();
95+
return -EINVAL;
96+
}
97+
params.mode = 1;
98+
break;
99+
case 't':
100+
if (params.turbo_boost)
101+
print_wrong_arg_exit();
102+
turbo_boost = atoi(optarg);
103+
if (turbo_boost < 0 || turbo_boost > 1) {
104+
printf("--turbo-boost param out of range [0-1]\n");
105+
print_wrong_arg_exit();
106+
}
107+
params.turbo_boost = 1;
108+
break;
109+
110+
72111
default:
73112
print_wrong_arg_exit();
74113
}
@@ -77,6 +116,18 @@ int cmd_set(int argc, char **argv)
77116
if (!params.params)
78117
print_wrong_arg_exit();
79118

119+
if (params.mode) {
120+
ret = cpupower_set_amd_pstate_mode(mode);
121+
if (ret)
122+
fprintf(stderr, "Error setting mode\n");
123+
}
124+
125+
if (params.turbo_boost) {
126+
ret = cpupower_set_turbo_boost(turbo_boost);
127+
if (ret)
128+
fprintf(stderr, "Error setting turbo-boost\n");
129+
}
130+
80131
/* Default is: set all CPUs */
81132
if (bitmask_isallclear(cpus_chosen))
82133
bitmask_setall(cpus_chosen);
@@ -102,6 +153,16 @@ int cmd_set(int argc, char **argv)
102153
break;
103154
}
104155
}
156+
157+
if (params.epp) {
158+
ret = cpupower_set_epp(cpu, epp);
159+
if (ret) {
160+
fprintf(stderr,
161+
"Error setting epp value on CPU %d\n", cpu);
162+
break;
163+
}
164+
}
165+
105166
}
106167
return ret;
107168
}

0 commit comments

Comments
 (0)