Commit baff384b authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'platform-drivers-x86-v5.4-2' of git://git.infradead.org/linux-platform-drivers-x86

Pull x86 platform-drivers fixes from Andy Shevchenko:

 - Fix compilation error of ASUS WMI driver when CONFIG_ACPI_BATTERY=n

 - Fix I²C multi-instantiate driver to work with several USB PD devices

 - Fix boot issue on Siemens SIMATIC IPC277E when PMC critical clock is
   being disabled

 - Plenty of fixes to Intel Speed-Select Technology tools

* tag 'platform-drivers-x86-v5.4-2' of git://git.infradead.org/linux-platform-drivers-x86:
  platform/x86: i2c-multi-instantiate: Derive the device name from parent
  platform/x86: pmc_atom: Add Siemens SIMATIC IPC277E to critclk_systems DMI table
  tools/power/x86/intel-speed-select: Fix perf-profile command output
  tools/power/x86/intel-speed-select: Extend core-power command set
  tools/power/x86/intel-speed-select: Fix some debug prints
  tools/power/x86/intel-speed-select: Format get-assoc information
  tools/power/x86/intel-speed-select: Allow online/offline based on tdp
  tools/power/x86/intel-speed-select: Fix high priority core mask over count
  platform/x86: asus-wmi: Make it depend on ACPI battery API
parents af5a7e99 24a8d78a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -674,6 +674,7 @@ config EEEPC_LAPTOP
config ASUS_WMI
	tristate "ASUS WMI Driver"
	depends on ACPI_WMI
	depends on ACPI_BATTERY
	depends on INPUT
	depends on HWMON
	depends on BACKLIGHT_CLASS_DEVICE
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
	for (i = 0; i < multi->num_clients && inst_data[i].type; i++) {
		memset(&board_info, 0, sizeof(board_info));
		strlcpy(board_info.type, inst_data[i].type, I2C_NAME_SIZE);
		snprintf(name, sizeof(name), "%s-%s.%d", match->id,
		snprintf(name, sizeof(name), "%s-%s.%d", dev_name(dev),
			 inst_data[i].type, i);
		board_info.dev_name = name;
		switch (inst_data[i].flags & IRQ_RESOURCE_TYPE) {
+7 −0
Original line number Diff line number Diff line
@@ -422,6 +422,13 @@ static const struct dmi_system_id critclk_systems[] = {
			DMI_MATCH(DMI_PRODUCT_VERSION, "6ES7647-8B"),
		},
	},
	{
		.ident = "SIMATIC IPC277E",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "SIEMENS AG"),
			DMI_MATCH(DMI_PRODUCT_VERSION, "6AV7882-0"),
		},
	},
	{ /*sentinel*/ }
};

+108 −14
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ static int fact_avx = 0xFF;
static unsigned long long fact_trl;
static int out_format_json;
static int cmd_help;
static int force_online_offline;

/* clos related */
static int current_clos = -1;
@@ -138,14 +139,14 @@ int out_format_is_json(void)
int get_physical_package_id(int cpu)
{
	return parse_int_file(
		1, "/sys/devices/system/cpu/cpu%d/topology/physical_package_id",
		0, "/sys/devices/system/cpu/cpu%d/topology/physical_package_id",
		cpu);
}

int get_physical_core_id(int cpu)
{
	return parse_int_file(
		1, "/sys/devices/system/cpu/cpu%d/topology/core_id", cpu);
		0, "/sys/devices/system/cpu/cpu%d/topology/core_id", cpu);
}

int get_physical_die_id(int cpu)
@@ -165,6 +166,26 @@ int get_topo_max_cpus(void)
	return topo_max_cpus;
}

static void set_cpu_online_offline(int cpu, int state)
{
	char buffer[128];
	int fd;

	snprintf(buffer, sizeof(buffer),
		 "/sys/devices/system/cpu/cpu%d/online", cpu);

	fd = open(buffer, O_WRONLY);
	if (fd < 0)
		err(-1, "%s open failed", buffer);

	if (state)
		write(fd, "1\n", 2);
	else
		write(fd, "0\n", 2);

	close(fd);
}

#define MAX_PACKAGE_COUNT 8
#define MAX_DIE_PER_PACKAGE 2
static void for_each_online_package_in_set(void (*callback)(int, void *, void *,
@@ -402,6 +423,9 @@ void set_cpu_mask_from_punit_coremask(int cpu, unsigned long long core_mask,
			int j;

			for (j = 0; j < topo_max_cpus; ++j) {
				if (!CPU_ISSET_S(j, present_cpumask_size, present_cpumask))
					continue;

				if (cpu_map[j].pkg_id == pkg_id &&
				    cpu_map[j].die_id == die_id &&
				    cpu_map[j].punit_cpu_core == i) {
@@ -484,7 +508,7 @@ int isst_send_mbox_command(unsigned int cpu, unsigned char command,
		int write = 0;
		int clos_id, core_id, ret = 0;

		debug_printf("CLOS %d\n", cpu);
		debug_printf("CPU %d\n", cpu);

		if (parameter & BIT(MBOX_CMD_WRITE_BIT)) {
			value = req_data;
@@ -649,7 +673,7 @@ static void exec_on_get_ctdp_cpu(int cpu, void *arg1, void *arg2, void *arg3,
	if (ret)
		perror("get_tdp_*");
	else
		isst_display_result(cpu, outf, "perf-profile", (char *)arg3,
		isst_ctdp_display_core_info(cpu, outf, arg3,
					    *(unsigned int *)arg4);
}

@@ -733,9 +757,34 @@ static void set_tdp_level_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
	ret = isst_set_tdp_level(cpu, tdp_level);
	if (ret)
		perror("set_tdp_level_for_cpu");
	else
	else {
		isst_display_result(cpu, outf, "perf-profile", "set_tdp_level",
				    ret);
		if (force_online_offline) {
			struct isst_pkg_ctdp_level_info ctdp_level;
			int pkg_id = get_physical_package_id(cpu);
			int die_id = get_physical_die_id(cpu);

			fprintf(stderr, "Option is set to online/offline\n");
			ctdp_level.core_cpumask_size =
				alloc_cpu_set(&ctdp_level.core_cpumask);
			isst_get_coremask_info(cpu, tdp_level, &ctdp_level);
			if (ctdp_level.cpu_count) {
				int i, max_cpus = get_topo_max_cpus();
				for (i = 0; i < max_cpus; ++i) {
					if (pkg_id != get_physical_package_id(i) || die_id != get_physical_die_id(i))
						continue;
					if (CPU_ISSET_S(i, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask)) {
						fprintf(stderr, "online cpu %d\n", i);
						set_cpu_online_offline(i, 1);
					} else {
						fprintf(stderr, "offline cpu %d\n", i);
						set_cpu_online_offline(i, 0);
					}
				}
			}
		}
	}
}

static void set_tdp_level(void)
@@ -744,6 +793,8 @@ static void set_tdp_level(void)
		fprintf(stderr, "Set Config TDP level\n");
		fprintf(stderr,
			"\t Arguments: -l|--level : Specify tdp level\n");
		fprintf(stderr,
			"\t Optional Arguments: -o | online : online/offline for the tdp level\n");
		exit(0);
	}

@@ -1082,6 +1133,40 @@ static void dump_clos_config(void)
	isst_ctdp_display_information_end(outf);
}

static void get_clos_info_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
				  void *arg4)
{
	int enable, ret, prio_type;

	ret = isst_clos_get_clos_information(cpu, &enable, &prio_type);
	if (ret)
		perror("isst_clos_get_info");
	else
		isst_clos_display_clos_information(cpu, outf, enable, prio_type);
}

static void dump_clos_info(void)
{
	if (cmd_help) {
		fprintf(stderr,
			"Print Intel Speed Select Technology core power information\n");
		fprintf(stderr, "\tSpecify targeted cpu id with [--cpu|-c]\n");
		exit(0);
	}

	if (!max_target_cpus) {
		fprintf(stderr,
			"Invalid target cpu. Specify with [-c|--cpu]\n");
		exit(0);
	}

	isst_ctdp_display_information_start(outf);
	for_each_online_target_cpu_in_set(get_clos_info_for_cpu, NULL,
					  NULL, NULL, NULL);
	isst_ctdp_display_information_end(outf);

}

static void set_clos_config_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
				    void *arg4)
{
@@ -1198,7 +1283,7 @@ static void get_clos_assoc_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
	if (ret)
		perror("isst_clos_get_assoc_status");
	else
		isst_display_result(cpu, outf, "core-power", "get-assoc", clos);
		isst_clos_display_assoc_information(cpu, outf, clos);
}

static void get_clos_assoc(void)
@@ -1208,13 +1293,17 @@ static void get_clos_assoc(void)
		fprintf(stderr, "\tSpecify targeted cpu id with [--cpu|-c]\n");
		exit(0);
	}
	if (max_target_cpus)
		for_each_online_target_cpu_in_set(get_clos_assoc_for_cpu, NULL,
						  NULL, NULL, NULL);
	else {

	if (!max_target_cpus) {
		fprintf(stderr,
			"Invalid target cpu. Specify with [-c|--cpu]\n");
		exit(0);
	}

	isst_ctdp_display_information_start(outf);
	for_each_online_target_cpu_in_set(get_clos_assoc_for_cpu, NULL,
					  NULL, NULL, NULL);
	isst_ctdp_display_information_end(outf);
}

static struct process_cmd_struct isst_cmds[] = {
@@ -1231,10 +1320,11 @@ static struct process_cmd_struct isst_cmds[] = {
	{ "turbo-freq", "info", dump_fact_config },
	{ "turbo-freq", "enable", set_fact_enable },
	{ "turbo-freq", "disable", set_fact_disable },
	{ "core-power", "info", dump_clos_config },
	{ "core-power", "info", dump_clos_info },
	{ "core-power", "enable", set_clos_enable },
	{ "core-power", "disable", set_clos_disable },
	{ "core-power", "config", set_clos_config },
	{ "core-power", "get-config", dump_clos_config },
	{ "core-power", "assoc", set_clos_assoc },
	{ "core-power", "get-assoc", get_clos_assoc },
	{ NULL, NULL, NULL }
@@ -1316,6 +1406,7 @@ static void parse_cmd_args(int argc, int start, char **argv)
	static struct option long_options[] = {
		{ "bucket", required_argument, 0, 'b' },
		{ "level", required_argument, 0, 'l' },
		{ "online", required_argument, 0, 'o' },
		{ "trl-type", required_argument, 0, 'r' },
		{ "trl", required_argument, 0, 't' },
		{ "help", no_argument, 0, 'h' },
@@ -1332,7 +1423,7 @@ static void parse_cmd_args(int argc, int start, char **argv)
	option_index = start;

	optind = start + 1;
	while ((opt = getopt_long(argc, argv, "b:l:t:c:d:e:n:m:p:w:h",
	while ((opt = getopt_long(argc, argv, "b:l:t:c:d:e:n:m:p:w:ho",
				  long_options, &option_index)) != -1) {
		switch (opt) {
		case 'b':
@@ -1344,6 +1435,9 @@ static void parse_cmd_args(int argc, int start, char **argv)
		case 'l':
			tdp_level = atoi(optarg);
			break;
		case 'o':
			force_online_offline = 1;
			break;
		case 't':
			sscanf(optarg, "0x%llx", &fact_trl);
			break;
@@ -1362,7 +1456,6 @@ static void parse_cmd_args(int argc, int start, char **argv)
		/* CLOS related */
		case 'c':
			current_clos = atoi(optarg);
			printf("clos %d\n", current_clos);
			break;
		case 'd':
			clos_desired = atoi(optarg);
@@ -1433,6 +1526,7 @@ static void core_power_help(void)
	printf("\tenable\n");
	printf("\tdisable\n");
	printf("\tconfig\n");
	printf("\tget-config\n");
	printf("\tassoc\n");
	printf("\tget-assoc\n");
}
+25 −0
Original line number Diff line number Diff line
@@ -619,6 +619,31 @@ int isst_get_process_ctdp(int cpu, int tdp_level, struct isst_pkg_ctdp *pkg_dev)
	return 0;
}

int isst_clos_get_clos_information(int cpu, int *enable, int *type)
{
	unsigned int resp;
	int ret;

	ret = isst_send_mbox_command(cpu, CONFIG_CLOS, CLOS_PM_QOS_CONFIG, 0, 0,
				     &resp);
	if (ret)
		return ret;

	debug_printf("cpu:%d CLOS_PM_QOS_CONFIG resp:%x\n", cpu, resp);

	if (resp & BIT(1))
		*enable = 1;
	else
		*enable = 0;

	if (resp & BIT(2))
		*type = 1;
	else
		*type = 0;

	return 0;
}

int isst_pm_qos_config(int cpu, int enable_clos, int priority_type)
{
	unsigned int req, resp;
Loading