linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Intel Speed Select Core Power Support
@ 2020-01-14 19:22 Srinivas Pandruvada
  2020-01-14 19:22 ` [PATCH 1/5] platform/x86: ISST: Allow additional core-power mailbox commands Srinivas Pandruvada
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Srinivas Pandruvada @ 2020-01-14 19:22 UTC (permalink / raw)
  To: andriy.shevchenko, prarit
  Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada

This series add core-power or SST-CP support. Also fixes some display
issue with SST-TF.

Srinivas Pandruvada (5):
  platform/x86: ISST: Allow additional core-power mailbox commands
  tools/power/x86/intel-speed-select: Add support for core-power
    discovery
  tools/power/x86/intel-speed-select: Fix result display for turbo-freq
    auto mode
  tools/power/x86/intel-speed-select: Change the order for clos disable
  tools/power/x86/intel-speed-select: Update version

 .../intel_speed_select_if/isst_if_common.c    |  3 +
 .../x86/intel-speed-select/isst-config.c      | 34 ++++++------
 .../power/x86/intel-speed-select/isst-core.c  | 55 +++++++++++++++++++
 .../x86/intel-speed-select/isst-display.c     | 27 ++++++---
 tools/power/x86/intel-speed-select/isst.h     |  6 ++
 5 files changed, 100 insertions(+), 25 deletions(-)

-- 
2.24.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] platform/x86: ISST: Allow additional core-power mailbox commands
  2020-01-14 19:22 [PATCH 0/5] Intel Speed Select Core Power Support Srinivas Pandruvada
@ 2020-01-14 19:22 ` Srinivas Pandruvada
  2020-01-14 19:22 ` [PATCH 2/5] tools/power/x86/intel-speed-select: Add support for core-power discovery Srinivas Pandruvada
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Srinivas Pandruvada @ 2020-01-14 19:22 UTC (permalink / raw)
  To: andriy.shevchenko, prarit
  Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada

To discover core-power capability, some new mailbox commands are added. Allow
those commands to execute.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/platform/x86/intel_speed_select_if/isst_if_common.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/platform/x86/intel_speed_select_if/isst_if_common.c b/drivers/platform/x86/intel_speed_select_if/isst_if_common.c
index 3de5a3c66529..0c2aa22c7a12 100644
--- a/drivers/platform/x86/intel_speed_select_if/isst_if_common.c
+++ b/drivers/platform/x86/intel_speed_select_if/isst_if_common.c
@@ -50,6 +50,8 @@ static const struct isst_valid_cmd_ranges isst_valid_cmds[] = {
 	{0x7F, 0x00, 0x0B},
 	{0x7F, 0x10, 0x12},
 	{0x7F, 0x20, 0x23},
+	{0x94, 0x03, 0x03},
+	{0x95, 0x03, 0x03},
 };
 
 static const struct isst_cmd_set_req_type isst_cmd_set_reqs[] = {
@@ -59,6 +61,7 @@ static const struct isst_cmd_set_req_type isst_cmd_set_reqs[] = {
 	{0xD0, 0x03, 0x08},
 	{0x7F, 0x02, 0x00},
 	{0x7F, 0x08, 0x00},
+	{0x95, 0x03, 0x03},
 };
 
 struct isst_cmd {
-- 
2.24.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/5] tools/power/x86/intel-speed-select: Add support for core-power discovery
  2020-01-14 19:22 [PATCH 0/5] Intel Speed Select Core Power Support Srinivas Pandruvada
  2020-01-14 19:22 ` [PATCH 1/5] platform/x86: ISST: Allow additional core-power mailbox commands Srinivas Pandruvada
@ 2020-01-14 19:22 ` Srinivas Pandruvada
  2020-01-14 19:22 ` [PATCH 3/5] tools/power/x86/intel-speed-select: Fix result display for turbo-freq auto mode Srinivas Pandruvada
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Srinivas Pandruvada @ 2020-01-14 19:22 UTC (permalink / raw)
  To: andriy.shevchenko, prarit
  Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada

It is possible that BIOS may not enable core-power feature. In this case
this additional interface will allow to enable from this utility. Also
the information dump, includes the current status of core-power.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 .../power/x86/intel-speed-select/isst-core.c  | 55 +++++++++++++++++++
 .../x86/intel-speed-select/isst-display.c     | 11 ++++
 tools/power/x86/intel-speed-select/isst.h     |  6 ++
 3 files changed, 72 insertions(+)

diff --git a/tools/power/x86/intel-speed-select/isst-core.c b/tools/power/x86/intel-speed-select/isst-core.c
index d14c7bcd327a..81a119f688a3 100644
--- a/tools/power/x86/intel-speed-select/isst-core.c
+++ b/tools/power/x86/intel-speed-select/isst-core.c
@@ -6,6 +6,44 @@
 
 #include "isst.h"
 
+int isst_write_pm_config(int cpu, int cp_state)
+{
+	unsigned int req, resp;
+	int ret;
+
+	if (cp_state)
+		req = BIT(16);
+	else
+		req = 0;
+
+	ret = isst_send_mbox_command(cpu, WRITE_PM_CONFIG, PM_FEATURE, 0, req,
+				     &resp);
+	if (ret)
+		return ret;
+
+	debug_printf("cpu:%d WRITE_PM_CONFIG resp:%x\n", cpu, resp);
+
+	return 0;
+}
+
+int isst_read_pm_config(int cpu, int *cp_state, int *cp_cap)
+{
+	unsigned int resp;
+	int ret;
+
+	ret = isst_send_mbox_command(cpu, READ_PM_CONFIG, PM_FEATURE, 0, 0,
+				     &resp);
+	if (ret)
+		return ret;
+
+	debug_printf("cpu:%d READ_PM_CONFIG resp:%x\n", cpu, resp);
+
+	*cp_state = resp & BIT(16);
+	*cp_cap = resp & BIT(0) ? 1 : 0;
+
+	return 0;
+}
+
 int isst_get_ctdp_levels(int cpu, struct isst_pkg_ctdp *pkg_dev)
 {
 	unsigned int resp;
@@ -36,6 +74,7 @@ int isst_get_ctdp_levels(int cpu, struct isst_pkg_ctdp *pkg_dev)
 int isst_get_ctdp_control(int cpu, int config_index,
 			  struct isst_pkg_ctdp_level_info *ctdp_level)
 {
+	int cp_state, cp_cap;
 	unsigned int resp;
 	int ret;
 
@@ -50,6 +89,15 @@ int isst_get_ctdp_control(int cpu, int config_index,
 	ctdp_level->fact_enabled = !!(resp & BIT(16));
 	ctdp_level->pbf_enabled = !!(resp & BIT(17));
 
+	ret = isst_read_pm_config(cpu, &cp_state, &cp_cap);
+	if (ret) {
+		debug_printf("cpu:%d pm_config is not supported \n", cpu);
+	} else {
+		debug_printf("cpu:%d pm_config SST-CP state:%d cap:%d \n", cpu, cp_state, cp_cap);
+		ctdp_level->sst_cp_support = cp_cap;
+		ctdp_level->sst_cp_enabled = cp_state;
+	}
+
 	debug_printf(
 		"cpu:%d CONFIG_TDP_GET_TDP_CONTROL resp:%x fact_support:%d pbf_support: %d fact_enabled:%d pbf_enabled:%d\n",
 		cpu, resp, ctdp_level->fact_support, ctdp_level->pbf_support,
@@ -779,6 +827,13 @@ int isst_pm_qos_config(int cpu, int enable_clos, int priority_type)
 			debug_printf("Turbo-freq feature must be disabled first\n");
 			return -EINVAL;
 		}
+		ret = isst_write_pm_config(cpu, 0);
+		if (ret)
+			perror("isst_write_pm_config\n");
+	} else {
+		ret = isst_write_pm_config(cpu, 1);
+		if (ret)
+			perror("isst_write_pm_config\n");
 	}
 
 	ret = isst_send_mbox_command(cpu, CONFIG_CLOS, CLOS_PM_QOS_CONFIG, 0, 0,
diff --git a/tools/power/x86/intel-speed-select/isst-display.c b/tools/power/x86/intel-speed-select/isst-display.c
index 040dd09d5eee..1d1439036c12 100644
--- a/tools/power/x86/intel-speed-select/isst-display.c
+++ b/tools/power/x86/intel-speed-select/isst-display.c
@@ -418,6 +418,17 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
 			snprintf(value, sizeof(value), "unsupported");
 		format_and_print(outf, base_level + 4, header, value);
 
+		snprintf(header, sizeof(header),
+			 "speed-select-core-power");
+		if (ctdp_level->sst_cp_support) {
+			if (ctdp_level->sst_cp_enabled)
+				snprintf(value, sizeof(value), "enabled");
+			else
+				snprintf(value, sizeof(value), "disabled");
+		} else
+			snprintf(value, sizeof(value), "unsupported");
+		format_and_print(outf, base_level + 4, header, value);
+
 		if (is_clx_n_platform()) {
 			if (ctdp_level->pbf_support)
 				_isst_pbf_display_information(cpu, outf,
diff --git a/tools/power/x86/intel-speed-select/isst.h b/tools/power/x86/intel-speed-select/isst.h
index cdf0f8a6dbbf..ad5aa6341d0f 100644
--- a/tools/power/x86/intel-speed-select/isst.h
+++ b/tools/power/x86/intel-speed-select/isst.h
@@ -69,6 +69,10 @@
 #define PM_CLOS_OFFSET				0x08
 #define PQR_ASSOC_OFFSET			0x20
 
+#define READ_PM_CONFIG				0x94
+#define WRITE_PM_CONFIG				0x95
+#define PM_FEATURE				0x03
+
 #define DISP_FREQ_MULTIPLIER 100
 
 struct isst_clos_config {
@@ -119,6 +123,8 @@ struct isst_pkg_ctdp_level_info {
 	int pbf_support;
 	int fact_enabled;
 	int pbf_enabled;
+	int sst_cp_support;
+	int sst_cp_enabled;
 	int tdp_ratio;
 	int active;
 	int tdp_control;
-- 
2.24.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/5] tools/power/x86/intel-speed-select: Fix result display for turbo-freq auto mode
  2020-01-14 19:22 [PATCH 0/5] Intel Speed Select Core Power Support Srinivas Pandruvada
  2020-01-14 19:22 ` [PATCH 1/5] platform/x86: ISST: Allow additional core-power mailbox commands Srinivas Pandruvada
  2020-01-14 19:22 ` [PATCH 2/5] tools/power/x86/intel-speed-select: Add support for core-power discovery Srinivas Pandruvada
@ 2020-01-14 19:22 ` Srinivas Pandruvada
  2020-01-14 19:22 ` [PATCH 4/5] tools/power/x86/intel-speed-select: Change the order for clos disable Srinivas Pandruvada
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Srinivas Pandruvada @ 2020-01-14 19:22 UTC (permalink / raw)
  To: andriy.shevchenko, prarit
  Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada

The turbo-freq enable with auto mode, prints result for the last possible
CPU, which is not correct when either CPU is not present or user wants
command to be limited to a single die/package. For example, in the
below command user wants to limit to die/package 0, but the
"turbo-freq --auto" result is displayed using the other package.

$ sudo intel-speed-select -c 0 turbo-freq enable -a
Intel(R) Speed Select Technology
 package-0
  die-0
    cpu-0
      turbo-freq
        enable:success
 package--1
  die-0
    cpu-31
      turbo-freq --auto
        enable:success

Since we do have to traverse all CPUs, don't display CPU info for
"turbo-freq --auto", as we already displayed the result for
turbo-freq enable with the CPU information.

With the fix, the same command results in:

$ sudo intel-speed-select -c 0 turbo-freq enable -a
Intel(R) Speed Select Technology
package-0
  die-0
    cpu-0
      turbo-freq
        enable:success
      turbo-freq --auto
        enable:success

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 tools/power/x86/intel-speed-select/isst-config.c |  2 +-
 .../power/x86/intel-speed-select/isst-display.c  | 16 +++++++++-------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c
index 944183f9ed5a..e22a694e6410 100644
--- a/tools/power/x86/intel-speed-select/isst-config.c
+++ b/tools/power/x86/intel-speed-select/isst-config.c
@@ -1638,7 +1638,7 @@ static void set_fact_enable(int arg)
 			if (ret)
 				goto error_disp;
 		}
-		isst_display_result(i, outf, "turbo-freq --auto", "enable", 0);
+		isst_display_result(-1, outf, "turbo-freq --auto", "enable", 0);
 	}
 
 	return;
diff --git a/tools/power/x86/intel-speed-select/isst-display.c b/tools/power/x86/intel-speed-select/isst-display.c
index 1d1439036c12..4fb0c1d49d64 100644
--- a/tools/power/x86/intel-speed-select/isst-display.c
+++ b/tools/power/x86/intel-speed-select/isst-display.c
@@ -645,13 +645,15 @@ void isst_display_result(int cpu, FILE *outf, char *feature, char *cmd,
 	char header[256];
 	char value[256];
 
-	snprintf(header, sizeof(header), "package-%d",
-		 get_physical_package_id(cpu));
-	format_and_print(outf, 1, header, NULL);
-	snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
-	format_and_print(outf, 2, header, NULL);
-	snprintf(header, sizeof(header), "cpu-%d", cpu);
-	format_and_print(outf, 3, header, NULL);
+	if (cpu >= 0) {
+		snprintf(header, sizeof(header), "package-%d",
+			 get_physical_package_id(cpu));
+		format_and_print(outf, 1, header, NULL);
+		snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
+		format_and_print(outf, 2, header, NULL);
+		snprintf(header, sizeof(header), "cpu-%d", cpu);
+		format_and_print(outf, 3, header, NULL);
+	}
 	snprintf(header, sizeof(header), "%s", feature);
 	format_and_print(outf, 4, header, NULL);
 	snprintf(header, sizeof(header), "%s", cmd);
-- 
2.24.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/5] tools/power/x86/intel-speed-select: Change the order for clos disable
  2020-01-14 19:22 [PATCH 0/5] Intel Speed Select Core Power Support Srinivas Pandruvada
                   ` (2 preceding siblings ...)
  2020-01-14 19:22 ` [PATCH 3/5] tools/power/x86/intel-speed-select: Fix result display for turbo-freq auto mode Srinivas Pandruvada
@ 2020-01-14 19:22 ` Srinivas Pandruvada
  2020-01-14 19:22 ` [PATCH 5/5] tools/power/x86/intel-speed-select: Update version Srinivas Pandruvada
  2020-01-23 12:32 ` [PATCH 0/5] Intel Speed Select Core Power Support Andy Shevchenko
  5 siblings, 0 replies; 7+ messages in thread
From: Srinivas Pandruvada @ 2020-01-14 19:22 UTC (permalink / raw)
  To: andriy.shevchenko, prarit
  Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada

In turbo-freq or base-freq auto mode, for disable, first disable the feature and
then disable clos.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 .../x86/intel-speed-select/isst-config.c      | 30 +++++++++----------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c
index e22a694e6410..84baba34d311 100644
--- a/tools/power/x86/intel-speed-select/isst-config.c
+++ b/tools/power/x86/intel-speed-select/isst-config.c
@@ -1384,14 +1384,10 @@ static void set_pbf_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
 		goto disp_result;
 	}
 
-	if (auto_mode) {
-		if (status) {
-			ret = set_pbf_core_power(cpu);
-			if (ret)
-				goto disp_result;
-		} else {
-			isst_pm_qos_config(cpu, 0, 0);
-		}
+	if (auto_mode && status) {
+		ret = set_pbf_core_power(cpu);
+		if (ret)
+			goto disp_result;
 	}
 
 	ret = isst_set_pbf_fact_status(cpu, 1, status);
@@ -1408,6 +1404,9 @@ static void set_pbf_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
 		}
 	}
 
+	if (auto_mode && !status)
+		isst_pm_qos_config(cpu, 0, 0);
+
 disp_result:
 	if (status)
 		isst_display_result(cpu, outf, "base-freq", "enable",
@@ -1496,14 +1495,10 @@ static void set_fact_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
 	int ret;
 	int status = *(int *)arg4;
 
-	if (auto_mode) {
-		if (status) {
-			ret = isst_pm_qos_config(cpu, 1, 1);
-			if (ret)
-				goto disp_results;
-		} else {
-			isst_pm_qos_config(cpu, 0, 0);
-		}
+	if (auto_mode && status) {
+		ret = isst_pm_qos_config(cpu, 1, 1);
+		if (ret)
+			goto disp_results;
 	}
 
 	ret = isst_set_pbf_fact_status(cpu, 0, status);
@@ -1524,6 +1519,9 @@ static void set_fact_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
 			ret = isst_set_trl(cpu, fact_trl);
 		if (ret && auto_mode)
 			isst_pm_qos_config(cpu, 0, 0);
+	} else {
+		if (auto_mode)
+			isst_pm_qos_config(cpu, 0, 0);
 	}
 
 disp_results:
-- 
2.24.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 5/5] tools/power/x86/intel-speed-select: Update version
  2020-01-14 19:22 [PATCH 0/5] Intel Speed Select Core Power Support Srinivas Pandruvada
                   ` (3 preceding siblings ...)
  2020-01-14 19:22 ` [PATCH 4/5] tools/power/x86/intel-speed-select: Change the order for clos disable Srinivas Pandruvada
@ 2020-01-14 19:22 ` Srinivas Pandruvada
  2020-01-23 12:32 ` [PATCH 0/5] Intel Speed Select Core Power Support Andy Shevchenko
  5 siblings, 0 replies; 7+ messages in thread
From: Srinivas Pandruvada @ 2020-01-14 19:22 UTC (permalink / raw)
  To: andriy.shevchenko, prarit
  Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada

As we added new set of mailbox commands, increment version.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 tools/power/x86/intel-speed-select/isst-config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c
index 84baba34d311..2b2b8167c65b 100644
--- a/tools/power/x86/intel-speed-select/isst-config.c
+++ b/tools/power/x86/intel-speed-select/isst-config.c
@@ -15,7 +15,7 @@ struct process_cmd_struct {
 	int arg;
 };
 
-static const char *version_str = "v1.1";
+static const char *version_str = "v1.2";
 static const int supported_api_ver = 1;
 static struct isst_if_platform_info isst_platform_info;
 static char *progname;
-- 
2.24.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/5] Intel Speed Select Core Power Support
  2020-01-14 19:22 [PATCH 0/5] Intel Speed Select Core Power Support Srinivas Pandruvada
                   ` (4 preceding siblings ...)
  2020-01-14 19:22 ` [PATCH 5/5] tools/power/x86/intel-speed-select: Update version Srinivas Pandruvada
@ 2020-01-23 12:32 ` Andy Shevchenko
  5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2020-01-23 12:32 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: Andriy Shevchenko, Prarit Bhargava, Platform Driver,
	Linux Kernel Mailing List

On Tue, Jan 14, 2020 at 9:22 PM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> This series add core-power or SST-CP support. Also fixes some display
> issue with SST-TF.
>

Pushed to my review and testing queue, thanks!

> Srinivas Pandruvada (5):
>   platform/x86: ISST: Allow additional core-power mailbox commands
>   tools/power/x86/intel-speed-select: Add support for core-power
>     discovery
>   tools/power/x86/intel-speed-select: Fix result display for turbo-freq
>     auto mode
>   tools/power/x86/intel-speed-select: Change the order for clos disable
>   tools/power/x86/intel-speed-select: Update version
>
>  .../intel_speed_select_if/isst_if_common.c    |  3 +
>  .../x86/intel-speed-select/isst-config.c      | 34 ++++++------
>  .../power/x86/intel-speed-select/isst-core.c  | 55 +++++++++++++++++++
>  .../x86/intel-speed-select/isst-display.c     | 27 ++++++---
>  tools/power/x86/intel-speed-select/isst.h     |  6 ++
>  5 files changed, 100 insertions(+), 25 deletions(-)
>
> --
> 2.24.1
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-23 12:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 19:22 [PATCH 0/5] Intel Speed Select Core Power Support Srinivas Pandruvada
2020-01-14 19:22 ` [PATCH 1/5] platform/x86: ISST: Allow additional core-power mailbox commands Srinivas Pandruvada
2020-01-14 19:22 ` [PATCH 2/5] tools/power/x86/intel-speed-select: Add support for core-power discovery Srinivas Pandruvada
2020-01-14 19:22 ` [PATCH 3/5] tools/power/x86/intel-speed-select: Fix result display for turbo-freq auto mode Srinivas Pandruvada
2020-01-14 19:22 ` [PATCH 4/5] tools/power/x86/intel-speed-select: Change the order for clos disable Srinivas Pandruvada
2020-01-14 19:22 ` [PATCH 5/5] tools/power/x86/intel-speed-select: Update version Srinivas Pandruvada
2020-01-23 12:32 ` [PATCH 0/5] Intel Speed Select Core Power Support Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).