tools/power/x86/intel-speed-select: Add retries for mail box commands
Retry mail box command on failure. The default retry count is 3. This can be changed by "-r|--retry" options. This helps during early bring up of platforms. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
This commit is contained in:
parent
a85a35fc1d
commit
32279be7e1
|
@ -45,6 +45,7 @@ static int auto_mode;
|
||||||
static int fact_enable_fail;
|
static int fact_enable_fail;
|
||||||
|
|
||||||
static int mbox_delay;
|
static int mbox_delay;
|
||||||
|
static int mbox_retries = 3;
|
||||||
|
|
||||||
/* clos related */
|
/* clos related */
|
||||||
static int current_clos = -1;
|
static int current_clos = -1;
|
||||||
|
@ -738,7 +739,7 @@ int isst_send_mbox_command(unsigned int cpu, unsigned char command,
|
||||||
unsigned int req_data, unsigned int *resp)
|
unsigned int req_data, unsigned int *resp)
|
||||||
{
|
{
|
||||||
const char *pathname = "/dev/isst_interface";
|
const char *pathname = "/dev/isst_interface";
|
||||||
int fd;
|
int fd, retry;
|
||||||
struct isst_if_mbox_cmds mbox_cmds = { 0 };
|
struct isst_if_mbox_cmds mbox_cmds = { 0 };
|
||||||
|
|
||||||
debug_printf(
|
debug_printf(
|
||||||
|
@ -797,25 +798,35 @@ int isst_send_mbox_command(unsigned int cpu, unsigned char command,
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
err(-1, "%s open failed", pathname);
|
err(-1, "%s open failed", pathname);
|
||||||
|
|
||||||
if (ioctl(fd, ISST_IF_MBOX_COMMAND, &mbox_cmds) == -1) {
|
retry = mbox_retries;
|
||||||
if (errno == ENOTTY) {
|
|
||||||
perror("ISST_IF_MBOX_COMMAND\n");
|
do {
|
||||||
fprintf(stderr, "Check presence of kernel modules: isst_if_mbox_pci or isst_if_mbox_msr\n");
|
if (ioctl(fd, ISST_IF_MBOX_COMMAND, &mbox_cmds) == -1) {
|
||||||
exit(0);
|
if (errno == ENOTTY) {
|
||||||
|
perror("ISST_IF_MBOX_COMMAND\n");
|
||||||
|
fprintf(stderr, "Check presence of kernel modules: isst_if_mbox_pci or isst_if_mbox_msr\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
debug_printf(
|
||||||
|
"Error: mbox_cmd cpu:%d command:%x sub_command:%x parameter:%x req_data:%x errorno:%d\n",
|
||||||
|
cpu, command, sub_command, parameter, req_data, errno);
|
||||||
|
--retry;
|
||||||
|
} else {
|
||||||
|
*resp = mbox_cmds.mbox_cmd[0].resp_data;
|
||||||
|
debug_printf(
|
||||||
|
"mbox_cmd response: cpu:%d command:%x sub_command:%x parameter:%x req_data:%x resp:%x\n",
|
||||||
|
cpu, command, sub_command, parameter, req_data, *resp);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
debug_printf(
|
} while (retry);
|
||||||
"Error: mbox_cmd cpu:%d command:%x sub_command:%x parameter:%x req_data:%x errorno:%d\n",
|
|
||||||
cpu, command, sub_command, parameter, req_data, errno);
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
*resp = mbox_cmds.mbox_cmd[0].resp_data;
|
|
||||||
debug_printf(
|
|
||||||
"mbox_cmd response: cpu:%d command:%x sub_command:%x parameter:%x req_data:%x resp:%x\n",
|
|
||||||
cpu, command, sub_command, parameter, req_data, *resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
if (!retry) {
|
||||||
|
debug_printf("Failed mbox command even after retries\n");
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2605,6 +2616,7 @@ static void usage(void)
|
||||||
printf("\t[-o|--out] : Output file\n");
|
printf("\t[-o|--out] : Output file\n");
|
||||||
printf("\t\t\tDefault : stderr\n");
|
printf("\t\t\tDefault : stderr\n");
|
||||||
printf("\t[-p|--pause] : Delay between two mail box commands in milliseconds\n");
|
printf("\t[-p|--pause] : Delay between two mail box commands in milliseconds\n");
|
||||||
|
printf("\t[-r|--retry] : Retry count for mail box commands on failure, default 3\n");
|
||||||
printf("\t[-v|--version] : Print version\n");
|
printf("\t[-v|--version] : Print version\n");
|
||||||
|
|
||||||
printf("\nResult format\n");
|
printf("\nResult format\n");
|
||||||
|
@ -2650,6 +2662,7 @@ static void cmdline(int argc, char **argv)
|
||||||
{ "info", no_argument, 0, 'i' },
|
{ "info", no_argument, 0, 'i' },
|
||||||
{ "pause", required_argument, 0, 'p' },
|
{ "pause", required_argument, 0, 'p' },
|
||||||
{ "out", required_argument, 0, 'o' },
|
{ "out", required_argument, 0, 'o' },
|
||||||
|
{ "retry", required_argument, 0, 'r' },
|
||||||
{ "version", no_argument, 0, 'v' },
|
{ "version", no_argument, 0, 'v' },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
@ -2709,6 +2722,13 @@ static void cmdline(int argc, char **argv)
|
||||||
else
|
else
|
||||||
mbox_delay = ret;
|
mbox_delay = ret;
|
||||||
break;
|
break;
|
||||||
|
case 'r':
|
||||||
|
ret = strtol(optarg, &ptr, 10);
|
||||||
|
if (!ret)
|
||||||
|
fprintf(stderr, "Invalid retry count, ignore\n");
|
||||||
|
else
|
||||||
|
mbox_retries = ret;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
print_version();
|
print_version();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue