aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu/common.c
diff options
context:
space:
mode:
authorPaolo Ciarrocchi <paolo.ciarrocchi@gmail.com>2008-02-24 05:58:13 -0500
committerIngo Molnar <mingo@elte.hu>2008-04-17 11:40:50 -0400
commit34048c9e927d5ae29c6ba802c826370de2a046d2 (patch)
treee2e2e955022b6d2ac497a9dcb976ba069f96c72b /arch/x86/kernel/cpu/common.c
parentdb96598494f2a2ab9ab79999dd8fc365a906914b (diff)
x86: coding style fixes to arch/x86/kernel/cpu/common.c
Before: total: 55 errors, 6 warnings, 727 lines checked After: total: 0 errors, 3 warnings, 734 lines checked No code changed: arch/x86/kernel/cpu/common.o: text data bss dec hex filename 3500 4611 44 8155 1fdb common.o.before 3500 4611 44 8155 1fdb common.o.after md5: e37091f11fbeb682c0db152ac3022a38 common.o.before.asm e37091f11fbeb682c0db152ac3022a38 common.o.after.asm Signed-off-by: Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/cpu/common.c')
-rw-r--r--arch/x86/kernel/cpu/common.c105
1 files changed, 56 insertions, 49 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 0fd6be154d5d..ef9e31b89b35 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -62,9 +62,9 @@ __u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata;
62static int cachesize_override __cpuinitdata = -1; 62static int cachesize_override __cpuinitdata = -1;
63static int disable_x86_serial_nr __cpuinitdata = 1; 63static int disable_x86_serial_nr __cpuinitdata = 1;
64 64
65struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {}; 65struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {};
66 66
67static void __cpuinit default_init(struct cpuinfo_x86 * c) 67static void __cpuinit default_init(struct cpuinfo_x86 *c)
68{ 68{
69 /* Not much we can do here... */ 69 /* Not much we can do here... */
70 /* Check if at least it has cpuid */ 70 /* Check if at least it has cpuid */
@@ -81,11 +81,11 @@ static struct cpu_dev __cpuinitdata default_cpu = {
81 .c_init = default_init, 81 .c_init = default_init,
82 .c_vendor = "Unknown", 82 .c_vendor = "Unknown",
83}; 83};
84static struct cpu_dev * this_cpu __cpuinitdata = &default_cpu; 84static struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
85 85
86static int __init cachesize_setup(char *str) 86static int __init cachesize_setup(char *str)
87{ 87{
88 get_option (&str, &cachesize_override); 88 get_option(&str, &cachesize_override);
89 return 1; 89 return 1;
90} 90}
91__setup("cachesize=", cachesize_setup); 91__setup("cachesize=", cachesize_setup);
@@ -107,12 +107,12 @@ int __cpuinit get_model_name(struct cpuinfo_x86 *c)
107 /* Intel chips right-justify this string for some dumb reason; 107 /* Intel chips right-justify this string for some dumb reason;
108 undo that brain damage */ 108 undo that brain damage */
109 p = q = &c->x86_model_id[0]; 109 p = q = &c->x86_model_id[0];
110 while ( *p == ' ' ) 110 while (*p == ' ')
111 p++; 111 p++;
112 if ( p != q ) { 112 if (p != q) {
113 while ( *p ) 113 while (*p)
114 *q++ = *p++; 114 *q++ = *p++;
115 while ( q <= &c->x86_model_id[48] ) 115 while (q <= &c->x86_model_id[48])
116 *q++ = '\0'; /* Zero-pad the rest */ 116 *q++ = '\0'; /* Zero-pad the rest */
117 } 117 }
118 118
@@ -130,7 +130,7 @@ void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
130 cpuid(0x80000005, &dummy, &dummy, &ecx, &edx); 130 cpuid(0x80000005, &dummy, &dummy, &ecx, &edx);
131 printk(KERN_INFO "CPU: L1 I Cache: %dK (%d bytes/line), D cache %dK (%d bytes/line)\n", 131 printk(KERN_INFO "CPU: L1 I Cache: %dK (%d bytes/line), D cache %dK (%d bytes/line)\n",
132 edx>>24, edx&0xFF, ecx>>24, ecx&0xFF); 132 edx>>24, edx&0xFF, ecx>>24, ecx&0xFF);
133 c->x86_cache_size=(ecx>>24)+(edx>>24); 133 c->x86_cache_size = (ecx>>24)+(edx>>24);
134 } 134 }
135 135
136 if (n < 0x80000006) /* Some chips just has a large L1. */ 136 if (n < 0x80000006) /* Some chips just has a large L1. */
@@ -138,16 +138,16 @@ void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
138 138
139 ecx = cpuid_ecx(0x80000006); 139 ecx = cpuid_ecx(0x80000006);
140 l2size = ecx >> 16; 140 l2size = ecx >> 16;
141 141
142 /* do processor-specific cache resizing */ 142 /* do processor-specific cache resizing */
143 if (this_cpu->c_size_cache) 143 if (this_cpu->c_size_cache)
144 l2size = this_cpu->c_size_cache(c,l2size); 144 l2size = this_cpu->c_size_cache(c, l2size);
145 145
146 /* Allow user to override all this if necessary. */ 146 /* Allow user to override all this if necessary. */
147 if (cachesize_override != -1) 147 if (cachesize_override != -1)
148 l2size = cachesize_override; 148 l2size = cachesize_override;
149 149
150 if ( l2size == 0 ) 150 if (l2size == 0)
151 return; /* Again, no L2 cache is possible */ 151 return; /* Again, no L2 cache is possible */
152 152
153 c->x86_cache_size = l2size; 153 c->x86_cache_size = l2size;
@@ -156,16 +156,19 @@ void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
156 l2size, ecx & 0xFF); 156 l2size, ecx & 0xFF);
157} 157}
158 158
159/* Naming convention should be: <Name> [(<Codename>)] */ 159/*
160/* This table only is used unless init_<vendor>() below doesn't set it; */ 160 * Naming convention should be: <Name> [(<Codename>)]
161/* in particular, if CPUID levels 0x80000002..4 are supported, this isn't used */ 161 * This table only is used unless init_<vendor>() below doesn't set it;
162 * in particular, if CPUID levels 0x80000002..4 are supported, this isn't used
163 *
164 */
162 165
163/* Look up CPU names by table lookup. */ 166/* Look up CPU names by table lookup. */
164static char __cpuinit *table_lookup_model(struct cpuinfo_x86 *c) 167static char __cpuinit *table_lookup_model(struct cpuinfo_x86 *c)
165{ 168{
166 struct cpu_model_info *info; 169 struct cpu_model_info *info;
167 170
168 if ( c->x86_model >= 16 ) 171 if (c->x86_model >= 16)
169 return NULL; /* Range check */ 172 return NULL; /* Range check */
170 173
171 if (!this_cpu) 174 if (!this_cpu)
@@ -190,9 +193,9 @@ static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c, int early)
190 193
191 for (i = 0; i < X86_VENDOR_NUM; i++) { 194 for (i = 0; i < X86_VENDOR_NUM; i++) {
192 if (cpu_devs[i]) { 195 if (cpu_devs[i]) {
193 if (!strcmp(v,cpu_devs[i]->c_ident[0]) || 196 if (!strcmp(v, cpu_devs[i]->c_ident[0]) ||
194 (cpu_devs[i]->c_ident[1] && 197 (cpu_devs[i]->c_ident[1] &&
195 !strcmp(v,cpu_devs[i]->c_ident[1]))) { 198 !strcmp(v, cpu_devs[i]->c_ident[1]))) {
196 c->x86_vendor = i; 199 c->x86_vendor = i;
197 if (!early) 200 if (!early)
198 this_cpu = cpu_devs[i]; 201 this_cpu = cpu_devs[i];
@@ -210,7 +213,7 @@ static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c, int early)
210} 213}
211 214
212 215
213static int __init x86_fxsr_setup(char * s) 216static int __init x86_fxsr_setup(char *s)
214{ 217{
215 setup_clear_cpu_cap(X86_FEATURE_FXSR); 218 setup_clear_cpu_cap(X86_FEATURE_FXSR);
216 setup_clear_cpu_cap(X86_FEATURE_XMM); 219 setup_clear_cpu_cap(X86_FEATURE_XMM);
@@ -219,7 +222,7 @@ static int __init x86_fxsr_setup(char * s)
219__setup("nofxsr", x86_fxsr_setup); 222__setup("nofxsr", x86_fxsr_setup);
220 223
221 224
222static int __init x86_sep_setup(char * s) 225static int __init x86_sep_setup(char *s)
223{ 226{
224 setup_clear_cpu_cap(X86_FEATURE_SEP); 227 setup_clear_cpu_cap(X86_FEATURE_SEP);
225 return 1; 228 return 1;
@@ -308,12 +311,15 @@ static void __cpuinit early_get_cap(struct cpuinfo_x86 *c)
308 311
309} 312}
310 313
311/* Do minimum CPU detection early. 314/*
312 Fields really needed: vendor, cpuid_level, family, model, mask, cache alignment. 315 * Do minimum CPU detection early.
313 The others are not touched to avoid unwanted side effects. 316 * Fields really needed: vendor, cpuid_level, family, model, mask,
314 317 * cache alignment.
315 WARNING: this function is only called on the BP. Don't add code here 318 * The others are not touched to avoid unwanted side effects.
316 that is supposed to run on all CPUs. */ 319 *
320 * WARNING: this function is only called on the BP. Don't add code here
321 * that is supposed to run on all CPUs.
322 */
317static void __init early_cpu_detect(void) 323static void __init early_cpu_detect(void)
318{ 324{
319 struct cpuinfo_x86 *c = &boot_cpu_data; 325 struct cpuinfo_x86 *c = &boot_cpu_data;
@@ -335,7 +341,7 @@ static void __init early_cpu_detect(void)
335 early_get_cap(c); 341 early_get_cap(c);
336} 342}
337 343
338static void __cpuinit generic_identify(struct cpuinfo_x86 * c) 344static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
339{ 345{
340 u32 tfms, xlvl; 346 u32 tfms, xlvl;
341 unsigned int ebx; 347 unsigned int ebx;
@@ -346,13 +352,12 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 * c)
346 (unsigned int *)&c->x86_vendor_id[0], 352 (unsigned int *)&c->x86_vendor_id[0],
347 (unsigned int *)&c->x86_vendor_id[8], 353 (unsigned int *)&c->x86_vendor_id[8],
348 (unsigned int *)&c->x86_vendor_id[4]); 354 (unsigned int *)&c->x86_vendor_id[4]);
349 355
350 get_cpu_vendor(c, 0); 356 get_cpu_vendor(c, 0);
351 /* Initialize the standard set of capabilities */ 357 /* Initialize the standard set of capabilities */
352 /* Note that the vendor-specific code below might override */ 358 /* Note that the vendor-specific code below might override */
353
354 /* Intel-defined flags: level 0x00000001 */ 359 /* Intel-defined flags: level 0x00000001 */
355 if ( c->cpuid_level >= 0x00000001 ) { 360 if (c->cpuid_level >= 0x00000001) {
356 u32 capability, excap; 361 u32 capability, excap;
357 cpuid(0x00000001, &tfms, &ebx, &excap, &capability); 362 cpuid(0x00000001, &tfms, &ebx, &excap, &capability);
358 c->x86_capability[0] = capability; 363 c->x86_capability[0] = capability;
@@ -378,12 +383,12 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 * c)
378 383
379 /* AMD-defined flags: level 0x80000001 */ 384 /* AMD-defined flags: level 0x80000001 */
380 xlvl = cpuid_eax(0x80000000); 385 xlvl = cpuid_eax(0x80000000);
381 if ( (xlvl & 0xffff0000) == 0x80000000 ) { 386 if ((xlvl & 0xffff0000) == 0x80000000) {
382 if ( xlvl >= 0x80000001 ) { 387 if (xlvl >= 0x80000001) {
383 c->x86_capability[1] = cpuid_edx(0x80000001); 388 c->x86_capability[1] = cpuid_edx(0x80000001);
384 c->x86_capability[6] = cpuid_ecx(0x80000001); 389 c->x86_capability[6] = cpuid_ecx(0x80000001);
385 } 390 }
386 if ( xlvl >= 0x80000004 ) 391 if (xlvl >= 0x80000004)
387 get_model_name(c); /* Default name */ 392 get_model_name(c); /* Default name */
388 } 393 }
389 394
@@ -397,12 +402,12 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 * c)
397 402
398static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c) 403static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
399{ 404{
400 if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr ) { 405 if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr) {
401 /* Disable processor serial number */ 406 /* Disable processor serial number */
402 unsigned long lo,hi; 407 unsigned long lo, hi;
403 rdmsr(MSR_IA32_BBL_CR_CTL,lo,hi); 408 rdmsr(MSR_IA32_BBL_CR_CTL, lo, hi);
404 lo |= 0x200000; 409 lo |= 0x200000;
405 wrmsr(MSR_IA32_BBL_CR_CTL,lo,hi); 410 wrmsr(MSR_IA32_BBL_CR_CTL, lo, hi);
406 printk(KERN_NOTICE "CPU serial number disabled.\n"); 411 printk(KERN_NOTICE "CPU serial number disabled.\n");
407 clear_bit(X86_FEATURE_PN, c->x86_capability); 412 clear_bit(X86_FEATURE_PN, c->x86_capability);
408 413
@@ -439,9 +444,11 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
439 memset(&c->x86_capability, 0, sizeof c->x86_capability); 444 memset(&c->x86_capability, 0, sizeof c->x86_capability);
440 445
441 if (!have_cpuid_p()) { 446 if (!have_cpuid_p()) {
442 /* First of all, decide if this is a 486 or higher */ 447 /*
443 /* It's a 486 if we can modify the AC flag */ 448 * First of all, decide if this is a 486 or higher
444 if ( flag_is_changeable_p(X86_EFLAGS_AC) ) 449 * It's a 486 if we can modify the AC flag
450 */
451 if (flag_is_changeable_p(X86_EFLAGS_AC))
445 c->x86 = 4; 452 c->x86 = 4;
446 else 453 else
447 c->x86 = 3; 454 c->x86 = 3;
@@ -474,10 +481,10 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
474 */ 481 */
475 482
476 /* If the model name is still unset, do table lookup. */ 483 /* If the model name is still unset, do table lookup. */
477 if ( !c->x86_model_id[0] ) { 484 if (!c->x86_model_id[0]) {
478 char *p; 485 char *p;
479 p = table_lookup_model(c); 486 p = table_lookup_model(c);
480 if ( p ) 487 if (p)
481 strcpy(c->x86_model_id, p); 488 strcpy(c->x86_model_id, p);
482 else 489 else
483 /* Last resort... */ 490 /* Last resort... */
@@ -491,9 +498,9 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
491 * common between the CPUs. The first time this routine gets 498 * common between the CPUs. The first time this routine gets
492 * executed, c == &boot_cpu_data. 499 * executed, c == &boot_cpu_data.
493 */ 500 */
494 if ( c != &boot_cpu_data ) { 501 if (c != &boot_cpu_data) {
495 /* AND the already accumulated flags with these */ 502 /* AND the already accumulated flags with these */
496 for ( i = 0 ; i < NCAPINTS ; i++ ) 503 for (i = 0 ; i < NCAPINTS ; i++)
497 boot_cpu_data.x86_capability[i] &= c->x86_capability[i]; 504 boot_cpu_data.x86_capability[i] &= c->x86_capability[i];
498 } 505 }
499 506
@@ -537,7 +544,7 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
537 544
538 if (smp_num_siblings == 1) { 545 if (smp_num_siblings == 1) {
539 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); 546 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n");
540 } else if (smp_num_siblings > 1 ) { 547 } else if (smp_num_siblings > 1) {
541 548
542 if (smp_num_siblings > NR_CPUS) { 549 if (smp_num_siblings > NR_CPUS) {
543 printk(KERN_WARNING "CPU: Unsupported number of the " 550 printk(KERN_WARNING "CPU: Unsupported number of the "
@@ -592,7 +599,7 @@ void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
592 else 599 else
593 printk("%s", c->x86_model_id); 600 printk("%s", c->x86_model_id);
594 601
595 if (c->x86_mask || c->cpuid_level >= 0) 602 if (c->x86_mask || c->cpuid_level >= 0)
596 printk(" stepping %02x\n", c->x86_mask); 603 printk(" stepping %02x\n", c->x86_mask);
597 else 604 else
598 printk("\n"); 605 printk("\n");
@@ -653,7 +660,7 @@ void __cpuinit cpu_init(void)
653{ 660{
654 int cpu = smp_processor_id(); 661 int cpu = smp_processor_id();
655 struct task_struct *curr = current; 662 struct task_struct *curr = current;
656 struct tss_struct * t = &per_cpu(init_tss, cpu); 663 struct tss_struct *t = &per_cpu(init_tss, cpu);
657 struct thread_struct *thread = &curr->thread; 664 struct thread_struct *thread = &curr->thread;
658 665
659 if (cpu_test_and_set(cpu, cpu_initialized)) { 666 if (cpu_test_and_set(cpu, cpu_initialized)) {
@@ -679,7 +686,7 @@ void __cpuinit cpu_init(void)
679 enter_lazy_tlb(&init_mm, curr); 686 enter_lazy_tlb(&init_mm, curr);
680 687
681 load_sp0(t, thread); 688 load_sp0(t, thread);
682 set_tss_desc(cpu,t); 689 set_tss_desc(cpu, t);
683 load_TR_desc(); 690 load_TR_desc();
684 load_LDT(&init_mm.context); 691 load_LDT(&init_mm.context);
685 692