Commit 91b156f8 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge tag 'linux-cpupower-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux

Merge cpupower utility update for 6.6-rc1 from Shuah Khan:

"This cpupower update for Linux 6.6-rc1 consists of 2 fixes and
 enhancements to add support for amd-pstate active mode driver,
 amd_pstate mode change, EPP value change, turbo-boost support,
 and is_valid_path API."

* tag 'linux-cpupower-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux:
  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
parents 5d0c230f 99481d21
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ DESTDIR ?=

VERSION:=			$(shell ./utils/version-gen.sh)
LIB_MAJ=			0.0.1
LIB_MIN=			0
LIB_MIN=			1

PACKAGE =			cpupower
PACKAGE_BUGREPORT =		linux-pm@vger.kernel.org
+7 −0
Original line number Diff line number Diff line
@@ -14,6 +14,13 @@
#include "cpupower.h"
#include "cpupower_intern.h"

int is_valid_path(const char *path)
{
	if (access(path, F_OK) == -1)
		return 0;
	return 1;
}

unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen)
{
	ssize_t numread;
+1 −0
Original line number Diff line number Diff line
@@ -7,5 +7,6 @@

#define SYSFS_PATH_MAX 255

int is_valid_path(const char *path);
unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen);
unsigned int cpupower_write_sysfs(const char *path, char *buf, size_t buflen);
+7 −9
Original line number Diff line number Diff line
@@ -41,14 +41,6 @@ int cmd_idle_set(int argc, char **argv)
			cont = 0;
			break;
		case 'd':
			if (param) {
				param = -1;
				cont = 0;
				break;
			}
			param = ret;
			idlestate = atoi(optarg);
			break;
		case 'e':
			if (param) {
				param = -1;
@@ -56,7 +48,13 @@ int cmd_idle_set(int argc, char **argv)
				break;
			}
			param = ret;
			strtol(optarg, &endptr, 10);
			if (*endptr != '\0') {
				printf(_("Bad value: %s, Integer expected\n"), optarg);
				exit(EXIT_FAILURE);
			} else {
				idlestate = atoi(optarg);
			}
			break;
		case 'D':
			if (param) {
+63 −2
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@

static struct option set_opts[] = {
	{"perf-bias", required_argument, NULL, 'b'},
	{"epp", required_argument, NULL, 'e'},
	{"amd-pstate-mode", required_argument, NULL, 'm'},
	{"turbo-boost", required_argument, NULL, 't'},
	{ },
};

@@ -37,11 +40,15 @@ int cmd_set(int argc, char **argv)
	union {
		struct {
			int perf_bias:1;
			int epp:1;
			int mode:1;
			int turbo_boost:1;
		};
		int params;
	} params;
	int perf_bias = 0;
	int perf_bias = 0, turbo_boost = 1;
	int ret = 0;
	char epp[30], mode[20];

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

	params.params = 0;
	/* parameter parsing */
	while ((ret = getopt_long(argc, argv, "b:",
	while ((ret = getopt_long(argc, argv, "b:e:m:",
						set_opts, NULL)) != -1) {
		switch (ret) {
		case 'b':
@@ -69,6 +76,38 @@ int cmd_set(int argc, char **argv)
			}
			params.perf_bias = 1;
			break;
		case 'e':
			if (params.epp)
				print_wrong_arg_exit();
			if (sscanf(optarg, "%29s", epp) != 1) {
				print_wrong_arg_exit();
				return -EINVAL;
			}
			params.epp = 1;
			break;
		case 'm':
			if (cpupower_cpu_info.vendor != X86_VENDOR_AMD)
				print_wrong_arg_exit();
			if (params.mode)
				print_wrong_arg_exit();
			if (sscanf(optarg, "%19s", mode) != 1) {
				print_wrong_arg_exit();
				return -EINVAL;
			}
			params.mode = 1;
			break;
		case 't':
			if (params.turbo_boost)
				print_wrong_arg_exit();
			turbo_boost = atoi(optarg);
			if (turbo_boost < 0 || turbo_boost > 1) {
				printf("--turbo-boost param out of range [0-1]\n");
				print_wrong_arg_exit();
			}
			params.turbo_boost = 1;
			break;


		default:
			print_wrong_arg_exit();
		}
@@ -77,6 +116,18 @@ int cmd_set(int argc, char **argv)
	if (!params.params)
		print_wrong_arg_exit();

	if (params.mode) {
		ret = cpupower_set_amd_pstate_mode(mode);
		if (ret)
			fprintf(stderr, "Error setting mode\n");
	}

	if (params.turbo_boost) {
		ret = cpupower_set_turbo_boost(turbo_boost);
		if (ret)
			fprintf(stderr, "Error setting turbo-boost\n");
	}

	/* Default is: set all CPUs */
	if (bitmask_isallclear(cpus_chosen))
		bitmask_setall(cpus_chosen);
@@ -102,6 +153,16 @@ int cmd_set(int argc, char **argv)
				break;
			}
		}

		if (params.epp) {
			ret = cpupower_set_epp(cpu, epp);
			if (ret) {
				fprintf(stderr,
					"Error setting epp value on CPU %d\n", cpu);
				break;
			}
		}

	}
	return ret;
}
Loading