anolis: RAS/AMD/ATL: fix error nodes per socket on for Hygon Dhyana processor

ANBZ: #22615

For Hygon Dhyana processor other than hygon family 18h model 4h, using atl
to convert umc_mca_addr to sys_addr. When geting die id, it use
amd_get_nodes_per_socket() function to get "nodes_per_socket" value. It will
get wrong value for Hygon CPU.

To fix it, we use hygon_get_nodes_per_socket() function to get the correct
"nodes_per_socket" value.

Fixes: 8df0979486c2("EDAC/amd64: Use new AMD Address Translation Library")
Signed-off-by: Bo Liu <liubo03@inspur.com>
Reviewed-by: Wenhui Fan <fanwh@hygon.cn>
Reviewed-by: Guixin Liu <kanie@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/5521
This commit is contained in:
Bo Liu 2025-07-15 17:12:16 +08:00 committed by 小龙
parent 3884211d3c
commit bfec42ac43
3 changed files with 16 additions and 1 deletions

View File

@ -819,12 +819,16 @@ extern u32 amd_get_nodes_per_socket(void);
extern u32 amd_get_highest_perf(void);
extern bool cpu_has_ibpb_brtype_microcode(void);
extern void amd_clear_divider(void);
extern u32 hygon_get_nodes_per_socket(void);
#else
static inline u16 amd_get_nb_id(int cpu) { return 0; }
static inline u32 amd_get_nodes_per_socket(void) { return 0; }
static inline u32 amd_get_highest_perf(void) { return 0; }
static inline bool cpu_has_ibpb_brtype_microcode(void) { return false; }
static inline void amd_clear_divider(void) { }
static inline u32 hygon_get_nodes_per_socket(void) { return 0; }
#endif
static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)

View File

@ -32,6 +32,12 @@
*/
static u32 nodes_per_socket = 1;
u32 hygon_get_nodes_per_socket(void)
{
return nodes_per_socket;
}
EXPORT_SYMBOL_GPL(hygon_get_nodes_per_socket);
#ifdef CONFIG_NUMA
/*
* To workaround broken NUMA config. Read the comment in

View File

@ -18,7 +18,12 @@ static u8 get_die_id(struct atl_err *err)
* For CPUs, this is the AMD Node ID modulo the number
* of AMD Nodes per socket.
*/
return topology_die_id(err->cpu) % amd_get_nodes_per_socket();
if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON &&
boot_cpu_data.x86 == 0x18)
return topology_die_id(err->cpu) %
hygon_get_nodes_per_socket();
else
return topology_die_id(err->cpu) % amd_get_nodes_per_socket();
}
#define UMC_CHANNEL_NUM GENMASK(31, 20)