From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SN4PR2101CU001.outbound.protection.outlook.com (mail-southcentralusazon11012029.outbound.protection.outlook.com [40.93.195.29]) (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 2C8E824E4A1 for ; Sun, 19 Jul 2026 20:36:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.195.29 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784493379; cv=fail; b=N7ryj4ti+tDwCAYWjc6ZeOf4XofObrtYAvOO0ebpU1Bpy3nw8yYsfP5JEGWrLBsiD8OlLNLWmQA7Dl8nHEkOkVV8TEC9x/1Re4zcLBAz21MURkVHSiL1mxpWB0QYyDqfByqDpZjlGQKNfxVKbG4aBjXKiNzl6cYN3Edyj9yk1hc= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784493379; c=relaxed/simple; bh=FLjAzuaO0l59tvm7M1z3wrj4P0trJL0T47PmcCYmEv4=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=nTw2lfyh5PzBX3NKxJKNZViUXWaYb5Xp5CIDTzHRYUeUxDbXPMUgGd0Y3hp0tyyAHg5Y1yLlFHqIb1P5/8513OxjISn8nSZiiEKBEEfJe54aZ6d+ff+5Oi5e9T0NOrVvaAHka+ykioJFRh7BNRk6SM2XkqxNzkN4qDVoxqaJAuQ= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=HsCNq5gy; arc=fail smtp.client-ip=40.93.195.29 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="HsCNq5gy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YZY/cCGjgeML1Msk0Tz8KNxYzf2Wl+GBN4xhViQ4EHb0EJM2eLZgGnGSLLLWDDC0/sli7CJrsRCyNqAF0VyiqKGT6ACrMoWXqLzgxVCVO+aoIzTIyyLNsxAnOjDiy83m5JflrBsU+Bt6WzysYLDfVwl3akViDlLHuUvaYVxy/Djqe+FQL6Tj6cJDOKXhcDoPkvY/ox4lk5c9+DOpA0r+hiJ1+ayzsbYnY15ewT7N8J5ZBKsbkH0UtLH1A9qIMhHuVb5361d4m7kc++8W4jTkwNnjMRsGR223vr3NCP+4kANUdfMA+Q7J5g92xPP2I961ftnNSD8UC1X5uVcWBh5UDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KX3wyVs2lJV5PCftNP6/w/KtqdYtkszbRCbYpCenr2A=; b=odSh+pHhK30M4fM/zav0cAghf7qi1AGXsGuLgrsl0xQuaVIuBtYCS0Hwdto3TE2GoUGJYw0KOIWj3bM3O3d4TDcJsaS+vxLRaVMuYg5HhzmVVSeOLq9lYCFL6WdBmOFfpNm6TSXv2dxiGW+1B13VA/2lzEiWFAQlGaw0GHUhasBJtnIzN4WkEsh0c/OFhR+O/hedvIxnnpiLGT/1bSWfoATC4wfslvg9PfoS8KNOOvnHyAkPiCkjTPU3DZdswCieogUl3xjYAwqzTUa3KewIync+UNiVqxk9thueyXZWMQd8/mSGkTLqOuO1aPjS/xw4lWKQ7RlTLxXzQmF3UWuXJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KX3wyVs2lJV5PCftNP6/w/KtqdYtkszbRCbYpCenr2A=; b=HsCNq5gy3WWtOP7g8EhaaoBU05a/+KfrixWNUltta6DDBZ2jijKMiz5JdFDGTVDMy8iqTHYGUdFtrmcmy9vxyFSkx9EN1pro9dSeZ41IHMq+EzSMPe8V3AosBxBZCnbKTLhgumBp4UGDAYWMCW3kgbZoriqcmVFKnAcIzS52OLw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB6374.namprd12.prod.outlook.com (2603:10b6:8:a3::18) by CH3PR12MB9251.namprd12.prod.outlook.com (2603:10b6:610:1bd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.11; Sun, 19 Jul 2026 20:36:12 +0000 Received: from DM4PR12MB6374.namprd12.prod.outlook.com ([fe80::af35:a7a6:6ca:7fcf]) by DM4PR12MB6374.namprd12.prod.outlook.com ([fe80::af35:a7a6:6ca:7fcf%3]) with mapi id 15.21.0223.015; Sun, 19 Jul 2026 20:36:12 +0000 Date: Sun, 19 Jul 2026 16:36:07 -0400 From: Yazen Ghannam To: Lin Wang Cc: mario.limonciello@amd.com, Borislav Petkov , tglx@kernel.org, mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 4/6] x86/hygon: Add Family 0x18 DF node enumeration Message-ID: <20260719203412.GA4058@yaz-khff2.amd.com> References: <20260709075549.626095-1-wanglin@open-hieco.net> <20260709075549.626095-5-wanglin@open-hieco.net> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260709075549.626095-5-wanglin@open-hieco.net> X-ClientProxiedBy: CH0PR03CA0387.namprd03.prod.outlook.com (2603:10b6:610:119::21) To DM4PR12MB6374.namprd12.prod.outlook.com (2603:10b6:8:a3::18) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR12MB6374:EE_|CH3PR12MB9251:EE_ X-MS-Office365-Filtering-Correlation-Id: 00e15908-dd82-4ac5-b566-08dee5d55edf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|23010399003|1800799024|366016|4143699003|6133799003|11063799006|56012099006|10067099003|3023799007|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: qLjvh27wZQmDx5NFRjBbMcBXX5/F4QBEAlE28vX3lZwe8O6+q0DcVJbufO/i06yOGHjk8sGzL4xzCPpVScuZE6UE/oevBhinUhGFlq56ZclM0wbuhia5q9WB/GKdIjIZTXQtx8XET6+MQS5dJjPhI//Wi/FAWZvEB85UCnFjzy0YcKUHmeO6WNsIajhu5cP9uCpwoXIKDNkFk5gC0A7z91g04McL+7X59jKVxSjvtLK5OmGMwLZgXyENtaiQ4GPKmJjpv8g7R3aqgWsVABVLmBajv59LWjQsBqbf3BQZWlqTbB70/tXlD/7aYEnSonI6NBsSkXieWy91he0rXrPg9vhAWsILb+wydHnXrm9xI6uEccFAym2/94M6QccxceujgRPiZdNOkUNYUMdN2sVvOmZLOWbsA9Urc6Mp5vGTxzXDQ1ndR3R63pEZY8ZlAz47BNDtNbAD1cTrHktKm1fTVd4WyihVhIunMXF3if0Bg4WLsSggJZpEzWMyAiBK1wTOOloaU8RNjZsMP6N7MzFkvRhYRPNfyurN6inKB9beyDbuUiJTdD+Yk4BNnd4omGXDA29Bfv8Y8Qi4BNuTD3QxZIs0/X8VmuEzWnBsxxsTbe1kFUVg59qmokftH4r0rpxSxyY0EGC5HsPuVBXpPIrOuuTgrBJvgfRUbkvcew1JvXY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB6374.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(23010399003)(1800799024)(366016)(4143699003)(6133799003)(11063799006)(56012099006)(10067099003)(3023799007)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?o5p+PyaIjrSf0MQ+rR7+DFZ2OzM1R/4d0b7EfueIny+zLRUQLQnGfFL7xMWs?= =?us-ascii?Q?LtgIZPpkcspUT8gZaNQwlhd63cukviR/nu0mAcFNPHD9NDq3I4oopzc4xpVn?= =?us-ascii?Q?+YjdEnuwCVUevHj7F4Xjj1QZUlEnLxTXXEftAvKc8mQ5rqbGfhhIDwmo1ndY?= =?us-ascii?Q?1fizpT3blRleaUSkFoOjtT/QYyjIc/uOqFCDYwgBhlBIqMyh7fP7mdk5PQ3P?= =?us-ascii?Q?rv1GGFpylul7X/6lRl8wUfnrMeqFT6cyanBjtSxLBpf92d71FTCgQVB2Q3wI?= =?us-ascii?Q?/0QbCDWz5flqZRFzG9qqr5pargmd63a1H01fZq3qviNkWousTXKQReApQkEX?= =?us-ascii?Q?a6lT5/nvJ4j6VlPIbU8yWiIMtRIcL1udj5KnMk4/hdilcb3aq6eb2xnJCW0z?= =?us-ascii?Q?eRJuWfBW97dOo1B/+jPaAs80uhmuFxcKo9uwjEUv+/FZu8YX5IqXwkgIOTQH?= =?us-ascii?Q?gq1nnFHCl6JABCEVOICta6Oxh9vKwtUW4kjcr6VVp/63AO0x89sbUfxX1AVu?= =?us-ascii?Q?WTHqrwGc4u6JUFUmJmGsG/yUn+qypbbmH7QDvsGWBpdFwe9W3ELFkT6kA2BE?= =?us-ascii?Q?7shK6IlLoLxk4YfqRQMtHWIJgFmuHPyly5x9dUSfKafIpoeIzaSO8nwFJ02V?= =?us-ascii?Q?sxKxaQNUWqDucMgnw4wUXg8+Vz74pWWqTqMv7QY0B5zR3uqn2IL5jB2ykE4p?= =?us-ascii?Q?c5A+qYz41MqnxP8EgbH8ZHtM5cy1O73EWtkY9TzOM44vvLKwcT66f3e7Gy4g?= =?us-ascii?Q?2wGu8Kb+RAYZiy0c5/dZCfUKvIAlIYB8YFjJBGiYaWzsAN6HY5m+vk6djXP9?= =?us-ascii?Q?cMb4gO5eGB3kG6wa6ZRaBZJtaBacogVzgyPDBZ3RDNrV2X2nNIIfpTCcLOHi?= =?us-ascii?Q?LubdkSGJK+2yrycfQAimfhN/KO28+jR/7K+tHPZLzMdbTKZcG069dWRM0r8w?= =?us-ascii?Q?swEf/Ia5CP1d/NqoVxXwGbjkMsP0tKLXSQci8fLErkYUin1G0RexeaG5Ma3Z?= =?us-ascii?Q?f4ZJiZZK0zf8YEbSyVP4dmIXMz44LUigHnc5lzXzRGrTwBSLMd8P2TeIAois?= =?us-ascii?Q?cgBBG2noF0E1hQ1XfI0qfMbSH6ssZ93B81W/Q5GIadEGzUra0Cch9sXEt0x0?= =?us-ascii?Q?Bil1N3zKBP/LwVTkwsX9vRytxxZcMty+/7jAyOLYA4jAHQV+XPSjHbCNoDgz?= =?us-ascii?Q?axg82c9AI4fQfBzn/klZDmNjmDqkOx21ZJtAErTtWgaUqb62uBZ/wPt3+CBm?= =?us-ascii?Q?ofsRhJwLDh1z2owsw0ifeV91fL/Sn4stDsJqCUq4QfmsqHvC/ns7TusfaA+J?= =?us-ascii?Q?ee1lH0grXSp6UiJShQOwYBkCh1ytkuC/dk/JcbTNa9JYL1MRDxLT5XY6swU+?= =?us-ascii?Q?aQKQZMj3gsqSJda6qGJMDTDiE0gYiK2gqGE54RwRnULbD7TrCrVq8ChvQDyD?= =?us-ascii?Q?s1zH0FxHc+mbochRS4Gtx6vAX6kzN4EUsnZ3mTzUz7e9+awM4TRE4fhJk0BB?= =?us-ascii?Q?1LhbeR1OAOMauY5Do7G6T1jEM9h96BC7ksaCBWfs9gEFJztFv6U47Viry4aH?= =?us-ascii?Q?oaKtdPFVQxcbD69NSgf7i+SBowo366rKr5NunUxYFht/RoH9bNrSaHvSqtgf?= =?us-ascii?Q?qpG5fBup8O+e3Yd9OjuxnX90YIF9vLauANDgXEa4RGdyITyNimRWpWf1C0f+?= =?us-ascii?Q?Lw1vNJlLjqq6Zy6r6cH5Am20I50Vvdbl77sZFS57Q8dgFK6P?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00e15908-dd82-4ac5-b566-08dee5d55edf X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB6374.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2026 20:36:12.1201 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Kdo27zt77E2AA4RNYhKSl97mJzJvu7HBUKhBqT/svLzudZDwJV6XLgoHdk7WZK/xvrD+Inl4fvjQ8lOysLWPAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9251 On Thu, Jul 09, 2026 at 03:55:47PM +0800, Lin Wang wrote: > Add a Hygon-specific Data Fabric (DF) node enumeration module, gated > by the new CONFIG_HYGON_NODE. > > AMD systems can enumerate DF nodes from fixed PCI slots 00:18..1f on > bus 0. Hygon Family 0x18 systems expose DF instances at > platform-assigned PCI slots, so PCI slot number cannot be used as node > identity and the AMD node enumeration path cannot be reused. > > Enumerate Hygon DF nodes by walking DF misc (F3) devices by PCI ID and > reading hardware identity from DF registers. F1x200 provides socket > identity and the system-wide SocketPresent mask, which is checked > against the enumerated sockets to catch a missing one; supported models > that encode sparse DFIDs use F5x180 for the real Fabric ID. The > resulting node cache is sorted into a dense software order: CDD nodes > first, ordered by socket and DFID, followed by IOD nodes. > > Provide a Hygon node API in for consumers that need > node counts, socket/DFID/type identity, CPU-to-DF translation, F3/F4 > PCI function lookup, and PCI-device-to-DF-node lookup. > > CPU topology reports a sparse phys_node_id value, while Hygon DF > consumers need the dense CDD index used by the DF node cache. On the > supported Fam18h models, CPUID 0x8000001E ECX[7:0] encodes the socket > in the high nibble and a socket-local CDD ordinal in the low nibble. > The translator uses that encoding to select the matching CDD from the > DF cache, whose CDD region is sorted by hardware (socket_id, dfid). > This keeps CPU-to-DF translation independent of the online CPU set. > > After the node cache is built, init enables the CPU-to-DF helper only > when CPUID NodesPerProcessor matches the enumerated CDD count per > socket; otherwise the rest of the node stack remains usable and only > hygon_cpu_to_df_node() is disabled. > > Supported-model matching is private to the Hygon node module and is > driven by its internal DF identity table. The public API exposes > validated topology rather than model-range helpers. Model-specific > behavior for consumers is left to their own x86_cpu_id tables and > driver_data. > > The cache is built once from fs_initcall and is read-only afterwards. > SMN access support is added in the following patch. > > Signed-off-by: Lin Wang > --- > MAINTAINERS | 3 + > arch/x86/Kconfig | 4 + > arch/x86/include/asm/hygon/node.h | 171 ++++++ > arch/x86/kernel/Makefile | 1 + > arch/x86/kernel/hygon_node.c | 849 ++++++++++++++++++++++++++++++ > 5 files changed, 1028 insertions(+) > create mode 100644 arch/x86/include/asm/hygon/node.h > create mode 100644 arch/x86/kernel/hygon_node.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index f37a81950e25..a533fa480f95 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -12052,9 +12052,12 @@ 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 > +F: arch/x86/kernel/hygon_node.c > > HYNIX HI556 SENSOR DRIVER > M: Sakari Ailus > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index bdad90f210e4..2e9396520203 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -3073,6 +3073,10 @@ config AMD_NODE > def_bool y > depends on CPU_SUP_AMD && PCI > > +config HYGON_NODE > + def_bool y > + depends on CPU_SUP_HYGON && PCI > + > endmenu > > menu "Binary Emulations" > diff --git a/arch/x86/include/asm/hygon/node.h b/arch/x86/include/asm/hygon/node.h > new file mode 100644 > index 000000000000..bb8168beb288 > --- /dev/null > +++ b/arch/x86/include/asm/hygon/node.h > @@ -0,0 +1,171 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Hygon Family 0x18 Data Fabric node enumeration API > + * > + * This header exposes the Hygon Fam18h DF node enumeration and DF > + * function access primitives consumers (EDAC, MCE decode, ATL, etc.) > + * need. > + */ > +#ifndef _ASM_X86_HYGON_NODE_H > +#define _ASM_X86_HYGON_NODE_H > + > +#include > +#include > +#include > + > +struct pci_dev; > + > +/* DF function indices supported by hygon_node_get_func(). */ > +#define HYGON_DF_F3 3 /* misc */ > +#define HYGON_DF_F4 4 /* link */ > + > +/* Hygon compute dies (CDD) start at DFID 4; IO dies occupy DFIDs 0-3. */ I noticed the regular to of "CDD" to mean compute dies. Is this the official use for Hygon systems? It is very similar to "CCD" that is used for AMD systems. So I just wanted to make sure it's not a mixup. > +#define HYGON_CDD_DFID_BASE 4 > + > +/** > + * enum hygon_node_type - DF node type, derived from DFID > + * @HYGON_NODE_IOD: I/O die (DFID < HYGON_CDD_DFID_BASE); no UMC. > + * @HYGON_NODE_CDD: compute die (DFID >= HYGON_CDD_DFID_BASE); hosts > + * CPU cores and UMC controllers. This is the opposite of AMD systems, so is this a Hygon-specific implementatoin detail? On AMD systems, the compute die holds the CPU cores and cache while the I/O die holds the 'uncore' logical which includes the memory controllers. > + */ > +enum hygon_node_type { > + HYGON_NODE_IOD = 0, > + HYGON_NODE_CDD = 1, > +}; > + > +/** > + * struct hygon_node_info - identity snapshot for a DF node > + * @socket_id: physical socket ID, F1x200[30:28] > + * @dfid: Data Fabric ID, model-dependent source > + * @type: HYGON_NODE_CDD or HYGON_NODE_IOD > + */ > +struct hygon_node_info { > + u8 socket_id; > + u8 dfid; > + enum hygon_node_type type; > +}; > + > +#ifdef CONFIG_HYGON_NODE > + > +/** > + * hygon_node_num() - total number of DF nodes (CDD + IOD) > + * > + * Return: total node count, or 0 if the cache is not ready or this is > + * not a Hygon Fam18h platform. Use this as the upper bound when > + * iterating over DF nodes or indexing SMN access. > + */ > +u16 hygon_node_num(void); > + > +/** > + * hygon_cdd_num() - number of compute dies (CDD) > + * > + * DFID >= 4 marks a compute die (CDD). DFID < 4 marks an I/O die > + * (IOD) which has no UMC. Use this count to size EDAC memory-controller > + * instances and to iterate over UMC-bearing nodes. > + * > + * Return: CDD count, or 0 if the cache is not ready. > + */ > +u16 hygon_cdd_num(void); > + > +/** > + * hygon_node_get_info() - read identity snapshot for a DF node > + * @node: DF node index in [0, hygon_node_num()) > + * @info: output structure (socket_id, dfid, type) > + * > + * Copies all immutable identity fields in one call so callers that > + * need to make decisions on multiple fields (e.g. "if CDD then read > + * DFID and compute UMC base") do not need multiple cache lookups. > + * > + * Return: 0 on success, -EINVAL if @node is out of range or @info is > + * NULL, -ENODEV if the cache is not ready. > + */ > +int hygon_node_get_info(u16 node, struct hygon_node_info *info); > + > +/** > + * hygon_cpu_to_df_node() - map CPU to dense DF CDD index > + * @cpu: CPU index > + * > + * Hygon Fam18h exposes sparse physical node IDs via CPUID 8000001E[7:0]. > + * This function translates the per-CPU physical node ID into a dense > + * DF CDD index in [0, hygon_cdd_num()). > + * > + * Return: DF CDD index on success, -EINVAL if @cpu is out of range, > + * -ENODEV if CPU-to-DF mapping is unsupported on this model or the > + * physical node ID does not map to a known DF node. > + */ > +int hygon_cpu_to_df_node(unsigned int cpu); > + > +/** > + * hygon_node_get_func() - get DF function PCI device for a node > + * @node: DF node index in [0, hygon_node_num()) > + * @func: HYGON_DF_F3 or HYGON_DF_F4 > + * > + * Return: referenced pci_dev on success. NULL if @node is out of > + * range, @func is unsupported, or the cache is not ready. The > + * caller must release the reference with pci_dev_put(). > + */ > +struct pci_dev *hygon_node_get_func(u16 node, u8 func); > + > +/** > + * hygon_pci_dev_to_df_node() - find DF node owning the given PCI device > + * @pdev: PCI device on the same domain, bus and slot as one of the DF > + * nodes (typically a sibling function of the DF misc device, > + * e.g. a UMC channel) > + * > + * Looks up the DF node whose misc (F3) device shares the same PCI > + * domain, bus, and slot as @pdev. Useful for drivers that hold a > + * per-PCI-function device and need the containing DF node index for > + * SMN access or other node-indexed operations. > + * > + * Return: DF node index in [0, hygon_node_num()) on success, -EINVAL > + * if @pdev is NULL, -ENODEV if no matching node is found or the cache > + * is not ready. > + */ > +int hygon_pci_dev_to_df_node(struct pci_dev *pdev); > + > +#else /* !CONFIG_HYGON_NODE */ > + > +static inline u16 hygon_node_num(void) > +{ > + return 0; > +} > + > +static inline u16 hygon_cdd_num(void) > +{ > + return 0; > +} > + > +static inline int hygon_node_get_info(u16 node, struct hygon_node_info *info) > +{ > + return -ENODEV; > +} > + > +static inline int hygon_cpu_to_df_node(unsigned int cpu) > +{ > + return -ENODEV; > +} > + > +static inline struct pci_dev *hygon_node_get_func(u16 node, u8 func) > +{ > + return NULL; > +} > + > +static inline int hygon_pci_dev_to_df_node(struct pci_dev *pdev) > +{ > + return -ENODEV; > +} > + Many of these ^^^ function prototypes can fit on a single line. > +#endif /* CONFIG_HYGON_NODE */ > + > +/* Inline helpers, available regardless of CONFIG_HYGON_NODE. */ > + > +/** > + * is_hygon_f18h() - true on Hygon Family 0x18 CPUs > + */ This comment is redundant. > +static inline bool is_hygon_f18h(void) > +{ > + return boot_cpu_data.x86_vendor == X86_VENDOR_HYGON && > + boot_cpu_data.x86 == 0x18; Is, or will, there be a Hygon system that is not "Family 0x18"? If not, then the family check is not necessary. If so, then it would be good to know for other developers to audit AMD/Hygon shared code. Thanks, Yazen