提交 a2424d81 编写于 作者: S Srinivas Pandruvada 提交者: Caspar Zhang

tools/power/x86/intel-speed-select: Helpful warning for missing kernel interface

task #29499913

commit f362cdccca07c2b90fc4fac9bf13d9ce975e9aa7 upstream

When the device file "/dev/isst_interface" is not present, instead of
failing on access, check at the start and print a helpful warning.

Here CLX platform is an exception, which doesn't depend on the device
file. So continue for CLX platform.
Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NErwei Deng <erwei@linux.alibaba.com>
Reviewed-by: NArtie Ding <artie.ding@linux.alibaba.com>
上级 3b81f525
...@@ -2408,6 +2408,8 @@ static void print_version(void) ...@@ -2408,6 +2408,8 @@ static void print_version(void)
static void cmdline(int argc, char **argv) static void cmdline(int argc, char **argv)
{ {
const char *pathname = "/dev/isst_interface";
FILE *fp;
int opt; int opt;
int option_index = 0; int option_index = 0;
int ret; int ret;
...@@ -2423,6 +2425,28 @@ static void cmdline(int argc, char **argv) ...@@ -2423,6 +2425,28 @@ static void cmdline(int argc, char **argv)
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
if (geteuid() != 0) {
fprintf(stderr, "Must run as root\n");
exit(0);
}
ret = update_cpu_model();
if (ret)
err(-1, "Invalid CPU model (%d)\n", cpu_model);
printf("Intel(R) Speed Select Technology\n");
printf("Executing on CPU model:%d[0x%x]\n", cpu_model, cpu_model);
if (!is_clx_n_platform()) {
fp = fopen(pathname, "rb");
if (!fp) {
fprintf(stderr, "Intel speed select drivers are not loaded on this system.\n");
fprintf(stderr, "Verify that kernel config includes CONFIG_INTEL_SPEED_SELECT_INTERFACE.\n");
fprintf(stderr, "If the config is included then this is not a supported platform.\n");
exit(0);
}
fclose(fp);
}
progname = argv[0]; progname = argv[0];
while ((opt = getopt_long_only(argc, argv, "+c:df:hio:v", long_options, while ((opt = getopt_long_only(argc, argv, "+c:df:hio:v", long_options,
&option_index)) != -1) { &option_index)) != -1) {
...@@ -2457,20 +2481,10 @@ static void cmdline(int argc, char **argv) ...@@ -2457,20 +2481,10 @@ static void cmdline(int argc, char **argv)
} }
} }
if (geteuid() != 0) {
fprintf(stderr, "Must run as root\n");
exit(0);
}
if (optind > (argc - 2)) { if (optind > (argc - 2)) {
fprintf(stderr, "Feature name and|or command not specified\n"); fprintf(stderr, "Feature name and|or command not specified\n");
exit(0); exit(0);
} }
ret = update_cpu_model();
if (ret)
err(-1, "Invalid CPU model (%d)\n", cpu_model);
printf("Intel(R) Speed Select Technology\n");
printf("Executing on CPU model:%d[0x%x]\n", cpu_model, cpu_model);
set_max_cpu_num(); set_max_cpu_num();
store_cpu_topology(); store_cpu_topology();
set_cpu_present_cpu_mask(); set_cpu_present_cpu_mask();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册