* [PATCH 0/8] Add support for Hygon Family 18h model 4h~8h processors
@ 2026-03-27 8:06 Fu Hao
2026-03-27 8:07 ` [PATCH 1/8] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon model 4h~8h Fu Hao
` (7 more replies)
0 siblings, 8 replies; 19+ messages in thread
From: Fu Hao @ 2026-03-27 8:06 UTC (permalink / raw)
To: puwen, tglx, mingo, bp, dave.hansen, x86, peterz, acme, joro,
will, suravee.suthikulpanit, robin.murphy, bhelgaas, perex,
tiwai, namhyung, alexander.shishkin, jolsa, irogers, james.clark,
hpa
Cc: linux-kernel, Fu Hao
This patch series introduce support for the new-generation Hygon
model 4h~8h processors, addressing five key areas:
1. CPU Topology Updates
The new processor introduces a revised CPU topology hierarchy
compared to previous generations. This patch updates the kernel's
topology detection logic to correctly identify core/socket
relationships and cache sharing patterns.
2. L3 Performance Monitoring Updates
The L3 perf registers of model 6h differ from those of the
previous processor.
3. Microcode loading
Add microcode loading support for Hygon processor.
4. Audio Controller Driver
Add initial support for the integrated HD-Audio controller.
5. New SB IOAPIC information support
The southbridge IOAPIC of Hygon's new-generation processors is
located at 00:0b.0.
Fu Hao (8):
x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon model
4h~8h
x86/cpu: Get LLC ID for Hygon family 18h model 4h
x86/cpu/hygon: Remove Spectral Chicken for Hygon processors
perf/x86/uncore: Add L3 PMU support for Hygon family 18h model 6h
x86/microcode/hygon: Add microcode loading support for Hygon
processors
ALSA: hda: Add support for Hygon family 18h model 5h HD-Audio
ALSA: hda: Fix single byte writing issue for Hygon family 18h model 5h
iommu/hygon: Add support for Hygon family 18h model 4h IOAPIC
arch/x86/Kconfig | 2 +-
arch/x86/events/amd/uncore.c | 48 +++++++++++++++++-
arch/x86/include/asm/perf_event.h | 8 +++
arch/x86/kernel/cpu/cacheinfo.c | 22 +++++++--
arch/x86/kernel/cpu/hygon.c | 21 +++++---
arch/x86/kernel/cpu/microcode/amd.c | 63 ++++++++++++++++++------
arch/x86/kernel/cpu/microcode/core.c | 11 +++++
arch/x86/kernel/cpu/microcode/internal.h | 12 +++++
drivers/iommu/amd/init.c | 10 +++-
include/linux/pci_ids.h | 1 +
include/sound/hdaudio.h | 1 +
sound/hda/controllers/intel.c | 9 ++++
sound/hda/core/controller.c | 10 +++-
sound/hda/core/stream.c | 42 ++++++++++++----
14 files changed, 220 insertions(+), 40 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/8] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon model 4h~8h
2026-03-27 8:06 [PATCH 0/8] Add support for Hygon Family 18h model 4h~8h processors Fu Hao
@ 2026-03-27 8:07 ` Fu Hao
2026-03-28 13:34 ` Borislav Petkov
2026-03-27 8:08 ` [PATCH 2/8] x86/cpu: Get LLC ID for Hygon family 18h model 4h Fu Hao
` (6 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Fu Hao @ 2026-03-27 8:07 UTC (permalink / raw)
To: puwen, tglx, mingo, bp, dave.hansen, x86, hpa; +Cc: linux-kernel, Fu Hao
The die id should be get from the NodeId field of CPUID leaf 0x8000001e
ecx for Hygon model 4h~8h processors.
Signed-off-by: Fu Hao <fuhao@open-hieco.net>
---
arch/x86/kernel/cpu/hygon.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c
index 7f95a74e4..f39d32a68 100644
--- a/arch/x86/kernel/cpu/hygon.c
+++ b/arch/x86/kernel/cpu/hygon.c
@@ -168,6 +168,19 @@ static void early_init_hygon(struct cpuinfo_x86 *c)
set_cpu_cap(c, X86_FEATURE_VMMCALL);
}
+/*
+ * Adjust the die_id and logical_die_id for Hygon model 4h~8h.
+ */
+static void cpu_topology_fixup_hygon(struct cpuinfo_x86 *c)
+{
+ if (c->x86_model >= 0x4 && c->x86_model <= 0x8) {
+ c->topo.die_id = cpuid_ecx(0x8000001e) & 0xff;
+ c->topo.logical_die_id = (c->topo.die_id >> 4) *
+ topology_amd_nodes_per_pkg() +
+ (c->topo.die_id & 0xf);
+ }
+}
+
static void init_hygon(struct cpuinfo_x86 *c)
{
u64 vm_cr;
@@ -191,6 +204,8 @@ static void init_hygon(struct cpuinfo_x86 *c)
init_hygon_cacheinfo(c);
+ cpu_topology_fixup_hygon(c);
+
if (cpu_has(c, X86_FEATURE_SVM)) {
rdmsrq(MSR_VM_CR, vm_cr);
if (vm_cr & SVM_VM_CR_SVM_DIS_MASK) {
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/8] x86/cpu: Get LLC ID for Hygon family 18h model 4h
2026-03-27 8:06 [PATCH 0/8] Add support for Hygon Family 18h model 4h~8h processors Fu Hao
2026-03-27 8:07 ` [PATCH 1/8] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon model 4h~8h Fu Hao
@ 2026-03-27 8:08 ` Fu Hao
2026-03-27 8:09 ` [PATCH 3/8] x86/cpu/hygon: Remove Spectral Chicken for Hygon processors Fu Hao
` (5 subsequent siblings)
7 siblings, 0 replies; 19+ messages in thread
From: Fu Hao @ 2026-03-27 8:08 UTC (permalink / raw)
To: tglx, mingo, bp, dave.hansen, x86, hpa; +Cc: linux-kernel, Fu Hao
Add support to calculate LLC ID from the number of threads sharing
the cache for Hygon family 18h model 4h processor.
Signed-off-by: Fu Hao <fuhao@open-hieco.net>
---
arch/x86/kernel/cpu/cacheinfo.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c
index 51a95b078..98862afc4 100644
--- a/arch/x86/kernel/cpu/cacheinfo.c
+++ b/arch/x86/kernel/cpu/cacheinfo.c
@@ -341,11 +341,23 @@ void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *c)
if (!cpuid_amd_hygon_has_l3_cache())
return;
- /*
- * Hygons are similar to AMD Family 17h up to 1F models: LLC is
- * at the core complex level. Core complex ID is ApicId[3].
- */
- c->topo.llc_id = c->topo.apicid >> 3;
+ if (c->x86_model >= 0x4) {
+ /*
+ * From model 4h: LLC ID is calculated from the number
+ * of threads sharing the L3 cache.
+ */
+ u32 llc_index = find_num_cache_leaves(c) - 1;
+ struct _cpuid4_info id4 = {};
+
+ if (!amd_fill_cpuid4_info(llc_index, &id4))
+ c->topo.llc_id = get_cache_id(c->topo.apicid, &id4);
+ } else {
+ /*
+ * The others are similar to AMD Family 17h up to 1F models: LLC is
+ * at the core complex level. Core complex ID is ApicId[3].
+ */
+ c->topo.llc_id = c->topo.apicid >> 3;
+ }
}
void init_amd_cacheinfo(struct cpuinfo_x86 *c)
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 3/8] x86/cpu/hygon: Remove Spectral Chicken for Hygon processors
2026-03-27 8:06 [PATCH 0/8] Add support for Hygon Family 18h model 4h~8h processors Fu Hao
2026-03-27 8:07 ` [PATCH 1/8] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon model 4h~8h Fu Hao
2026-03-27 8:08 ` [PATCH 2/8] x86/cpu: Get LLC ID for Hygon family 18h model 4h Fu Hao
@ 2026-03-27 8:09 ` Fu Hao
2026-03-27 8:09 ` [PATCH 4/8] perf/x86/uncore: Add L3 PMU support for Hygon family 18h model 6h Fu Hao
` (4 subsequent siblings)
7 siblings, 0 replies; 19+ messages in thread
From: Fu Hao @ 2026-03-27 8:09 UTC (permalink / raw)
To: puwen, tglx, mingo, bp, dave.hansen, x86, hpa; +Cc: linux-kernel, Fu Hao
The chicken bit is not need to be set for Hygon processors,
so remove it.
Fixes: d7caac991fee ("x86/cpu/amd: Add Spectral Chicken")
Signed-off-by: Fu Hao <fuhao@open-hieco.net>
---
arch/x86/kernel/cpu/hygon.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c
index f39d32a68..72110eb73 100644
--- a/arch/x86/kernel/cpu/hygon.c
+++ b/arch/x86/kernel/cpu/hygon.c
@@ -189,12 +189,6 @@ static void init_hygon(struct cpuinfo_x86 *c)
set_cpu_cap(c, X86_FEATURE_REP_GOOD);
- /*
- * XXX someone from Hygon needs to confirm this DTRT
- *
- init_spectral_chicken(c);
- */
-
set_cpu_cap(c, X86_FEATURE_ZEN);
set_cpu_cap(c, X86_FEATURE_CPB);
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 4/8] perf/x86/uncore: Add L3 PMU support for Hygon family 18h model 6h
2026-03-27 8:06 [PATCH 0/8] Add support for Hygon Family 18h model 4h~8h processors Fu Hao
` (2 preceding siblings ...)
2026-03-27 8:09 ` [PATCH 3/8] x86/cpu/hygon: Remove Spectral Chicken for Hygon processors Fu Hao
@ 2026-03-27 8:09 ` Fu Hao
2026-03-27 8:10 ` [PATCH 5/8] x86/microcode/hygon: Add microcode loading support for Hygon processors Fu Hao
` (3 subsequent siblings)
7 siblings, 0 replies; 19+ messages in thread
From: Fu Hao @ 2026-03-27 8:09 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung, tglx, bp, dave.hansen, x86,
alexander.shishkin, jolsa, irogers, james.clark, hpa
Cc: linux-perf-users, linux-kernel, Fu Hao
Adjust the L3 PMU slicemask and threadmask for Hygon family 18h
model 6h processor.
Signed-off-by: Fu Hao <fuhao@open-hieco.net>
---
arch/x86/events/amd/uncore.c | 48 ++++++++++++++++++++++++++++++-
arch/x86/include/asm/perf_event.h | 8 ++++++
2 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c
index dd956cfca..e71d9e784 100644
--- a/arch/x86/events/amd/uncore.c
+++ b/arch/x86/events/amd/uncore.c
@@ -308,6 +308,14 @@ amd_f17h_uncore_is_visible(struct kobject *kobj, struct attribute *attr, int i)
attr->mode : 0;
}
+static umode_t
+hygon_f18h_m6h_uncore_is_visible(struct kobject *kobj, struct attribute *attr, int i)
+{
+ return boot_cpu_data.x86 == 0x18 &&
+ boot_cpu_data.x86_model >= 0x6 && boot_cpu_data.x86_model <= 0xf ?
+ attr->mode : 0;
+}
+
static umode_t
amd_f19h_uncore_is_visible(struct kobject *kobj, struct attribute *attr, int i)
{
@@ -359,6 +367,8 @@ DEFINE_UNCORE_FORMAT_ATTR(enallslices, enallslices, "config:46"); /* F19h L3
DEFINE_UNCORE_FORMAT_ATTR(enallcores, enallcores, "config:47"); /* F19h L3 */
DEFINE_UNCORE_FORMAT_ATTR(sliceid, sliceid, "config:48-50"); /* F19h L3 */
DEFINE_UNCORE_FORMAT_ATTR(rdwrmask, rdwrmask, "config:8-9"); /* PerfMonV2 UMC */
+DEFINE_UNCORE_FORMAT_ATTR(slicemask4, slicemask, "config:28-31"); /* F18h L3 */
+DEFINE_UNCORE_FORMAT_ATTR(threadmask32, threadmask, "config:32-63"); /* F18h L3 */
/* Common DF and NB attributes */
static struct attribute *amd_uncore_df_format_attr[] = {
@@ -388,6 +398,12 @@ static struct attribute *amd_f17h_uncore_l3_format_attr[] = {
NULL,
};
+/* F18h M06h unique L3 attributes */
+static struct attribute *hygon_f18h_m6h_uncore_l3_format_attr[] = {
+ &format_attr_slicemask4.attr, /* slicemask */
+ NULL,
+};
+
/* F19h unique L3 attributes */
static struct attribute *amd_f19h_uncore_l3_format_attr[] = {
&format_attr_coreid.attr, /* coreid */
@@ -413,6 +429,12 @@ static struct attribute_group amd_f17h_uncore_l3_format_group = {
.is_visible = amd_f17h_uncore_is_visible,
};
+static struct attribute_group hygon_f18h_m6h_uncore_l3_format_group = {
+ .name = "format",
+ .attrs = hygon_f18h_m6h_uncore_l3_format_attr,
+ .is_visible = hygon_f18h_m6h_uncore_is_visible,
+};
+
static struct attribute_group amd_f19h_uncore_l3_format_group = {
.name = "format",
.attrs = amd_f19h_uncore_l3_format_attr,
@@ -442,6 +464,11 @@ static const struct attribute_group *amd_uncore_l3_attr_update[] = {
NULL,
};
+static const struct attribute_group *hygon_uncore_l3_attr_update[] = {
+ &hygon_f18h_m6h_uncore_l3_format_group,
+ NULL,
+};
+
static const struct attribute_group *amd_uncore_umc_attr_groups[] = {
&amd_uncore_attr_group,
&amd_uncore_umc_format_group,
@@ -820,6 +847,12 @@ static int amd_uncore_l3_event_init(struct perf_event *event)
mask = AMD64_L3_F19H_THREAD_MASK | AMD64_L3_EN_ALL_SLICES |
AMD64_L3_EN_ALL_CORES;
+ if (boot_cpu_data.x86 == 0x18 &&
+ boot_cpu_data.x86_model >= 0x6 &&
+ boot_cpu_data.x86_model <= 0xf)
+ mask = ((config & HYGON_L3_SLICE_MASK) ? : HYGON_L3_SLICE_MASK) |
+ ((config & HYGON_L3_THREAD_MASK) ? : HYGON_L3_THREAD_MASK);
+
hwc->config |= mask;
return 0;
@@ -877,7 +910,8 @@ int amd_uncore_l3_ctx_init(struct amd_uncore *uncore, unsigned int cpu)
pmu->rdpmc_base = RDPMC_BASE_LLC;
pmu->group = amd_uncore_ctx_gid(uncore, cpu);
- if (boot_cpu_data.x86 >= 0x17) {
+ if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
+ boot_cpu_data.x86 >= 0x17) {
*l3_attr++ = &format_attr_event8.attr;
*l3_attr++ = &format_attr_umask8.attr;
*l3_attr++ = boot_cpu_data.x86 >= 0x19 ?
@@ -904,6 +938,18 @@ int amd_uncore_l3_ctx_init(struct amd_uncore *uncore, unsigned int cpu)
.module = THIS_MODULE,
};
+ if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON &&
+ boot_cpu_data.x86 == 0x18) {
+ *l3_attr++ = &format_attr_event8.attr;
+ *l3_attr++ = &format_attr_umask8.attr;
+ if (boot_cpu_data.x86_model >= 0x6 && boot_cpu_data.x86_model <= 0xf) {
+ *l3_attr++ = &format_attr_threadmask32.attr;
+ pmu->pmu.attr_update = hygon_uncore_l3_attr_update;
+ } else {
+ *l3_attr++ = &format_attr_threadmask8.attr;
+ }
+ }
+
if (perf_pmu_register(&pmu->pmu, pmu->pmu.name, -1)) {
free_percpu(pmu->ctx);
pmu->ctx = NULL;
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
index ff5acb8b1..404752601 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -89,6 +89,14 @@
#define AMD64_L3_COREID_MASK \
(0x7ULL << AMD64_L3_COREID_SHIFT)
+#define HYGON_L3_SLICE_SHIFT 28
+#define HYGON_L3_SLICE_MASK \
+ (0xFULL << HYGON_L3_SLICE_SHIFT)
+
+#define HYGON_L3_THREAD_SHIFT 32
+#define HYGON_L3_THREAD_MASK \
+ (0xFFFFFFFFULL << HYGON_L3_THREAD_SHIFT)
+
#define X86_RAW_EVENT_MASK \
(ARCH_PERFMON_EVENTSEL_EVENT | \
ARCH_PERFMON_EVENTSEL_UMASK | \
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 5/8] x86/microcode/hygon: Add microcode loading support for Hygon processors
2026-03-27 8:06 [PATCH 0/8] Add support for Hygon Family 18h model 4h~8h processors Fu Hao
` (3 preceding siblings ...)
2026-03-27 8:09 ` [PATCH 4/8] perf/x86/uncore: Add L3 PMU support for Hygon family 18h model 6h Fu Hao
@ 2026-03-27 8:10 ` Fu Hao
2026-03-27 8:13 ` Borislav Petkov
2026-03-27 8:10 ` [PATCH 6/8] ALSA: hda: Add support for Hygon family 18h model 5h HD-Audio Fu Hao
` (2 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Fu Hao @ 2026-03-27 8:10 UTC (permalink / raw)
To: tglx, mingo, bp, dave.hansen, x86, hpa; +Cc: linux-kernel, Fu Hao
Add support for loading Hygon microcode, which is compatible with AMD one.
Signed-off-by: Fu Hao <fuhao@open-hieco.net>
---
arch/x86/Kconfig | 2 +-
arch/x86/kernel/cpu/microcode/amd.c | 63 ++++++++++++++++++------
arch/x86/kernel/cpu/microcode/core.c | 11 +++++
arch/x86/kernel/cpu/microcode/internal.h | 12 +++++
4 files changed, 73 insertions(+), 15 deletions(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index e2df1b147..b94f3dbf1 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1330,7 +1330,7 @@ config X86_REBOOTFIXUPS
config MICROCODE
def_bool y
- depends on CPU_SUP_AMD || CPU_SUP_INTEL
+ depends on CPU_SUP_AMD || CPU_SUP_INTEL || CPU_SUP_HYGON
select CRYPTO_LIB_SHA256 if CPU_SUP_AMD
config MICROCODE_INITRD32
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index e53388128..0f2d4829c 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -347,7 +347,8 @@ static u16 find_equiv_id(struct equiv_cpu_table *et, u32 sig)
unsigned int i;
/* Zen and newer do not need an equivalence table. */
- if (x86_family(bsp_cpuid_1_eax) >= 0x17)
+ if (x86_cpuid_vendor() == X86_VENDOR_AMD &&
+ x86_family(bsp_cpuid_1_eax) >= 0x17)
return 0;
if (!et || !et->num_entries)
@@ -397,7 +398,8 @@ static bool verify_equivalence_table(const u8 *buf, size_t buf_size)
return false;
/* Zen and newer do not need an equivalence table. */
- if (x86_family(bsp_cpuid_1_eax) >= 0x17)
+ if (x86_cpuid_vendor() == X86_VENDOR_AMD &&
+ x86_family(bsp_cpuid_1_eax) >= 0x17)
return true;
cont_type = hdr[1];
@@ -577,7 +579,8 @@ static int verify_patch(const u8 *buf, size_t buf_size, u32 *patch_size)
static bool mc_patch_matches(struct microcode_amd *mc, u16 eq_id)
{
/* Zen and newer do not need an equivalence table. */
- if (x86_family(bsp_cpuid_1_eax) >= 0x17)
+ if (x86_cpuid_vendor() == X86_VENDOR_AMD &&
+ x86_family(bsp_cpuid_1_eax) >= 0x17)
return ucode_rev_to_cpuid(mc->hdr.patch_id).full == bsp_cpuid_1_eax;
else
return eq_id == mc->hdr.processor_rev_id;
@@ -701,7 +704,9 @@ static bool __apply_microcode_amd(struct microcode_amd *mc, u32 *cur_rev,
native_wrmsrq(MSR_AMD64_PATCH_LOADER, p_addr);
- if (x86_family(bsp_cpuid_1_eax) == 0x17) {
+ if ((x86_cpuid_vendor() == X86_VENDOR_AMD &&
+ x86_family(bsp_cpuid_1_eax) == 0x17) ||
+ x86_cpuid_vendor() == X86_VENDOR_HYGON) {
unsigned long p_addr_end = p_addr + psize - 1;
invlpg(p_addr);
@@ -730,16 +735,19 @@ static bool __apply_microcode_amd(struct microcode_amd *mc, u32 *cur_rev,
static bool get_builtin_microcode(struct cpio_data *cp)
{
- char fw_name[36] = "amd-ucode/microcode_amd.bin";
+ char fw_name[40] = "amd-ucode/microcode_amd.bin";
u8 family = x86_family(bsp_cpuid_1_eax);
struct firmware fw;
if (IS_ENABLED(CONFIG_X86_32))
return false;
- if (family >= 0x15)
+ if (x86_cpuid_vendor() == X86_VENDOR_AMD && family >= 0x15)
snprintf(fw_name, sizeof(fw_name),
"amd-ucode/microcode_amd_fam%02hhxh.bin", family);
+ else if (x86_cpuid_vendor() == X86_VENDOR_HYGON)
+ snprintf(fw_name, sizeof(fw_name),
+ "hygon-ucode/microcode_hygon_fam%.2xh.bin", family);
if (firmware_request_builtin(&fw, fw_name)) {
cp->size = fw.size;
@@ -824,7 +832,8 @@ static inline bool patch_cpus_equivalent(struct ucode_patch *p,
bool ignore_stepping)
{
/* Zen and newer hardcode the f/m/s in the patch ID */
- if (x86_family(bsp_cpuid_1_eax) >= 0x17) {
+ if (x86_cpuid_vendor() == X86_VENDOR_AMD &&
+ x86_family(bsp_cpuid_1_eax) >= 0x17) {
union cpuid_1_eax p_cid = ucode_rev_to_cpuid(p->patch_id);
union cpuid_1_eax n_cid = ucode_rev_to_cpuid(n->patch_id);
@@ -860,7 +869,8 @@ static struct ucode_patch *cache_find_patch(struct ucode_cpu_info *uci, u16 equi
static inline int patch_newer(struct ucode_patch *p, struct ucode_patch *n)
{
/* Zen and newer hardcode the f/m/s in the patch ID */
- if (x86_family(bsp_cpuid_1_eax) >= 0x17) {
+ if (x86_cpuid_vendor() == X86_VENDOR_AMD &&
+ x86_family(bsp_cpuid_1_eax) >= 0x17) {
union zen_patch_rev zp, zn;
zp.ucode_rev = p->patch_id;
@@ -920,7 +930,9 @@ static struct ucode_patch *find_patch(unsigned int cpu)
uci->cpu_sig.rev = get_patch_level();
- if (x86_family(bsp_cpuid_1_eax) < 0x17) {
+ if ((x86_cpuid_vendor() == X86_VENDOR_AMD &&
+ x86_family(bsp_cpuid_1_eax) < 0x17) ||
+ x86_cpuid_vendor() == X86_VENDOR_HYGON) {
equiv_id = find_equiv_id(&equiv_table, uci->cpu_sig.sig);
if (!equiv_id)
return NULL;
@@ -1035,7 +1047,8 @@ static size_t install_equiv_cpu_table(const u8 *buf, size_t buf_size)
equiv_tbl_len = hdr[2];
/* Zen and newer do not need an equivalence table. */
- if (x86_family(bsp_cpuid_1_eax) >= 0x17)
+ if (x86_cpuid_vendor() == X86_VENDOR_AMD &&
+ x86_family(bsp_cpuid_1_eax) >= 0x17)
goto out;
equiv_table.entry = vmalloc(equiv_tbl_len);
@@ -1054,7 +1067,8 @@ static size_t install_equiv_cpu_table(const u8 *buf, size_t buf_size)
static void free_equiv_cpu_table(void)
{
- if (x86_family(bsp_cpuid_1_eax) >= 0x17)
+ if (x86_cpuid_vendor() == X86_VENDOR_AMD &&
+ x86_family(bsp_cpuid_1_eax) >= 0x17)
return;
vfree(equiv_table.entry);
@@ -1200,7 +1214,9 @@ static int __init save_microcode_in_initrd(void)
enum ucode_state ret;
struct cpio_data cp;
- if (microcode_loader_disabled() || c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10)
+ if (microcode_loader_disabled() ||
+ ((c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) &&
+ (c->x86_vendor != X86_VENDOR_HYGON)))
return 0;
cpuid_1_eax = native_cpuid_eax(1);
@@ -1238,7 +1254,7 @@ early_initcall(save_microcode_in_initrd);
*/
static enum ucode_state request_microcode_amd(int cpu, struct device *device)
{
- char fw_name[36] = "amd-ucode/microcode_amd.bin";
+ char fw_name[40] = "amd-ucode/microcode_amd.bin";
struct cpuinfo_x86 *c = &cpu_data(cpu);
enum ucode_state ret = UCODE_NFOUND;
const struct firmware *fw;
@@ -1246,8 +1262,11 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device)
if (force_minrev)
return UCODE_NFOUND;
- if (c->x86 >= 0x15)
+ if (x86_cpuid_vendor() == X86_VENDOR_AMD && c->x86 >= 0x15)
snprintf(fw_name, sizeof(fw_name), "amd-ucode/microcode_amd_fam%.2xh.bin", c->x86);
+ else if (x86_cpuid_vendor() == X86_VENDOR_HYGON)
+ snprintf(fw_name, sizeof(fw_name),
+ "hygon-ucode/microcode_hygon_fam%.2xh.bin", c->x86);
if (request_firmware_direct(&fw, (const char *)fw_name, device)) {
ucode_dbg("failed to load file %s\n", fw_name);
@@ -1297,8 +1316,24 @@ struct microcode_ops * __init init_amd_microcode(void)
pr_warn("AMD CPU family 0x%x not supported\n", c->x86);
return NULL;
}
+
+ return µcode_amd_ops;
+}
+
+#ifdef CONFIG_CPU_SUP_HYGON
+struct microcode_ops * __init init_hygon_microcode(void)
+{
+ struct cpuinfo_x86 *c = &boot_cpu_data;
+
+ if (c->x86_vendor != X86_VENDOR_HYGON)
+ return NULL;
+
+ strscpy((char *)ucode_path, "kernel/x86/microcode/HygonGenuine.bin",
+ sizeof(ucode_path));
+
return µcode_amd_ops;
}
+#endif
void __exit exit_amd_microcode(void)
{
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index 651202e6f..813c5c157 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -195,6 +195,9 @@ void __init load_ucode_bsp(void)
return;
intel = false;
break;
+ case X86_VENDOR_HYGON:
+ intel = false;
+ break;
default:
return;
@@ -229,6 +232,9 @@ void load_ucode_ap(void)
if (x86_family(cpuid_1_eax) >= 0x10)
load_ucode_amd_ap(cpuid_1_eax);
break;
+ case X86_VENDOR_HYGON:
+ load_ucode_amd_ap(cpuid_1_eax);
+ break;
default:
break;
}
@@ -288,6 +294,9 @@ static void reload_early_microcode(unsigned int cpu)
if (family >= 0x10)
reload_ucode_amd(cpu);
break;
+ case X86_VENDOR_HYGON:
+ reload_ucode_amd(cpu);
+ break;
default:
break;
}
@@ -895,6 +904,8 @@ static int __init microcode_init(void)
microcode_ops = init_intel_microcode();
else if (c->x86_vendor == X86_VENDOR_AMD)
microcode_ops = init_amd_microcode();
+ else if (c->x86_vendor == X86_VENDOR_HYGON)
+ microcode_ops = init_hygon_microcode();
else
pr_err("no support for this CPU vendor\n");
diff --git a/arch/x86/kernel/cpu/microcode/internal.h b/arch/x86/kernel/cpu/microcode/internal.h
index 3b93c0676..75591afae 100644
--- a/arch/x86/kernel/cpu/microcode/internal.h
+++ b/arch/x86/kernel/cpu/microcode/internal.h
@@ -61,6 +61,9 @@ struct cpio_data find_microcode_in_initrd(const char *path);
#define CPUID_AMD1 QCHAR('A', 'u', 't', 'h')
#define CPUID_AMD2 QCHAR('e', 'n', 't', 'i')
#define CPUID_AMD3 QCHAR('c', 'A', 'M', 'D')
+#define CPUID_HYGON1 QCHAR('H', 'y', 'g', 'o')
+#define CPUID_HYGON2 QCHAR('n', 'G', 'e', 'n')
+#define CPUID_HYGON3 QCHAR('u', 'i', 'n', 'e')
#define CPUID_IS(a, b, c, ebx, ecx, edx) \
(!(((ebx) ^ (a)) | ((edx) ^ (b)) | ((ecx) ^ (c))))
@@ -87,6 +90,9 @@ static inline int x86_cpuid_vendor(void)
if (CPUID_IS(CPUID_AMD1, CPUID_AMD2, CPUID_AMD3, ebx, ecx, edx))
return X86_VENDOR_AMD;
+ if (CPUID_IS(CPUID_HYGON1, CPUID_HYGON2, CPUID_HYGON3, ebx, ecx, edx))
+ return X86_VENDOR_HYGON;
+
return X86_VENDOR_UNKNOWN;
}
@@ -128,6 +134,12 @@ static inline void reload_ucode_intel(void) { }
static inline struct microcode_ops *init_intel_microcode(void) { return NULL; }
#endif /* !CONFIG_CPU_SUP_INTEL */
+#ifdef CONFIG_CPU_SUP_HYGON
+struct microcode_ops *init_hygon_microcode(void);
+#else /* CONFIG_CPU_SUP_HYGON */
+static inline struct microcode_ops *init_hygon_microcode(void) { return NULL; }
+#endif /* !CONFIG_CPU_SUP_HYGON */
+
#define ucode_dbg(fmt, ...) \
({ \
if (IS_ENABLED(CONFIG_MICROCODE_DBG)) \
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 6/8] ALSA: hda: Add support for Hygon family 18h model 5h HD-Audio
2026-03-27 8:06 [PATCH 0/8] Add support for Hygon Family 18h model 4h~8h processors Fu Hao
` (4 preceding siblings ...)
2026-03-27 8:10 ` [PATCH 5/8] x86/microcode/hygon: Add microcode loading support for Hygon processors Fu Hao
@ 2026-03-27 8:10 ` Fu Hao
2026-03-27 8:11 ` [PATCH 7/8] ALSA: hda: Fix single byte writing issue for Hygon family 18h model 5h Fu Hao
2026-03-27 8:11 ` [PATCH 8/8] iommu/hygon: Add support for Hygon family 18h model 4h IOAPIC Fu Hao
7 siblings, 0 replies; 19+ messages in thread
From: Fu Hao @ 2026-03-27 8:10 UTC (permalink / raw)
To: bhelgaas, perex, tiwai; +Cc: linux-kernel, linux-sound, linux-pci, Fu Hao
Add the new PCI ID 0x1d94 0x14a9 for Hygon family 18h model 5h
HDA controller.
Signed-off-by: Fu Hao <fuhao@open-hieco.net>
---
include/linux/pci_ids.h | 1 +
sound/hda/controllers/intel.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 406abf629..19d968017 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2613,6 +2613,7 @@
#define PCI_VENDOR_ID_ROCKCHIP 0x1d87
#define PCI_VENDOR_ID_HYGON 0x1d94
+#define PCI_DEVICE_ID_HYGON_18H_M05H_HDA 0x14a9
#define PCI_VENDOR_ID_META 0x1d9b
diff --git a/sound/hda/controllers/intel.c b/sound/hda/controllers/intel.c
index 3f434994c..eb5d48d90 100644
--- a/sound/hda/controllers/intel.c
+++ b/sound/hda/controllers/intel.c
@@ -241,6 +241,7 @@ enum {
AZX_DRIVER_ZHAOXIN,
AZX_DRIVER_ZHAOXINHDMI,
AZX_DRIVER_LOONGSON,
+ AZX_DRIVER_HYGON,
AZX_DRIVER_GENERIC,
AZX_NUM_DRIVERS, /* keep this as last entry */
};
@@ -357,6 +358,7 @@ static const char * const driver_short_names[] = {
[AZX_DRIVER_ZHAOXIN] = "HDA Zhaoxin",
[AZX_DRIVER_ZHAOXINHDMI] = "HDA Zhaoxin HDMI",
[AZX_DRIVER_LOONGSON] = "HDA Loongson",
+ [AZX_DRIVER_HYGON] = "HDA Hygon",
[AZX_DRIVER_GENERIC] = "HD-Audio Generic",
};
@@ -2818,6 +2820,9 @@ static const struct pci_device_id azx_ids[] = {
.driver_data = AZX_DRIVER_LOONGSON | AZX_DCAPS_NO_TCSEL },
{ PCI_VDEVICE(LOONGSON, PCI_DEVICE_ID_LOONGSON_HDMI),
.driver_data = AZX_DRIVER_LOONGSON | AZX_DCAPS_NO_TCSEL },
+ /* Hygon HDAudio */
+ { PCI_VDEVICE(HYGON, PCI_DEVICE_ID_HYGON_18H_M05H_HDA),
+ .driver_data = AZX_DRIVER_HYGON | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_NO_MSI },
{ 0, }
};
MODULE_DEVICE_TABLE(pci, azx_ids);
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 7/8] ALSA: hda: Fix single byte writing issue for Hygon family 18h model 5h
2026-03-27 8:06 [PATCH 0/8] Add support for Hygon Family 18h model 4h~8h processors Fu Hao
` (5 preceding siblings ...)
2026-03-27 8:10 ` [PATCH 6/8] ALSA: hda: Add support for Hygon family 18h model 5h HD-Audio Fu Hao
@ 2026-03-27 8:11 ` Fu Hao
2026-03-27 12:11 ` Takashi Iwai
2026-03-27 13:02 ` David Laight
2026-03-27 8:11 ` [PATCH 8/8] iommu/hygon: Add support for Hygon family 18h model 4h IOAPIC Fu Hao
7 siblings, 2 replies; 19+ messages in thread
From: Fu Hao @ 2026-03-27 8:11 UTC (permalink / raw)
To: perex, tiwai; +Cc: linux-kernel, linux-sound, Fu Hao
On Hygon family 18h model 5h controller, some registers such as
GCTL, SD_CTL and SD_CTL_3B should be accessed in dword, or the
writing will fail.
Signed-off-by: Fu Hao <fuhao@open-hieco.net>
---
include/sound/hdaudio.h | 1 +
sound/hda/controllers/intel.c | 4 ++++
sound/hda/core/controller.c | 10 +++++++--
sound/hda/core/stream.c | 42 ++++++++++++++++++++++++++---------
4 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index f11bfc6b9..57a144fec 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -352,6 +352,7 @@ struct hdac_bus {
bool not_use_interrupts:1; /* prohibiting the RIRB IRQ */
bool access_sdnctl_in_dword:1; /* accessing the sdnctl register by dword */
bool use_pio_for_commands:1; /* Use PIO instead of CORB for commands */
+ bool hygon_dword_access:1;
int poll_count;
diff --git a/sound/hda/controllers/intel.c b/sound/hda/controllers/intel.c
index eb5d48d90..6b27248dc 100644
--- a/sound/hda/controllers/intel.c
+++ b/sound/hda/controllers/intel.c
@@ -1885,6 +1885,10 @@ static int azx_first_init(struct azx *chip)
if (chip->driver_type == AZX_DRIVER_ZHAOXINHDMI)
bus->polling_mode = 1;
+ if (chip->driver_type == AZX_DRIVER_HYGON &&
+ chip->pci->device == PCI_DEVICE_ID_HYGON_18H_M05H_HDA)
+ bus->hygon_dword_access = 1;
+
bus->remap_addr = pcim_iomap_region(pci, 0, "ICH HD audio");
if (IS_ERR(bus->remap_addr))
return PTR_ERR(bus->remap_addr);
diff --git a/sound/hda/core/controller.c b/sound/hda/core/controller.c
index 69e11d62b..bfe817045 100644
--- a/sound/hda/core/controller.c
+++ b/sound/hda/core/controller.c
@@ -511,7 +511,10 @@ void snd_hdac_bus_exit_link_reset(struct hdac_bus *bus)
{
unsigned long timeout;
- snd_hdac_chip_updateb(bus, GCTL, AZX_GCTL_RESET, AZX_GCTL_RESET);
+ if (bus->hygon_dword_access)
+ snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_RESET, AZX_GCTL_RESET);
+ else
+ snd_hdac_chip_updateb(bus, GCTL, AZX_GCTL_RESET, AZX_GCTL_RESET);
timeout = jiffies + msecs_to_jiffies(100);
while (!snd_hdac_chip_readb(bus, GCTL) && time_before(jiffies, timeout))
@@ -576,7 +579,10 @@ static void azx_int_disable(struct hdac_bus *bus)
/* disable interrupts in stream descriptor */
list_for_each_entry(azx_dev, &bus->stream_list, list)
- snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_INT_MASK, 0);
+ if (bus->hygon_dword_access)
+ snd_hdac_stream_updatel(azx_dev, SD_CTL, SD_INT_MASK, 0);
+ else
+ snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_INT_MASK, 0);
/* disable SIE for all streams & disable controller CIE and GIE */
snd_hdac_chip_writel(bus, INTCTL, 0);
diff --git a/sound/hda/core/stream.c b/sound/hda/core/stream.c
index b471a038b..ccc0003a8 100644
--- a/sound/hda/core/stream.c
+++ b/sound/hda/core/stream.c
@@ -146,11 +146,15 @@ void snd_hdac_stream_start(struct hdac_stream *azx_dev)
stripe_ctl = snd_hdac_get_stream_stripe_ctl(bus, azx_dev->substream);
else
stripe_ctl = 0;
- snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK,
- stripe_ctl);
+ if (bus->hygon_dword_access)
+ snd_hdac_stream_updatel(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK,
+ stripe_ctl);
+ else
+ snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK,
+ stripe_ctl);
}
/* set DMA start and interrupt mask */
- if (bus->access_sdnctl_in_dword)
+ if (bus->access_sdnctl_in_dword || bus->hygon_dword_access)
snd_hdac_stream_updatel(azx_dev, SD_CTL,
0, SD_CTL_DMA_START | SD_INT_MASK);
else
@@ -166,11 +170,22 @@ EXPORT_SYMBOL_GPL(snd_hdac_stream_start);
*/
static void snd_hdac_stream_clear(struct hdac_stream *azx_dev)
{
- snd_hdac_stream_updateb(azx_dev, SD_CTL,
- SD_CTL_DMA_START | SD_INT_MASK, 0);
- snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
- if (azx_dev->stripe)
- snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0);
+ struct hdac_bus *bus = azx_dev->bus;
+
+ if (bus->hygon_dword_access) {
+ snd_hdac_stream_updatel(azx_dev, SD_CTL,
+ SD_CTL_DMA_START | SD_INT_MASK, 0);
+ snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
+ if (azx_dev->stripe)
+ snd_hdac_stream_updatel(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0);
+ } else {
+ snd_hdac_stream_updateb(azx_dev, SD_CTL,
+ SD_CTL_DMA_START | SD_INT_MASK, 0);
+ snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
+ if (azx_dev->stripe)
+ snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0);
+ }
+
azx_dev->running = false;
}
@@ -225,12 +240,16 @@ void snd_hdac_stream_reset(struct hdac_stream *azx_dev)
{
unsigned char val;
int dma_run_state;
+ struct hdac_bus *bus = azx_dev->bus;
snd_hdac_stream_clear(azx_dev);
dma_run_state = snd_hdac_stream_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START;
- snd_hdac_stream_updateb(azx_dev, SD_CTL, 0, SD_CTL_STREAM_RESET);
+ if (bus->hygon_dword_access)
+ snd_hdac_stream_updatel(azx_dev, SD_CTL, 0, SD_CTL_STREAM_RESET);
+ else
+ snd_hdac_stream_updateb(azx_dev, SD_CTL, 0, SD_CTL_STREAM_RESET);
/* wait for hardware to report that the stream entered reset */
snd_hdac_stream_readb_poll(azx_dev, SD_CTL, val, (val & SD_CTL_STREAM_RESET), 3, 300);
@@ -238,7 +257,10 @@ void snd_hdac_stream_reset(struct hdac_stream *azx_dev)
if (azx_dev->bus->dma_stop_delay && dma_run_state)
udelay(azx_dev->bus->dma_stop_delay);
- snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_CTL_STREAM_RESET, 0);
+ if (bus->hygon_dword_access)
+ snd_hdac_stream_updatel(azx_dev, SD_CTL, SD_CTL_STREAM_RESET, 0);
+ else
+ snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_CTL_STREAM_RESET, 0);
/* wait for hardware to report that the stream is out of reset */
snd_hdac_stream_readb_poll(azx_dev, SD_CTL, val, !(val & SD_CTL_STREAM_RESET), 3, 300);
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 8/8] iommu/hygon: Add support for Hygon family 18h model 4h IOAPIC
2026-03-27 8:06 [PATCH 0/8] Add support for Hygon Family 18h model 4h~8h processors Fu Hao
` (6 preceding siblings ...)
2026-03-27 8:11 ` [PATCH 7/8] ALSA: hda: Fix single byte writing issue for Hygon family 18h model 5h Fu Hao
@ 2026-03-27 8:11 ` Fu Hao
7 siblings, 0 replies; 19+ messages in thread
From: Fu Hao @ 2026-03-27 8:11 UTC (permalink / raw)
To: joro, will, suravee.suthikulpanit, robin.murphy
Cc: linux-kernel, iommu, Fu Hao
The SB IOAPIC is on the device 0xb from Hygon family 18h model 4h.
Signed-off-by: Fu Hao <fuhao@open-hieco.net>
---
drivers/iommu/amd/init.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index f3fd7f39e..568851cc2 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -3096,6 +3096,9 @@ static void __init free_iommu_resources(void)
/* SB IOAPIC is always on this device in AMD systems */
#define IOAPIC_SB_DEVID ((0x00 << 8) | PCI_DEVFN(0x14, 0))
+/* SB IOAPIC for Hygon family 18h model 4h is on the device 0xb */
+#define IOAPIC_SB_DEVID_FAM18H_M4H ((0x00 << 8) | PCI_DEVFN(0xb, 0))
+
static bool __init check_ioapic_information(void)
{
const char *fw_bug = FW_BUG;
@@ -3121,7 +3124,12 @@ static bool __init check_ioapic_information(void)
pr_err("%s: IOAPIC[%d] not in IVRS table\n",
fw_bug, id);
ret = false;
- } else if (devid == IOAPIC_SB_DEVID) {
+ } else if (devid == IOAPIC_SB_DEVID ||
+ (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON &&
+ boot_cpu_data.x86 == 0x18 &&
+ boot_cpu_data.x86_model >= 0x4 &&
+ boot_cpu_data.x86_model <= 0xf &&
+ devid == IOAPIC_SB_DEVID_FAM18H_M4H)) {
has_sb_ioapic = true;
ret = true;
}
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 5/8] x86/microcode/hygon: Add microcode loading support for Hygon processors
2026-03-27 8:10 ` [PATCH 5/8] x86/microcode/hygon: Add microcode loading support for Hygon processors Fu Hao
@ 2026-03-27 8:13 ` Borislav Petkov
2026-03-27 8:37 ` Fu Hao
0 siblings, 1 reply; 19+ messages in thread
From: Borislav Petkov @ 2026-03-27 8:13 UTC (permalink / raw)
To: Fu Hao; +Cc: tglx, mingo, dave.hansen, x86, hpa, linux-kernel
On Fri, Mar 27, 2026 at 04:10:09PM +0800, Fu Hao wrote:
> Add support for loading Hygon microcode, which is compatible with AMD one.
>
> Signed-off-by: Fu Hao <fuhao@open-hieco.net>
> ---
> arch/x86/Kconfig | 2 +-
> arch/x86/kernel/cpu/microcode/amd.c | 63 ++++++++++++++++++------
No.
arch/x86/kernel/cpu/microcode/hygon.c
please.
Do a separate compilation unit where all the Hygon stuff can live instead of
sprinkling "if HYGON" everywhere in the AMD loader.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 5/8] x86/microcode/hygon: Add microcode loading support for Hygon processors
2026-03-27 8:13 ` Borislav Petkov
@ 2026-03-27 8:37 ` Fu Hao
0 siblings, 0 replies; 19+ messages in thread
From: Fu Hao @ 2026-03-27 8:37 UTC (permalink / raw)
To: Borislav Petkov; +Cc: tglx, mingo, dave.hansen, x86, hpa, linux-kernel
On 2026/3/27 16:13, Borislav Petkov wrote:
> On Fri, Mar 27, 2026 at 04:10:09PM +0800, Fu Hao wrote:
>> Add support for loading Hygon microcode, which is compatible with AMD one.
>>
>> Signed-off-by: Fu Hao <fuhao@open-hieco.net>
>> ---
>> arch/x86/Kconfig | 2 +-
>> arch/x86/kernel/cpu/microcode/amd.c | 63 ++++++++++++++++++------
>
> No.
>
> arch/x86/kernel/cpu/microcode/hygon.c
>
> please.
>
> Do a separate compilation unit where all the Hygon stuff can live instead of
> sprinkling "if HYGON" everywhere in the AMD loader.
>
> Thx.
>
OK, thanks! I will create arch/x86/kernel/cpu/microcode/hygon.c in next
patch series.
--
Regards,
Fu Hao
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 7/8] ALSA: hda: Fix single byte writing issue for Hygon family 18h model 5h
2026-03-27 8:11 ` [PATCH 7/8] ALSA: hda: Fix single byte writing issue for Hygon family 18h model 5h Fu Hao
@ 2026-03-27 12:11 ` Takashi Iwai
2026-03-27 12:55 ` Fu Hao
2026-03-27 13:02 ` David Laight
1 sibling, 1 reply; 19+ messages in thread
From: Takashi Iwai @ 2026-03-27 12:11 UTC (permalink / raw)
To: Fu Hao; +Cc: perex, tiwai, linux-kernel, linux-sound
On Fri, 27 Mar 2026 09:11:13 +0100,
Fu Hao wrote:
>
> On Hygon family 18h model 5h controller, some registers such as
> GCTL, SD_CTL and SD_CTL_3B should be accessed in dword, or the
> writing will fail.
>
> Signed-off-by: Fu Hao <fuhao@open-hieco.net>
> ---
> include/sound/hdaudio.h | 1 +
> sound/hda/controllers/intel.c | 4 ++++
> sound/hda/core/controller.c | 10 +++++++--
> sound/hda/core/stream.c | 42 ++++++++++++++++++++++++++---------
> 4 files changed, 45 insertions(+), 12 deletions(-)
>
> diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
> index f11bfc6b9..57a144fec 100644
> --- a/include/sound/hdaudio.h
> +++ b/include/sound/hdaudio.h
> @@ -352,6 +352,7 @@ struct hdac_bus {
> bool not_use_interrupts:1; /* prohibiting the RIRB IRQ */
> bool access_sdnctl_in_dword:1; /* accessing the sdnctl register by dword */
> bool use_pio_for_commands:1; /* Use PIO instead of CORB for commands */
> + bool hygon_dword_access:1;
>
> int poll_count;
>
I hesitate to add another flag just for this platform.
And looking at the changes, all appear to be about the dword access
for sdnctl writes. So I believe we can simply extend
access_sdnctl_in_dword to do the dword access in each write access,
instead? The performance shouldn't matter as it's no hot path.
Alternatively, you can enable bus->aligned_mmio flag, but this needs
to enable CONFIG_SND_HDA_ALIGNED_MMIO. That's a visible cost for
other platforms, though.
thanks,
Takashi
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 7/8] ALSA: hda: Fix single byte writing issue for Hygon family 18h model 5h
2026-03-27 12:11 ` Takashi Iwai
@ 2026-03-27 12:55 ` Fu Hao
0 siblings, 0 replies; 19+ messages in thread
From: Fu Hao @ 2026-03-27 12:55 UTC (permalink / raw)
To: Takashi Iwai; +Cc: perex, tiwai, linux-kernel, linux-sound
On 2026/3/27 20:11, Takashi Iwai wrote:
> On Fri, 27 Mar 2026 09:11:13 +0100,
> Fu Hao wrote:
>>
>> On Hygon family 18h model 5h controller, some registers such as
>> GCTL, SD_CTL and SD_CTL_3B should be accessed in dword, or the
>> writing will fail.
>>
>> Signed-off-by: Fu Hao <fuhao@open-hieco.net>
>> ---
>> include/sound/hdaudio.h | 1 +
>> sound/hda/controllers/intel.c | 4 ++++
>> sound/hda/core/controller.c | 10 +++++++--
>> sound/hda/core/stream.c | 42 ++++++++++++++++++++++++++---------
>> 4 files changed, 45 insertions(+), 12 deletions(-)
>>
>> diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
>> index f11bfc6b9..57a144fec 100644
>> --- a/include/sound/hdaudio.h
>> +++ b/include/sound/hdaudio.h
>> @@ -352,6 +352,7 @@ struct hdac_bus {
>> bool not_use_interrupts:1; /* prohibiting the RIRB IRQ */
>> bool access_sdnctl_in_dword:1; /* accessing the sdnctl register by dword */
>> bool use_pio_for_commands:1; /* Use PIO instead of CORB for commands */
>> + bool hygon_dword_access:1;
>>
>> int poll_count;
>>
>
> I hesitate to add another flag just for this platform.
> And looking at the changes, all appear to be about the dword access
> for sdnctl writes. So I believe we can simply extend
> access_sdnctl_in_dword to do the dword access in each write access,
> instead? The performance shouldn't matter as it's no hot path.
>
> Alternatively, you can enable bus->aligned_mmio flag, but this needs
> to enable CONFIG_SND_HDA_ALIGNED_MMIO. That's a visible cost for
> other platforms, though.
>
>
> thanks,
>
> Takashi
>
OK, thanks!I will try to use access_sdnctl_in_dword in
next patch series.
--
Regards,
Fu Hao
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 7/8] ALSA: hda: Fix single byte writing issue for Hygon family 18h model 5h
2026-03-27 8:11 ` [PATCH 7/8] ALSA: hda: Fix single byte writing issue for Hygon family 18h model 5h Fu Hao
2026-03-27 12:11 ` Takashi Iwai
@ 2026-03-27 13:02 ` David Laight
2026-03-28 2:41 ` Fu Hao
1 sibling, 1 reply; 19+ messages in thread
From: David Laight @ 2026-03-27 13:02 UTC (permalink / raw)
To: Fu Hao; +Cc: perex, tiwai, linux-kernel, linux-sound
On Fri, 27 Mar 2026 16:11:13 +0800
Fu Hao <fuhao@open-hieco.net> wrote:
> On Hygon family 18h model 5h controller, some registers such as
> GCTL, SD_CTL and SD_CTL_3B should be accessed in dword, or the
> writing will fail.
What's a 'dword' ?
It is short for 'double word', a 64bit cpu has a word size of
64 bits, so a dword would be 128 bits.
On Hygon family 18h model 5h controller 32bit accesses must be
used to access registers such as CTL, SD_CTL and SD_CTL_3B.
David
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 7/8] ALSA: hda: Fix single byte writing issue for Hygon family 18h model 5h
2026-03-27 13:02 ` David Laight
@ 2026-03-28 2:41 ` Fu Hao
0 siblings, 0 replies; 19+ messages in thread
From: Fu Hao @ 2026-03-28 2:41 UTC (permalink / raw)
To: David Laight; +Cc: perex, tiwai, linux-kernel, linux-sound
On 2026/3/27 21:02, David Laight wrote:
> On Fri, 27 Mar 2026 16:11:13 +0800
> Fu Hao <fuhao@open-hieco.net> wrote:
>
>> On Hygon family 18h model 5h controller, some registers such as
>> GCTL, SD_CTL and SD_CTL_3B should be accessed in dword, or the
>> writing will fail.
>
> What's a 'dword' ?
> It is short for 'double word', a 64bit cpu has a word size of
> 64 bits, so a dword would be 128 bits.
>
> On Hygon family 18h model 5h controller 32bit accesses must be
> used to access registers such as CTL, SD_CTL and SD_CTL_3B.
>
> David
>
Accessing in dword alignment means performing register read and write
operations in 32-bit increments. In the current driver, some HDA
registers are accessed by default in byte increments. However, for
certain registers of the Hygon HD-audio controller, such as CTL, SD_CTL,
and SD_CTL_3B, they need to be accessed in 32-bit increments during
initialization, in accordance with the 32-bit nature of the registers
themselves.
If you access it using dword, the API snd_hdac_stream_updatel(writel,
32bit) will be used.
--
Regards,
Fu Hao
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/8] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon model 4h~8h
2026-03-27 8:07 ` [PATCH 1/8] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon model 4h~8h Fu Hao
@ 2026-03-28 13:34 ` Borislav Petkov
2026-03-30 2:59 ` Fu Hao
0 siblings, 1 reply; 19+ messages in thread
From: Borislav Petkov @ 2026-03-28 13:34 UTC (permalink / raw)
To: Fu Hao; +Cc: puwen, tglx, mingo, dave.hansen, x86, hpa, linux-kernel
On Fri, Mar 27, 2026 at 04:07:31PM +0800, Fu Hao wrote:
> The die id should be get from the NodeId field of CPUID leaf 0x8000001e
^^^^^^^^^^^^^
Pls run all your English text through an LLM so that corrects it for you.
Also "die ID".
> ecx for Hygon model 4h~8h processors.
>
> Signed-off-by: Fu Hao <fuhao@open-hieco.net>
> ---
> arch/x86/kernel/cpu/hygon.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c
> index 7f95a74e4..f39d32a68 100644
> --- a/arch/x86/kernel/cpu/hygon.c
> +++ b/arch/x86/kernel/cpu/hygon.c
> @@ -168,6 +168,19 @@ static void early_init_hygon(struct cpuinfo_x86 *c)
> set_cpu_cap(c, X86_FEATURE_VMMCALL);
> }
>
> +/*
> + * Adjust the die_id and logical_die_id for Hygon model 4h~8h.
What does "model 4h~8h" mean?
Models 0x4-0x8 ?
> + */
> +static void cpu_topology_fixup_hygon(struct cpuinfo_x86 *c)
> +{
> + if (c->x86_model >= 0x4 && c->x86_model <= 0x8) {
> + c->topo.die_id = cpuid_ecx(0x8000001e) & 0xff;
> + c->topo.logical_die_id = (c->topo.die_id >> 4) *
> + topology_amd_nodes_per_pkg() +
> + (c->topo.die_id & 0xf);
> + }
> +}
Does this really need to be a separate function or can you stick the
if-conditional along with the comment where it needs to be executed?
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/8] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon model 4h~8h
2026-03-28 13:34 ` Borislav Petkov
@ 2026-03-30 2:59 ` Fu Hao
2026-06-03 2:17 ` Borislav Petkov
0 siblings, 1 reply; 19+ messages in thread
From: Fu Hao @ 2026-03-30 2:59 UTC (permalink / raw)
To: Borislav Petkov; +Cc: puwen, tglx, mingo, dave.hansen, x86, hpa, linux-kernel
On 2026/3/28 21:34, Borislav Petkov wrote:
> On Fri, Mar 27, 2026 at 04:07:31PM +0800, Fu Hao wrote:
>> The die id should be get from the NodeId field of CPUID leaf 0x8000001e
> ^^^^^^^^^^^^^
>
> Pls run all your English text through an LLM so that corrects it for you.
>
> Also "die ID".
>
>> ecx for Hygon model 4h~8h processors.
>>
>> Signed-off-by: Fu Hao <fuhao@open-hieco.net>
>> ---
>> arch/x86/kernel/cpu/hygon.c | 15 +++++++++++++++
>> 1 file changed, 15 insertions(+)
>>
>> diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c
>> index 7f95a74e4..f39d32a68 100644
>> --- a/arch/x86/kernel/cpu/hygon.c
>> +++ b/arch/x86/kernel/cpu/hygon.c
>> @@ -168,6 +168,19 @@ static void early_init_hygon(struct cpuinfo_x86 *c)
>> set_cpu_cap(c, X86_FEATURE_VMMCALL);
>> }
>>
>> +/*
>> + * Adjust the die_id and logical_die_id for Hygon model 4h~8h.
>
> What does "model 4h~8h" mean?
>
> Models 0x4-0x8 ?
>
>> + */
>> +static void cpu_topology_fixup_hygon(struct cpuinfo_x86 *c)
>> +{
>> + if (c->x86_model >= 0x4 && c->x86_model <= 0x8) {
>> + c->topo.die_id = cpuid_ecx(0x8000001e) & 0xff;
>> + c->topo.logical_die_id = (c->topo.die_id >> 4) *
>> + topology_amd_nodes_per_pkg() +
>> + (c->topo.die_id & 0xf);
>> + }
>> +}
>
> Does this really need to be a separate function or can you stick the
> if-conditional along with the comment where it needs to be executed?
>
> Thx.
>
Thank you very much for your suggestion.
The Hygon model 4h~8h, which is also the Hygon family 0x18
model 0x4~0x8 series of processors.
Using separate functions for encapsulation is primarily due to the
consideration for subsequent new processors, there may be different
ways to obtain the core ID, die ID and pkg ID. Of course, it can also
be temporarily placed in the "init_hygon" function at present.
What about your suggestion?
--
Regards,
Fu Hao
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/8] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon model 4h~8h
2026-03-30 2:59 ` Fu Hao
@ 2026-06-03 2:17 ` Borislav Petkov
2026-06-05 6:05 ` Fu Hao
0 siblings, 1 reply; 19+ messages in thread
From: Borislav Petkov @ 2026-06-03 2:17 UTC (permalink / raw)
To: Fu Hao; +Cc: puwen, tglx, mingo, dave.hansen, x86, hpa, linux-kernel
On Mon, Mar 30, 2026 at 10:59:48AM +0800, Fu Hao wrote:
> > What does "model 4h~8h" mean?
> >
> > Models 0x4-0x8 ?
You didn't explain that one.
> Using separate functions for encapsulation is primarily due to the
> consideration for subsequent new processors, there may be different
> ways to obtain the core ID, die ID and pkg ID. Of course, it can also
> be temporarily placed in the "init_hygon" function at present.
Yes, do that.
You can carve it out later, when it gets unwieldy.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/8] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon model 4h~8h
2026-06-03 2:17 ` Borislav Petkov
@ 2026-06-05 6:05 ` Fu Hao
0 siblings, 0 replies; 19+ messages in thread
From: Fu Hao @ 2026-06-05 6:05 UTC (permalink / raw)
To: Borislav Petkov; +Cc: puwen, tglx, mingo, dave.hansen, x86, hpa, linux-kernel
On 6/3/2026 10:17 AM, Borislav Petkov wrote:
> On Mon, Mar 30, 2026 at 10:59:48AM +0800, Fu Hao wrote:
>>> What does "model 4h~8h" mean?
>>>
>>> Models 0x4-0x8 ?
>
> You didn't explain that one.
>
Yes. This refers to Hygon processor models 0x4–0x8.
--
Regards,
Fu Hao
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-06-05 6:06 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-27 8:06 [PATCH 0/8] Add support for Hygon Family 18h model 4h~8h processors Fu Hao
2026-03-27 8:07 ` [PATCH 1/8] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon model 4h~8h Fu Hao
2026-03-28 13:34 ` Borislav Petkov
2026-03-30 2:59 ` Fu Hao
2026-06-03 2:17 ` Borislav Petkov
2026-06-05 6:05 ` Fu Hao
2026-03-27 8:08 ` [PATCH 2/8] x86/cpu: Get LLC ID for Hygon family 18h model 4h Fu Hao
2026-03-27 8:09 ` [PATCH 3/8] x86/cpu/hygon: Remove Spectral Chicken for Hygon processors Fu Hao
2026-03-27 8:09 ` [PATCH 4/8] perf/x86/uncore: Add L3 PMU support for Hygon family 18h model 6h Fu Hao
2026-03-27 8:10 ` [PATCH 5/8] x86/microcode/hygon: Add microcode loading support for Hygon processors Fu Hao
2026-03-27 8:13 ` Borislav Petkov
2026-03-27 8:37 ` Fu Hao
2026-03-27 8:10 ` [PATCH 6/8] ALSA: hda: Add support for Hygon family 18h model 5h HD-Audio Fu Hao
2026-03-27 8:11 ` [PATCH 7/8] ALSA: hda: Fix single byte writing issue for Hygon family 18h model 5h Fu Hao
2026-03-27 12:11 ` Takashi Iwai
2026-03-27 12:55 ` Fu Hao
2026-03-27 13:02 ` David Laight
2026-03-28 2:41 ` Fu Hao
2026-03-27 8:11 ` [PATCH 8/8] iommu/hygon: Add support for Hygon family 18h model 4h IOAPIC Fu Hao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox