diff options
author | Yinghai Lu <yhlu.kernel@gmail.com> | 2008-08-24 05:01:50 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-16 10:53:02 -0400 |
commit | fa2bd35a8d5c88c03b638c72daf7f38a132d0e8c (patch) | |
tree | a83e22fef3a1b71df13d5f5232eb3089a429f047 /arch | |
parent | f28c0ae21d80ffd6eb0987901c5273843387e341 (diff) |
x86: merge APIC_init_uniprocessor
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/apic_32.c | 51 | ||||
-rw-r--r-- | arch/x86/kernel/apic_64.c | 48 |
2 files changed, 90 insertions, 9 deletions
diff --git a/arch/x86/kernel/apic_32.c b/arch/x86/kernel/apic_32.c index bfac26a16099..8f8b0e1f3eb3 100644 --- a/arch/x86/kernel/apic_32.c +++ b/arch/x86/kernel/apic_32.c | |||
@@ -1355,6 +1355,17 @@ int apic_version[MAX_APICS]; | |||
1355 | 1355 | ||
1356 | int __init APIC_init_uniprocessor(void) | 1356 | int __init APIC_init_uniprocessor(void) |
1357 | { | 1357 | { |
1358 | #ifdef CONFIG_X86_64 | ||
1359 | if (disable_apic) { | ||
1360 | printk(KERN_INFO "Apic disabled\n"); | ||
1361 | return -1; | ||
1362 | } | ||
1363 | if (!cpu_has_apic) { | ||
1364 | disable_apic = 1; | ||
1365 | printk(KERN_INFO "Apic disabled by BIOS\n"); | ||
1366 | return -1; | ||
1367 | } | ||
1368 | #else | ||
1358 | if (!smp_found_config && !cpu_has_apic) | 1369 | if (!smp_found_config && !cpu_has_apic) |
1359 | return -1; | 1370 | return -1; |
1360 | 1371 | ||
@@ -1368,34 +1379,62 @@ int __init APIC_init_uniprocessor(void) | |||
1368 | clear_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC); | 1379 | clear_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC); |
1369 | return -1; | 1380 | return -1; |
1370 | } | 1381 | } |
1382 | #endif | ||
1371 | 1383 | ||
1384 | #ifdef HAVE_X2APIC | ||
1385 | enable_IR_x2apic(); | ||
1386 | #endif | ||
1387 | #ifdef CONFIG_X86_64 | ||
1388 | setup_apic_routing(); | ||
1389 | #endif | ||
1372 | verify_local_APIC(); | 1390 | verify_local_APIC(); |
1373 | |||
1374 | connect_bsp_APIC(); | 1391 | connect_bsp_APIC(); |
1375 | 1392 | ||
1393 | #ifdef CONFIG_X86_64 | ||
1394 | apic_write(APIC_ID, SET_APIC_ID(boot_cpu_physical_apicid)); | ||
1395 | #else | ||
1376 | /* | 1396 | /* |
1377 | * Hack: In case of kdump, after a crash, kernel might be booting | 1397 | * Hack: In case of kdump, after a crash, kernel might be booting |
1378 | * on a cpu with non-zero lapic id. But boot_cpu_physical_apicid | 1398 | * on a cpu with non-zero lapic id. But boot_cpu_physical_apicid |
1379 | * might be zero if read from MP tables. Get it from LAPIC. | 1399 | * might be zero if read from MP tables. Get it from LAPIC. |
1380 | */ | 1400 | */ |
1381 | #ifdef CONFIG_CRASH_DUMP | 1401 | # ifdef CONFIG_CRASH_DUMP |
1382 | boot_cpu_physical_apicid = read_apic_id(); | 1402 | boot_cpu_physical_apicid = read_apic_id(); |
1403 | # endif | ||
1383 | #endif | 1404 | #endif |
1384 | physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); | 1405 | physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); |
1385 | |||
1386 | setup_local_APIC(); | 1406 | setup_local_APIC(); |
1387 | 1407 | ||
1408 | #ifdef CONFIG_X86_64 | ||
1409 | /* | ||
1410 | * Now enable IO-APICs, actually call clear_IO_APIC | ||
1411 | * We need clear_IO_APIC before enabling vector on BP | ||
1412 | */ | ||
1413 | if (!skip_ioapic_setup && nr_ioapics) | ||
1414 | enable_IO_APIC(); | ||
1415 | #endif | ||
1416 | |||
1388 | #ifdef CONFIG_X86_IO_APIC | 1417 | #ifdef CONFIG_X86_IO_APIC |
1389 | if (!smp_found_config || skip_ioapic_setup || !nr_ioapics) | 1418 | if (!smp_found_config || skip_ioapic_setup || !nr_ioapics) |
1390 | #endif | 1419 | #endif |
1391 | localise_nmi_watchdog(); | 1420 | localise_nmi_watchdog(); |
1392 | end_local_APIC_setup(); | 1421 | end_local_APIC_setup(); |
1422 | |||
1393 | #ifdef CONFIG_X86_IO_APIC | 1423 | #ifdef CONFIG_X86_IO_APIC |
1394 | if (smp_found_config) | 1424 | if (smp_found_config && !skip_ioapic_setup && nr_ioapics) |
1395 | if (!skip_ioapic_setup && nr_ioapics) | 1425 | setup_IO_APIC(); |
1396 | setup_IO_APIC(); | 1426 | # ifdef CONFIG_X86_64 |
1427 | else | ||
1428 | nr_ioapics = 0; | ||
1429 | # endif | ||
1397 | #endif | 1430 | #endif |
1431 | |||
1432 | #ifdef CONFIG_X86_64 | ||
1433 | setup_boot_APIC_clock(); | ||
1434 | check_nmi_watchdog(); | ||
1435 | #else | ||
1398 | setup_boot_clock(); | 1436 | setup_boot_clock(); |
1437 | #endif | ||
1399 | 1438 | ||
1400 | return 0; | 1439 | return 0; |
1401 | } | 1440 | } |
diff --git a/arch/x86/kernel/apic_64.c b/arch/x86/kernel/apic_64.c index dca6c246e731..16a30c22b07c 100644 --- a/arch/x86/kernel/apic_64.c +++ b/arch/x86/kernel/apic_64.c | |||
@@ -1351,6 +1351,7 @@ int apic_version[MAX_APICS]; | |||
1351 | 1351 | ||
1352 | int __init APIC_init_uniprocessor(void) | 1352 | int __init APIC_init_uniprocessor(void) |
1353 | { | 1353 | { |
1354 | #ifdef CONFIG_X86_64 | ||
1354 | if (disable_apic) { | 1355 | if (disable_apic) { |
1355 | printk(KERN_INFO "Apic disabled\n"); | 1356 | printk(KERN_INFO "Apic disabled\n"); |
1356 | return -1; | 1357 | return -1; |
@@ -1360,37 +1361,78 @@ int __init APIC_init_uniprocessor(void) | |||
1360 | printk(KERN_INFO "Apic disabled by BIOS\n"); | 1361 | printk(KERN_INFO "Apic disabled by BIOS\n"); |
1361 | return -1; | 1362 | return -1; |
1362 | } | 1363 | } |
1364 | #else | ||
1365 | if (!smp_found_config && !cpu_has_apic) | ||
1366 | return -1; | ||
1367 | |||
1368 | /* | ||
1369 | * Complain if the BIOS pretends there is one. | ||
1370 | */ | ||
1371 | if (!cpu_has_apic && | ||
1372 | APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) { | ||
1373 | printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n", | ||
1374 | boot_cpu_physical_apicid); | ||
1375 | clear_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC); | ||
1376 | return -1; | ||
1377 | } | ||
1378 | #endif | ||
1379 | |||
1363 | #ifdef HAVE_X2APIC | 1380 | #ifdef HAVE_X2APIC |
1364 | enable_IR_x2apic(); | 1381 | enable_IR_x2apic(); |
1365 | #endif | 1382 | #endif |
1383 | #ifdef CONFIG_X86_64 | ||
1366 | setup_apic_routing(); | 1384 | setup_apic_routing(); |
1385 | #endif | ||
1367 | 1386 | ||
1368 | verify_local_APIC(); | 1387 | verify_local_APIC(); |
1369 | |||
1370 | connect_bsp_APIC(); | 1388 | connect_bsp_APIC(); |
1371 | 1389 | ||
1372 | physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); | 1390 | #ifdef CONFIG_X86_64 |
1373 | apic_write(APIC_ID, SET_APIC_ID(boot_cpu_physical_apicid)); | 1391 | apic_write(APIC_ID, SET_APIC_ID(boot_cpu_physical_apicid)); |
1374 | 1392 | #else | |
1393 | /* | ||
1394 | * Hack: In case of kdump, after a crash, kernel might be booting | ||
1395 | * on a cpu with non-zero lapic id. But boot_cpu_physical_apicid | ||
1396 | * might be zero if read from MP tables. Get it from LAPIC. | ||
1397 | */ | ||
1398 | # ifdef CONFIG_CRASH_DUMP | ||
1399 | boot_cpu_physical_apicid = read_apic_id(); | ||
1400 | # endif | ||
1401 | #endif | ||
1402 | physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); | ||
1375 | setup_local_APIC(); | 1403 | setup_local_APIC(); |
1376 | 1404 | ||
1405 | #ifdef CONFIG_X86_64 | ||
1377 | /* | 1406 | /* |
1378 | * Now enable IO-APICs, actually call clear_IO_APIC | 1407 | * Now enable IO-APICs, actually call clear_IO_APIC |
1379 | * We need clear_IO_APIC before enabling vector on BP | 1408 | * We need clear_IO_APIC before enabling vector on BP |
1380 | */ | 1409 | */ |
1381 | if (!skip_ioapic_setup && nr_ioapics) | 1410 | if (!skip_ioapic_setup && nr_ioapics) |
1382 | enable_IO_APIC(); | 1411 | enable_IO_APIC(); |
1412 | #endif | ||
1383 | 1413 | ||
1414 | #ifdef CONFIG_X86_IO_APIC | ||
1384 | if (!smp_found_config || skip_ioapic_setup || !nr_ioapics) | 1415 | if (!smp_found_config || skip_ioapic_setup || !nr_ioapics) |
1416 | #endif | ||
1385 | localise_nmi_watchdog(); | 1417 | localise_nmi_watchdog(); |
1386 | end_local_APIC_setup(); | 1418 | end_local_APIC_setup(); |
1387 | 1419 | ||
1420 | #ifdef CONFIG_X86_IO_APIC | ||
1388 | if (smp_found_config && !skip_ioapic_setup && nr_ioapics) | 1421 | if (smp_found_config && !skip_ioapic_setup && nr_ioapics) |
1389 | setup_IO_APIC(); | 1422 | setup_IO_APIC(); |
1423 | # ifdef CONFIG_X86_64 | ||
1390 | else | 1424 | else |
1391 | nr_ioapics = 0; | 1425 | nr_ioapics = 0; |
1426 | # endif | ||
1427 | #endif | ||
1428 | |||
1429 | #ifdef CONFIG_X86_64 | ||
1392 | setup_boot_APIC_clock(); | 1430 | setup_boot_APIC_clock(); |
1393 | check_nmi_watchdog(); | 1431 | check_nmi_watchdog(); |
1432 | #else | ||
1433 | setup_boot_clock(); | ||
1434 | #endif | ||
1435 | |||
1394 | return 0; | 1436 | return 0; |
1395 | } | 1437 | } |
1396 | 1438 | ||