Skip to content

Commit d691c5f

Browse files
kudureranganathingomolnar
authored andcommitted
x86/cpu/topology: Check for X86_FEATURE_XTOPOLOGY instead of passing has_xtopology
cpu_parse_topology_ext() sets X86_FEATURE_XTOPOLOGY before returning true if any of the XTOPOLOGY leaf (0x80000026 / 0xb) could be parsed successfully. Instead of storing and passing around this return value using "has_xtopology" in parse_topology_amd(), check for X86_FEATURE_XTOPOLOGY directly in parse_8000_001e() to simplify the flow. No functional changes intended. Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/20250901170418.4314-1-kprateek.nayak@amd.com
1 parent af507c6 commit d691c5f

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

arch/x86/kernel/cpu/topology_amd.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void store_node(struct topo_scan *tscan, u16 nr_nodes, u16 node_id)
5959
tscan->amd_node_id = node_id;
6060
}
6161

62-
static bool parse_8000_001e(struct topo_scan *tscan, bool has_topoext)
62+
static bool parse_8000_001e(struct topo_scan *tscan)
6363
{
6464
struct {
6565
// eax
@@ -85,7 +85,7 @@ static bool parse_8000_001e(struct topo_scan *tscan, bool has_topoext)
8585
* If leaf 0xb/0x26 is available, then the APIC ID and the domain
8686
* shifts are set already.
8787
*/
88-
if (!has_topoext) {
88+
if (!cpu_feature_enabled(X86_FEATURE_XTOPOLOGY)) {
8989
tscan->c->topo.initial_apicid = leaf.ext_apic_id;
9090

9191
/*
@@ -175,30 +175,27 @@ static void topoext_fixup(struct topo_scan *tscan)
175175

176176
static void parse_topology_amd(struct topo_scan *tscan)
177177
{
178+
if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES))
179+
tscan->c->topo.cpu_type = cpuid_ebx(0x80000026);
180+
178181
/*
179182
* Try to get SMT, CORE, TILE, and DIE shifts from extended
180183
* CPUID leaf 0x8000_0026 on supported processors first. If
181184
* extended CPUID leaf 0x8000_0026 is not supported, try to
182185
* get SMT and CORE shift from leaf 0xb. If either leaf is
183186
* available, cpu_parse_topology_ext() will return true.
184-
*/
185-
bool has_xtopology = cpu_parse_topology_ext(tscan);
186-
187-
if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES))
188-
tscan->c->topo.cpu_type = cpuid_ebx(0x80000026);
189-
190-
/*
187+
*
191188
* If XTOPOLOGY leaves (0x26/0xb) are not available, try to
192189
* get the CORE shift from leaf 0x8000_0008 first.
193190
*/
194-
if (!has_xtopology && !parse_8000_0008(tscan))
191+
if (!cpu_parse_topology_ext(tscan) && !parse_8000_0008(tscan))
195192
return;
196193

197194
/*
198195
* Prefer leaf 0x8000001e if available to get the SMT shift and
199196
* the initial APIC ID if XTOPOLOGY leaves are not available.
200197
*/
201-
if (parse_8000_001e(tscan, has_xtopology))
198+
if (parse_8000_001e(tscan))
202199
return;
203200

204201
/* Try the NODEID MSR */

0 commit comments

Comments
 (0)