From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out28-128.mail.aliyun.com (out28-128.mail.aliyun.com [115.124.28.128]) (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 EEE43314B72 for ; Tue, 16 Jun 2026 07:10:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.28.128 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781593822; cv=none; b=aVx5ltJsBkuoEQp4QxKA25Kt5YqCfpChN+5Y6XEQ7/6JJWPYyFrXSgfO5zOrLCjYBz7ZH1eRRravH2Q1ARK8PzajnhE31Gq3eZ4F9rTcbAFJ0QtCEZ/lmFmqCabwrlHDqvbs9rTnFHJ1LwTdJIGAGjsiLho4pdw1JtLgMTG419Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781593822; c=relaxed/simple; bh=Ugh7waiB9ktSN6fFbbwwNjDjBIvcSqU4OPODZfPxiVI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=t6bJeq9KUpgTuB7tnDqQAU0pKtBbHbvCJUhbpa6QkMSy9ok3FtAyNGFfTQsG2e+pqnpWUvy+BCQU79fuHAmPCsh+Aor+XlmO9F6ei/OhPod6RIf+7kKETCKTJw0qrg/YeAR3P0w7UM9Dou3dqBab/Z/rCgLQaEx5UboLyffP8Jw= 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=115.124.28.128 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.07563233|-1;CH=blue;DM=|OVERLOAD|false|;DS=CONTINUE|ham_system_inform|0.00327456-0.00013727-0.996588;FP=6764825946298607638|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033045220102;MF=fuhao@open-hieco.net;NM=1;PH=DS;RN=9;RT=9;SR=0;TI=SMTPD_---.hzYQnh5_1781593814; Received: from 172.25.21.212(mailfrom:fuhao@open-hieco.net fp:SMTPD_---.hzYQnh5_1781593814 cluster:ay29) by smtp.aliyun-inc.com; Tue, 16 Jun 2026 15:10:15 +0800 Message-ID: <09338b64-dc3e-4a26-9be4-1902ea30219f@open-hieco.net> Date: Tue, 16 Jun 2026 15:10:12 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/7] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon models 0x4 through 0x8 To: Dave Hansen , puwen@hygon.cn, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com Cc: linux-kernel@vger.kernel.org References: <8d0f20314a4fb95111479166b5397e34e382a3f0.1781523812.git.fuhao@open-hieco.net> Content-Language: en-US From: Fu Hao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 6/15/2026 10:07 PM, Dave Hansen wrote: > On 6/15/26 05:17, Fu Hao wrote: >> + /* >> + * Adjust the die_id and logical_die_id for Hygon models 0x4-0x8. >> + */ >> + if (c->x86_model >= 0x4 && c->x86_model <= 0x8) { >> + c->topo.die_id = cpuid_ecx(0x8000001e) & 0xff; >> + c->topo.logical_die_id = (c->topo.die_id >> 4) * >> + topology_amd_nodes_per_pkg() + >> + (c->topo.die_id & 0xf); >> + } > > My assumption for Hygon stuff is that there's AMD code _somewhere_ for > 99% of it. It's just a matter of using it. > > Why doesn't this use parse_8000_001e()? > > I think that kind of justification needs to be the baseline for Hygon > work when it adds code. It needs to explain why the code is being added > and why the existing (AMD usually) code doesn't work. Hi Dave Hansen, Thank you for the feedback. Let me clarify the situation regarding Hygon Family 18h Model 4h and newer. Starting with these models, Hygon CPUs support CPUID leaf 0xb​ but do not​ support leaf 0x80000026. Consequently, the Die ID and Logical Die ID cannot be derived from the APIC ID space. CPUID leaf 0xb only supports core and package levels, it cannot enumerate die IDs within a socket. However, we found that CPUID leaf 0x8000001e (ECX)​ provides the necessary information. In Hygon CPU design, the NodeId field [7:0]​ encodes both Socket and Die IDs in the format: Bits [7:4]: Socket ID Bits [3:0]: Die ID We can calculate the correct IDs(die_id and logical_die_id) by parsing this field. Regarding the reuse of parse_8000_001e(): 1. On AMD, this function retrieves amd_node_id, which is an AMD-specific Node ID. We suspect this is kept for CDD compatibility, but its semantics differ from Hygon's requirements. 2. AMD derives its Die ID via leaf 0x80000026 (from APIC ID shifts), whereas Hygon must use the NodeId field from leaf 0x8000001e. Due to these architectural divergences, the current implementation is inconsistent for Hygon. To ensure correct topology detection and to facilitate subsequent Node management​ and EDAC address translation, we must explicitly parse the NodeId field for Hygon instead of relying on amd_node_id. Please let me know if this explanation clears up the rationale for the change. -- Regards, Fu Hao