OSDN Git Service

tools/power/x86/intel-speed-select: Improve output of perf-profile commands
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Thu, 5 Mar 2020 22:45:27 +0000 (14:45 -0800)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 20 Mar 2020 12:46:21 +0000 (14:46 +0200)
Improve output of perf-profile commands:
get-config-enabled
get-lock-status

Instead of showing 0/1, show meaningful strings. Also show error when
command is failed.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
tools/power/x86/intel-speed-select/isst-config.c
tools/power/x86/intel-speed-select/isst-display.c
tools/power/x86/intel-speed-select/isst.h

index 75c8e1a..362a352 100644 (file)
@@ -953,6 +953,7 @@ static void isst_print_platform_information(void)
        exit(0);
 }
 
+static char *local_str0, *local_str1;
 static void exec_on_get_ctdp_cpu(int cpu, void *arg1, void *arg2, void *arg3,
                                 void *arg4)
 {
@@ -962,13 +963,14 @@ static void exec_on_get_ctdp_cpu(int cpu, void *arg1, void *arg2, void *arg3,
        fn_ptr = arg1;
        ret = fn_ptr(cpu, arg2);
        if (ret)
-               perror("get_tdp_*");
+               isst_display_error_info_message(1, "get_tdp_* failed", 0, 0);
        else
                isst_ctdp_display_core_info(cpu, outf, arg3,
-                                           *(unsigned int *)arg4);
+                                           *(unsigned int *)arg4,
+                                           local_str0, local_str1);
 }
 
-#define _get_tdp_level(desc, suffix, object, help)                                \
+#define _get_tdp_level(desc, suffix, object, help, str0, str1)                 \
        static void get_tdp_##object(int arg)                                    \
        {                                                                         \
                struct isst_pkg_ctdp ctdp;                                        \
@@ -979,6 +981,8 @@ static void exec_on_get_ctdp_cpu(int cpu, void *arg1, void *arg2, void *arg3,
                                help);                                            \
                        exit(0);                                                  \
                }                                                                 \
+               local_str0 = str0;                                                \
+               local_str1 = str1;                                                \
                isst_ctdp_display_information_start(outf);                        \
                if (max_target_cpus)                                              \
                        for_each_online_target_cpu_in_set(                        \
@@ -992,12 +996,12 @@ static void exec_on_get_ctdp_cpu(int cpu, void *arg1, void *arg2, void *arg3,
                isst_ctdp_display_information_end(outf);                          \
        }
 
-_get_tdp_level("get-config-levels", levels, levels, "TDP levels");
-_get_tdp_level("get-config-version", levels, version, "TDP version");
-_get_tdp_level("get-config-enabled", levels, enabled, "TDP enable status");
+_get_tdp_level("get-config-levels", levels, levels, "Max TDP level", NULL, NULL);
+_get_tdp_level("get-config-version", levels, version, "TDP version", NULL, NULL);
+_get_tdp_level("get-config-enabled", levels, enabled, "perf-profile enable status", "disabled", "enabled");
 _get_tdp_level("get-config-current_level", levels, current_level,
-              "Current TDP Level");
-_get_tdp_level("get-lock-status", levels, locked, "TDP lock status");
+              "Current TDP Level", NULL, NULL);
+_get_tdp_level("get-lock-status", levels, locked, "TDP lock status", "unlocked", "locked");
 
 struct isst_pkg_ctdp clx_n_pkg_dev;
 
index 943226d..0667b40 100644 (file)
@@ -289,7 +289,7 @@ static void _isst_fact_display_information(int cpu, FILE *outf, int level,
 }
 
 void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix,
-                                unsigned int val)
+                                unsigned int val, char *str0, char *str1)
 {
        char header[256];
        char value[256];
@@ -301,8 +301,12 @@ void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix,
        format_and_print(outf, 2, header, NULL);
        snprintf(header, sizeof(header), "cpu-%d", cpu);
        format_and_print(outf, 3, header, NULL);
-
-       snprintf(value, sizeof(value), "%u", val);
+       if (str0 && !val)
+               snprintf(value, sizeof(value), "%s", str0);
+       else if (str1 && val)
+               snprintf(value, sizeof(value), "%s", str1);
+       else
+               snprintf(value, sizeof(value), "%u", val);
        format_and_print(outf, 4, prefix, value);
 
        format_and_print(outf, 1, NULL, NULL);
index 4950d23..69fa2c3 100644 (file)
@@ -208,7 +208,7 @@ extern void isst_get_process_ctdp_complete(int cpu,
 extern void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
                                          struct isst_pkg_ctdp *pkg_dev);
 extern void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix,
-                                       unsigned int val);
+                                       unsigned int val, char *str0, char *str1);
 extern void isst_ctdp_display_information_start(FILE *outf);
 extern void isst_ctdp_display_information_end(FILE *outf);
 extern void isst_pbf_display_information(int cpu, FILE *outf, int level,