tools/power/x86/intel-speed-select: Improve error display for base-freq feature

This change adds improved error display and handling for commands related
to base-freq feature. The changes include:
- Replace perror/fprintf with helpful error message
- Error for not specifying TDP level when required
- For CLX show help which shows limitation

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
Srinivas Pandruvada 2020-03-05 14:45:28 -08:00 committed by Andy Shevchenko
parent 3d1a857981
commit 39bae0fce4
2 changed files with 34 additions and 5 deletions

View File

@ -1276,7 +1276,7 @@ static void clx_n_dump_pbf_config_for_cpu(int cpu, void *arg1, void *arg2,
ret = clx_n_config(cpu);
if (ret) {
perror("isst_get_process_ctdp");
isst_display_error_info_message(1, "clx_n_config failed", 0, 0);
} else {
struct isst_pkg_ctdp_level_info *ctdp_level;
struct isst_pbf_info *pbf_info;
@ -1297,7 +1297,9 @@ static void dump_pbf_config_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
ret = isst_get_pbf_info(cpu, tdp_level, &pbf_info);
if (ret) {
perror("isst_get_pbf_info");
isst_display_error_info_message(1, "Failed to get base-freq info at this level", 1, tdp_level);
isst_ctdp_display_information_end(outf);
exit(1);
} else {
isst_pbf_display_information(cpu, outf, tdp_level, &pbf_info);
isst_get_pbf_info_complete(&pbf_info);
@ -1317,7 +1319,7 @@ static void dump_pbf_config(int arg)
}
if (tdp_level == 0xff) {
fprintf(outf, "Invalid command: specify tdp_level\n");
isst_display_error_info_message(1, "Invalid command: specify tdp_level", 0, 0);
exit(1);
}
@ -1635,7 +1637,7 @@ static void set_pbf_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
ret = isst_set_pbf_fact_status(cpu, 1, status);
if (ret) {
perror("isst_set_pbf");
debug_printf("isst_set_pbf_fact_status failed");
if (auto_mode)
isst_pm_qos_config(cpu, 0, 0);
} else {
@ -1667,10 +1669,25 @@ static void set_pbf_enable(int arg)
if (enable) {
fprintf(stderr,
"Enable Intel Speed Select Technology base frequency feature\n");
if (is_clx_n_platform()) {
fprintf(stderr,
"\tOn this platform this command doesn't enable feature in the hardware.\n");
fprintf(stderr,
"\tIt updates the cpufreq scaling_min_freq to match cpufreq base_frequency.\n");
exit(0);
}
fprintf(stderr,
"\tOptional Arguments: -a|--auto : Use priority of cores to set core-power associations\n");
} else {
if (is_clx_n_platform()) {
fprintf(stderr,
"\tOn this platform this command doesn't disable feature in the hardware.\n");
fprintf(stderr,
"\tIt updates the cpufreq scaling_min_freq to match cpuinfo_min_freq\n");
exit(0);
}
fprintf(stderr,
"Disable Intel Speed Select Technology base frequency feature\n");
fprintf(stderr,

View File

@ -395,15 +395,27 @@ int isst_set_tdp_level(int cpu, int tdp_level)
int isst_get_pbf_info(int cpu, int level, struct isst_pbf_info *pbf_info)
{
struct isst_pkg_ctdp_level_info ctdp_level;
struct isst_pkg_ctdp pkg_dev;
int i, ret, core_cnt, max;
unsigned int req, resp;
ret = isst_get_ctdp_levels(cpu, &pkg_dev);
if (ret) {
isst_display_error_info_message(1, "Failed to get number of levels", 0, 0);
return ret;
}
if (level > pkg_dev.levels) {
isst_display_error_info_message(1, "Invalid level", 1, level);
return -1;
}
ret = isst_get_ctdp_control(cpu, level, &ctdp_level);
if (ret)
return ret;
if (!ctdp_level.pbf_support) {
fprintf(stderr, "base-freq feature is not present at this level:%d\n", level);
isst_display_error_info_message(1, "base-freq feature is not present at this level", 1, level);
return -1;
}