aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386/kernel/cpu')
-rw-r--r--arch/i386/kernel/cpu/amd.c13
-rw-r--r--arch/i386/kernel/cpu/common.c28
-rw-r--r--arch/i386/kernel/cpu/intel.c23
-rw-r--r--arch/i386/kernel/cpu/proc.c8
4 files changed, 58 insertions, 14 deletions
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index ae94585d0445..fa10d0a509c7 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -188,6 +188,13 @@ static void __init init_amd(struct cpuinfo_x86 *c)
188 } 188 }
189 189
190 display_cacheinfo(c); 190 display_cacheinfo(c);
191
192 if (cpuid_eax(0x80000000) >= 0x80000008) {
193 c->x86_num_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
194 if (c->x86_num_cores & (c->x86_num_cores - 1))
195 c->x86_num_cores = 1;
196 }
197
191 detect_ht(c); 198 detect_ht(c);
192 199
193#ifdef CONFIG_X86_HT 200#ifdef CONFIG_X86_HT
@@ -199,12 +206,6 @@ static void __init init_amd(struct cpuinfo_x86 *c)
199 if (cpu_has(c, X86_FEATURE_CMP_LEGACY)) 206 if (cpu_has(c, X86_FEATURE_CMP_LEGACY))
200 smp_num_siblings = 1; 207 smp_num_siblings = 1;
201#endif 208#endif
202
203 if (cpuid_eax(0x80000000) >= 0x80000008) {
204 c->x86_num_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
205 if (c->x86_num_cores & (c->x86_num_cores - 1))
206 c->x86_num_cores = 1;
207 }
208} 209}
209 210
210static unsigned int amd_size_cache(struct cpuinfo_x86 * c, unsigned int size) 211static unsigned int amd_size_cache(struct cpuinfo_x86 * c, unsigned int size)
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index ebd5d8247faa..ed4c9c3fe667 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -434,7 +434,7 @@ void __init identify_cpu(struct cpuinfo_x86 *c)
434void __init detect_ht(struct cpuinfo_x86 *c) 434void __init detect_ht(struct cpuinfo_x86 *c)
435{ 435{
436 u32 eax, ebx, ecx, edx; 436 u32 eax, ebx, ecx, edx;
437 int index_lsb, index_msb, tmp; 437 int index_msb, tmp;
438 int cpu = smp_processor_id(); 438 int cpu = smp_processor_id();
439 439
440 if (!cpu_has(c, X86_FEATURE_HT)) 440 if (!cpu_has(c, X86_FEATURE_HT))
@@ -446,7 +446,6 @@ void __init detect_ht(struct cpuinfo_x86 *c)
446 if (smp_num_siblings == 1) { 446 if (smp_num_siblings == 1) {
447 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); 447 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n");
448 } else if (smp_num_siblings > 1 ) { 448 } else if (smp_num_siblings > 1 ) {
449 index_lsb = 0;
450 index_msb = 31; 449 index_msb = 31;
451 450
452 if (smp_num_siblings > NR_CPUS) { 451 if (smp_num_siblings > NR_CPUS) {
@@ -455,21 +454,34 @@ void __init detect_ht(struct cpuinfo_x86 *c)
455 return; 454 return;
456 } 455 }
457 tmp = smp_num_siblings; 456 tmp = smp_num_siblings;
458 while ((tmp & 1) == 0) {
459 tmp >>=1 ;
460 index_lsb++;
461 }
462 tmp = smp_num_siblings;
463 while ((tmp & 0x80000000 ) == 0) { 457 while ((tmp & 0x80000000 ) == 0) {
464 tmp <<=1 ; 458 tmp <<=1 ;
465 index_msb--; 459 index_msb--;
466 } 460 }
467 if (index_lsb != index_msb ) 461 if (smp_num_siblings & (smp_num_siblings - 1))
468 index_msb++; 462 index_msb++;
469 phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb); 463 phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb);
470 464
471 printk(KERN_INFO "CPU: Physical Processor ID: %d\n", 465 printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
472 phys_proc_id[cpu]); 466 phys_proc_id[cpu]);
467
468 smp_num_siblings = smp_num_siblings / c->x86_num_cores;
469
470 tmp = smp_num_siblings;
471 index_msb = 31;
472 while ((tmp & 0x80000000) == 0) {
473 tmp <<=1 ;
474 index_msb--;
475 }
476
477 if (smp_num_siblings & (smp_num_siblings - 1))
478 index_msb++;
479
480 cpu_core_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb);
481
482 if (c->x86_num_cores > 1)
483 printk(KERN_INFO "CPU: Processor Core ID: %d\n",
484 cpu_core_id[cpu]);
473 } 485 }
474} 486}
475#endif 487#endif
diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c
index b8d847b850dc..121aa2176e69 100644
--- a/arch/i386/kernel/cpu/intel.c
+++ b/arch/i386/kernel/cpu/intel.c
@@ -77,6 +77,27 @@ static void __init Intel_errata_workarounds(struct cpuinfo_x86 *c)
77} 77}
78 78
79 79
80/*
81 * find out the number of processor cores on the die
82 */
83static int __init num_cpu_cores(struct cpuinfo_x86 *c)
84{
85 unsigned int eax;
86
87 if (c->cpuid_level < 4)
88 return 1;
89
90 __asm__("cpuid"
91 : "=a" (eax)
92 : "0" (4), "c" (0)
93 : "bx", "dx");
94
95 if (eax & 0x1f)
96 return ((eax >> 26) + 1);
97 else
98 return 1;
99}
100
80static void __init init_intel(struct cpuinfo_x86 *c) 101static void __init init_intel(struct cpuinfo_x86 *c)
81{ 102{
82 unsigned int l2 = 0; 103 unsigned int l2 = 0;
@@ -139,6 +160,8 @@ static void __init init_intel(struct cpuinfo_x86 *c)
139 if ( p ) 160 if ( p )
140 strcpy(c->x86_model_id, p); 161 strcpy(c->x86_model_id, p);
141 162
163 c->x86_num_cores = num_cpu_cores(c);
164
142 detect_ht(c); 165 detect_ht(c);
143 166
144 /* Work around errata */ 167 /* Work around errata */
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index 89a2956ee657..0f1125b15b76 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -129,6 +129,14 @@ static int show_cpuinfo(struct seq_file *m, void *v)
129 seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n", 129 seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",
130 c->loops_per_jiffy/(500000/HZ), 130 c->loops_per_jiffy/(500000/HZ),
131 (c->loops_per_jiffy/(5000/HZ)) % 100); 131 (c->loops_per_jiffy/(5000/HZ)) % 100);
132
133#ifdef CONFIG_SMP
134 /* Put new fields at the end to lower the probability of
135 breaking user space parsers. */
136 seq_printf(m, "core id\t\t: %d\n", cpu_core_id[n]);
137 seq_printf(m, "cpu cores\t: %d\n", c->x86_num_cores);
138#endif
139
132 return 0; 140 return 0;
133} 141}
134 142