OSDN Git Service

tools/power/x86/intel-speed-select: Fix result display for turbo-freq auto mode
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Tue, 14 Jan 2020 19:22:15 +0000 (11:22 -0800)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 20 Jan 2020 09:39:31 +0000 (11:39 +0200)
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>
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

index 944183f..e22a694 100644 (file)
@@ -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;
index 1d14390..4fb0c1d 100644 (file)
@@ -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);