@@ -15,7 +15,7 @@ struct process_cmd_struct {
15
15
int arg ;
16
16
};
17
17
18
- static const char * version_str = "v1.4 " ;
18
+ static const char * version_str = "v1.5 " ;
19
19
static const int supported_api_ver = 1 ;
20
20
static struct isst_if_platform_info isst_platform_info ;
21
21
static char * progname ;
@@ -44,6 +44,9 @@ static int force_online_offline;
44
44
static int auto_mode ;
45
45
static int fact_enable_fail ;
46
46
47
+ static int mbox_delay ;
48
+ static int mbox_retries = 3 ;
49
+
47
50
/* clos related */
48
51
static int current_clos = -1 ;
49
52
static int clos_epp = -1 ;
@@ -198,7 +201,7 @@ int out_format_is_json(void)
198
201
199
202
static int get_stored_topology_info (int cpu , int * core_id , int * pkg_id , int * die_id )
200
203
{
201
- const char * pathname = "/tmp /isst_cpu_topology.dat" ;
204
+ const char * pathname = "/var/run /isst_cpu_topology.dat" ;
202
205
struct cpu_topology cpu_top ;
203
206
FILE * fp ;
204
207
int ret ;
@@ -230,7 +233,7 @@ static int get_stored_topology_info(int cpu, int *core_id, int *pkg_id, int *die
230
233
231
234
static void store_cpu_topology (void )
232
235
{
233
- const char * pathname = "/tmp /isst_cpu_topology.dat" ;
236
+ const char * pathname = "/var/run /isst_cpu_topology.dat" ;
234
237
FILE * fp ;
235
238
int i ;
236
239
@@ -247,6 +250,8 @@ static void store_cpu_topology(void)
247
250
return ;
248
251
}
249
252
253
+ fprintf (stderr , "Caching topology information\n" );
254
+
250
255
for (i = 0 ; i < topo_max_cpus ; ++ i ) {
251
256
struct cpu_topology cpu_top ;
252
257
@@ -734,7 +739,7 @@ int isst_send_mbox_command(unsigned int cpu, unsigned char command,
734
739
unsigned int req_data , unsigned int * resp )
735
740
{
736
741
const char * pathname = "/dev/isst_interface" ;
737
- int fd ;
742
+ int fd , retry ;
738
743
struct isst_if_mbox_cmds mbox_cmds = { 0 };
739
744
740
745
debug_printf (
@@ -786,29 +791,42 @@ int isst_send_mbox_command(unsigned int cpu, unsigned char command,
786
791
mbox_cmds .mbox_cmd [0 ].parameter = parameter ;
787
792
mbox_cmds .mbox_cmd [0 ].req_data = req_data ;
788
793
794
+ if (mbox_delay )
795
+ usleep (mbox_delay * 1000 );
796
+
789
797
fd = open (pathname , O_RDWR );
790
798
if (fd < 0 )
791
799
err (-1 , "%s open failed" , pathname );
792
800
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 ;
798
820
}
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 );
809
822
810
823
close (fd );
811
824
825
+ if (!retry ) {
826
+ debug_printf ("Failed mbox command even after retries\n" );
827
+ return -1 ;
828
+
829
+ }
812
830
return 0 ;
813
831
}
814
832
@@ -1245,7 +1263,11 @@ static void set_tdp_level_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
1245
1263
fprintf (stderr , "Option is set to online/offline\n" );
1246
1264
ctdp_level .core_cpumask_size =
1247
1265
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
+ }
1249
1271
if (ctdp_level .cpu_count ) {
1250
1272
int i , max_cpus = get_topo_max_cpus ();
1251
1273
for (i = 0 ; i < max_cpus ; ++ i ) {
@@ -2593,6 +2615,8 @@ static void usage(void)
2593
2615
printf ("\t[-i|--info] : Print platform information\n" );
2594
2616
printf ("\t[-o|--out] : Output file\n" );
2595
2617
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" );
2596
2620
printf ("\t[-v|--version] : Print version\n" );
2597
2621
2598
2622
printf ("\nResult format\n" );
@@ -2624,6 +2648,7 @@ static void print_version(void)
2624
2648
static void cmdline (int argc , char * * argv )
2625
2649
{
2626
2650
const char * pathname = "/dev/isst_interface" ;
2651
+ char * ptr ;
2627
2652
FILE * fp ;
2628
2653
int opt ;
2629
2654
int option_index = 0 ;
@@ -2635,7 +2660,9 @@ static void cmdline(int argc, char **argv)
2635
2660
{ "format" , required_argument , 0 , 'f' },
2636
2661
{ "help" , no_argument , 0 , 'h' },
2637
2662
{ "info" , no_argument , 0 , 'i' },
2663
+ { "pause" , required_argument , 0 , 'p' },
2638
2664
{ "out" , required_argument , 0 , 'o' },
2665
+ { "retry" , required_argument , 0 , 'r' },
2639
2666
{ "version" , no_argument , 0 , 'v' },
2640
2667
{ 0 , 0 , 0 , 0 }
2641
2668
};
@@ -2688,6 +2715,20 @@ static void cmdline(int argc, char **argv)
2688
2715
fclose (outf );
2689
2716
outf = fopen_or_exit (optarg , "w" );
2690
2717
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 ;
2691
2732
case 'v' :
2692
2733
print_version ();
2693
2734
break ;
0 commit comments