Skip to content

Commit 7981521

Browse files
committed
[AMD][F17h...F19h] Programming the Data Fabric Performance Monitors
* Read DF_PERF_CTR MSR register as UNCORE counter
1 parent c7c3def commit 7981521

File tree

4 files changed

+105
-40
lines changed

4 files changed

+105
-40
lines changed

amdmsr.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
#define MSR_SVM_LOCK_KEY 0xc0010118
6565
#endif
6666

67+
#define MSR_AMD_F17H_DF_PERF_CTL 0xc0010240
68+
#define MSR_AMD_F17H_DF_PERF_CTR 0xc0010241
6769
#define MSR_AMD_F17H_PMGT_MISC 0xc0010292
6870
#define MSR_AMD_F17H_HW_PSTATE_STATUS 0xc0010293
6971
#define MSR_AMD_F17H_CSTATE_POLICY 0xc0010294
@@ -471,6 +473,24 @@ typedef union
471473
} Family_17h;
472474
} PSTATEDEF;
473475

476+
typedef union
477+
{
478+
unsigned long long value;
479+
struct
480+
{
481+
unsigned long long /* MSR 0xC001024{0,2,4,6} */
482+
EventSelect00 : 8-0,
483+
UnitMask : 16-8,
484+
Reserved1 : 22-16,
485+
CounterEn : 23-22,
486+
Reserved2 : 32-23,
487+
EventSelect08 : 36-32,
488+
Reserved3 : 59-36,
489+
EventSelect12 : 61-59,
490+
Reserved4 : 64-61;
491+
};
492+
} ZEN_DF_PERF_CTL;
493+
474494
typedef union
475495
{
476496
unsigned long long value;

corefreq-api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ typedef struct
834834
UNCORE_FIXED_PERF_CONTROL Uncore_FixedPerfControl;
835835
} Intel;
836836
struct {
837+
ZEN_DF_PERF_CTL Zen_DataFabricPerfControl;
837838
} AMD;
838839
} SaveArea;
839840

corefreqk.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11232,6 +11232,14 @@ static void PKG_Counters_IvyBridge_EP(CORE_RO *Core, unsigned int T)
1123211232
PUBLIC(RO(Proc))->Counter[T].Uncore.FC0);\
1123311233
})
1123411234

11235+
#define PKG_Counters_AMD_Family_17h(Core, T) \
11236+
({ \
11237+
PUBLIC(RO(Proc))->Counter[T].PTSC = Core->Counter[T].TSC; \
11238+
\
11239+
RDCOUNTER( PUBLIC(RO(Proc))->Counter[T].Uncore.FC0, \
11240+
MSR_AMD_F17H_DF_PERF_CTR ); \
11241+
})
11242+
1123511243
#define Pkg_OVH(Pkg, Core) \
1123611244
({ \
1123711245
Pkg->Delta.PTSC -= (Pkg->Counter[1].PTSC - Core->Overhead.TSC); \
@@ -15245,7 +15253,7 @@ void Cycle_AMD_Family_17h(CORE_RO *Core,
1524515253

1524615254
if (Core->Bind == PUBLIC(RO(Proc))->Service.Core)
1524715255
{
15248-
PKG_Counters_Generic(Core, 1);
15256+
PKG_Counters_AMD_Family_17h(Core, 1);
1524915257

1525015258
Pkg_AMD_Family_17h_Temp(PUBLIC(RO(Proc)), Core);
1525115259

@@ -15268,10 +15276,14 @@ void Cycle_AMD_Family_17h(CORE_RO *Core,
1526815276

1526915277
Delta_PTSC_OVH(PUBLIC(RO(Proc)), Core);
1527015278

15279+
Delta_UNCORE_FC0(PUBLIC(RO(Proc)));
15280+
1527115281
Delta_PWR_ACCU(Proc, PKG);
1527215282

1527315283
Save_PTSC(PUBLIC(RO(Proc)));
1527415284

15285+
Save_UNCORE_FC0(PUBLIC(RO(Proc)));
15286+
1527515287
Save_PWR_ACCU(PUBLIC(RO(Proc)), PKG);
1527615288

1527715289
Sys_Tick(PUBLIC(RO(Proc)),
@@ -15508,7 +15520,7 @@ static void Start_AMD_Family_17h(void *arg)
1550815520
if (Arch[PUBLIC(RO(Proc))->ArchID].Uncore.Start != NULL) {
1550915521
Arch[PUBLIC(RO(Proc))->ArchID].Uncore.Start(NULL);
1551015522
}
15511-
PKG_Counters_Generic(Core, 0);
15523+
PKG_Counters_AMD_Family_17h(Core, 0);
1551215524

1551315525
RDCOUNTER(PUBLIC(RO(Proc))->Counter[0].Power.ACCU[PWR_DOMAIN(PKG)],
1551415526
MSR_AMD_PKG_ENERGY_STATUS );
@@ -15551,6 +15563,34 @@ static void Stop_AMD_Family_17h(void *arg)
1555115563
BITCLR(LOCKLESS, PRIVATE(OF(Join, AT(cpu)))->TSM, STARTED);
1555215564
}
1555315565

15566+
static void Start_Uncore_AMD_Family_17h(void *arg)
15567+
{
15568+
ZEN_DF_PERF_CTL Zen_DataFabricPerfControl;
15569+
UNUSED(arg);
15570+
15571+
RDMSR(Zen_DataFabricPerfControl, MSR_AMD_F17H_DF_PERF_CTL);
15572+
15573+
PUBLIC(RO(Proc))->SaveArea.AMD.Zen_DataFabricPerfControl = \
15574+
Zen_DataFabricPerfControl;
15575+
15576+
Zen_DataFabricPerfControl.EventSelect00 = 0x0f;
15577+
Zen_DataFabricPerfControl.UnitMask = 0xff;
15578+
Zen_DataFabricPerfControl.CounterEn = 1;
15579+
Zen_DataFabricPerfControl.EventSelect08 = 0x00;
15580+
Zen_DataFabricPerfControl.EventSelect12 = 0x00;
15581+
15582+
WRMSR(Zen_DataFabricPerfControl, MSR_AMD_F17H_DF_PERF_CTL);
15583+
}
15584+
15585+
static void Stop_Uncore_AMD_Family_17h(void *arg)
15586+
{
15587+
UNUSED(arg);
15588+
15589+
WRMSR( PUBLIC(RO(Proc))->SaveArea.AMD.Zen_DataFabricPerfControl,
15590+
MSR_AMD_F17H_DF_PERF_CTL );
15591+
}
15592+
15593+
1555415594
long Sys_OS_Driver_Query(void)
1555515595
{
1555615596
int rc = RC_SUCCESS;

corefreqk.h

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,8 @@ static void InitTimer_AMD_F17h_Zen(unsigned int cpu) ;
15561556
static void InitTimer_AMD_F17h_Zen2_SP(unsigned int cpu) ;
15571557
static void InitTimer_AMD_F17h_Zen2_MP(unsigned int cpu) ;
15581558
static void InitTimer_AMD_F17h_Zen2_APU(unsigned int cpu) ;
1559+
static void Start_Uncore_AMD_Family_17h(void *arg) ;
1560+
static void Stop_Uncore_AMD_Family_17h(void *arg) ;
15591561

15601562
static void Core_AMD_F17h_No_Thermal(CORE_RO *Core)
15611563
{
@@ -1575,6 +1577,8 @@ static void Query_Hygon_F18h(unsigned int cpu);
15751577
#define InitTimer_AMD_Family_19h InitTimer_AMD_Family_17h
15761578
#define InitTimer_AMD_F17h_Zen3_SP InitTimer_AMD_F17h_Zen2_SP
15771579
#define InitTimer_AMD_F17h_Zen3_MP InitTimer_AMD_F17h_Zen2_MP
1580+
#define Start_Uncore_AMD_Family_19h Start_Uncore_AMD_Family_17h
1581+
#define Stop_Uncore_AMD_Family_19h Stop_Uncore_AMD_Family_17h
15781582

15791583
/* [Void] */
15801584
#define _Void_Signature {.ExtFamily=0x0, .Family=0x0, .ExtModel=0x0, .Model=0x0}
@@ -6846,8 +6850,8 @@ static ARCH Arch[ARCHITECTURES] = {
68466850
.powerFormula = POWER_FORMULA_AMD_17h,
68476851
.PCI_ids = PCI_AMD_17h_ids,
68486852
.Uncore = {
6849-
.Start = NULL,
6850-
.Stop = NULL,
6853+
.Start = Start_Uncore_AMD_Family_17h,
6854+
.Stop = Stop_Uncore_AMD_Family_17h,
68516855
.ClockMod = NULL
68526856
},
68536857
.Specific = Void_Specific,
@@ -6870,8 +6874,8 @@ static ARCH Arch[ARCHITECTURES] = {
68706874
.powerFormula = POWER_FORMULA_AMD_17h,
68716875
.PCI_ids = PCI_Void_ids,
68726876
.Uncore = {
6873-
.Start = NULL,
6874-
.Stop = NULL,
6877+
.Start = Start_Uncore_AMD_Family_17h,
6878+
.Stop = Stop_Uncore_AMD_Family_17h,
68756879
.ClockMod = NULL
68766880
},
68776881
.Specific = Void_Specific,
@@ -6894,8 +6898,8 @@ static ARCH Arch[ARCHITECTURES] = {
68946898
.powerFormula = POWER_FORMULA_AMD_19h,
68956899
.PCI_ids = PCI_AMD_19h_ids,
68966900
.Uncore = {
6897-
.Start = NULL,
6898-
.Stop = NULL,
6901+
.Start = Start_Uncore_AMD_Family_19h,
6902+
.Stop = Stop_Uncore_AMD_Family_19h,
68996903
.ClockMod = NULL
69006904
},
69016905
.Specific = Void_Specific,
@@ -8716,8 +8720,8 @@ static ARCH Arch[ARCHITECTURES] = {
87168720
.powerFormula = POWER_FORMULA_AMD_17h,
87178721
.PCI_ids = PCI_AMD_17h_ids,
87188722
.Uncore = {
8719-
.Start = NULL,
8720-
.Stop = NULL,
8723+
.Start = Start_Uncore_AMD_Family_17h,
8724+
.Stop = Stop_Uncore_AMD_Family_17h,
87218725
.ClockMod = NULL
87228726
},
87238727
.Specific = AMD_Zen_Specific,
@@ -8740,8 +8744,8 @@ static ARCH Arch[ARCHITECTURES] = {
87408744
.powerFormula = POWER_FORMULA_AMD_17h,
87418745
.PCI_ids = PCI_AMD_17h_ids,
87428746
.Uncore = {
8743-
.Start = NULL,
8744-
.Stop = NULL,
8747+
.Start = Start_Uncore_AMD_Family_17h,
8748+
.Stop = Stop_Uncore_AMD_Family_17h,
87458749
.ClockMod = NULL
87468750
},
87478751
.Specific = AMD_Zen_APU_Specific,
@@ -8764,8 +8768,8 @@ static ARCH Arch[ARCHITECTURES] = {
87648768
.powerFormula = POWER_FORMULA_AMD_17h,
87658769
.PCI_ids = PCI_AMD_17h_ids,
87668770
.Uncore = {
8767-
.Start = NULL,
8768-
.Stop = NULL,
8771+
.Start = Start_Uncore_AMD_Family_17h,
8772+
.Stop = Stop_Uncore_AMD_Family_17h,
87698773
.ClockMod = NULL
87708774
},
87718775
.Specific = AMD_ZenPlus_Specific,
@@ -8788,8 +8792,8 @@ static ARCH Arch[ARCHITECTURES] = {
87888792
.powerFormula = POWER_FORMULA_AMD_17h,
87898793
.PCI_ids = PCI_AMD_17h_ids,
87908794
.Uncore = {
8791-
.Start = NULL,
8792-
.Stop = NULL,
8795+
.Start = Start_Uncore_AMD_Family_17h,
8796+
.Stop = Stop_Uncore_AMD_Family_17h,
87938797
.ClockMod = NULL
87948798
},
87958799
.Specific = AMD_ZenPlus_APU_Specific,
@@ -8812,8 +8816,8 @@ static ARCH Arch[ARCHITECTURES] = {
88128816
.powerFormula = POWER_FORMULA_AMD_17h,
88138817
.PCI_ids = PCI_AMD_17h_ids,
88148818
.Uncore = {
8815-
.Start = NULL,
8816-
.Stop = NULL,
8819+
.Start = Start_Uncore_AMD_Family_17h,
8820+
.Stop = Stop_Uncore_AMD_Family_17h,
88178821
.ClockMod = NULL
88188822
},
88198823
.Specific = AMD_Zen_Dali_Specific,
@@ -8836,8 +8840,8 @@ static ARCH Arch[ARCHITECTURES] = {
88368840
.powerFormula = POWER_FORMULA_AMD_17h,
88378841
.PCI_ids = PCI_AMD_17h_ids,
88388842
.Uncore = {
8839-
.Start = NULL,
8840-
.Stop = NULL,
8843+
.Start = Start_Uncore_AMD_Family_17h,
8844+
.Stop = Stop_Uncore_AMD_Family_17h,
88418845
.ClockMod = NULL
88428846
},
88438847
.Specific = AMD_EPYC_Rome_CPK_Specific,
@@ -8860,8 +8864,8 @@ static ARCH Arch[ARCHITECTURES] = {
88608864
.powerFormula = POWER_FORMULA_AMD_17h,
88618865
.PCI_ids = PCI_AMD_17h_ids,
88628866
.Uncore = {
8863-
.Start = NULL,
8864-
.Stop = NULL,
8867+
.Start = Start_Uncore_AMD_Family_17h,
8868+
.Stop = Stop_Uncore_AMD_Family_17h,
88658869
.ClockMod = NULL
88668870
},
88678871
.Specific = AMD_Zen2_Renoir_Specific,
@@ -8884,8 +8888,8 @@ static ARCH Arch[ARCHITECTURES] = {
88848888
.powerFormula = POWER_FORMULA_AMD_17h,
88858889
.PCI_ids = PCI_AMD_17h_ids,
88868890
.Uncore = {
8887-
.Start = NULL,
8888-
.Stop = NULL,
8891+
.Start = Start_Uncore_AMD_Family_17h,
8892+
.Stop = Stop_Uncore_AMD_Family_17h,
88898893
.ClockMod = NULL
88908894
},
88918895
.Specific = AMD_Zen2_LCN_Specific,
@@ -8908,8 +8912,8 @@ static ARCH Arch[ARCHITECTURES] = {
89088912
.powerFormula = POWER_FORMULA_AMD_17h,
89098913
.PCI_ids = PCI_AMD_17h_ids,
89108914
.Uncore = {
8911-
.Start = NULL,
8912-
.Stop = NULL,
8915+
.Start = Start_Uncore_AMD_Family_17h,
8916+
.Stop = Stop_Uncore_AMD_Family_17h,
89138917
.ClockMod = NULL
89148918
},
89158919
.Specific = AMD_Zen2_MTS_Specific,
@@ -8932,8 +8936,8 @@ static ARCH Arch[ARCHITECTURES] = {
89328936
.powerFormula = POWER_FORMULA_AMD_17h,
89338937
.PCI_ids = PCI_Void_ids,
89348938
.Uncore = {
8935-
.Start = NULL,
8936-
.Stop = NULL,
8939+
.Start = Start_Uncore_AMD_Family_17h,
8940+
.Stop = Stop_Uncore_AMD_Family_17h,
89378941
.ClockMod = NULL
89388942
},
89398943
.Specific = Void_Specific,
@@ -8956,8 +8960,8 @@ static ARCH Arch[ARCHITECTURES] = {
89568960
.powerFormula = POWER_FORMULA_AMD_19h,
89578961
.PCI_ids = PCI_AMD_19h_ids,
89588962
.Uncore = {
8959-
.Start = NULL,
8960-
.Stop = NULL,
8963+
.Start = Start_Uncore_AMD_Family_19h,
8964+
.Stop = Stop_Uncore_AMD_Family_19h,
89618965
.ClockMod = NULL
89628966
},
89638967
.Specific = AMD_Zen3_VMR_Specific,
@@ -8980,8 +8984,8 @@ static ARCH Arch[ARCHITECTURES] = {
89808984
.powerFormula = POWER_FORMULA_AMD_19h,
89818985
.PCI_ids = PCI_AMD_19h_ids,
89828986
.Uncore = {
8983-
.Start = NULL,
8984-
.Stop = NULL,
8987+
.Start = Start_Uncore_AMD_Family_19h,
8988+
.Stop = Stop_Uncore_AMD_Family_19h,
89858989
.ClockMod = NULL
89868990
},
89878991
.Specific = AMD_Zen3_CZN_Specific,
@@ -9004,8 +9008,8 @@ static ARCH Arch[ARCHITECTURES] = {
90049008
.powerFormula = POWER_FORMULA_AMD_19h,
90059009
.PCI_ids = PCI_AMD_19h_ids,
90069010
.Uncore = {
9007-
.Start = NULL,
9008-
.Stop = NULL,
9011+
.Start = Start_Uncore_AMD_Family_19h,
9012+
.Stop = Stop_Uncore_AMD_Family_19h,
90099013
.ClockMod = NULL
90109014
},
90119015
.Specific = AMD_EPYC_Milan_Specific,
@@ -9028,8 +9032,8 @@ static ARCH Arch[ARCHITECTURES] = {
90289032
.powerFormula = POWER_FORMULA_AMD_19h,
90299033
.PCI_ids = PCI_AMD_19h_ids,
90309034
.Uncore = {
9031-
.Start = NULL,
9032-
.Stop = NULL,
9035+
.Start = Start_Uncore_AMD_Family_19h,
9036+
.Stop = Stop_Uncore_AMD_Family_19h,
90339037
.ClockMod = NULL
90349038
},
90359039
.Specific = Void_Specific,
@@ -9052,8 +9056,8 @@ static ARCH Arch[ARCHITECTURES] = {
90529056
.powerFormula = POWER_FORMULA_AMD_19h,
90539057
.PCI_ids = PCI_AMD_19h_ids,
90549058
.Uncore = {
9055-
.Start = NULL,
9056-
.Stop = NULL,
9059+
.Start = Start_Uncore_AMD_Family_19h,
9060+
.Stop = Stop_Uncore_AMD_Family_19h,
90579061
.ClockMod = NULL
90589062
},
90599063
.Specific = Void_Specific,
@@ -9076,8 +9080,8 @@ static ARCH Arch[ARCHITECTURES] = {
90769080
.powerFormula = POWER_FORMULA_AMD_19h,
90779081
.PCI_ids = PCI_AMD_19h_ids,
90789082
.Uncore = {
9079-
.Start = NULL,
9080-
.Stop = NULL,
9083+
.Start = Start_Uncore_AMD_Family_19h,
9084+
.Stop = Stop_Uncore_AMD_Family_19h,
90819085
.ClockMod = NULL
90829086
},
90839087
.Specific = AMD_Zen3Plus_RMB_Specific,

0 commit comments

Comments
 (0)