From nobody Thu Apr 2 18:29:46 2026 Received: from out28-107.mail.aliyun.com (out28-107.mail.aliyun.com [115.124.28.107]) (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 EC4763A5E77 for ; Fri, 27 Mar 2026 08:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.28.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774598931; cv=none; b=IFSPc0xNc5lja/obSnF0rWeyW6hjlOdR6Al/FMvg1TopU8CLW4R+8pqJyhrWP8ILhG1PI/Hp8Vy0IUmQYux/ReBJgU1Jk1waqd4V0grTf3GrvVHZ7BIuGWvnzCoxS/D3C6t4OwKqLuVBMnMwD3wiaOVTpoibU9hTTwYwFoZlZEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774598931; c=relaxed/simple; bh=oibeUgxHcNCRV8WSG7Akkc5rxD45S1mXhPzoWTwmtys=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fouDLP/edkWG5RQbWi975KmWHNeF42hsE+llo6eMFDE4E9BQg6efp06maPB/oAkTvayoHkOEWc+Ma5VLrHOie+QzEjm+gkK0xlvDfRWTe0ckAaKaczouygvbPFMLzbMo1Sy0WRw2IBfJOuszGj6w4y48vu2suL7crxaBY1VsK5w= 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.107 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.09426788|-1;CH=blue;DM=|OVERLOAD|false|;DS=CONTINUE|ham_system_inform|0.0559394-0.000520006-0.943541;FP=5616368311665788086|4|1|1|0|-1|-1|-1;HT=maildocker-contentspam033037006180;MF=fuhao@open-hieco.net;NM=1;PH=DS;RN=8;RT=8;SR=0;TI=SMTPD_---.h.JPrSH_1774598908; Received: from higon..(mailfrom:fuhao@open-hieco.net fp:SMTPD_---.h.JPrSH_1774598908 cluster:ay29) by smtp.aliyun-inc.com; Fri, 27 Mar 2026 16:08:34 +0800 From: Fu Hao To: 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, Fu Hao Subject: [PATCH 2/8] x86/cpu: Get LLC ID for Hygon family 18h model 4h Date: Fri, 27 Mar 2026 16:08:25 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support to calculate LLC ID from the number of threads sharing the cache for Hygon family 18h model 4h processor. Signed-off-by: Fu Hao --- arch/x86/kernel/cpu/cacheinfo.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinf= o.c index 51a95b078..98862afc4 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -341,11 +341,23 @@ void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *= c) if (!cpuid_amd_hygon_has_l3_cache()) return; =20 - /* - * Hygons are similar to AMD Family 17h up to 1F models: LLC is - * at the core complex level. Core complex ID is ApicId[3]. - */ - c->topo.llc_id =3D c->topo.apicid >> 3; + if (c->x86_model >=3D 0x4) { + /* + * From model 4h: LLC ID is calculated from the number + * of threads sharing the L3 cache. + */ + u32 llc_index =3D find_num_cache_leaves(c) - 1; + struct _cpuid4_info id4 =3D {}; + + if (!amd_fill_cpuid4_info(llc_index, &id4)) + c->topo.llc_id =3D get_cache_id(c->topo.apicid, &id4); + } else { + /* + * The others are similar to AMD Family 17h up to 1F models: LLC is + * at the core complex level. Core complex ID is ApicId[3]. + */ + c->topo.llc_id =3D c->topo.apicid >> 3; + } } =20 void init_amd_cacheinfo(struct cpuinfo_x86 *c) --=20 2.34.1