Skip to contentSkip to conversation

x86/cpu/topology: Consolidate AMD and Hygon cases in parse_topology()

PATCH RESEND In review Wei Wang 2 participants 2 messages Mar 23 x86

lore
Share & tools
lore

Wei Wang

author
#0 lore raw

PATCH RESEND 1/1 x86/cpu/topology: Consolidate AMD and Hygon cases in parse_topology()

Merge the two separate switch cases for AMD and Hygon as they share the common cpu_parse_topology_amd().

Also drop the IS_ENABLED(CONFIG_CPU_SUP_AMD/HYGON) guards, because
1) they are dead code: when a vendor's CONFIG_CPU_SUP_* is disabled, its vendor detection code (in amd.c / hygon.c) is not compiled, so x86_vendor will never be set to X86_VENDOR_AMD / X86_VENDOR_HYGON, instead it will default to X86_VENDOR_UNKNOWN and those switch cases are unreachable.
2) topology_amd.o is always built (obj-y), so cpu_parse_topology_amd() is always available regardless of CPU_SUP_* configuration.

---
RESEND changes
- Add Tested-by from Yongwei
- Rebase to 7.0.0-rc4

 arch/x86/kernel/cpu/topology_common.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/topology_common.c +2 -6
index 71625795d711..d0d79d5b8eb9 100644
@@ -157,8 +157,8 @@ static void parse_topology(struct topo_scan *tscan, bool early)
 
 	switch (c->x86_vendor) {
 	case X86_VENDOR_AMD:
-		if (IS_ENABLED(CONFIG_CPU_SUP_AMD))
-			cpu_parse_topology_amd(tscan);
+	case X86_VENDOR_HYGON:
+		cpu_parse_topology_amd(tscan);
 		break;
 	case X86_VENDOR_CENTAUR:
 	case X86_VENDOR_ZHAOXIN:
@@ -170,10 +170,6 @@ static void parse_topology(struct topo_scan *tscan, bool early)
 		if (c->cpuid_level >= 0x1a)
 			c->topo.cpu_type = cpuid_eax(0x1a);
 		break;
-	case X86_VENDOR_HYGON:
-		if (IS_ENABLED(CONFIG_CPU_SUP_HYGON))
-			cpu_parse_topology_amd(tscan);
-		break;
 	}
 }
 

base-commit: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e

Signature · 1 line
2.51.0
#1 lore raw
Quoted 12 lines · Wei Wang

Merge the two separate switch cases for AMD and Hygon as they share the common cpu_parse_topology_amd().

Also drop the IS_ENABLED(CONFIG_CPU_SUP_AMD/HYGON) guards, because
1) they are dead code: when a vendor's CONFIG_CPU_SUP_* is disabled, its vendor detection code (in amd.c / hygon.c) is not compiled, so x86_vendor will never be set to X86_VENDOR_AMD / X86_VENDOR_HYGON, instead it will default to X86_VENDOR_UNKNOWN and those switch cases are unreachable.
2) topology_amd.o is always built (obj-y), so cpu_parse_topology_amd() is always available regardless of CPU_SUP_* configuration.

Quoted 2 lines

Tested on AMD Genoa and Hygon 7447v servers. Kernel builds and boots

normally, and no regressions found!

Quoted 36 lines

---
RESEND changes
- Add Tested-by from Yongwei
- Rebase to 7.0.0-rc4

  arch/x86/kernel/cpu/topology_common.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/topology_common.c +2 -6
index 71625795d711..d0d79d5b8eb9 100644
@@ -157,8 +157,8 @@ static void parse_topology(struct topo_scan *tscan, bool early)
 
  	switch (c->x86_vendor) {
  	case X86_VENDOR_AMD:
-		if (IS_ENABLED(CONFIG_CPU_SUP_AMD))
-			cpu_parse_topology_amd(tscan);
+	case X86_VENDOR_HYGON:
+		cpu_parse_topology_amd(tscan);
  		break;
  	case X86_VENDOR_CENTAUR:
  	case X86_VENDOR_ZHAOXIN:
@@ -170,10 +170,6 @@ static void parse_topology(struct topo_scan *tscan, bool early)
  		if (c->cpuid_level >= 0x1a)
  			c->topo.cpu_type = cpuid_eax(0x1a);
  		break;
-	case X86_VENDOR_HYGON:
-		if (IS_ENABLED(CONFIG_CPU_SUP_HYGON))
-			cpu_parse_topology_amd(tscan);
-		break;
  	}
  }
 

base-commit: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e