Re: [RFC PATCH 5/5] x86/amd_node: Support Hygon SMN roots by socket
From: Borislav Petkov
Date: Thu Apr 02 2026 - 19:51:08 EST
On Thu, Apr 02, 2026 at 07:15:11PM +0800, Lin Wang wrote:
> SMN root devices (PCI class 0x0600, vendor 0x1d94) are already
> enumerated by get_next_root(), which already matches the Hygon vendor
> ID. The difference from AMD is root-to-node assignment:
>
> AMD: one root per node (roots_per_node grouping)
> Hygon: one root per socket, shared across all nodes on that socket
>
> Extend amd_smn_init() with a Hygon branch that:
> - uses hygon_node_num() and hygon_socket_num() to determine the node
> and socket counts from the hygon_node cache
> - groups the discovered roots by socket (roots_per_socket)
> - expands them to per-node entries in amd_roots[] using
> hygon_node_socket()
>
> Introduce smn_num_nodes to hold the per-vendor node count, so that
> __amd_smn_rw() and the debugfs bounds check work correctly for both
> AMD and Hygon system layouts.
>
> AMD behavior is unchanged.
>
> Signed-off-by: Lin Wang <wanglin@xxxxxxxxxxxxxx>
> ---
> arch/x86/kernel/amd_node.c | 122 +++++++++++++++++++++++++++++++------
> 1 file changed, 102 insertions(+), 20 deletions(-)
All Hygon enablement goes into Hygon-specific files. If there's a piece of
functionality which is generic enough, then that can be extracted into
a function which can be called by both vendors code.
But pls forget this piggy-backing on AMD code and thus turning AMD code into
an unmaintainable mess.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette