tools/power/x86/intel-speed-select: Add option to delay mbox commands

Add option "p|--pause" to introduce delay between two mail box commands
for test purpose. This delay can be specified in milliseconds. By default
there is no delay between two mailbox commands.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
This commit is contained in:
Srinivas Pandruvada 2020-07-01 14:27:18 -07:00
parent 6374de8489
commit a85a35fc1d
1 changed files with 15 additions and 0 deletions

View File

@ -44,6 +44,8 @@ static int force_online_offline;
static int auto_mode;
static int fact_enable_fail;
static int mbox_delay;
/* clos related */
static int current_clos = -1;
static int clos_epp = -1;
@ -788,6 +790,9 @@ int isst_send_mbox_command(unsigned int cpu, unsigned char command,
mbox_cmds.mbox_cmd[0].parameter = parameter;
mbox_cmds.mbox_cmd[0].req_data = req_data;
if (mbox_delay)
usleep(mbox_delay * 1000);
fd = open(pathname, O_RDWR);
if (fd < 0)
err(-1, "%s open failed", pathname);
@ -2599,6 +2604,7 @@ static void usage(void)
printf("\t[-i|--info] : Print platform information\n");
printf("\t[-o|--out] : Output file\n");
printf("\t\t\tDefault : stderr\n");
printf("\t[-p|--pause] : Delay between two mail box commands in milliseconds\n");
printf("\t[-v|--version] : Print version\n");
printf("\nResult format\n");
@ -2630,6 +2636,7 @@ static void print_version(void)
static void cmdline(int argc, char **argv)
{
const char *pathname = "/dev/isst_interface";
char *ptr;
FILE *fp;
int opt;
int option_index = 0;
@ -2641,6 +2648,7 @@ static void cmdline(int argc, char **argv)
{ "format", required_argument, 0, 'f' },
{ "help", no_argument, 0, 'h' },
{ "info", no_argument, 0, 'i' },
{ "pause", required_argument, 0, 'p' },
{ "out", required_argument, 0, 'o' },
{ "version", no_argument, 0, 'v' },
{ 0, 0, 0, 0 }
@ -2694,6 +2702,13 @@ static void cmdline(int argc, char **argv)
fclose(outf);
outf = fopen_or_exit(optarg, "w");
break;
case 'p':
ret = strtol(optarg, &ptr, 10);
if (!ret)
fprintf(stderr, "Invalid pause interval, ignore\n");
else
mbox_delay = ret;
break;
case 'v':
print_version();
break;