@@ -9290,13 +9290,7 @@ static unsigned int Query_AMD_HSMP_FreqRange(unsigned int cpu)
92909290 rx = AMD_HSMP_Exec(HSMP_RD_FMAX_SKT, arg);
92919291 if ((rx == HSMP_RESULT_OK) && (arg[0].value > 0))
92929292 {
9293- union {
9294- struct {
9295- unsigned short Fmin,
9296- Fmax;
9297- };
9298- unsigned int value;
9299- } Socket = { .value = arg[0].value };
9293+ ZEN_HSMP_FMAX_SKT Socket = { .value = arg[0].value };
93009294
93019295 PUBLIC(RO(Core, AT(cpu)))->Boost[BOOST(MIN)] = \
93029296 Socket.Fmin / PRECISION ? :
@@ -20823,42 +20817,62 @@ static void Call_MSR_ACCU(CORE_RO *Core)
2082320817 }
2082420818}
2082520819
20826- static void Call_HSMP_ACCU(CORE_RO *Core)
20827- { /* Convert DIMM Power from HSMP to RAPL. */
20828- if (PUBLIC(RO(Proc))->Features.HSMP_Enable)
20829- {
20820+ static unsigned long long Query_AMD_HSMP_DIMM_Power(const unsigned short umc,
20821+ const unsigned short dimm)
20822+ {
20823+ ZEN_HSMP_DIMM_ADDR DIMM = {
20824+ .UMC_Inst = umc,
20825+ .Dimm_Bit = dimm,
20826+ .Reserved = 0,
20827+ .Sensor = 0,
20828+ .Mode1 = 1
20829+ };
2083020830 ZEN_HSMP_DIMM_PWR DIMM_PWR = {
20831- .mWatt = 0, .ms = 0, .addr = Core->T.ApicID
20831+ .mWatt = 0, .ms = 0, .addr = DIMM.addr
2083220832 };
2083320833 HSMP_ARG arg[8] = {
2083420834 [7] = {0x0}, [6] = {0x0}, [5] = {0x0}, [4] = {0x0},
20835- [3] = {0x0}, [2] = {0x0}, [1] = {0x0}, [0] = {DIMM_PWR.value}
20835+ [3] = {0x0}, [2] = {0x0}, [1] = {0x0}, [0] = { DIMM_PWR.value }
2083620836 };
2083720837 unsigned int rx;
20838- if ((rx = AMD_HSMP_Exec(HSMP_RD_DIMM_PWR, arg)) == HSMP_RESULT_OK)
20839- {
20840- DIMM_PWR.value = arg[0].value;
20841- if ((DIMM_PWR.mWatt > 0) && (DIMM_PWR.mWatt != 0b111111111111111))
20842- {
20843- Core->Delta.RAM.ACCU = (unsigned long long) DIMM_PWR.mWatt;
20844- Core->Delta.RAM.ACCU <<= PUBLIC(RO(Proc))->PowerThermal.Unit.ESU;
20845- Core->Delta.RAM.ACCU *= PUBLIC(RO(Proc))->SleepInterval;
20846- Core->Delta.RAM.ACCU = Core->Delta.RAM.ACCU / (1000LLU * 1000LLU);
20847- }
20848- }
20849- else if (IS_HSMP_OOO(rx))
20850- {
20851- PUBLIC(RO(Proc))->Features.HSMP_Enable = 0;
20852- }
20853- }
20838+ if ((rx = AMD_HSMP_Exec(HSMP_RD_DIMM_PWR, arg)) == HSMP_RESULT_OK)
20839+ {
20840+ DIMM_PWR.value = arg[0].value;
20841+ if ((DIMM_PWR.mWatt > 0) && (DIMM_PWR.mWatt != 0b111111111111111))
20842+ {
20843+ return (unsigned long long) DIMM_PWR.mWatt;
20844+ }
20845+ }
20846+ else if (IS_HSMP_OOO(rx))
20847+ {
20848+ PUBLIC(RO(Proc))->Features.HSMP_Enable = 0;
20849+ }
20850+ return 0LLU;
20851+ }
20852+
20853+ static void Call_HSMP_ACCU(const unsigned short ids, const unsigned short UMC[])
20854+ {
20855+ unsigned long long DIMM_PWR_mWatt = 0;
20856+
20857+ unsigned short id = 0;
20858+ for (id = 0; id < ids && PUBLIC(RO(Proc))->Features.HSMP_Enable; id++)
20859+ {
20860+ DIMM_PWR_mWatt += Query_AMD_HSMP_DIMM_Power(UMC[id], 0);
20861+ }
20862+ /* Convert DIMM Power from HSMP to RAPL. */
20863+ DIMM_PWR_mWatt <<= PUBLIC(RO(Proc))->PowerThermal.Unit.ESU;
20864+ DIMM_PWR_mWatt *= PUBLIC(RO(Proc))->SleepInterval;
20865+ DIMM_PWR_mWatt /= (1000LLU * 1000LLU);
20866+ PUBLIC(RW(Proc))->Delta.Power.ACCU[PWR_DOMAIN(RAM)] = DIMM_PWR_mWatt;
2085420867}
2085520868
2085620869static void Call_Genoa_ACCU(CORE_RO *Core)
2085720870{
2085820871 Call_MSR_ACCU(Core);
20859- Call_HSMP_ACCU(Core);
2086020872}
2086120873
20874+ #define Call_Turin_ACCU Call_Genoa_ACCU
20875+
2086220876static void SoC_RAPL(AMD_F17H_SVI SVI, const unsigned long long factor)
2086320877{
2086420878 unsigned long long VCC, ICC, ACCU;
@@ -20963,6 +20977,26 @@ static void Call_Genoa( const unsigned int plane0, const unsigned int plane1,
2096320977 }
2096420978}
2096520979
20980+ #define Call_Turin Call_Genoa
20981+
20982+ static void Call_Genoa_SP5(const unsigned int plane0, const unsigned int plane1,
20983+ const unsigned long long factor)
20984+ {
20985+ Call_Genoa(plane0, plane1, factor);
20986+
20987+ Call_HSMP_ACCU( 12, (const unsigned short[12])
20988+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 } );
20989+ }
20990+
20991+ static void Call_Turin_SP5(const unsigned int plane0, const unsigned int plane1,
20992+ const unsigned long long factor)
20993+ {
20994+ Call_Turin(plane0, plane1, factor);
20995+
20996+ Call_HSMP_ACCU( 12, (const unsigned short[12])
20997+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 } );
20998+ }
20999+
2096621000static enum hrtimer_restart Entry_AMD_F17h(struct hrtimer *pTimer,
2096721001 void (*Call_PWR)(CORE_RO *Core),
2096821002 void (*Call_SMU)(const unsigned int, const unsigned int,
@@ -21015,7 +21049,11 @@ static enum hrtimer_restart Cycle_AMD_Zen4_RPL(struct hrtimer *pTimer)
2101521049}
2101621050static enum hrtimer_restart Cycle_AMD_Zen4_Genoa(struct hrtimer *pTimer)
2101721051{
21018- return Entry_AMD_F17h(pTimer, Call_Genoa_ACCU, Call_Genoa, 1, 2, 0LLU);
21052+ return Entry_AMD_F17h(pTimer, Call_Genoa_ACCU, Call_Genoa_SP5,1,2,0LLU);
21053+ }
21054+ static enum hrtimer_restart Cycle_AMD_Zen5_Turin(struct hrtimer *pTimer)
21055+ {
21056+ return Entry_AMD_F17h(pTimer, Call_Turin_ACCU, Call_Turin_SP5,1,2,0LLU);
2101921057}
2102021058static enum hrtimer_restart Cycle_AMD_F17h(struct hrtimer *pTimer)
2102121059{
@@ -21062,6 +21100,11 @@ static void InitTimer_AMD_Zen4_Genoa(unsigned int cpu)
2106221100 smp_call_function_single(cpu, InitTimer, Cycle_AMD_Zen4_Genoa, 1);
2106321101}
2106421102
21103+ static void InitTimer_AMD_Zen5_Turin(unsigned int cpu)
21104+ {
21105+ smp_call_function_single(cpu, InitTimer, Cycle_AMD_Zen5_Turin, 1);
21106+ }
21107+
2106521108static void InitTimer_AMD_Zen5_STX(unsigned int cpu)
2106621109{
2106721110 smp_call_function_single(cpu, InitTimer, Cycle_AMD_F17h, 1);
0 commit comments