[PATCH v4 4/5] x86/amd_node: Skip SMN setup on Hygon Fam18h models 0x04-0x08
From: Lin Wang
Date: Tue Sep 01 2026 - 03:20:07 EST
amd_smn_init() distributes host bridge roots according to
amd_num_nodes() and PCI enumeration order. Hygon Fam18h models
0x04-0x08 have multiple DF nodes per socket and group SMN roots by
socket, so the AMD mapping cannot provide their node-to-root map.
Leave the roots unclaimed on these models regardless of
CONFIG_HYGON_NODE; the AMD mapping does not apply to their topology.
Since amd_num_nodes() is independent of the root array, check
smn_exclusive before indexing the array so AMD SMN calls return
-ENODEV while its setup is inactive. When built, the Hygon node layer
provides the node-to-root mapping. Other Hygon models keep the existing
AMD SMN setup. amd_smn_init() can become AMD-only after the remaining
Hygon callers have moved to Hygon-specific interfaces.
Signed-off-by: Lin Wang <wanglin@xxxxxxxxxxxxxx>
---
arch/x86/kernel/amd_node.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c
index 0be01725a2a4..a0cfd74ada03 100644
--- a/arch/x86/kernel/amd_node.c
+++ b/arch/x86/kernel/amd_node.c
@@ -88,6 +88,9 @@ static int __amd_smn_rw(u8 i_off, u8 d_off, u16 node, u32 address, u32 *value, b
struct pci_dev *root;
int err = -ENODEV;
+ if (!smn_exclusive)
+ return err;
+
if (node >= amd_num_nodes())
return err;
@@ -95,9 +98,6 @@ static int __amd_smn_rw(u8 i_off, u8 d_off, u16 node, u32 address, u32 *value, b
if (!root)
return err;
- if (!smn_exclusive)
- return err;
-
guard(mutex)(&smn_mutex);
err = pci_write_config_dword(root, i_off, address);
@@ -252,6 +252,18 @@ static int __init amd_smn_init(void)
if (!cpu_feature_enabled(X86_FEATURE_ZEN))
return 0;
+ /*
+ * Hygon models outside this range, including legacy parts, keep the
+ * existing AMD SMN setup. Models 0x04-0x08 group SMN roots by socket
+ * instead of amd_num_nodes(), so leave AMD SMN inactive. The Hygon node
+ * layer, when built, owns their node-to-root mapping.
+ */
+ if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON &&
+ boot_cpu_data.x86 == 0x18 &&
+ boot_cpu_data.x86_model >= 0x04 &&
+ boot_cpu_data.x86_model <= 0x08)
+ return 0;
+
guard(mutex)(&smn_mutex);
if (amd_roots)
--
2.43.0