aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/smpboot_64.c
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2008-03-19 13:26:11 -0400
committerIngo Molnar <mingo@elte.hu>2008-04-17 11:41:04 -0400
commit8aef135c73436fa46fdb4dc8aba49d5539dee72d (patch)
treed733efeff177fc41ccf110dfb1d805b81518f8ef /arch/x86/kernel/smpboot_64.c
parent9f3734f631267d2f36008833b62670ca342ac000 (diff)
x86: merge native_smp_prepare_cpus
With the previous changes, code for native_smp_prepare_cpus() in i386 and x86_64 now look very similar. merge them into smpboot.c. Minor differences are inside ifdef Signed-off-by: Glauber Costa <gcosta@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/smpboot_64.c')
-rw-r--r--arch/x86/kernel/smpboot_64.c141
1 files changed, 0 insertions, 141 deletions
diff --git a/arch/x86/kernel/smpboot_64.c b/arch/x86/kernel/smpboot_64.c
index 775244545ffa..66b55629733b 100644
--- a/arch/x86/kernel/smpboot_64.c
+++ b/arch/x86/kernel/smpboot_64.c
@@ -71,144 +71,3 @@ int smp_threads_ready;
71 71
72cycles_t cacheflush_time; 72cycles_t cacheflush_time;
73unsigned long cache_decay_ticks; 73unsigned long cache_decay_ticks;
74
75static int boot_cpu_logical_apicid;
76/*
77 * Fall back to non SMP mode after errors.
78 *
79 * RED-PEN audit/test this more. I bet there is more state messed up here.
80 */
81static __init void disable_smp(void)
82{
83 cpu_present_map = cpumask_of_cpu(0);
84 cpu_possible_map = cpumask_of_cpu(0);
85 if (smp_found_config)
86 phys_cpu_present_map =
87 physid_mask_of_physid(boot_cpu_physical_apicid);
88 else
89 phys_cpu_present_map = physid_mask_of_physid(0);
90 cpu_set(0, per_cpu(cpu_sibling_map, 0));
91 cpu_set(0, per_cpu(cpu_core_map, 0));
92}
93
94/*
95 * Various sanity checks.
96 */
97static int __init smp_sanity_check(unsigned max_cpus)
98{
99 if (!physid_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
100 printk("weird, boot CPU (#%d) not listed by the BIOS.\n",
101 hard_smp_processor_id());
102 physid_set(hard_smp_processor_id(), phys_cpu_present_map);
103 }
104
105 /*
106 * If we couldn't find an SMP configuration at boot time,
107 * get out of here now!
108 */
109 if (!smp_found_config && !acpi_lapic) {
110 printk(KERN_NOTICE "SMP motherboard not detected.\n");
111 disable_smp();
112 if (APIC_init_uniprocessor())
113 printk(KERN_NOTICE "Local APIC not detected."
114 " Using dummy APIC emulation.\n");
115 return -1;
116 }
117
118 /*
119 * Should not be necessary because the MP table should list the boot
120 * CPU too, but we do it for the sake of robustness anyway.
121 */
122 if (!check_phys_apicid_present(boot_cpu_physical_apicid)) {
123 printk(KERN_NOTICE
124 "weird, boot CPU (#%d) not listed by the BIOS.\n",
125 boot_cpu_physical_apicid);
126 physid_set(hard_smp_processor_id(), phys_cpu_present_map);
127 }
128
129 /*
130 * If we couldn't find a local APIC, then get out of here now!
131 */
132 if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) &&
133 !cpu_has_apic) {
134 printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
135 boot_cpu_physical_apicid);
136 printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
137 smpboot_clear_io_apic();
138 return -1;
139 }
140
141 verify_local_APIC();
142
143 /*
144 * If SMP should be disabled, then really disable it!
145 */
146 if (!max_cpus) {
147 printk(KERN_INFO "SMP mode deactivated, forcing use of dummy APIC emulation.\n");
148 smpboot_clear_io_apic();
149 return -1;
150 }
151
152 return 0;
153}
154
155static void __init smp_cpu_index_default(void)
156{
157 int i;
158 struct cpuinfo_x86 *c;
159
160 for_each_cpu_mask(i, cpu_possible_map) {
161 c = &cpu_data(i);
162 /* mark all to hotplug */
163 c->cpu_index = NR_CPUS;
164 }
165}
166
167/*
168 * Prepare for SMP bootup. The MP table or ACPI has been read
169 * earlier. Just do some sanity checking here and enable APIC mode.
170 */
171void __init native_smp_prepare_cpus(unsigned int max_cpus)
172{
173 nmi_watchdog_default();
174 smp_cpu_index_default();
175 cpu_callin_map = cpumask_of_cpu(0);
176 mb();
177
178 current_cpu_data = boot_cpu_data;
179 boot_cpu_logical_apicid = logical_smp_processor_id();
180 current_thread_info()->cpu = 0; /* needed? */
181 set_cpu_sibling_map(0);
182
183 if (smp_sanity_check(max_cpus) < 0) {
184 printk(KERN_INFO "SMP disabled\n");
185 disable_smp();
186 return;
187 }
188
189 if (GET_APIC_ID(apic_read(APIC_ID)) != boot_cpu_physical_apicid) {
190 panic("Boot APIC ID in local APIC unexpected (%d vs %d)",
191 GET_APIC_ID(apic_read(APIC_ID)), boot_cpu_physical_apicid);
192 /* Or can we switch back to PIC here? */
193 }
194
195 /*
196 * Switch from PIC to APIC mode.
197 */
198 setup_local_APIC();
199
200 /*
201 * Enable IO APIC before setting up error vector
202 */
203 if (!skip_ioapic_setup && nr_ioapics)
204 enable_IO_APIC();
205 end_local_APIC_setup();
206
207 /*
208 * Set up local APIC timer on boot CPU.
209 */
210
211 setup_boot_clock();
212 printk(KERN_INFO "CPU%d: ", 0);
213 print_cpu_info(&cpu_data(0));
214}