aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386')
-rw-r--r--arch/i386/kernel/cpu/common.c5
-rw-r--r--arch/i386/kernel/cpu/intel.c2
-rw-r--r--arch/i386/kernel/cpu/mtrr/generic.c22
-rw-r--r--arch/i386/kernel/cpu/mtrr/main.c76
-rw-r--r--arch/i386/kernel/cpu/mtrr/mtrr.h1
-rw-r--r--arch/i386/kernel/smpboot.c18
-rw-r--r--arch/i386/kernel/time.c2
-rw-r--r--arch/i386/kernel/timers/timer_hpet.c4
-rw-r--r--arch/i386/kernel/vmlinux.lds.S3
-rw-r--r--arch/i386/mm/ioremap.c6
-rw-r--r--arch/i386/power/cpu.c1
11 files changed, 90 insertions, 50 deletions
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index 2203a9d20212..4553ffd94b1f 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -435,6 +435,11 @@ void __devinit identify_cpu(struct cpuinfo_x86 *c)
435 if (c == &boot_cpu_data) 435 if (c == &boot_cpu_data)
436 sysenter_setup(); 436 sysenter_setup();
437 enable_sep_cpu(); 437 enable_sep_cpu();
438
439 if (c == &boot_cpu_data)
440 mtrr_bp_init();
441 else
442 mtrr_ap_init();
438} 443}
439 444
440#ifdef CONFIG_X86_HT 445#ifdef CONFIG_X86_HT
diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c
index 96a75d045835..a2c33c1a46c5 100644
--- a/arch/i386/kernel/cpu/intel.c
+++ b/arch/i386/kernel/cpu/intel.c
@@ -25,7 +25,7 @@ extern int trap_init_f00f_bug(void);
25/* 25/*
26 * Alignment at which movsl is preferred for bulk memory copies. 26 * Alignment at which movsl is preferred for bulk memory copies.
27 */ 27 */
28struct movsl_mask movsl_mask; 28struct movsl_mask movsl_mask __read_mostly;
29#endif 29#endif
30 30
31void __devinit early_intel_workaround(struct cpuinfo_x86 *c) 31void __devinit early_intel_workaround(struct cpuinfo_x86 *c)
diff --git a/arch/i386/kernel/cpu/mtrr/generic.c b/arch/i386/kernel/cpu/mtrr/generic.c
index 64d91f73a0a4..169ac8e0db68 100644
--- a/arch/i386/kernel/cpu/mtrr/generic.c
+++ b/arch/i386/kernel/cpu/mtrr/generic.c
@@ -67,13 +67,6 @@ void __init get_mtrr_state(void)
67 mtrr_state.enabled = (lo & 0xc00) >> 10; 67 mtrr_state.enabled = (lo & 0xc00) >> 10;
68} 68}
69 69
70/* Free resources associated with a struct mtrr_state */
71void __init finalize_mtrr_state(void)
72{
73 kfree(mtrr_state.var_ranges);
74 mtrr_state.var_ranges = NULL;
75}
76
77/* Some BIOS's are fucked and don't set all MTRRs the same! */ 70/* Some BIOS's are fucked and don't set all MTRRs the same! */
78void __init mtrr_state_warn(void) 71void __init mtrr_state_warn(void)
79{ 72{
@@ -334,6 +327,9 @@ static void generic_set_mtrr(unsigned int reg, unsigned long base,
334*/ 327*/
335{ 328{
336 unsigned long flags; 329 unsigned long flags;
330 struct mtrr_var_range *vr;
331
332 vr = &mtrr_state.var_ranges[reg];
337 333
338 local_irq_save(flags); 334 local_irq_save(flags);
339 prepare_set(); 335 prepare_set();
@@ -342,11 +338,15 @@ static void generic_set_mtrr(unsigned int reg, unsigned long base,
342 /* The invalid bit is kept in the mask, so we simply clear the 338 /* The invalid bit is kept in the mask, so we simply clear the
343 relevant mask register to disable a range. */ 339 relevant mask register to disable a range. */
344 mtrr_wrmsr(MTRRphysMask_MSR(reg), 0, 0); 340 mtrr_wrmsr(MTRRphysMask_MSR(reg), 0, 0);
341 memset(vr, 0, sizeof(struct mtrr_var_range));
345 } else { 342 } else {
346 mtrr_wrmsr(MTRRphysBase_MSR(reg), base << PAGE_SHIFT | type, 343 vr->base_lo = base << PAGE_SHIFT | type;
347 (base & size_and_mask) >> (32 - PAGE_SHIFT)); 344 vr->base_hi = (base & size_and_mask) >> (32 - PAGE_SHIFT);
348 mtrr_wrmsr(MTRRphysMask_MSR(reg), -size << PAGE_SHIFT | 0x800, 345 vr->mask_lo = -size << PAGE_SHIFT | 0x800;
349 (-size & size_and_mask) >> (32 - PAGE_SHIFT)); 346 vr->mask_hi = (-size & size_and_mask) >> (32 - PAGE_SHIFT);
347
348 mtrr_wrmsr(MTRRphysBase_MSR(reg), vr->base_lo, vr->base_hi);
349 mtrr_wrmsr(MTRRphysMask_MSR(reg), vr->mask_lo, vr->mask_hi);
350 } 350 }
351 351
352 post_set(); 352 post_set();
diff --git a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
index d66b09e0c820..764cac64e211 100644
--- a/arch/i386/kernel/cpu/mtrr/main.c
+++ b/arch/i386/kernel/cpu/mtrr/main.c
@@ -332,6 +332,8 @@ int mtrr_add_page(unsigned long base, unsigned long size,
332 332
333 error = -EINVAL; 333 error = -EINVAL;
334 334
335 /* No CPU hotplug when we change MTRR entries */
336 lock_cpu_hotplug();
335 /* Search for existing MTRR */ 337 /* Search for existing MTRR */
336 down(&main_lock); 338 down(&main_lock);
337 for (i = 0; i < num_var_ranges; ++i) { 339 for (i = 0; i < num_var_ranges; ++i) {
@@ -372,6 +374,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
372 error = i; 374 error = i;
373 out: 375 out:
374 up(&main_lock); 376 up(&main_lock);
377 unlock_cpu_hotplug();
375 return error; 378 return error;
376} 379}
377 380
@@ -461,6 +464,8 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
461 return -ENXIO; 464 return -ENXIO;
462 465
463 max = num_var_ranges; 466 max = num_var_ranges;
467 /* No CPU hotplug when we change MTRR entries */
468 lock_cpu_hotplug();
464 down(&main_lock); 469 down(&main_lock);
465 if (reg < 0) { 470 if (reg < 0) {
466 /* Search for existing MTRR */ 471 /* Search for existing MTRR */
@@ -501,6 +506,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
501 error = reg; 506 error = reg;
502 out: 507 out:
503 up(&main_lock); 508 up(&main_lock);
509 unlock_cpu_hotplug();
504 return error; 510 return error;
505} 511}
506/** 512/**
@@ -544,21 +550,9 @@ static void __init init_ifs(void)
544 centaur_init_mtrr(); 550 centaur_init_mtrr();
545} 551}
546 552
547static void __init init_other_cpus(void) 553/* The suspend/resume methods are only for CPU without MTRR. CPU using generic
548{ 554 * MTRR driver doesn't require this
549 if (use_intel()) 555 */
550 get_mtrr_state();
551
552 /* bring up the other processors */
553 set_mtrr(~0U,0,0,0);
554
555 if (use_intel()) {
556 finalize_mtrr_state();
557 mtrr_state_warn();
558 }
559}
560
561
562struct mtrr_value { 556struct mtrr_value {
563 mtrr_type ltype; 557 mtrr_type ltype;
564 unsigned long lbase; 558 unsigned long lbase;
@@ -611,13 +605,13 @@ static struct sysdev_driver mtrr_sysdev_driver = {
611 605
612 606
613/** 607/**
614 * mtrr_init - initialize mtrrs on the boot CPU 608 * mtrr_bp_init - initialize mtrrs on the boot CPU
615 * 609 *
616 * This needs to be called early; before any of the other CPUs are 610 * This needs to be called early; before any of the other CPUs are
617 * initialized (i.e. before smp_init()). 611 * initialized (i.e. before smp_init()).
618 * 612 *
619 */ 613 */
620static int __init mtrr_init(void) 614void __init mtrr_bp_init(void)
621{ 615{
622 init_ifs(); 616 init_ifs();
623 617
@@ -674,12 +668,48 @@ static int __init mtrr_init(void)
674 if (mtrr_if) { 668 if (mtrr_if) {
675 set_num_var_ranges(); 669 set_num_var_ranges();
676 init_table(); 670 init_table();
677 init_other_cpus(); 671 if (use_intel())
678 672 get_mtrr_state();
679 return sysdev_driver_register(&cpu_sysdev_class,
680 &mtrr_sysdev_driver);
681 } 673 }
682 return -ENXIO;
683} 674}
684 675
685subsys_initcall(mtrr_init); 676void mtrr_ap_init(void)
677{
678 unsigned long flags;
679
680 if (!mtrr_if || !use_intel())
681 return;
682 /*
683 * Ideally we should hold main_lock here to avoid mtrr entries changed,
684 * but this routine will be called in cpu boot time, holding the lock
685 * breaks it. This routine is called in two cases: 1.very earily time
686 * of software resume, when there absolutely isn't mtrr entry changes;
687 * 2.cpu hotadd time. We let mtrr_add/del_page hold cpuhotplug lock to
688 * prevent mtrr entry changes
689 */
690 local_irq_save(flags);
691
692 mtrr_if->set_all();
693
694 local_irq_restore(flags);
695}
696
697static int __init mtrr_init_finialize(void)
698{
699 if (!mtrr_if)
700 return 0;
701 if (use_intel())
702 mtrr_state_warn();
703 else {
704 /* The CPUs haven't MTRR and seemes not support SMP. They have
705 * specific drivers, we use a tricky method to support
706 * suspend/resume for them.
707 * TBD: is there any system with such CPU which supports
708 * suspend/resume? if no, we should remove the code.
709 */
710 sysdev_driver_register(&cpu_sysdev_class,
711 &mtrr_sysdev_driver);
712 }
713 return 0;
714}
715subsys_initcall(mtrr_init_finialize);
diff --git a/arch/i386/kernel/cpu/mtrr/mtrr.h b/arch/i386/kernel/cpu/mtrr/mtrr.h
index de1351245599..99c9f2682041 100644
--- a/arch/i386/kernel/cpu/mtrr/mtrr.h
+++ b/arch/i386/kernel/cpu/mtrr/mtrr.h
@@ -91,7 +91,6 @@ extern struct mtrr_ops * mtrr_if;
91 91
92extern unsigned int num_var_ranges; 92extern unsigned int num_var_ranges;
93 93
94void finalize_mtrr_state(void);
95void mtrr_state_warn(void); 94void mtrr_state_warn(void);
96char *mtrr_attrib_to_str(int x); 95char *mtrr_attrib_to_str(int x);
97void mtrr_wrmsr(unsigned, unsigned, unsigned); 96void mtrr_wrmsr(unsigned, unsigned, unsigned);
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index d66bf489a2e9..8ac8e9fd5614 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -68,21 +68,21 @@ EXPORT_SYMBOL(smp_num_siblings);
68#endif 68#endif
69 69
70/* Package ID of each logical CPU */ 70/* Package ID of each logical CPU */
71int phys_proc_id[NR_CPUS] = {[0 ... NR_CPUS-1] = BAD_APICID}; 71int phys_proc_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID};
72EXPORT_SYMBOL(phys_proc_id); 72EXPORT_SYMBOL(phys_proc_id);
73 73
74/* Core ID of each logical CPU */ 74/* Core ID of each logical CPU */
75int cpu_core_id[NR_CPUS] = {[0 ... NR_CPUS-1] = BAD_APICID}; 75int cpu_core_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID};
76EXPORT_SYMBOL(cpu_core_id); 76EXPORT_SYMBOL(cpu_core_id);
77 77
78cpumask_t cpu_sibling_map[NR_CPUS]; 78cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
79EXPORT_SYMBOL(cpu_sibling_map); 79EXPORT_SYMBOL(cpu_sibling_map);
80 80
81cpumask_t cpu_core_map[NR_CPUS]; 81cpumask_t cpu_core_map[NR_CPUS] __read_mostly;
82EXPORT_SYMBOL(cpu_core_map); 82EXPORT_SYMBOL(cpu_core_map);
83 83
84/* bitmap of online cpus */ 84/* bitmap of online cpus */
85cpumask_t cpu_online_map; 85cpumask_t cpu_online_map __read_mostly;
86EXPORT_SYMBOL(cpu_online_map); 86EXPORT_SYMBOL(cpu_online_map);
87 87
88cpumask_t cpu_callin_map; 88cpumask_t cpu_callin_map;
@@ -100,7 +100,7 @@ static int __devinitdata tsc_sync_disabled;
100struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned; 100struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned;
101EXPORT_SYMBOL(cpu_data); 101EXPORT_SYMBOL(cpu_data);
102 102
103u8 x86_cpu_to_apicid[NR_CPUS] = 103u8 x86_cpu_to_apicid[NR_CPUS] __read_mostly =
104 { [0 ... NR_CPUS-1] = 0xff }; 104 { [0 ... NR_CPUS-1] = 0xff };
105EXPORT_SYMBOL(x86_cpu_to_apicid); 105EXPORT_SYMBOL(x86_cpu_to_apicid);
106 106
@@ -550,10 +550,10 @@ extern struct {
550#ifdef CONFIG_NUMA 550#ifdef CONFIG_NUMA
551 551
552/* which logical CPUs are on which nodes */ 552/* which logical CPUs are on which nodes */
553cpumask_t node_2_cpu_mask[MAX_NUMNODES] = 553cpumask_t node_2_cpu_mask[MAX_NUMNODES] __read_mostly =
554 { [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE }; 554 { [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE };
555/* which node each logical CPU is on */ 555/* which node each logical CPU is on */
556int cpu_2_node[NR_CPUS] = { [0 ... NR_CPUS-1] = 0 }; 556int cpu_2_node[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0 };
557EXPORT_SYMBOL(cpu_2_node); 557EXPORT_SYMBOL(cpu_2_node);
558 558
559/* set up a mapping between cpu and node. */ 559/* set up a mapping between cpu and node. */
@@ -581,7 +581,7 @@ static inline void unmap_cpu_to_node(int cpu)
581 581
582#endif /* CONFIG_NUMA */ 582#endif /* CONFIG_NUMA */
583 583
584u8 cpu_2_logical_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID }; 584u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = BAD_APICID };
585 585
586static void map_cpu_to_logical_apicid(void) 586static void map_cpu_to_logical_apicid(void)
587{ 587{
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
index 2854c357377f..0ee9dee8af06 100644
--- a/arch/i386/kernel/time.c
+++ b/arch/i386/kernel/time.c
@@ -91,7 +91,7 @@ EXPORT_SYMBOL(rtc_lock);
91DEFINE_SPINLOCK(i8253_lock); 91DEFINE_SPINLOCK(i8253_lock);
92EXPORT_SYMBOL(i8253_lock); 92EXPORT_SYMBOL(i8253_lock);
93 93
94struct timer_opts *cur_timer = &timer_none; 94struct timer_opts *cur_timer __read_mostly = &timer_none;
95 95
96/* 96/*
97 * This is a special lock that is owned by the CPU and holds the index 97 * This is a special lock that is owned by the CPU and holds the index
diff --git a/arch/i386/kernel/timers/timer_hpet.c b/arch/i386/kernel/timers/timer_hpet.c
index d766e0963ac1..ef8dac5dd33b 100644
--- a/arch/i386/kernel/timers/timer_hpet.c
+++ b/arch/i386/kernel/timers/timer_hpet.c
@@ -18,7 +18,7 @@
18#include "mach_timer.h" 18#include "mach_timer.h"
19#include <asm/hpet.h> 19#include <asm/hpet.h>
20 20
21static unsigned long hpet_usec_quotient; /* convert hpet clks to usec */ 21static unsigned long __read_mostly hpet_usec_quotient; /* convert hpet clks to usec */
22static unsigned long tsc_hpet_quotient; /* convert tsc to hpet clks */ 22static unsigned long tsc_hpet_quotient; /* convert tsc to hpet clks */
23static unsigned long hpet_last; /* hpet counter value at last tick*/ 23static unsigned long hpet_last; /* hpet counter value at last tick*/
24static unsigned long last_tsc_low; /* lsb 32 bits of Time Stamp Counter */ 24static unsigned long last_tsc_low; /* lsb 32 bits of Time Stamp Counter */
@@ -180,7 +180,7 @@ static int __init init_hpet(char* override)
180/************************************************************/ 180/************************************************************/
181 181
182/* tsc timer_opts struct */ 182/* tsc timer_opts struct */
183static struct timer_opts timer_hpet = { 183static struct timer_opts timer_hpet __read_mostly = {
184 .name = "hpet", 184 .name = "hpet",
185 .mark_offset = mark_offset_hpet, 185 .mark_offset = mark_offset_hpet,
186 .get_offset = get_offset_hpet, 186 .get_offset = get_offset_hpet,
diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S
index 7e01a528a83a..761972f8cb6c 100644
--- a/arch/i386/kernel/vmlinux.lds.S
+++ b/arch/i386/kernel/vmlinux.lds.S
@@ -57,6 +57,9 @@ SECTIONS
57 *(.data.cacheline_aligned) 57 *(.data.cacheline_aligned)
58 } 58 }
59 59
60 /* rarely changed data like cpu maps */
61 . = ALIGN(32);
62 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { *(.data.read_mostly) }
60 _edata = .; /* End of data section */ 63 _edata = .; /* End of data section */
61 64
62 . = ALIGN(THREAD_SIZE); /* init_task */ 65 . = ALIGN(THREAD_SIZE); /* init_task */
diff --git a/arch/i386/mm/ioremap.c b/arch/i386/mm/ioremap.c
index 6b25afc933b6..f379b8d67558 100644
--- a/arch/i386/mm/ioremap.c
+++ b/arch/i386/mm/ioremap.c
@@ -228,7 +228,8 @@ EXPORT_SYMBOL(ioremap_nocache);
228void iounmap(volatile void __iomem *addr) 228void iounmap(volatile void __iomem *addr)
229{ 229{
230 struct vm_struct *p; 230 struct vm_struct *p;
231 if ((void __force *) addr <= high_memory) 231
232 if ((void __force *)addr <= high_memory)
232 return; 233 return;
233 234
234 /* 235 /*
@@ -241,9 +242,10 @@ void iounmap(volatile void __iomem *addr)
241 return; 242 return;
242 243
243 write_lock(&vmlist_lock); 244 write_lock(&vmlist_lock);
244 p = __remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr)); 245 p = __remove_vm_area((void *)(PAGE_MASK & (unsigned long __force)addr));
245 if (!p) { 246 if (!p) {
246 printk(KERN_WARNING "iounmap: bad address %p\n", addr); 247 printk(KERN_WARNING "iounmap: bad address %p\n", addr);
248 dump_stack();
247 goto out_unlock; 249 goto out_unlock;
248 } 250 }
249 251
diff --git a/arch/i386/power/cpu.c b/arch/i386/power/cpu.c
index 0e6b45b61251..c547c1af6fa1 100644
--- a/arch/i386/power/cpu.c
+++ b/arch/i386/power/cpu.c
@@ -137,6 +137,7 @@ void __restore_processor_state(struct saved_context *ctxt)
137 137
138 fix_processor_context(); 138 fix_processor_context();
139 do_fpu_end(); 139 do_fpu_end();
140 mtrr_ap_init();
140} 141}
141 142
142void restore_processor_state(void) 143void restore_processor_state(void)