1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-11-10 22:59:13 +00:00

RDMSR: support for AMD 19h family

This commit is contained in:
The Tumultuous Unicorn Of Darkness 2023-03-27 10:02:51 +02:00
parent 995f7d12d9
commit 52f5924cb4
No known key found for this signature in database
GPG key ID: 1E55EE2EFF18BC1A

View file

@ -659,8 +659,9 @@ static int get_amd_multipliers(struct msr_info_t *info, uint32_t pstate, double
if (pstate < MSR_PSTATE_0 || MSR_PSTATE_7 < pstate)
return 1;
/* Overview of AMD CPU microarchitectures: https://en.wikipedia.org/wiki/List_of_AMD_CPU_microarchitectures#Nomenclature */
switch (info->id->ext_family) {
case 0x12:
case 0x12: /* K10 (Llano) / K12 */
/* BKDG 12h, page 469
MSRC001_00[6B:64][8:4] is CpuFid
MSRC001_00[6B:64][3:0] is CpuDid
@ -676,7 +677,7 @@ static int get_amd_multipliers(struct msr_info_t *info, uint32_t pstate, double
else
err++;
break;
case 0x14:
case 0x14: /* Bobcat */
/* BKDG 14h, page 430
MSRC001_00[6B:64][8:4] is CpuDidMSD
MSRC001_00[6B:64][3:0] is CpuDidLSD
@ -688,25 +689,28 @@ static int get_amd_multipliers(struct msr_info_t *info, uint32_t pstate, double
err += cpu_rdmsr_range(info->handle, pstate, 3, 0, &CpuDidLSD);
*multiplier = (double) (((info->cpu_clock + 5) / 100 + magic_constant) / (CpuDid + CpuDidLSD * 0.25 + 1));
break;
case 0x10:
case 0x10: /* K10 */
/* BKDG 10h, page 429
MSRC001_00[6B:64][8:6] is CpuDid
MSRC001_00[6B:64][5:0] is CpuFid
CPU COF is (100 MHz * (CpuFid + 10h) / (2^CpuDid))
Note: This family contains only CPUs */
case 0x11:
/* Fall through */
case 0x11: /* K8 & K10 "hybrid" */
/* BKDG 11h, page 236
MSRC001_00[6B:64][8:6] is CpuDid
MSRC001_00[6B:64][5:0] is CpuFid
CPU COF is ((100 MHz * (CpuFid + 08h)) / (2^CpuDid))
Note: This family contains only CPUs */
case 0x15:
/* Fall through */
case 0x15: /* Bulldozer / Piledriver / Steamroller / Excavator */
/* BKDG 15h, page 570/580/635/692 (00h-0Fh/10h-1Fh/30h-3Fh/60h-6Fh)
MSRC001_00[6B:64][8:6] is CpuDid
MSRC001_00[6B:64][5:0] is CpuFid
CoreCOF is (100 * (MSRC001_00[6B:64][CpuFid] + 10h) / (2^MSRC001_00[6B:64][CpuDid]))
Note: This family contains BOTH CPUs and APUs */
case 0x16:
/* Fall through */
case 0x16: /* Jaguar / Puma */
/* BKDG 16h, page 549/611 (00h-0Fh/30h-3Fh)
MSRC001_00[6B:64][8:6] is CpuDid
MSRC001_00[6B:64][5:0] is CpuFid
@ -716,16 +720,27 @@ static int get_amd_multipliers(struct msr_info_t *info, uint32_t pstate, double
err += cpu_rdmsr_range(info->handle, pstate, 5, 0, &CpuFid);
*multiplier = ((double) (CpuFid + magic_constant) / (1ull << CpuDid)) / divisor;
break;
case 0x17:
case 0x17: /* Zen / Zen+ / Zen 2 */
/* PPR 17h, pages 30 and 138-139
MSRC001_00[6B:64][13:8] is CpuDfsId
MSRC001_00[6B:64][7:0] is CpuFid
CoreCOF is (Core::X86::Msr::PStateDef[CpuFid[7:0]] / Core::X86::Msr::PStateDef[CpuDfsId]) * 200 */
/* Fall through */
case 0x18: /* Hygon Dhyana */
/* Note: Dhyana is "mostly a re-branded Zen CPU for the Chinese server market"
https://www.phoronix.com/news/Hygon-Dhyana-AMD-China-CPUs */
/* Fall through */
case 0x19: /* Zen 3 / Zen 3+ / Zen 4 */
/* PPR for AMD Family 19h Model 70h A0, pages 37 and 206-207
MSRC001_006[4...B][13:8] is CpuDfsId
MSRC001_006[4...B][7:0] is CpuFid
CoreCOF is (Core::X86::Msr::PStateDef[CpuFid[7:0]]/Core::X86::Msr::PStateDef[CpuDfsId]) *200 */
err = cpu_rdmsr_range(info->handle, pstate, 13, 8, &CpuDid);
err += cpu_rdmsr_range(info->handle, pstate, 7, 0, &CpuFid);
*multiplier = ((double) CpuFid / CpuDid) * 2;
break;
default:
warnf("get_amd_multipliers(): unsupported CPU extended family: %xh\n", info->id->ext_family);
err = 1;
break;
}