]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools/power/x86/intel-speed-select: Add new command to get/set TRL
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Tue, 22 Dec 2020 09:33:55 +0000 (01:33 -0800)
committerSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Mon, 8 Feb 2021 19:54:58 +0000 (11:54 -0800)
Add a new command to get and set TRL (Turbo Ratio Limits). This will
help users to get/set TRL, when the direct MSR access is removed.

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

index 3d6bfe4f7caa72c844d27b27ea00b30ff65e1885..b3e30f00ce22189e25a6d32ba3fbb105cc4653a0 100644 (file)
@@ -2353,6 +2353,53 @@ static void set_turbo_mode(int arg)
        isst_ctdp_display_information_end(outf);
 }
 
+static void get_set_trl(int cpu, void *arg1, void *arg2, void *arg3,
+                       void *arg4)
+{
+       unsigned long long trl;
+       int set = *(int *)arg4;
+       int ret;
+
+       if (set && !fact_trl) {
+               isst_display_error_info_message(1, "Invalid TRL. Specify with [-t|--trl]", 0, 0);
+               exit(0);
+       }
+
+       if (set) {
+               ret = isst_set_trl(cpu, fact_trl);
+               isst_display_result(cpu, outf, "turbo-mode", "set-trl", ret);
+               return;
+       }
+
+       ret = isst_get_trl(cpu, &trl);
+       if (ret)
+               isst_display_result(cpu, outf, "turbo-mode", "get-trl", ret);
+       else
+               isst_trl_display_information(cpu, outf, trl);
+}
+
+static void process_trl(int arg)
+{
+       if (cmd_help) {
+               if (arg) {
+                       fprintf(stderr, "Set TRL (turbo ratio limits)\n");
+                       fprintf(stderr, "\t t|--trl: Specify turbo ratio limit for setting TRL\n");
+               } else {
+                       fprintf(stderr, "Get TRL (turbo ratio limits)\n");
+               }
+               exit(0);
+       }
+
+       isst_ctdp_display_information_start(outf);
+       if (max_target_cpus)
+               for_each_online_target_cpu_in_set(get_set_trl, NULL,
+                                                 NULL, NULL, &arg);
+       else
+               for_each_online_package_in_set(get_set_trl, NULL,
+                                              NULL, NULL, &arg);
+       isst_ctdp_display_information_end(outf);
+}
+
 static struct process_cmd_struct clx_n_cmds[] = {
        { "perf-profile", "info", dump_isst_config, 0 },
        { "base-freq", "info", dump_pbf_config, 0 },
@@ -2385,6 +2432,8 @@ static struct process_cmd_struct isst_cmds[] = {
        { "core-power", "get-assoc", get_clos_assoc, 0 },
        { "turbo-mode", "enable", set_turbo_mode, 0 },
        { "turbo-mode", "disable", set_turbo_mode, 1 },
+       { "turbo-mode", "get-trl", process_trl, 0 },
+       { "turbo-mode", "set-trl", process_trl, 1 },
        { NULL, NULL, NULL }
 };
 
@@ -2602,9 +2651,11 @@ static void fact_help(void)
 
 static void turbo_mode_help(void)
 {
-       printf("turbo-mode:\tEnables users to enable/disable turbo mode by adjusting frequency settings\n");
+       printf("turbo-mode:\tEnables users to enable/disable turbo mode by adjusting frequency settings. Also allows to get and set turbo ratio limits (TRL).\n");
        printf("\tcommand : enable\n");
        printf("\tcommand : disable\n");
+       printf("\tcommand : get-trl\n");
+       printf("\tcommand : set-trl\n");
 }
 
 
index 8afd23407522004b72678c98338d0768f1f25bee..6a26d5769984506f4ce4cf891a32dddf51912b65 100644 (file)
@@ -665,6 +665,17 @@ int isst_get_fact_info(int cpu, int level, int fact_bucket, struct isst_fact_inf
        return 0;
 }
 
+int isst_get_trl(int cpu, unsigned long long *trl)
+{
+       int ret;
+
+       ret = isst_send_msr_command(cpu, 0x1AD, 0, trl);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
 int isst_set_trl(int cpu, unsigned long long trl)
 {
        int ret;
index e105fece47b617cbcf50e6006aac0246a0b79ee9..8e54ce47648e28f0ffc0c297e6fd0e7655f77f71 100644 (file)
@@ -763,3 +763,21 @@ void isst_display_error_info_message(int error, char *msg, int arg_valid, int ar
        if (!start)
                format_and_print(outf, 0, NULL, NULL);
 }
+
+void isst_trl_display_information(int cpu, FILE *outf, unsigned long long trl)
+{
+       char header[256];
+       char value[256];
+       int level;
+
+       level = print_package_info(cpu, outf);
+
+       snprintf(header, sizeof(header), "get-trl");
+       format_and_print(outf, level + 1, header, NULL);
+
+       snprintf(header, sizeof(header), "trl");
+       snprintf(value, sizeof(value), "0x%llx", trl);
+       format_and_print(outf, level + 2, header, value);
+
+       format_and_print(outf, level, NULL, NULL);
+}
index 60db0bb084d58fee1c389275a4bc2a5a59dc3d92..0cac6c54be8734a4ac5d271ebe9bd175b2066e94 100644 (file)
@@ -228,6 +228,7 @@ extern void isst_fact_display_information(int cpu, FILE *outf, int level,
                                          int fact_bucket, int fact_avx,
                                          struct isst_fact_info *fact_info);
 extern int isst_set_trl(int cpu, unsigned long long trl);
+extern int isst_get_trl(int cpu, unsigned long long *trl);
 extern int isst_set_trl_from_current_tdp(int cpu, unsigned long long trl);
 extern int isst_get_config_tdp_lock_status(int cpu);
 
@@ -256,4 +257,5 @@ extern int get_cpufreq_base_freq(int cpu);
 extern int isst_read_pm_config(int cpu, int *cp_state, int *cp_cap);
 extern void isst_display_error_info_message(int error, char *msg, int arg_valid, int arg);
 extern int is_skx_based_platform(void);
+extern void isst_trl_display_information(int cpu, FILE *outf, unsigned long long trl);
 #endif