Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7062211 authored by Yinghai Lu's avatar Yinghai Lu Committed by Ingo Molnar
Browse files

x86: fix amd_detect_cmp



for system with apicid lifting, boot cpu apicid will be 4

got:

  CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
  CPU: L2 Cache: 512K (64 bytes/line)
  CPU 0/4 -> Node 0
  CPU: Physical Processor ID: 1
  CPU: Processor Core ID: 0

so try to offset apicid back before get phys_proc_id with bits shift.
then we can get correct socket ID

also remove remove cpu_data(0) reference.

because cpu_data(0) only be ready after smp_prepare_cpus with the assignment
from boot_cpu_data to current_cpu_data aka cpu_data(0).

and check_bugs()==>identify_cpu(&boot_cpu_data) is quite before than
smp_prepare_cpus. So just use boot_cpu_id instead.

Signed-off-by: default avatarYinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 97b44ae6
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -564,7 +564,7 @@ static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c)
	/* Low order bits define the core id (index of core in socket) */
	/* Low order bits define the core id (index of core in socket) */
	c->cpu_core_id = c->phys_proc_id & ((1 << bits)-1);
	c->cpu_core_id = c->phys_proc_id & ((1 << bits)-1);
	/* Convert the APIC ID into the socket ID */
	/* Convert the APIC ID into the socket ID */
	c->phys_proc_id = phys_pkg_id(bits);
	c->phys_proc_id = (c->apicid - boot_cpu_id) >> bits;


#ifdef CONFIG_NUMA
#ifdef CONFIG_NUMA
	node = c->phys_proc_id;
	node = c->phys_proc_id;
@@ -581,7 +581,7 @@ static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c)
		   If that doesn't result in a usable node fall back to the
		   If that doesn't result in a usable node fall back to the
		   path for the previous case.  */
		   path for the previous case.  */


		int ht_nodeid = apicid - (cpu_data(0).phys_proc_id << bits);
		int ht_nodeid = apicid - boot_cpu_id;


		if (ht_nodeid >= 0 &&
		if (ht_nodeid >= 0 &&
		    apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
		    apicid_to_node[ht_nodeid] != NUMA_NO_NODE)