To map Linux CPU numbering scheme to hardware CPU numbering scheme MSR 0x53 is getting used. But for new generation of CPUs, this MSR is not valid. Since this is model specific MSR, this is possible. A new MSR 0x54 is defined for this purpose. User space can use the API version to distinguish format from MSR 0x53. Intel speed select utility is updated to use the new format based on the API version.
Unified · Split
| @@ -19,9 +19,13 @@ · 18 unmodified lines | ||
| 19 | 19 | #include <linux/uaccess.h> |
| 20 | 20 | #include <uapi/linux/isst_if.h> |
| 21 | 21 | |
| 22 | +#include <asm/cpu_device_id.h> | |
| 23 | +#include <asm/intel-family.h> | |
| 24 | + | |
| 22 | 25 | #include "isst_if_common.h" |
| 23 | 26 | |
| 24 | 27 | #define MSR_THREAD_ID_INFO 0x53 |
| 28 | +#define MSR_PM_LOGICAL_ID 0x54 | |
| 25 | 29 | #define MSR_CPU_BUS_NUMBER 0x128 |
| 26 | 30 | |
| 27 | 31 | static struct isst_if_cmd_cb punit_callbacks[ISST_IF_DEV_MAX]; |
| @@ -31,6 +35,7 @@ static int punit_msr_white_list[] = { · 3 unmodified lines | ||
| 31 | 35 | MSR_CONFIG_TDP_CONTROL, |
| 32 | 36 | MSR_TURBO_RATIO_LIMIT1, |
| 33 | 37 | MSR_TURBO_RATIO_LIMIT2, |
| 38 | + MSR_PM_LOGICAL_ID, | |
| 34 | 39 | }; |
| 35 | 40 | |
| 36 | 41 | struct isst_valid_cmd_ranges { |
| @@ -73,6 +78,8 @@ struct isst_cmd { · 36 unmodified lines | ||
| 73 | 78 | u32 param; |
| 74 | 79 | }; |
| 75 | 80 | |
| 81 | +static bool isst_hpm_support; | |
| 82 | + | |
| 76 | 83 | static DECLARE_HASHTABLE(isst_hash, 8); |
| 77 | 84 | static DEFINE_MUTEX(isst_hash_lock); |
| 78 | 85 | |
| @@ -411,11 +418,20 @@ static int isst_if_cpu_online(unsigned int cpu) · 332 unmodified lines | ||
| 411 | 418 | isst_cpu_info[cpu].pci_dev[1] = _isst_if_get_pci_dev(cpu, 1, 30, 1); |
| 412 | 419 | } |
| 413 | 420 | |
| 421 | + if (isst_hpm_support) { | |
| 422 | + | |
| 423 | + ret = rdmsrl_safe(MSR_PM_LOGICAL_ID, &data); | |
| 424 | + if (!ret) | |
| 425 | + goto set_punit_id; | |
| 426 | + } | |
| 427 | + | |
| 414 | 428 | ret = rdmsrl_safe(MSR_THREAD_ID_INFO, &data); |
| 415 | 429 | if (ret) { |
| 416 | 430 | isst_cpu_info[cpu].punit_cpu_id = -1; |
| 417 | 431 | return ret; |
| 418 | 432 | } |
| 433 | + | |
| 434 | +set_punit_id: | |
| 419 | 435 | isst_cpu_info[cpu].punit_cpu_id = data; |
| 420 | 436 | |
| 421 | 437 | isst_restore_msr_local(cpu); |
| @@ -704,6 +720,12 @@ static struct miscdevice isst_if_char_driver = { · 282 unmodified lines | ||
| 704 | 720 | .fops = &isst_if_char_driver_ops, |
| 705 | 721 | }; |
| 706 | 722 | |
| 723 | +static const struct x86_cpu_id hpm_cpu_ids[] = { | |
| 724 | + X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_X, NULL), | |
| 725 | + X86_MATCH_INTEL_FAM6_MODEL(SIERRAFOREST_X, NULL), | |
| 726 | + {} | |
| 727 | +}; | |
| 728 | + | |
| 707 | 729 | static int isst_misc_reg(void) |
| 708 | 730 | { |
| 709 | 731 | mutex_lock(&punit_misc_dev_reg_lock); |
| @@ -711,6 +733,12 @@ static int isst_misc_reg(void) · 1 unmodified line | ||
| 711 | 733 | goto unlock_exit; |
| 712 | 734 | |
| 713 | 735 | if (!misc_usage_count) { |
| 736 | + const struct x86_cpu_id *id; | |
| 737 | + | |
| 738 | + id = x86_match_cpu(hpm_cpu_ids); | |
| 739 | + if (id) | |
| 740 | + isst_hpm_support = true; | |
| 741 | + | |
| 714 | 742 | misc_device_ret = isst_if_cpu_info_init(); |
| 715 | 743 | if (misc_device_ret) |
| 716 | 744 | goto unlock_exit; |