pmc: Add Hygon Dhyana support.

To make the PMC tool pmcstat working properly on Hygon platform, add
support for Hygon Dhyana family 18h by using the PMC initialization
code path of AMD family 17h.

Submitted by:	Pu Wen <puwen@hygon.cn>
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D23562
This commit is contained in:
Konstantin Belousov 2020-02-07 22:28:04 +00:00
parent fc9134243d
commit 53071ed1c9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=357670
4 changed files with 10 additions and 3 deletions

View File

@ -103,7 +103,8 @@ pmu_events_mfr(void)
free(buf);
return (PMU_INVALID);
}
if (strcasestr(buf, "AuthenticAMD") != NULL)
if (strcasestr(buf, "AuthenticAMD") != NULL ||
strcasestr(buf, "HygonGenuine") != NULL)
mfr = PMU_AMD;
else if (strcasestr(buf, "GenuineIntel") != NULL)
mfr = PMU_INTEL;

View File

@ -41,3 +41,4 @@ AuthenticAMD-23-02,v1,amdfam17h,core
AuthenticAMD-23-03,v1,amdfam17h,core
AuthenticAMD-23-04,v1,amdfam17h,core
AuthenticAMD-23-05,v1,amdfam17h,core
HygonGenuine-24-00,v1,amdfam17h,core

1 Family-model Version Filename EventType
41 AuthenticAMD-23-03 v1 amdfam17h core
42 AuthenticAMD-23-04 v1 amdfam17h core
43 AuthenticAMD-23-05 v1 amdfam17h core
44 HygonGenuine-24-00 v1 amdfam17h core

View File

@ -1089,6 +1089,9 @@ pmc_amd_initialize(void)
if (CPUID_TO_FAMILY(cpu_id) == 0x17)
snprintf(pmc_cpuid, sizeof(pmc_cpuid), "AuthenticAMD-%d-%02X",
CPUID_TO_FAMILY(cpu_id), model);
if (CPUID_TO_FAMILY(cpu_id) == 0x18)
snprintf(pmc_cpuid, sizeof(pmc_cpuid), "HygonGenuine-%d-%02X",
CPUID_TO_FAMILY(cpu_id), model);
switch (cpu_id & 0xF00) {
#if defined(__i386__)

View File

@ -248,7 +248,8 @@ pmc_md_initialize()
struct pmc_mdep *md;
/* determine the CPU kind */
if (cpu_vendor_id == CPU_VENDOR_AMD)
if (cpu_vendor_id == CPU_VENDOR_AMD ||
cpu_vendor_id == CPU_VENDOR_HYGON)
md = pmc_amd_initialize();
else if (cpu_vendor_id == CPU_VENDOR_INTEL)
md = pmc_intel_initialize();
@ -271,7 +272,8 @@ pmc_md_finalize(struct pmc_mdep *md)
{
lapic_disable_pmc();
if (cpu_vendor_id == CPU_VENDOR_AMD)
if (cpu_vendor_id == CPU_VENDOR_AMD ||
cpu_vendor_id == CPU_VENDOR_HYGON)
pmc_amd_finalize(md);
else if (cpu_vendor_id == CPU_VENDOR_INTEL)
pmc_intel_finalize(md);