Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <andriy.shevchenko@linux.intel.com>

+61 -20
+61 -20
tools/power/x86/intel-speed-select/isst-config.c
··· 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; ··· 43 43 static int force_online_offline; 44 44 static int auto_mode; 45 45 static int fact_enable_fail; 46 + 47 + static int mbox_delay; 48 + static int mbox_retries = 3; 46 49 47 50 /* clos related */ 48 51 static int current_clos = -1; ··· 201 198 202 199 static int get_stored_topology_info(int cpu, int *core_id, int *pkg_id, int *die_id) 203 200 { 204 - const char *pathname = "/tmp/isst_cpu_topology.dat"; 201 + const char *pathname = "/var/run/isst_cpu_topology.dat"; 205 202 struct cpu_topology cpu_top; 206 203 FILE *fp; 207 204 int ret; ··· 233 230 234 231 static void store_cpu_topology(void) 235 232 { 236 - const char *pathname = "/tmp/isst_cpu_topology.dat"; 233 + const char *pathname = "/var/run/isst_cpu_topology.dat"; 237 234 FILE *fp; 238 235 int i; 239 236 ··· 249 246 fprintf(stderr, "Can't create file:%s\n", pathname); 250 247 return; 251 248 } 249 + 250 + fprintf(stderr, "Caching topology information\n"); 252 251 253 252 for (i = 0; i < topo_max_cpus; ++i) { 254 253 struct cpu_topology cpu_top; ··· 739 734 unsigned int req_data, unsigned int *resp) 740 735 { 741 736 const char *pathname = "/dev/isst_interface"; 742 - int fd; 737 + int fd, retry; 743 738 struct isst_if_mbox_cmds mbox_cmds = { 0 }; 744 739 745 740 debug_printf( ··· 791 786 mbox_cmds.mbox_cmd[0].parameter = parameter; 792 787 mbox_cmds.mbox_cmd[0].req_data = req_data; 793 788 789 + if (mbox_delay) 790 + usleep(mbox_delay * 1000); 791 + 794 792 fd = open(pathname, O_RDWR); 795 793 if (fd < 0) 796 794 err(-1, "%s open failed", pathname); 797 795 798 - if (ioctl(fd, ISST_IF_MBOX_COMMAND, &mbox_cmds) == -1) { 799 - if (errno == ENOTTY) { 800 - perror("ISST_IF_MBOX_COMMAND\n"); 801 - fprintf(stderr, "Check presence of kernel modules: isst_if_mbox_pci or isst_if_mbox_msr\n"); 802 - exit(0); 796 + retry = mbox_retries; 797 + 798 + do { 799 + if (ioctl(fd, ISST_IF_MBOX_COMMAND, &mbox_cmds) == -1) { 800 + if (errno == ENOTTY) { 801 + perror("ISST_IF_MBOX_COMMAND\n"); 802 + fprintf(stderr, "Check presence of kernel modules: isst_if_mbox_pci or isst_if_mbox_msr\n"); 803 + exit(0); 804 + } 805 + debug_printf( 806 + "Error: mbox_cmd cpu:%d command:%x sub_command:%x parameter:%x req_data:%x errorno:%d\n", 807 + cpu, command, sub_command, parameter, req_data, errno); 808 + --retry; 809 + } else { 810 + *resp = mbox_cmds.mbox_cmd[0].resp_data; 811 + debug_printf( 812 + "mbox_cmd response: cpu:%d command:%x sub_command:%x parameter:%x req_data:%x resp:%x\n", 813 + cpu, command, sub_command, parameter, req_data, *resp); 814 + break; 803 815 } 804 - debug_printf( 805 - "Error: mbox_cmd cpu:%d command:%x sub_command:%x parameter:%x req_data:%x errorno:%d\n", 806 - cpu, command, sub_command, parameter, req_data, errno); 807 - return -1; 808 - } else { 809 - *resp = mbox_cmds.mbox_cmd[0].resp_data; 810 - debug_printf( 811 - "mbox_cmd response: cpu:%d command:%x sub_command:%x parameter:%x req_data:%x resp:%x\n", 812 - cpu, command, sub_command, parameter, req_data, *resp); 813 - } 816 + } while (retry); 814 817 815 818 close(fd); 816 819 820 + if (!retry) { 821 + debug_printf("Failed mbox command even after retries\n"); 822 + return -1; 823 + 824 + } 817 825 return 0; 818 826 } 819 827 ··· 1263 1245 fprintf(stderr, "Option is set to online/offline\n"); 1264 1246 ctdp_level.core_cpumask_size = 1265 1247 alloc_cpu_set(&ctdp_level.core_cpumask); 1266 - isst_get_coremask_info(cpu, tdp_level, &ctdp_level); 1248 + ret = isst_get_coremask_info(cpu, tdp_level, &ctdp_level); 1249 + if (ret) { 1250 + isst_display_error_info_message(1, "Can't get coremask, online/offline option is ignored", 0, 0); 1251 + return; 1252 + } 1267 1253 if (ctdp_level.cpu_count) { 1268 1254 int i, max_cpus = get_topo_max_cpus(); 1269 1255 for (i = 0; i < max_cpus; ++i) { ··· 2615 2593 printf("\t[-i|--info] : Print platform information\n"); 2616 2594 printf("\t[-o|--out] : Output file\n"); 2617 2595 printf("\t\t\tDefault : stderr\n"); 2596 + printf("\t[-p|--pause] : Delay between two mail box commands in milliseconds\n"); 2597 + printf("\t[-r|--retry] : Retry count for mail box commands on failure, default 3\n"); 2618 2598 printf("\t[-v|--version] : Print version\n"); 2619 2599 2620 2600 printf("\nResult format\n"); ··· 2648 2624 static void cmdline(int argc, char **argv) 2649 2625 { 2650 2626 const char *pathname = "/dev/isst_interface"; 2627 + char *ptr; 2651 2628 FILE *fp; 2652 2629 int opt; 2653 2630 int option_index = 0; ··· 2660 2635 { "format", required_argument, 0, 'f' }, 2661 2636 { "help", no_argument, 0, 'h' }, 2662 2637 { "info", no_argument, 0, 'i' }, 2638 + { "pause", required_argument, 0, 'p' }, 2663 2639 { "out", required_argument, 0, 'o' }, 2640 + { "retry", required_argument, 0, 'r' }, 2664 2641 { "version", no_argument, 0, 'v' }, 2665 2642 { 0, 0, 0, 0 } 2666 2643 }; ··· 2714 2687 if (outf) 2715 2688 fclose(outf); 2716 2689 outf = fopen_or_exit(optarg, "w"); 2690 + break; 2691 + case 'p': 2692 + ret = strtol(optarg, &ptr, 10); 2693 + if (!ret) 2694 + fprintf(stderr, "Invalid pause interval, ignore\n"); 2695 + else 2696 + mbox_delay = ret; 2697 + break; 2698 + case 'r': 2699 + ret = strtol(optarg, &ptr, 10); 2700 + if (!ret) 2701 + fprintf(stderr, "Invalid retry count, ignore\n"); 2702 + else 2703 + mbox_retries = ret; 2717 2704 break; 2718 2705 case 'v': 2719 2706 print_version();