Lines Matching +full:switch +full:- +full:freq +full:- +full:select

1 // SPDX-License-Identifier: GPL-2.0
3 * Intel Speed Select -- Enumerate and control features
52 static int current_clos = -1;
53 static int clos_epp = -1;
54 static int clos_prop_prio = -1;
55 static int clos_min = -1;
56 static int clos_max = -1;
57 static int clos_desired = -1;
139 /* only three CascadeLake-N models are supported */ in update_cpu_model()
148 err(-1, "cannot open /proc/cpuinfo\n"); in update_cpu_model()
193 return -1; in parse_int_file()
229 return -1; in get_stored_topology_info()
237 ret = -1; in get_stored_topology_info()
279 cpu_top.core_id = -1; in store_cpu_topology()
284 cpu_top.pkg_id = -1; in store_cpu_topology()
289 cpu_top.die_id = -1; in store_cpu_topology()
307 return -1; in get_physical_package_id()
331 return -1; in get_physical_core_id()
355 return -1; in get_physical_die_id()
383 id->cpu = cpu; in set_isst_id()
385 id->pkg = get_physical_package_id(cpu); in set_isst_id()
386 if (id < 0 || id->pkg >= MAX_PACKAGE_COUNT) in set_isst_id()
387 id->pkg = -1; in set_isst_id()
389 id->die = get_physical_die_id(cpu); in set_isst_id()
390 if (id < 0 || id->die >= MAX_DIE_PER_PACKAGE) in set_isst_id()
391 id->die = -1; in set_isst_id()
400 if (id->pkg == tid.pkg && id->die == tid.die) in is_cpu_in_power_domain()
431 err(-1, "%s open failed", buffer); in set_cpu_online_offline()
439 if (ret == -1) in set_cpu_online_offline()
608 if (id->pkg < 0 || id->die < 0) in get_cpu_count()
611 return cpu_cnt[id->pkg][id->die]; in get_cpu_count()
629 err(-1, "%s open failed", pathname); in create_cpu_map()
668 if (ioctl(fd, ISST_IF_GET_PHY_ID, &map) == -1) { in create_cpu_map()
732 return -EINVAL; in find_phy_core_num()
747 err(-1, "%s open failed", pathname); in isst_send_mmio_command()
760 if (ioctl(fd, cmd, &io_regs) == -1) { in isst_send_mmio_command()
807 switch (sub_command) { in isst_send_mbox_command()
844 err(-1, "%s open failed", pathname); in isst_send_mbox_command()
849 if (ioctl(fd, ISST_IF_MBOX_COMMAND, &mbox_cmds) == -1) { in isst_send_mbox_command()
858 --retry; in isst_send_mbox_command()
872 return -1; in isst_send_mbox_command()
887 err(-1, "%s open failed", pathname); in isst_send_msr_command()
896 if (ioctl(fd, ISST_IF_MSR_COMMAND, &msr_cmds) == -1) { in isst_send_msr_command()
921 err(-1, "%s open failed", pathname); in isst_fill_platform_info()
923 if (ioctl(fd, ISST_IF_GET_PLATFORM_INFO, &isst_platform_info) == -1) { in isst_fill_platform_info()
926 return -1; in isst_fill_platform_info()
933 return -1; in isst_fill_platform_info()
968 fprintf(outf, "Intel(R) SST-PP (feature perf-profile) is supported\n"); in isst_print_extended_platform_info()
970 fprintf(outf, "Intel(R) SST-PP (feature perf-profile) is not supported\n"); in isst_print_extended_platform_info()
992 fprintf(outf, "Intel(R) SST-TF (feature turbo-freq) is supported\n"); in isst_print_extended_platform_info()
994 fprintf(outf, "Intel(R) SST-TF (feature turbo-freq) is not supported\n"); in isst_print_extended_platform_info()
997 fprintf(outf, "Intel(R) SST-BF (feature base-freq) is supported\n"); in isst_print_extended_platform_info()
999 fprintf(outf, "Intel(R) SST-BF (feature base-freq) is not supported\n"); in isst_print_extended_platform_info()
1003 fprintf(outf, "Intel(R) SST-CP (feature core-power) status is unknown\n"); in isst_print_extended_platform_info()
1007 fprintf(outf, "Intel(R) SST-CP (feature core-power) is supported\n"); in isst_print_extended_platform_info()
1009 fprintf(outf, "Intel(R) SST-CP (feature core-power) is not supported\n"); in isst_print_extended_platform_info()
1029 err(-1, "%s open failed", pathname); in isst_print_platform_information()
1031 if (ioctl(fd, ISST_IF_GET_PLATFORM_INFO, &platform_info) == -1) { in isst_print_platform_information()
1093 _get_tdp_level("get-config-levels", levels, levels, "Max TDP level", NULL, NULL);
1094 _get_tdp_level("get-config-version", levels, version, "TDP version", NULL, NULL);
1095 _get_tdp_level("get-config-enabled", levels, enabled, "perf-profile enable status", "disabled", "en…
1096 _get_tdp_level("get-config-current_level", levels, current_level,
1098 _get_tdp_level("get-lock-status", levels, locked, "TDP lock status", "unlocked", "locked");
1112 err(-1, "cannot open /proc/cpuinfo\n"); in clx_n_get_base_ratio()
1116 /* this is true for CascadeLake-N */ in clx_n_get_base_ratio()
1119 strncpy(number, begin, end - begin); in clx_n_get_base_ratio()
1138 pbf_info = &ctdp_level->pbf_info; in clx_n_config()
1139 ctdp_level->core_cpumask_size = in clx_n_config()
1140 alloc_cpu_set(&ctdp_level->core_cpumask); in clx_n_config()
1143 ctdp_level->tdp_ratio = clx_n_get_base_ratio(); in clx_n_config()
1144 if (ctdp_level->tdp_ratio == 0) { in clx_n_config()
1146 ret = -1; in clx_n_config()
1151 pbf_info->p1_high = 0; in clx_n_config()
1152 pbf_info->p1_low = ~0; in clx_n_config()
1161 CPU_SET_S(i, ctdp_level->core_cpumask_size, in clx_n_config()
1162 ctdp_level->core_cpumask); in clx_n_config()
1167 if (cpu_bf > pbf_info->p1_high) in clx_n_config()
1168 pbf_info->p1_high = cpu_bf; in clx_n_config()
1169 if (cpu_bf < pbf_info->p1_low) in clx_n_config()
1170 pbf_info->p1_low = cpu_bf; in clx_n_config()
1173 if (pbf_info->p1_high == ~0UL) { in clx_n_config()
1175 ret = -1; in clx_n_config()
1179 if (pbf_info->p1_low == 0) { in clx_n_config()
1181 ret = -1; in clx_n_config()
1186 pbf_info->p1_high = pbf_info->p1_high / 100000; in clx_n_config()
1187 pbf_info->p1_low = pbf_info->p1_low / 100000; in clx_n_config()
1190 pbf_info->core_cpumask_size = alloc_cpu_set(&pbf_info->core_cpumask); in clx_n_config()
1202 if (cpu_bf == pbf_info->p1_high) in clx_n_config()
1203 CPU_SET_S(i, pbf_info->core_cpumask_size, in clx_n_config()
1204 pbf_info->core_cpumask); in clx_n_config()
1208 ctdp_level->processed = 1; in clx_n_config()
1209 ctdp_level->pbf_support = 1; /* PBF is always supported and enabled */ in clx_n_config()
1210 ctdp_level->pbf_enabled = 1; in clx_n_config()
1211 ctdp_level->fact_support = 0; /* FACT is never supported */ in clx_n_config()
1212 ctdp_level->fact_enabled = 0; in clx_n_config()
1217 free_cpu_set(ctdp_level->core_cpumask); in clx_n_config()
1239 pbf_info = &ctdp_level->pbf_info; in dump_clx_n_config_for_cpu()
1242 free_cpu_set(ctdp_level->core_cpumask); in dump_clx_n_config_for_cpu()
1243 free_cpu_set(pbf_info->core_cpumask); in dump_clx_n_config_for_cpu()
1256 isst_display_error_info_message(1, "Failed to get perf-profile info on cpu", 1, id->cpu); in dump_isst_config_for_cpu()
1271 "Print Intel(R) Speed Select Technology Performance profile configuration\n"); in dump_isst_config()
1274 fprintf(stderr, "Optional: -l|--level : Specify tdp level\n"); in dump_isst_config()
1308 isst_display_result(id, outf, "perf-profile", "set_tdp_level", in set_tdp_level_for_cpu()
1348 "\t Arguments: -l|--level : Specify tdp level\n"); in set_tdp_level()
1350 "\t Optional Arguments: -o | online : online/offline for the tdp level\n"); in set_tdp_level()
1383 pbf_info = &ctdp_level->pbf_info; in clx_n_dump_pbf_config_for_cpu()
1385 free_cpu_set(ctdp_level->core_cpumask); in clx_n_dump_pbf_config_for_cpu()
1386 free_cpu_set(pbf_info->core_cpumask); in clx_n_dump_pbf_config_for_cpu()
1398 isst_display_error_info_message(1, "Failed to get base-freq info at this level", 1, tdp_level); in dump_pbf_config_for_cpu()
1413 "Print Intel(R) Speed Select Technology base frequency configuration for a TDP level\n"); in dump_pbf_config()
1415 "\tArguments: -l|--level : Specify tdp level\n"); in dump_pbf_config()
1462 static int set_cpufreq_scaling_min_max(int cpu, int max, int freq) in set_cpufreq_scaling_min_max() argument
1478 snprintf(freq_str, sizeof(freq_str), "%d", freq); in set_cpufreq_scaling_min_max()
1481 if (ret == -1) { in set_cpufreq_scaling_min_max()
1519 int i, freq, freq_high, freq_low; in set_clx_pbf_cpufreq_scaling_min_max() local
1529 pbf_info = &ctdp_level->pbf_info; in set_clx_pbf_cpufreq_scaling_min_max()
1530 freq_high = pbf_info->p1_high * 100000; in set_clx_pbf_cpufreq_scaling_min_max()
1531 freq_low = pbf_info->p1_low * 100000; in set_clx_pbf_cpufreq_scaling_min_max()
1537 if (CPU_ISSET_S(i, pbf_info->core_cpumask_size, in set_clx_pbf_cpufreq_scaling_min_max()
1538 pbf_info->core_cpumask)) in set_clx_pbf_cpufreq_scaling_min_max()
1539 freq = freq_high; in set_clx_pbf_cpufreq_scaling_min_max()
1541 freq = freq_low; in set_clx_pbf_cpufreq_scaling_min_max()
1543 set_cpufreq_scaling_min_max(i, 1, freq); in set_clx_pbf_cpufreq_scaling_min_max()
1544 set_cpufreq_scaling_min_max(i, 0, freq); in set_clx_pbf_cpufreq_scaling_min_max()
1556 return -1; in set_cpufreq_scaling_min_max_from_cpuinfo()
1588 if (ret == -1) { in set_cpufreq_scaling_min_max_from_cpuinfo()
1643 return -1; in set_core_priority_and_min()
1756 …isst_display_error_info_message(1, "base-freq feature is not present at this level", 1, pkg_dev.cu… in set_pbf_for_cpu()
1757 ret = -1; in set_pbf_for_cpu()
1786 isst_display_result(id, outf, "base-freq", "enable", in set_pbf_for_cpu()
1789 isst_display_result(id, outf, "base-freq", "disable", in set_pbf_for_cpu()
1800 "Enable Intel Speed Select Technology base frequency feature\n"); in set_pbf_enable()
1810 "\tOptional Arguments: -a|--auto : Use priority of cores to set core-power associations\n"); in set_pbf_enable()
1821 "Disable Intel Speed Select Technology base frequency feature\n"); in set_pbf_enable()
1823 "\tOptional Arguments: -a|--auto : Also disable core-power associations\n"); in set_pbf_enable()
1846 isst_display_error_info_message(1, "Failed to get turbo-freq info at this level", 1, tdp_level); in dump_fact_config_for_cpu()
1859 …"Print complete Intel Speed Select Technology turbo frequency configuration for a TDP level. Other… in dump_fact_config()
1861 "\tArguments: -l|--level : Specify tdp level\n"); in dump_fact_config()
1863 "\tArguments: -b|--bucket : Bucket index to dump\n"); in dump_fact_config()
1865 "\tArguments: -r|--trl-type : Specify trl type: sse|avx2|avx512\n"); in dump_fact_config()
1894 ret = -1; in set_fact_for_cpu()
1911 …isst_display_error_info_message(1, "turbo-freq feature is not present at this level", 1, pkg_dev.c… in set_fact_for_cpu()
1912 ret = -1; in set_fact_for_cpu()
1947 isst_display_result(id, outf, "turbo-freq", "enable", ret); in set_fact_for_cpu()
1953 isst_display_result(id, outf, "turbo-freq", "disable", ret); in set_fact_for_cpu()
1965 "Enable Intel Speed Select Technology Turbo frequency feature\n"); in set_fact_enable()
1967 "Optional: -t|--trl : Specify turbo ratio limit\n"); in set_fact_enable()
1969 "\tOptional Arguments: -a|--auto : Designate specified target CPUs with"); in set_fact_enable()
1971 "-C|--cpu option as as high priority using core-power feature\n"); in set_fact_enable()
1974 "Disable Intel Speed Select Technology turbo frequency feature\n"); in set_fact_enable()
1976 "Optional: -t|--trl : Specify turbo ratio limit\n"); in set_fact_enable()
1978 "\tOptional Arguments: -a|--auto : Also disable core-power associations\n"); in set_fact_enable()
2061 set_isst_id(&id, -1); in set_fact_enable()
2062 isst_display_result(&id, outf, "turbo-freq --auto", "enable", 0); in set_fact_enable()
2068 isst_display_result(&id, outf, "turbo-freq --auto", "enable", ret); in set_fact_enable()
2086 isst_display_result(id, outf, "core-power", "enable", in enable_clos_qos_config()
2089 isst_display_result(id, outf, "core-power", "disable", in enable_clos_qos_config()
2100 "Enable core-power for a package/die\n"); in set_clos_enable()
2103 "\tClos Enable: Specify priority type with [--priority|-p]\n"); in set_clos_enable()
2108 "Disable core-power: [No command arguments are required]\n"); in set_clos_enable()
2115 "cpufreq subsystem and core-power enable will interfere with each other!\n"); in set_clos_enable()
2146 "Print Intel Speed Select Technology core power configuration\n"); in dump_clos_config()
2148 "\tArguments: [-c | --clos]: Specify clos id\n"); in dump_clos_config()
2188 "Print Intel Speed Select Technology core power information\n"); in dump_clos_info()
2189 fprintf(stderr, "\t Optionally specify targeted cpu id with [--cpu|-c]\n"); in dump_clos_info()
2219 isst_display_result(id, outf, "core-power", "config", ret); in set_clos_config_for_cpu()
2226 "Set core-power configuration for one of the four clos ids\n"); in set_clos_config()
2228 "\tSpecify targeted clos id with [--clos|-c]\n"); in set_clos_config()
2230 fprintf(stderr, "\tSpecify clos EPP with [--epp|-e]\n"); in set_clos_config()
2232 "\tSpecify clos Proportional Priority [--weight|-w]\n"); in set_clos_config()
2234 fprintf(stderr, "\tSpecify clos min in MHz with [--min|-n]\n"); in set_clos_config()
2235 fprintf(stderr, "\tSpecify clos max in MHz with [--max|-m]\n"); in set_clos_config()
2284 isst_display_result(id, outf, "core-power", "assoc", ret); in set_clos_assoc_for_cpu()
2292 "\tSpecify targeted clos id with [--clos|-c]\n"); in set_clos_assoc()
2296 "\tintel-speed-select --cpu 0 core-power assoc --clos 1\n"); in set_clos_assoc()
2308 isst_display_error_info_message(1, "Invalid target cpu. Specify with [-c|--cpu]", 0, 0); in set_clos_assoc()
2328 fprintf(stderr, "\tSpecify targeted cpu id with [--cpu|-c]\n"); in get_clos_assoc()
2333 isst_display_error_info_message(1, "Invalid target cpu. Specify with [-c|--cpu]", 0, 0); in get_clos_assoc()
2348 base_freq = get_cpufreq_base_freq(id->cpu); in set_turbo_mode_for_cpu()
2349 set_cpufreq_scaling_min_max(id->cpu, 1, base_freq); in set_turbo_mode_for_cpu()
2355 isst_display_result(id, outf, "turbo-mode", "enable", 0); in set_turbo_mode_for_cpu()
2357 isst_display_result(id, outf, "turbo-mode", "disable", 0); in set_turbo_mode_for_cpu()
2403 isst_display_error_info_message(1, "Invalid TRL. Specify with [-t|--trl]", 0, 0); in get_set_trl()
2409 isst_display_result(id, outf, "turbo-mode", "set-trl", ret); in get_set_trl()
2415 isst_display_result(id, outf, "turbo-mode", "get-trl", ret); in get_set_trl()
2425 fprintf(stderr, "\t t|--trl: Specify turbo ratio limit for setting TRL\n"); in process_trl()
2443 { "perf-profile", "info", dump_isst_config, 0 },
2444 { "base-freq", "info", dump_pbf_config, 0 },
2445 { "base-freq", "enable", set_pbf_enable, 1 },
2446 { "base-freq", "disable", set_pbf_enable, 0 },
2451 { "perf-profile", "get-lock-status", get_tdp_locked, 0 },
2452 { "perf-profile", "get-config-levels", get_tdp_levels, 0 },
2453 { "perf-profile", "get-config-version", get_tdp_version, 0 },
2454 { "perf-profile", "get-config-enabled", get_tdp_enabled, 0 },
2455 { "perf-profile", "get-config-current-level", get_tdp_current_level,
2457 { "perf-profile", "set-config-level", set_tdp_level, 0 },
2458 { "perf-profile", "info", dump_isst_config, 0 },
2459 { "base-freq", "info", dump_pbf_config, 0 },
2460 { "base-freq", "enable", set_pbf_enable, 1 },
2461 { "base-freq", "disable", set_pbf_enable, 0 },
2462 { "turbo-freq", "info", dump_fact_config, 0 },
2463 { "turbo-freq", "enable", set_fact_enable, 1 },
2464 { "turbo-freq", "disable", set_fact_enable, 0 },
2465 { "core-power", "info", dump_clos_info, 0 },
2466 { "core-power", "enable", set_clos_enable, 1 },
2467 { "core-power", "disable", set_clos_enable, 0 },
2468 { "core-power", "config", set_clos_config, 0 },
2469 { "core-power", "get-config", dump_clos_config, 0 },
2470 { "core-power", "assoc", set_clos_assoc, 0 },
2471 { "core-power", "get-assoc", get_clos_assoc, 0 },
2472 { "turbo-mode", "enable", set_turbo_mode, 0 },
2473 { "turbo-mode", "disable", set_turbo_mode, 1 },
2474 { "turbo-mode", "get-trl", process_trl, 0 },
2475 { "turbo-mode", "set-trl", process_trl, 1 },
2481 * 1,2,4..6,8-10 and set bits in cpu_subset
2491 if (*next == '-') /* no negative cpu numbers */ in parse_cpu_command()
2507 if (*next == '-') { in parse_cpu_command()
2543 fprintf(stderr, "\"--cpu %s\" malformed\n", optarg); in parse_cpu_command()
2544 exit(-1); in parse_cpu_command()
2556 { "trl-type", required_argument, 0, 'r' }, in parse_cmd_args()
2574 long_options, &option_index)) != -1) { in parse_cmd_args()
2575 switch (opt) { in parse_cmd_args()
2654 printf("perf-profile:\tAn architectural mechanism that allows multiple optimized \n\ in isst_help()
2658 printf("\nCommands : For feature=perf-profile\n"); in isst_help()
2662 printf("\tget-lock-status\n"); in isst_help()
2663 printf("\tget-config-levels\n"); in isst_help()
2664 printf("\tget-config-version\n"); in isst_help()
2665 printf("\tget-config-enabled\n"); in isst_help()
2666 printf("\tget-config-current-level\n"); in isst_help()
2667 printf("\tset-config-level\n"); in isst_help()
2673 printf("base-freq:\tEnables users to increase guaranteed base frequency\n\ in pbf_help()
2683 printf("turbo-freq:\tEnables the ability to set different turbo ratio\n\ in fact_help()
2685 printf("\nCommand: For feature=turbo-freq\n"); in fact_help()
2693 …printf("turbo-mode:\tEnables users to enable/disable turbo mode by adjusting frequency settings. A… in turbo_mode_help()
2696 printf("\tcommand : get-trl\n"); in turbo_mode_help()
2697 printf("\tcommand : set-trl\n"); in turbo_mode_help()
2703 printf("core-power:\tInterface that allows user to define per core/tile\n\ in core_power_help()
2705 printf("\nCommands : For feature=core-power\n"); in core_power_help()
2710 printf("\tget-config\n"); in core_power_help()
2712 printf("\tget-assoc\n"); in core_power_help()
2721 { "perf-profile", isst_help },
2722 { "base-freq", pbf_help },
2723 { "turbo-freq", fact_help },
2724 { "core-power", core_power_help },
2725 { "turbo-mode", turbo_mode_help },
2730 { "perf-profile", isst_help },
2731 { "base-freq", pbf_help },
2747 if (!strcmp(cmd, "-h") || !strcmp(cmd, "--help")) { in process_command()
2776 fprintf(stderr, "\nThere is limited support of Intel Speed Select features on this platform.\n"); in usage()
2777 …fprintf(stderr, "Everything is pre-configured using BIOS options, this tool can't enable any featu… in usage()
2781 printf("intel-speed-select [OPTIONS] FEATURE COMMAND COMMAND_ARGUMENTS\n"); in usage()
2782 printf("\nUse this tool to enumerate and control the Intel Speed Select Technology features:\n"); in usage()
2784 printf("\nFEATURE : [perf-profile|base-freq]\n"); in usage()
2786 printf("\nFEATURE : [perf-profile|base-freq|turbo-freq|core-power|turbo-mode]\n"); in usage()
2787 printf("\nFor help on each feature, use -h|--help\n"); in usage()
2788 printf("\tFor example: intel-speed-select perf-profile -h\n"); in usage()
2790 printf("\nFor additional help on each command for a feature, use --h|--help\n"); in usage()
2791 printf("\tFor example: intel-speed-select perf-profile get-lock-status -h\n"); in usage()
2792 …printf("\t\t This will print help for the command \"get-lock-status\" for the feature \"perf-profi… in usage()
2795 printf("\t[-c|--cpu] : logical cpu number\n"); in usage()
2798 printf("\t[-d|--debug] : Debug mode\n"); in usage()
2799 printf("\t[-f|--format] : output format [json|text]. Default: text\n"); in usage()
2800 printf("\t[-h|--help] : Print help\n"); in usage()
2801 printf("\t[-i|--info] : Print platform information\n"); in usage()
2802 printf("\t[-a|--all-cpus-online] : Force online every CPU in the system\n"); in usage()
2803 printf("\t[-o|--out] : Output file\n"); in usage()
2805 printf("\t[-p|--pause] : Delay between two mail box commands in milliseconds\n"); in usage()
2806 printf("\t[-r|--retry] : Retry count for mail box commands on failure, default 3\n"); in usage()
2807 printf("\t[-v|--version] : Print version\n"); in usage()
2808 …printf("\t[-b|--oob : Start a daemon to process HFI events for perf profile change from Out of Ban… in usage()
2809 printf("\t[-n|--no-daemon : Don't run as daemon. By default --oob will turn on daemon mode\n"); in usage()
2810 printf("\t[-w|--delay : Delay for reading config level state change in OOB poll mode.\n"); in usage()
2818 printf("\t\tintel-speed-select --info\n"); in usage()
2819 printf("\tTo get full perf-profile information dump:\n"); in usage()
2820 printf("\t\tintel-speed-select perf-profile info\n"); in usage()
2821 printf("\tTo get full base-freq information dump:\n"); in usage()
2822 printf("\t\tintel-speed-select base-freq info -l 0\n"); in usage()
2824 printf("\tTo get full turbo-freq information dump:\n"); in usage()
2825 printf("\t\tintel-speed-select turbo-freq info -l 0\n"); in usage()
2845 int poll_interval = -1; in cmdline()
2849 { "all-cpus-online", no_argument, 0, 'a' }, in cmdline()
2860 { "no-daemon", no_argument, 0, 'n' }, in cmdline()
2861 { "poll-interval", required_argument, 0, 'w' }, in cmdline()
2872 err(-1, "Invalid CPU model (%d)\n", cpu_model); in cmdline()
2873 printf("Intel(R) Speed Select Technology\n"); in cmdline()
2879 fprintf(stderr, "Intel speed select drivers are not loaded on this system.\n"); in cmdline()
2889 &option_index)) != -1) { in cmdline()
2890 switch (opt) { in cmdline()
2952 if (optind > (argc - 2) && !oob_mode) { in cmdline()