@@ -2680,6 +2680,142 @@ static PROCESSOR_SPECIFIC *LookupProcessor(void)
26802680 return NULL;
26812681}
26822682
2683+ static void Intel_FlexRatio(bool OC_ENABLED)
2684+ {
2685+ if (OC_ENABLED) {
2686+ static struct {
2687+ struct SIGNATURE Arch;
2688+ unsigned short grantFlex : 1-0,
2689+ experimental : 2-1,
2690+ freeToUse : 16-2;
2691+ } list[] = {
2692+ {_Core_Yonah, 0, 1, 0},
2693+ {_Core_Conroe, 0, 1, 0},
2694+ {_Core_Kentsfield, 0, 1, 0},
2695+ {_Core_Conroe_616, 0, 1, 0},
2696+ {_Core_Penryn, 0, 1, 0},
2697+ {_Core_Dunnington, 0, 1, 0},
2698+
2699+ {_Atom_Bonnell, 0, 1, 0}, /* 06_1C */
2700+ {_Atom_Silvermont, 0, 1, 0}, /* 06_26 */
2701+ {_Atom_Lincroft, 0, 1, 0}, /* 06_27 */
2702+ {_Atom_Clover_Trail, 0, 1, 0}, /* 06_35 */
2703+ {_Atom_Saltwell, 0, 1, 0}, /* 06_36 */
2704+
2705+ {_Silvermont_Bay_Trail, 0, 1, 0}, /* 06_37 */
2706+
2707+ {_Atom_Avoton, 0, 1, 0}, /* 06_4D */
2708+ {_Atom_Airmont, 0, 1, 0}, /* 06_4C */
2709+ {_Atom_Goldmont, 1, 1, 0}, /* 06_5C */
2710+ {_Atom_Sofia, 1, 1, 0}, /* 06_5D */
2711+ {_Atom_Merrifield, 1, 1, 0}, /* 06_4A */
2712+ {_Atom_Moorefield, 1, 1, 0}, /* 06_5A */
2713+
2714+ {_Nehalem_Bloomfield, 1, 1, 0}, /* 06_1A */
2715+ {_Nehalem_Lynnfield, 1, 1, 0}, /* 06_1E */
2716+ {_Nehalem_MB, 1, 1, 0}, /* 06_1F */
2717+ {_Nehalem_EX, 1, 1, 0}, /* 06_2E */
2718+
2719+ {_Westmere, 1, 1, 0}, /* 06_25 */
2720+ {_Westmere_EP, 1, 1, 0}, /* 06_2C */
2721+ {_Westmere_EX, 1, 1, 0}, /* 06_2F */
2722+
2723+ {_SandyBridge, 1, 1, 0}, /* 06_2A */
2724+ {_SandyBridge_EP, 1, 1, 0}, /* 06_2D */
2725+
2726+ {_IvyBridge, 1, 0, 0}, /* 06_3A */
2727+ {_IvyBridge_EP, 1, 1, 0}, /* 06_3E */
2728+
2729+ {_Haswell_DT, 1, 1, 0}, /* 06_3C */
2730+ {_Haswell_EP, 1, 1, 0}, /* 06_3F */
2731+ {_Haswell_ULT, 1, 1, 0}, /* 06_45 */
2732+ {_Haswell_ULX, 1, 1, 0}, /* 06_46 */
2733+
2734+ {_Broadwell, 1, 1, 0}, /* 06_3D */
2735+ {_Broadwell_D, 1, 1, 0}, /* 06_56 */
2736+ {_Broadwell_H, 1, 1, 0}, /* 06_47 */
2737+ {_Broadwell_EP, 1, 1, 0}, /* 06_4F */
2738+
2739+ {_Skylake_UY, 1, 1, 0}, /* 06_4E */
2740+ {_Skylake_S, 1, 1, 0}, /* 06_5E */
2741+ {_Skylake_X, 1, 1, 0}, /* 06_55 */
2742+
2743+ {_Xeon_Phi, 0, 1, 0}, /* 06_57 */
2744+
2745+ {_Kabylake, 1, 1, 0}, /* 06_9E */
2746+ {_Kabylake_UY, 1, 1, 0}, /* 06_8E */
2747+
2748+ {_Cannonlake_U, 1, 1, 0}, /* 06_66 */
2749+ {_Cannonlake_H, 1, 1, 0},
2750+ {_Geminilake, 1, 1, 0}, /* 06_7A */
2751+ {_Icelake_UY, 1, 1, 0}, /* 06_7E */
2752+
2753+ {_Icelake_X, 1, 1, 0},
2754+ {_Icelake_D, 1, 1, 0},
2755+ {_Sunny_Cove, 1, 1, 0},
2756+ {_Tigerlake, 1, 1, 0},
2757+ {_Tigerlake_U, 1, 1, 0}, /* 06_8C */
2758+ {_Cometlake, 1, 1, 0},
2759+ {_Cometlake_UY, 1, 1, 0},
2760+ {_Atom_Denverton, 1, 1, 0},
2761+ {_Tremont_Jacobsville, 1, 1, 0},
2762+ {_Tremont_Lakefield, 1, 1, 0},
2763+ {_Tremont_Elkhartlake, 1, 1, 0},
2764+ {_Tremont_Jasperlake, 1, 1, 0},
2765+ {_Sapphire_Rapids, 1, 1, 0},
2766+ {_Emerald_Rapids, 1, 1, 0},
2767+ {_Granite_Rapids_X, 1, 1, 0},
2768+ {_Granite_Rapids_D, 1, 1, 0},
2769+ {_Sierra_Forest, 1, 1, 0},
2770+ {_Grand_Ridge, 1, 1, 0},
2771+ {_Rocketlake, 1, 1, 0},
2772+ {_Rocketlake_U, 1, 1, 0},
2773+ {_Alderlake_S, 1, 1, 0}, /* 06_97 */
2774+ {_Alderlake_H, 1, 1, 0},
2775+ {_Alderlake_N, 1, 1, 0},
2776+ {_Meteorlake_M, 1, 1, 0},
2777+ {_Meteorlake_N, 1, 1, 0},
2778+ {_Meteorlake_S, 1, 1, 0},
2779+ {_Raptorlake, 1, 1, 0}, /* 06_B7 */
2780+ {_Raptorlake_P, 1, 1, 0},
2781+ {_Raptorlake_S, 1, 1, 0},
2782+ {_Lunarlake, 1, 1, 0}, /* 06_BD */
2783+ {_Arrowlake, 1, 1, 0}, /* 06_C6 */
2784+ {_Arrowlake_H, 1, 1, 0}, /* 06_C5 */
2785+ {_Arrowlake_U, 1, 1, 0}, /* 06_B5 */
2786+ {_Pantherlake, 1, 1, 0}, /* 06_CC */
2787+ {_Clearwater_Forest, 1, 1, 0} /* 06_DD */
2788+ };
2789+ const unsigned int ids = sizeof(list) / sizeof(list[0]);
2790+ unsigned int id;
2791+ for (id = 0; id < ids; id++) {
2792+ if ((list[id].Arch.ExtFamily == PUBLIC(RO(Proc))->Features.Std.EAX.ExtFamily)
2793+ && (list[id].Arch.Family == PUBLIC(RO(Proc))->Features.Std.EAX.Family)
2794+ && (list[id].Arch.ExtModel == PUBLIC(RO(Proc))->Features.Std.EAX.ExtModel)
2795+ && (list[id].Arch.Model == PUBLIC(RO(Proc))->Features.Std.EAX.Model))
2796+ {
2797+ if (list[id].grantFlex) {
2798+ if (!list[id].experimental
2799+ || (list[id].experimental
2800+ && PUBLIC(RO(Proc))->Registration.Experimental))
2801+ {
2802+ FLEX_RATIO flexRegister = {.value = 0};
2803+ RDMSR(flexRegister, MSR_FLEX_RATIO);
2804+ PUBLIC(RO(Proc))->Features.OC_Enable = flexRegister.OC_ENABLED;
2805+ PUBLIC(RO(Proc))->Features.Factory.Bins = flexRegister.OC_BINS;
2806+ PUBLIC(RO(Proc))->Features.OC_Lock = flexRegister.OC_LOCK;
2807+ PUBLIC(RO(Proc))->Features.Factory.Overclock = \
2808+ ABS_FREQ_MHz( signed int,
2809+ PUBLIC(RO(Proc))->Features.Factory.Bins,
2810+ PUBLIC(RO(Proc))->Features.Factory.Clock );
2811+ }
2812+ }
2813+ break;
2814+ }
2815+ }
2816+ }
2817+ }
2818+
26832819static int Intel_MaxBusRatio(PLATFORM_ID *PfID)
26842820{
26852821 struct SIGNATURE whiteList[] = {
@@ -5904,6 +6040,8 @@ static PCI_CALLBACK IVB_IMC(struct pci_dev *dev)
59046040 pci_read_config_dword(dev, 0xe8,
59056041 &PUBLIC(RO(Proc))->Uncore.Bus.IVB_Cap.value);
59066042
6043+ Intel_FlexRatio(PUBLIC(RO(Proc))->Uncore.Bus.IVB_Cap.OC_ENABLED == 1);
6044+
59076045 PUBLIC(RO(Proc))->Uncore.CtrlCount = 1;
59086046
59096047 return Router(dev, 0x48, 64, 0x8000, Query_SNB_IMC, 0);
@@ -6104,6 +6242,8 @@ static PCI_CALLBACK HSW_HOST(struct pci_dev *dev, ROUTER Query)
61046242 pci_read_config_dword(dev, 0xe8,
61056243 &PUBLIC(RO(Proc))->Uncore.Bus.IVB_Cap.value);
61066244
6245+ Intel_FlexRatio(PUBLIC(RO(Proc))->Uncore.Bus.IVB_Cap.OC_ENABLED == 1);
6246+
61076247 PUBLIC(RO(Proc))->Uncore.CtrlCount = 1;
61086248
61096249 return Router(dev, 0x48, 64, 0x8000, Query, 0);
@@ -6345,6 +6485,8 @@ static PCI_CALLBACK SKL_HOST( struct pci_dev *dev,
63456485 pci_read_config_dword(dev, 0xec,
63466486 &PUBLIC(RO(Proc))->Uncore.Bus.SKL_Cap_C.value);
63476487
6488+ Intel_FlexRatio(PUBLIC(RO(Proc))->Uncore.Bus.SKL_Cap_B.OC_ENABLED == 1);
6489+
63486490 SoC_SKL_VTD();
63496491
63506492 return Router(dev, 0x48, 64, wsize, Query, mc);
@@ -6408,6 +6550,8 @@ static PCI_CALLBACK ADL_HOST( struct pci_dev *dev,
64086550 pci_read_config_dword(dev, 0xf0,
64096551 &PUBLIC(RO(Proc))->Uncore.Bus.ADL_Cap_E.value);
64106552
6553+ Intel_FlexRatio(PUBLIC(RO(Proc))->Uncore.Bus.ADL_Cap_B.OC_ENABLED == 1);
6554+
64116555 SoC_SKL_VTD();
64126556
64136557 return Router(dev, 0x48, 64, wsize, Query, mc);
@@ -6467,6 +6611,8 @@ static PCI_CALLBACK MTL_HOST( struct pci_dev *dev,
64676611 pci_read_config_dword(dev, 0xf0,
64686612 &PUBLIC(RO(Proc))->Uncore.Bus.MTL_Cap_E.value);
64696613
6614+ Intel_FlexRatio(PUBLIC(RO(Proc))->Uncore.Bus.MTL_Cap_B.OC_ENABLED == 1);
6615+
64706616 SoC_SKL_VTD();
64716617
64726618 return Router(dev, 0x48, 64, wsize, Query, mc);
@@ -6519,6 +6665,8 @@ static PCI_CALLBACK GLK_IMC(struct pci_dev *dev)
65196665 pci_read_config_dword(dev, 0xe8,
65206666 &PUBLIC(RO(Proc))->Uncore.Bus.GLK_Cap_B.value);
65216667
6668+ Intel_FlexRatio(PUBLIC(RO(Proc))->Uncore.Bus.GLK_Cap_B.OC_ENABLED == 1);
6669+
65226670 SoC_SKL_VTD();
65236671
65246672 return Router(dev, 0x48, 64, 0x8000, Query_GLK_IMC, 0);
0 commit comments