From: panpingsheng <panpingsheng(a)hygon.cn>
Date: Fri, 25 Sep 2020 19:48:12 +0800
Subject: [PATCH 01/19] suport hygon cpu
Change-Id: Icddced82b73b3c76de289570e15a9cadb20b2eca
---
arch/x86/kernel/acpi/cstate.c | 1 +
arch/x86/kernel/cpu/cacheinfo.c | 11 ++++++++++-
arch/x86/kernel/cpu/microcode/core.c | 4 ++++
drivers/acpi/acpi_apd.c | 1 +
drivers/i2c/busses/i2c-designware-platdrv.c | 1 +
drivers/infiniband/hw/qib/qib_wc_x86_64.c | 3 ++-
drivers/ntb/hw/amd/ntb_hw_amd.c | 1 +
tools/power/cpupower/utils/helpers/amd.c | 2 +-
8 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
index 158ad1483c43..751d908db9f9 100644
--- a/arch/x86/kernel/acpi/cstate.c
+++ b/arch/x86/kernel/acpi/cstate.c
@@ -168,6 +168,7 @@ static int __init ffh_cstate_init(void)
struct cpuinfo_x86 *c = &boot_cpu_data;
if (c->x86_vendor != X86_VENDOR_INTEL &&
+ c->x86_vendor != X86_VENDOR_HYGON &&
c->x86_vendor != X86_VENDOR_AMD)
return -1;
diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c
index ef972fe0d013..13874748552b 100644
--- a/arch/x86/kernel/cpu/cacheinfo.c
+++ b/arch/x86/kernel/cpu/cacheinfo.c
@@ -595,7 +595,8 @@ cpuid4_cache_lookup_regs(int index, struct _cpuid4_info_regs
*this_leaf)
union _cpuid4_leaf_ecx ecx;
unsigned edx;
- if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {
+ if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
+ boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {
if (boot_cpu_has(X86_FEATURE_TOPOEXT))
cpuid_count(0x8000001d, index, &eax.full,
&ebx.full, &ecx.full, &edx);
@@ -662,6 +663,14 @@ void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, int cpu, u8
node_id)
* Core complex ID is ApicId[3] for these processors.
*/
per_cpu(cpu_llc_id, cpu) = c->apicid >> 3;
+ } else if (c->x86 == 0x18) {
+ /* Socket ID is ApicId[6] for these processors. */
+ c->phys_proc_id = c->initial_apicid >> 6;
+ /*
+ * LLC is at the core complex level.
+ * Core complex ID is ApicId[3] for these processors.
+ */
+ per_cpu(cpu_llc_id, cpu) = c->apicid >> 3;
} else {
/*
* LLC ID is calculated from the number of threads sharing the
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index a96091d44a45..86b2feee4fcc 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -833,6 +833,10 @@ int __init microcode_init(void)
struct cpuinfo_x86 *c = &boot_cpu_data;
int error;
+ /* Hygon microcode loading to be implemented */
+ if (c->x86_vendor == X86_VENDOR_HYGON)
+ return 0;
+
if (dis_ucode_ldr)
return -EINVAL;
diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index ddf598ae8b6b..398b645927bf 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -231,6 +231,7 @@ static const struct acpi_device_id acpi_apd_device_ids[] = {
{ "AMDI0020", APD_ADDR(cz_uart_desc) },
{ "AMD0030", },
{ "AMD0040", APD_ADDR(st_misc_desc)},
+ { "HYGO0010", APD_ADDR(wt_i2c_desc) },
#endif
#ifdef CONFIG_ARM64
{ "APMC0D0F", APD_ADDR(xgene_i2c_desc) },
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c
b/drivers/i2c/busses/i2c-designware-platdrv.c
index b5750fd85125..f6004eb7832b 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -151,6 +151,7 @@ static const struct acpi_device_id dw_i2c_acpi_match[] = {
{ "APMC0D0F", 0 },
{ "HISI02A1", 0 },
{ "HISI02A2", 0 },
+ { "HYGO0010", ACCESS_INTR_MASK },
{ }
};
MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match);
diff --git a/drivers/infiniband/hw/qib/qib_wc_x86_64.c
b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
index edd0ddbd4481..b847016f6865 100644
--- a/drivers/infiniband/hw/qib/qib_wc_x86_64.c
+++ b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
@@ -146,5 +146,6 @@ void qib_disable_wc(struct qib_devdata *dd)
*/
int qib_unordered_wc(void)
{
- return boot_cpu_data.x86_vendor != X86_VENDOR_AMD;
+ return boot_cpu_data.x86_vendor != X86_VENDOR_AMD &&
+ boot_cpu_data.x86_vendor != X86_VENDOR_HYGON;
}
diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
index efb214fc545a..33245b1e86d4 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.c
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
@@ -1125,6 +1125,7 @@ static const struct file_operations amd_ntb_debugfs_info = {
static const struct pci_device_id amd_ntb_pci_tbl[] = {
{PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_NTB)},
+ {PCI_VDEVICE(HYGON, PCI_DEVICE_ID_AMD_NTB)},
{0}
};
MODULE_DEVICE_TABLE(pci, amd_ntb_pci_tbl);
diff --git a/tools/power/cpupower/utils/helpers/amd.c
b/tools/power/cpupower/utils/helpers/amd.c
index 7c4f83a8c973..24df49bc22a3 100644
--- a/tools/power/cpupower/utils/helpers/amd.c
+++ b/tools/power/cpupower/utils/helpers/amd.c
@@ -119,7 +119,7 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family,
}
if (read_msr(cpu, MSR_AMD_PSTATE + i, &pstate.val))
return -1;
- if ((cpu_family == 0x17) && (!pstate.fam17h_bits.en))
+ if ((cpu_family == 0x17 || cpu_family == 0x18) && (!pstate.fam17h_bits.en))
continue;
else if (!pstate.bits.en)
continue;
-- 2.27.0