Skip to content

Commit 69ce97f

Browse files
committed
Merge branch 'for-next'
Merge branch 'for-next' of https://github.com/spandruvada/linux-kernel.git to update Intel SST tools. Signed-off-by: Andy Shevchenko <[email protected]>
2 parents 78d15ee + f65e131 commit 69ce97f

File tree

1 file changed

+61
-20
lines changed

1 file changed

+61
-20
lines changed

tools/power/x86/intel-speed-select/isst-config.c

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct process_cmd_struct {
1515
int arg;
1616
};
1717

18-
static const char *version_str = "v1.4";
18+
static const char *version_str = "v1.5";
1919
static const int supported_api_ver = 1;
2020
static struct isst_if_platform_info isst_platform_info;
2121
static char *progname;
@@ -44,6 +44,9 @@ static int force_online_offline;
4444
static int auto_mode;
4545
static int fact_enable_fail;
4646

47+
static int mbox_delay;
48+
static int mbox_retries = 3;
49+
4750
/* clos related */
4851
static int current_clos = -1;
4952
static int clos_epp = -1;
@@ -198,7 +201,7 @@ int out_format_is_json(void)
198201

199202
static int get_stored_topology_info(int cpu, int *core_id, int *pkg_id, int *die_id)
200203
{
201-
const char *pathname = "/tmp/isst_cpu_topology.dat";
204+
const char *pathname = "/var/run/isst_cpu_topology.dat";
202205
struct cpu_topology cpu_top;
203206
FILE *fp;
204207
int ret;
@@ -230,7 +233,7 @@ static int get_stored_topology_info(int cpu, int *core_id, int *pkg_id, int *die
230233

231234
static void store_cpu_topology(void)
232235
{
233-
const char *pathname = "/tmp/isst_cpu_topology.dat";
236+
const char *pathname = "/var/run/isst_cpu_topology.dat";
234237
FILE *fp;
235238
int i;
236239

@@ -247,6 +250,8 @@ static void store_cpu_topology(void)
247250
return;
248251
}
249252

253+
fprintf(stderr, "Caching topology information\n");
254+
250255
for (i = 0; i < topo_max_cpus; ++i) {
251256
struct cpu_topology cpu_top;
252257

@@ -734,7 +739,7 @@ int isst_send_mbox_command(unsigned int cpu, unsigned char command,
734739
unsigned int req_data, unsigned int *resp)
735740
{
736741
const char *pathname = "/dev/isst_interface";
737-
int fd;
742+
int fd, retry;
738743
struct isst_if_mbox_cmds mbox_cmds = { 0 };
739744

740745
debug_printf(
@@ -786,29 +791,42 @@ int isst_send_mbox_command(unsigned int cpu, unsigned char command,
786791
mbox_cmds.mbox_cmd[0].parameter = parameter;
787792
mbox_cmds.mbox_cmd[0].req_data = req_data;
788793

794+
if (mbox_delay)
795+
usleep(mbox_delay * 1000);
796+
789797
fd = open(pathname, O_RDWR);
790798
if (fd < 0)
791799
err(-1, "%s open failed", pathname);
792800

793-
if (ioctl(fd, ISST_IF_MBOX_COMMAND, &mbox_cmds) == -1) {
794-
if (errno == ENOTTY) {
795-
perror("ISST_IF_MBOX_COMMAND\n");
796-
fprintf(stderr, "Check presence of kernel modules: isst_if_mbox_pci or isst_if_mbox_msr\n");
797-
exit(0);
801+
retry = mbox_retries;
802+
803+
do {
804+
if (ioctl(fd, ISST_IF_MBOX_COMMAND, &mbox_cmds) == -1) {
805+
if (errno == ENOTTY) {
806+
perror("ISST_IF_MBOX_COMMAND\n");
807+
fprintf(stderr, "Check presence of kernel modules: isst_if_mbox_pci or isst_if_mbox_msr\n");
808+
exit(0);
809+
}
810+
debug_printf(
811+
"Error: mbox_cmd cpu:%d command:%x sub_command:%x parameter:%x req_data:%x errorno:%d\n",
812+
cpu, command, sub_command, parameter, req_data, errno);
813+
--retry;
814+
} else {
815+
*resp = mbox_cmds.mbox_cmd[0].resp_data;
816+
debug_printf(
817+
"mbox_cmd response: cpu:%d command:%x sub_command:%x parameter:%x req_data:%x resp:%x\n",
818+
cpu, command, sub_command, parameter, req_data, *resp);
819+
break;
798820
}
799-
debug_printf(
800-
"Error: mbox_cmd cpu:%d command:%x sub_command:%x parameter:%x req_data:%x errorno:%d\n",
801-
cpu, command, sub_command, parameter, req_data, errno);
802-
return -1;
803-
} else {
804-
*resp = mbox_cmds.mbox_cmd[0].resp_data;
805-
debug_printf(
806-
"mbox_cmd response: cpu:%d command:%x sub_command:%x parameter:%x req_data:%x resp:%x\n",
807-
cpu, command, sub_command, parameter, req_data, *resp);
808-
}
821+
} while (retry);
809822

810823
close(fd);
811824

825+
if (!retry) {
826+
debug_printf("Failed mbox command even after retries\n");
827+
return -1;
828+
829+
}
812830
return 0;
813831
}
814832

@@ -1245,7 +1263,11 @@ static void set_tdp_level_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
12451263
fprintf(stderr, "Option is set to online/offline\n");
12461264
ctdp_level.core_cpumask_size =
12471265
alloc_cpu_set(&ctdp_level.core_cpumask);
1248-
isst_get_coremask_info(cpu, tdp_level, &ctdp_level);
1266+
ret = isst_get_coremask_info(cpu, tdp_level, &ctdp_level);
1267+
if (ret) {
1268+
isst_display_error_info_message(1, "Can't get coremask, online/offline option is ignored", 0, 0);
1269+
return;
1270+
}
12491271
if (ctdp_level.cpu_count) {
12501272
int i, max_cpus = get_topo_max_cpus();
12511273
for (i = 0; i < max_cpus; ++i) {
@@ -2593,6 +2615,8 @@ static void usage(void)
25932615
printf("\t[-i|--info] : Print platform information\n");
25942616
printf("\t[-o|--out] : Output file\n");
25952617
printf("\t\t\tDefault : stderr\n");
2618+
printf("\t[-p|--pause] : Delay between two mail box commands in milliseconds\n");
2619+
printf("\t[-r|--retry] : Retry count for mail box commands on failure, default 3\n");
25962620
printf("\t[-v|--version] : Print version\n");
25972621

25982622
printf("\nResult format\n");
@@ -2624,6 +2648,7 @@ static void print_version(void)
26242648
static void cmdline(int argc, char **argv)
26252649
{
26262650
const char *pathname = "/dev/isst_interface";
2651+
char *ptr;
26272652
FILE *fp;
26282653
int opt;
26292654
int option_index = 0;
@@ -2635,7 +2660,9 @@ static void cmdline(int argc, char **argv)
26352660
{ "format", required_argument, 0, 'f' },
26362661
{ "help", no_argument, 0, 'h' },
26372662
{ "info", no_argument, 0, 'i' },
2663+
{ "pause", required_argument, 0, 'p' },
26382664
{ "out", required_argument, 0, 'o' },
2665+
{ "retry", required_argument, 0, 'r' },
26392666
{ "version", no_argument, 0, 'v' },
26402667
{ 0, 0, 0, 0 }
26412668
};
@@ -2688,6 +2715,20 @@ static void cmdline(int argc, char **argv)
26882715
fclose(outf);
26892716
outf = fopen_or_exit(optarg, "w");
26902717
break;
2718+
case 'p':
2719+
ret = strtol(optarg, &ptr, 10);
2720+
if (!ret)
2721+
fprintf(stderr, "Invalid pause interval, ignore\n");
2722+
else
2723+
mbox_delay = ret;
2724+
break;
2725+
case 'r':
2726+
ret = strtol(optarg, &ptr, 10);
2727+
if (!ret)
2728+
fprintf(stderr, "Invalid retry count, ignore\n");
2729+
else
2730+
mbox_retries = ret;
2731+
break;
26912732
case 'v':
26922733
print_version();
26932734
break;

0 commit comments

Comments
 (0)