[PATCH v3 0/6] x86/hygon: Add Family 0x18 DF node enumeration and SMN access
From: Lin Wang
Date: Thu Jul 09 2026 - 03:57:31 EST
Hygon Family 0x18 systems expose Data Fabric (DF) devices in a layout
that cannot be handled by the AMD fixed-slot node model.
AMD node enumeration relies on DF nodes being visible at fixed PCI
slots 00:18.x through 00:1f.x. Hygon Family 0x18 instead enumerates
DF instances by PCI device ID at platform-assigned slots. The node
identity is provided by DF registers, not by the PCI slot number:
- F1x200 provides socket identity and SocketPresent.
- F5x180 provides the real DFID on models which need it.
- CPUID 0x8000001E reports sparse phys_node_id values across sockets.
- SMN root devices are shared per socket rather than per DF node.
This series adds a Hygon-specific node implementation in
arch/x86/kernel/hygon_node.c. The Hygon code owns DF enumeration,
node identity, CPU-to-DF-node translation, DF F3/F4 lookup, SMN access,
and the optional SMN debugfs interface.
The AMD-side changes are limited to vendor gating and access-path
hardening:
- amd_nb.c no longer runs AMD NB framework initialization for Hygon.
- amd_node.c no longer reserves Hygon SMN root devices from the AMD
SMN init path.
- __amd_smn_rw() checks smn_exclusive before indexing amd_roots[],
so callers that reach the AMD SMN path before initialization get
-ENODEV rather than dereferencing a NULL root array.
amd_get_mmconfig_range() is intentionally unchanged because it reads
the shared MSR_FAM10H_MMIO_CONF_BASE path used by x86 PCI/PnP code.
No intended behavioral change for AMD systems: the vendor-gating changes
only remove Hygon from AMD-only init paths, and the AMD CPU paths they
now exclusively gate are otherwise unchanged. The patch 3 SMN access
hardening does not affect AMD SMN access after successful initialization.
The Hygon node cache is built once from fs_initcall:
1. Enumerate DF misc (F3) devices by Hygon PCI ID.
2. Read node identity from DF registers.
3. Validate the enumerated socket set against SocketPresent.
4. Sort nodes into a dense software order:
CDD nodes first, sorted by socket and DFID;
IOD nodes afterwards, sorted by socket and DFID.
5. Enable CPU-to-DF translation when CPUID NodesPerProcessor matches
the enumerated CDD count per socket.
6. Set up Hygon SMN roots and optional debugfs.
The public API is provided by <asm/hygon/node.h>. It exposes validated
topology and lookup helpers, not model-range helpers. Model matching is
kept private to the Hygon node implementation through the internal DF
identity table. Consumers that need their own per-model behavior should
use standard x86_cpu_id matching with driver_data.
When CONFIG_HYGON_NODE=n, the header provides static-inline stubs
returning 0, NULL, or -ENODEV, so consumers do not need local #ifdefs.
SMN access uses the same index/data PCI config-space transaction model
as amd_smn_read/write(), serialized by a Hygon-local mutex. The
Hygon-specific part is the binding from dense DF node id to the correct
socket-local SMN root.
Patch layout:
[1/6] pci_ids: Add Hygon Family 0x18 DF F3/F4 device IDs.
[2/6] x86/amd_nb: Restrict AMD NB framework init to AMD vendor.
[3/6] x86/amd_node: Restrict AMD SMN root enumeration to AMD vendor
and harden AMD SMN access before root indexing.
[4/6] x86/hygon: Add Hygon DF node enumeration, node cache, lookup
API, and CPU-to-DF translation.
[5/6] x86/hygon: Add Hygon SMN read/write support.
[6/6] x86/hygon: Add optional Hygon SMN debugfs support.
Patch 5 depends on patch 3 at runtime: without the AMD SMN vendor gate,
amd_smn_init() can reserve Hygon root config space before the Hygon SMN
setup runs. Patch 6 is optional debugfs support and can be reverted
independently.
Tested on:
- Hygon Family 0x18 Model 0x04, 4 sockets, 16 CDD + 4 IOD
- Hygon Family 0x18 Model 0x04, 2 sockets, 8 CDD + 2 IOD
- Hygon Family 0x18 Model 0x07, 2 sockets, 12 CDD + 4 IOD
Verified:
- Boot and initcall ordering.
- DF identity register reads.
- SocketPresent validation against enumerated sockets.
- CPU-to-DF-node translation.
- CPU-to-DF-node translation with maxcpus=4 on Model 0x04.
- SMN read/write on representative addresses.
- AMD-only and Hygon-enabled build configurations.
- x86_64 defconfig and allyesconfig sanity builds.
Changes since RFC v2:
- Drop the vendor-neutral registration interfaces from amd_nb.c and
amd_node.c.
- Move Hygon DF enumeration, node identity, CPU-to-DF translation,
SMN access, and debugfs into Hygon-specific code.
- Restrict AMD NB and AMD SMN initialization paths to AMD vendor.
- Harden the AMD SMN access path before indexing amd_roots[].
- Replace the online-CPU-derived nid map with CPUID NodeId based
CPU-to-DF translation.
- Keep supported-model matching private to the Hygon node module.
- Limit this series to Hygon Family 0x18 models 0x04-0x08.
- Validate DF enumeration completeness against SocketPresent.
- Add Hygon SMN debugfs topology output.
Sashiko review follow-up:
RFC v2 also received a Sashiko automated review. The changes listed
above cover its main design findings; patch 3 additionally reorders
__amd_smn_rw() to check smn_exclusive before indexing amd_roots[].
The remaining low-level SMN index/data and selector-style debugfs
behavior stays aligned with the existing AMD SMN model, while
Hygon-specific discovery and topology binding live in hygon_node.c.
Patch-level nits are handled in the individual commit messages; patch
1 keeps the DF F3/F4 IDs as Hygon-prefixed pci_ids.h entries because
future Hygon DF consumers may share them.
Links:
RFC v1:
https://lore.kernel.org/all/20260402111515.1155505-1-wanglin@xxxxxxxxxxxxxx/
RFC v2:
https://lore.kernel.org/all/20260423060420.1785357-1-wanglin@xxxxxxxxxxxxxx/
Sashiko review of RFC v2:
https://sashiko.dev/#/patchset/20260423060420.1785357-1-wanglin@xxxxxxxxxxxxxx/
Lin Wang (6):
pci_ids: Add Hygon Family 0x18 DF F3/F4 device IDs
x86/amd_nb: Restrict NB framework init to AMD vendor
x86/amd_node: Restrict SMN root enumeration to AMD vendor
x86/hygon: Add Family 0x18 DF node enumeration
x86/hygon: Add Family 0x18 SMN access
x86/hygon: Add SMN debugfs interface
.../admin-guide/kernel-parameters.txt | 8 +
MAINTAINERS | 3 +
arch/x86/Kconfig | 4 +
arch/x86/include/asm/hygon/node.h | 205 +++
arch/x86/kernel/Makefile | 1 +
arch/x86/kernel/amd_nb.c | 6 +-
arch/x86/kernel/amd_node.c | 23 +-
arch/x86/kernel/hygon_node.c | 1340 +++++++++++++++++
include/linux/pci_ids.h | 6 +
9 files changed, 1584 insertions(+), 12 deletions(-)
create mode 100644 arch/x86/include/asm/hygon/node.h
create mode 100644 arch/x86/kernel/hygon_node.c
base-commit: 0e35b9b6ec0ffcc5e23cbdec09f5c622ad532b53
--
2.43.0