99
1010#define _GNU_SOURCE
1111#include MSRHEADER
12+
13+ // copied from arch/x86/include/asm/cpu_device_id.h
14+ #define VFM_MODEL_BIT 0
15+ #define VFM_FAMILY_BIT 8
16+ #define VFM_VENDOR_BIT 16
17+ #define VFM_RSVD_BIT 24
18+
19+ #define VFM_MODEL_MASK GENMASK(VFM_FAMILY_BIT - 1, VFM_MODEL_BIT)
20+ #define VFM_FAMILY_MASK GENMASK(VFM_VENDOR_BIT - 1, VFM_FAMILY_BIT)
21+ #define VFM_VENDOR_MASK GENMASK(VFM_RSVD_BIT - 1, VFM_VENDOR_BIT)
22+
23+ #define VFM_MODEL (vfm ) (((vfm) & VFM_MODEL_MASK) >> VFM_MODEL_BIT)
24+ #define VFM_FAMILY (vfm ) (((vfm) & VFM_FAMILY_MASK) >> VFM_FAMILY_BIT)
25+ #define VFM_VENDOR (vfm ) (((vfm) & VFM_VENDOR_MASK) >> VFM_VENDOR_BIT)
26+
27+ #define VFM_MAKE (_vendor , _family , _model ) ( \
28+ ((_model) << VFM_MODEL_BIT) | \
29+ ((_family) << VFM_FAMILY_BIT) | \
30+ ((_vendor) << VFM_VENDOR_BIT) \
31+ )
32+ // end copied section
33+
34+ #define X86_VENDOR_INTEL 0
35+
1236#include INTEL_FAMILY_HEADER
1337#include BUILD_BUG_HEADER
1438#include <stdarg.h>
@@ -367,7 +391,7 @@ struct platform_features {
367391};
368392
369393struct platform_data {
370- unsigned int model ;
394+ unsigned int vfm ;
371395 const struct platform_features * features ;
372396};
373397
@@ -910,75 +934,75 @@ static const struct platform_features amd_features_with_rapl = {
910934};
911935
912936static const struct platform_data turbostat_pdata [] = {
913- { INTEL_FAM6_NEHALEM , & nhm_features },
914- { INTEL_FAM6_NEHALEM_G , & nhm_features },
915- { INTEL_FAM6_NEHALEM_EP , & nhm_features },
916- { INTEL_FAM6_NEHALEM_EX , & nhx_features },
917- { INTEL_FAM6_WESTMERE , & nhm_features },
918- { INTEL_FAM6_WESTMERE_EP , & nhm_features },
919- { INTEL_FAM6_WESTMERE_EX , & nhx_features },
920- { INTEL_FAM6_SANDYBRIDGE , & snb_features },
921- { INTEL_FAM6_SANDYBRIDGE_X , & snx_features },
922- { INTEL_FAM6_IVYBRIDGE , & ivb_features },
923- { INTEL_FAM6_IVYBRIDGE_X , & ivx_features },
924- { INTEL_FAM6_HASWELL , & hsw_features },
925- { INTEL_FAM6_HASWELL_X , & hsx_features },
926- { INTEL_FAM6_HASWELL_L , & hswl_features },
927- { INTEL_FAM6_HASWELL_G , & hswg_features },
928- { INTEL_FAM6_BROADWELL , & bdw_features },
929- { INTEL_FAM6_BROADWELL_G , & bdwg_features },
930- { INTEL_FAM6_BROADWELL_X , & bdx_features },
931- { INTEL_FAM6_BROADWELL_D , & bdx_features },
932- { INTEL_FAM6_SKYLAKE_L , & skl_features },
933- { INTEL_FAM6_SKYLAKE , & skl_features },
934- { INTEL_FAM6_SKYLAKE_X , & skx_features },
935- { INTEL_FAM6_KABYLAKE_L , & skl_features },
936- { INTEL_FAM6_KABYLAKE , & skl_features },
937- { INTEL_FAM6_COMETLAKE , & skl_features },
938- { INTEL_FAM6_COMETLAKE_L , & skl_features },
939- { INTEL_FAM6_CANNONLAKE_L , & cnl_features },
940- { INTEL_FAM6_ICELAKE_X , & icx_features },
941- { INTEL_FAM6_ICELAKE_D , & icx_features },
942- { INTEL_FAM6_ICELAKE_L , & cnl_features },
943- { INTEL_FAM6_ICELAKE_NNPI , & cnl_features },
944- { INTEL_FAM6_ROCKETLAKE , & cnl_features },
945- { INTEL_FAM6_TIGERLAKE_L , & cnl_features },
946- { INTEL_FAM6_TIGERLAKE , & cnl_features },
947- { INTEL_FAM6_SAPPHIRERAPIDS_X , & spr_features },
948- { INTEL_FAM6_EMERALDRAPIDS_X , & spr_features },
949- { INTEL_FAM6_GRANITERAPIDS_X , & spr_features },
950- { INTEL_FAM6_LAKEFIELD , & cnl_features },
951- { INTEL_FAM6_ALDERLAKE , & adl_features },
952- { INTEL_FAM6_ALDERLAKE_L , & adl_features },
953- { INTEL_FAM6_RAPTORLAKE , & adl_features },
954- { INTEL_FAM6_RAPTORLAKE_P , & adl_features },
955- { INTEL_FAM6_RAPTORLAKE_S , & adl_features },
956- { INTEL_FAM6_METEORLAKE , & cnl_features },
957- { INTEL_FAM6_METEORLAKE_L , & cnl_features },
958- { INTEL_FAM6_ARROWLAKE_H , & arl_features },
959- { INTEL_FAM6_ARROWLAKE_U , & arl_features },
960- { INTEL_FAM6_ARROWLAKE , & arl_features },
961- { INTEL_FAM6_LUNARLAKE_M , & arl_features },
962- { INTEL_FAM6_ATOM_SILVERMONT , & slv_features },
963- { INTEL_FAM6_ATOM_SILVERMONT_D , & slvd_features },
964- { INTEL_FAM6_ATOM_AIRMONT , & amt_features },
965- { INTEL_FAM6_ATOM_GOLDMONT , & gmt_features },
966- { INTEL_FAM6_ATOM_GOLDMONT_D , & gmtd_features },
967- { INTEL_FAM6_ATOM_GOLDMONT_PLUS , & gmtp_features },
968- { INTEL_FAM6_ATOM_TREMONT_D , & tmtd_features },
969- { INTEL_FAM6_ATOM_TREMONT , & tmt_features },
970- { INTEL_FAM6_ATOM_TREMONT_L , & tmt_features },
971- { INTEL_FAM6_ATOM_GRACEMONT , & adl_features },
972- { INTEL_FAM6_ATOM_CRESTMONT_X , & srf_features },
973- { INTEL_FAM6_ATOM_CRESTMONT , & grr_features },
974- { INTEL_FAM6_XEON_PHI_KNL , & knl_features },
975- { INTEL_FAM6_XEON_PHI_KNM , & knl_features },
937+ { INTEL_NEHALEM , & nhm_features },
938+ { INTEL_NEHALEM_G , & nhm_features },
939+ { INTEL_NEHALEM_EP , & nhm_features },
940+ { INTEL_NEHALEM_EX , & nhx_features },
941+ { INTEL_WESTMERE , & nhm_features },
942+ { INTEL_WESTMERE_EP , & nhm_features },
943+ { INTEL_WESTMERE_EX , & nhx_features },
944+ { INTEL_SANDYBRIDGE , & snb_features },
945+ { INTEL_SANDYBRIDGE_X , & snx_features },
946+ { INTEL_IVYBRIDGE , & ivb_features },
947+ { INTEL_IVYBRIDGE_X , & ivx_features },
948+ { INTEL_HASWELL , & hsw_features },
949+ { INTEL_HASWELL_X , & hsx_features },
950+ { INTEL_HASWELL_L , & hswl_features },
951+ { INTEL_HASWELL_G , & hswg_features },
952+ { INTEL_BROADWELL , & bdw_features },
953+ { INTEL_BROADWELL_G , & bdwg_features },
954+ { INTEL_BROADWELL_X , & bdx_features },
955+ { INTEL_BROADWELL_D , & bdx_features },
956+ { INTEL_SKYLAKE_L , & skl_features },
957+ { INTEL_SKYLAKE , & skl_features },
958+ { INTEL_SKYLAKE_X , & skx_features },
959+ { INTEL_KABYLAKE_L , & skl_features },
960+ { INTEL_KABYLAKE , & skl_features },
961+ { INTEL_COMETLAKE , & skl_features },
962+ { INTEL_COMETLAKE_L , & skl_features },
963+ { INTEL_CANNONLAKE_L , & cnl_features },
964+ { INTEL_ICELAKE_X , & icx_features },
965+ { INTEL_ICELAKE_D , & icx_features },
966+ { INTEL_ICELAKE_L , & cnl_features },
967+ { INTEL_ICELAKE_NNPI , & cnl_features },
968+ { INTEL_ROCKETLAKE , & cnl_features },
969+ { INTEL_TIGERLAKE_L , & cnl_features },
970+ { INTEL_TIGERLAKE , & cnl_features },
971+ { INTEL_SAPPHIRERAPIDS_X , & spr_features },
972+ { INTEL_EMERALDRAPIDS_X , & spr_features },
973+ { INTEL_GRANITERAPIDS_X , & spr_features },
974+ { INTEL_LAKEFIELD , & cnl_features },
975+ { INTEL_ALDERLAKE , & adl_features },
976+ { INTEL_ALDERLAKE_L , & adl_features },
977+ { INTEL_RAPTORLAKE , & adl_features },
978+ { INTEL_RAPTORLAKE_P , & adl_features },
979+ { INTEL_RAPTORLAKE_S , & adl_features },
980+ { INTEL_METEORLAKE , & cnl_features },
981+ { INTEL_METEORLAKE_L , & cnl_features },
982+ { INTEL_ARROWLAKE_H , & arl_features },
983+ { INTEL_ARROWLAKE_U , & arl_features },
984+ { INTEL_ARROWLAKE , & arl_features },
985+ { INTEL_LUNARLAKE_M , & arl_features },
986+ { INTEL_ATOM_SILVERMONT , & slv_features },
987+ { INTEL_ATOM_SILVERMONT_D , & slvd_features },
988+ { INTEL_ATOM_AIRMONT , & amt_features },
989+ { INTEL_ATOM_GOLDMONT , & gmt_features },
990+ { INTEL_ATOM_GOLDMONT_D , & gmtd_features },
991+ { INTEL_ATOM_GOLDMONT_PLUS , & gmtp_features },
992+ { INTEL_ATOM_TREMONT_D , & tmtd_features },
993+ { INTEL_ATOM_TREMONT , & tmt_features },
994+ { INTEL_ATOM_TREMONT_L , & tmt_features },
995+ { INTEL_ATOM_GRACEMONT , & adl_features },
996+ { INTEL_ATOM_CRESTMONT_X , & srf_features },
997+ { INTEL_ATOM_CRESTMONT , & grr_features },
998+ { INTEL_XEON_PHI_KNL , & knl_features },
999+ { INTEL_XEON_PHI_KNM , & knl_features },
9761000 /*
9771001 * Missing support for
978- * INTEL_FAM6_ICELAKE
979- * INTEL_FAM6_ATOM_SILVERMONT_MID
980- * INTEL_FAM6_ATOM_AIRMONT_MID
981- * INTEL_FAM6_ATOM_AIRMONT_NP
1002+ * INTEL_ICELAKE
1003+ * INTEL_ATOM_SILVERMONT_MID
1004+ * INTEL_ATOM_AIRMONT_MID
1005+ * INTEL_ATOM_AIRMONT_NP
9821006 */
9831007 { 0 , NULL },
9841008};
@@ -1003,11 +1027,12 @@ void probe_platform_features(unsigned int family, unsigned int model)
10031027 return ;
10041028 }
10051029
1006- if (!genuine_intel || family != 6 )
1030+ if (!genuine_intel )
10071031 return ;
10081032
10091033 for (i = 0 ; turbostat_pdata [i ].features ; i ++ ) {
1010- if (turbostat_pdata [i ].model == model ) {
1034+ if (VFM_FAMILY (turbostat_pdata [i ].vfm ) == family &&
1035+ VFM_MODEL (turbostat_pdata [i ].vfm ) == model ) {
10111036 platform = turbostat_pdata [i ].features ;
10121037 return ;
10131038 }
0 commit comments