From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out198-7.us.a.mail.aliyun.com (out198-7.us.a.mail.aliyun.com [47.90.198.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA2E1244687 for ; Thu, 23 Apr 2026 06:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.90.198.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776924604; cv=none; b=q68Q4bjLfhnN2faJRQ5VVnwY5GFYAP2mm/6lpYWoLgWdLSxrdUQmR7kUbgf+8ejnUmx/4Y5/9TV0S9PEDf4WzQlH6/7HzEaNcleZ3tFyQYvv15y5m+pJNK6r6YoRF4sjWYdkCDAusOHfpelzwIZDYvG/pd+HLSC6wsALosrFsaY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776924604; c=relaxed/simple; bh=WdfFOrhb6WsaH96CZ60kQaLNuRRdpxzl12mZEJOE20k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rZSXT+JLNyiag1FAUq76sGv8fffQ+rDkjTkzU+vgLYH0naTPwoxAiElTiY3z8fSKSGhXQ1vpF0Fqvd0+JxrJGW4AaMK6pDjxpV5lu6F9zfQj29S1wu+K6hrWlYedIoLTorhFdhdxHHH09YTwlpfl1YQdJA0GbKp7f6BqW64WCak= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=open-hieco.net; spf=pass smtp.mailfrom=open-hieco.net; arc=none smtp.client-ip=47.90.198.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=open-hieco.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=open-hieco.net X-Alimail-AntiSpam:AC=CONTINUE;BC=0.07439327|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_alarm|0.016038-0.00203636-0.981926;FP=5198149419519265947|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033068016216;MF=wanglin@open-hieco.net;NM=1;PH=DS;RN=7;RT=7;SR=0;TI=SMTPD_---.hILPfOh_1776924267; Received: from localhost.localdomain(mailfrom:wanglin@open-hieco.net fp:SMTPD_---.hILPfOh_1776924267 cluster:ay29) by smtp.aliyun-inc.com; Thu, 23 Apr 2026 14:04:28 +0800 From: Lin Wang To: yazen.ghannam@amd.com, mario.limonciello@amd.com, Borislav Petkov Cc: tglx@kernel.org, mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 2/5] x86/hygon: Add Family 0x18 node enumeration API header Date: Thu, 23 Apr 2026 14:04:09 +0800 Message-ID: <20260423060420.1785357-3-wanglin@open-hieco.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260423060420.1785357-1-wanglin@open-hieco.net> References: <20260423060420.1785357-1-wanglin@open-hieco.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Introduce asm/hygon/node.h, a Hygon-only header that provides the public API for Hygon Family 0x18 Data Fabric node support. Exported function prototypes (under CONFIG_HYGON_NODE): hygon_f18h_model() model byte, 0 if not Hygon Fam18h hygon_cdd_num() compute die count for EDAC sizing hygon_get_dfid() DF ID for a DF misc device hygon_cpu_to_df_node() phys_node_id to dense DF node index Inline model-range helper (usable regardless of CONFIG_HYGON_NODE): hygon_f18h_model_in_range() true if model is within [first, last] All functions have static inline stubs returning 0/NULL/-ENODEV when CONFIG_HYGON_NODE=n, so consumers need no #ifdef guards. Also add the MAINTAINERS entry for Hygon node support header. Signed-off-by: Lin Wang --- MAINTAINERS | 2 + arch/x86/include/asm/hygon/node.h | 85 +++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 arch/x86/include/asm/hygon/node.h diff --git a/MAINTAINERS b/MAINTAINERS index c9b7b6f9828e..3d5ef8a344f3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11941,8 +11941,10 @@ F: drivers/input/touchscreen/hycon-hy46xx.c HYGON PROCESSOR SUPPORT M: Pu Wen +M: Lin Wang L: linux-kernel@vger.kernel.org S: Maintained +F: arch/x86/include/asm/hygon/ F: arch/x86/kernel/cpu/hygon.c HYNIX HI556 SENSOR DRIVER diff --git a/arch/x86/include/asm/hygon/node.h b/arch/x86/include/asm/hygon/node.h new file mode 100644 index 000000000000..18c4c7a3ea6e --- /dev/null +++ b/arch/x86/include/asm/hygon/node.h @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_X86_HYGON_NODE_H +#define _ASM_X86_HYGON_NODE_H + +#include +#include + +struct pci_dev; + +#define HYGON_MAX_SOCKETS 8 + +#ifdef CONFIG_HYGON_NODE + +/** + * hygon_cdd_num() - number of compute dies (CDD) + * + * DF IDs >= 4 represent compute dies (CDD). DF IDs < 4 represent IO dies + * (IOD). EDAC instances must be sized by CDD count, not total node count, + * because IOD nodes have no UMC. + */ +u16 hygon_cdd_num(void); + +/** + * hygon_f18h_model() - return Hygon Fam18h model byte, or 0 if not Hygon Fam18h + */ +u8 hygon_f18h_model(void); + +/** + * hygon_get_dfid() - read DF ID for a Hygon DF misc device + * @misc: PCI dev for DF misc (function 3) + * @dfid: output DF ID + */ +int hygon_get_dfid(struct pci_dev *misc, u8 *dfid); + +/** + * hygon_cpu_to_df_node() - map CPU to dense DF node index (O(1)) + * @cpu: CPU index + * + * Hygon Fam18h exposes sparse physical node IDs (CPUID 8000001E[7:0]). + * This function translates the per-CPU physical node ID into a contiguous + * DF node index (0..hygon_cdd_num()-1) that aligns with EDAC instance + * numbering and amd_nb[] indexing. + * + * Return: DF node index on success, negative errno on failure. + */ +int hygon_cpu_to_df_node(unsigned int cpu); + +#else /* !CONFIG_HYGON_NODE */ + +static inline u16 hygon_cdd_num(void) +{ + return 0; +} + +static inline u8 hygon_f18h_model(void) +{ + return 0; +} + +static inline int hygon_get_dfid(struct pci_dev *misc, u8 *dfid) +{ + return -ENODEV; +} + +static inline int hygon_cpu_to_df_node(unsigned int cpu) +{ + return -ENODEV; +} +#endif /* CONFIG_HYGON_NODE */ + +/** + * hygon_f18h_model_in_range() - check if Hygon Fam18h model is within [first, last] + * @first: lower bound (inclusive) + * @last: upper bound (inclusive) + * + * Returns false on non-Hygon-Fam18h systems (hygon_f18h_model() returns 0). + */ +static inline bool hygon_f18h_model_in_range(u8 first, u8 last) +{ + u8 m = hygon_f18h_model(); + + return m >= first && m <= last; +} + +#endif /* _ASM_X86_HYGON_NODE_H */ -- 2.43.0