diff options
author | Yinghai Lu <yinghai@kernel.org> | 2009-05-02 13:40:57 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-11 05:29:23 -0400 |
commit | 4401da6111ac58f94234417427d06a72c4048c74 (patch) | |
tree | 8e42dbef7e8dcc9a82cc43971cdfb68f1a35e6fc /arch/x86/kernel/apic | |
parent | 61fe91e1319556f32bebfd7ed2c68ef02e2c17f7 (diff) |
x86: read apic ID in the !acpi_lapic case
Ed found that on 32-bit, boot_cpu_physical_apicid is not read right,
when the mptable is broken.
Interestingly, actually three paths use/set it:
1. acpi: at that time that is already read from reg
2. mptable: only read from mptable
3. no madt, and no mptable, that use default apic id 0 for 64-bit, -1 for 32-bit
so we could read the apic id for the 2/3 path. We trust the hardware
register more than we trust a BIOS data structure (the mptable).
We can also avoid the double set_fixmap() when acpi_lapic
is used, and also need to move cpu_has_apic earlier and
call apic_disable().
Also when need to update the apic id, we'd better read and
set the apic version as well - so that quirks are applied precisely.
v2: make path 3 with 64bit, use -1 as apic id, so could read it later.
v3: fix whitespace problem pointed out by Ed Swierk
[ Impact: get correct apic id for bsp other than acpi path ]
Reported-by: Ed Swierk <eswierk@aristanetworks.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
LKML-Reference: <49FC85A9.2070702@kernel.org>
[ v4: sanity-check in the ACPI case too ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/apic')
-rw-r--r-- | arch/x86/kernel/apic/apic.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index e258bedce7cb..1ee966f4ae95 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c | |||
@@ -1456,7 +1456,6 @@ static int __init detect_init_APIC(void) | |||
1456 | } | 1456 | } |
1457 | 1457 | ||
1458 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; | 1458 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; |
1459 | boot_cpu_physical_apicid = 0; | ||
1460 | return 0; | 1459 | return 0; |
1461 | } | 1460 | } |
1462 | #else | 1461 | #else |
@@ -1570,6 +1569,8 @@ void __init early_init_lapic_mapping(void) | |||
1570 | */ | 1569 | */ |
1571 | void __init init_apic_mappings(void) | 1570 | void __init init_apic_mappings(void) |
1572 | { | 1571 | { |
1572 | unsigned int new_apicid; | ||
1573 | |||
1573 | if (x2apic_mode) { | 1574 | if (x2apic_mode) { |
1574 | boot_cpu_physical_apicid = read_apic_id(); | 1575 | boot_cpu_physical_apicid = read_apic_id(); |
1575 | return; | 1576 | return; |
@@ -1586,21 +1587,31 @@ void __init init_apic_mappings(void) | |||
1586 | } else | 1587 | } else |
1587 | apic_phys = mp_lapic_addr; | 1588 | apic_phys = mp_lapic_addr; |
1588 | 1589 | ||
1589 | set_fixmap_nocache(FIX_APIC_BASE, apic_phys); | 1590 | /* lets check if we may NOP'ify apic operations */ |
1591 | if (!cpu_has_apic) { | ||
1592 | pr_info("APIC: disable apic facility\n"); | ||
1593 | apic_disable(); | ||
1594 | return; | ||
1595 | } | ||
1596 | |||
1597 | /* | ||
1598 | * acpi lapic path already maps that address in | ||
1599 | * acpi_register_lapic_address() | ||
1600 | */ | ||
1601 | if (!acpi_lapic) | ||
1602 | set_fixmap_nocache(FIX_APIC_BASE, apic_phys); | ||
1603 | |||
1590 | apic_printk(APIC_VERBOSE, "mapped APIC to %08lx (%08lx)\n", | 1604 | apic_printk(APIC_VERBOSE, "mapped APIC to %08lx (%08lx)\n", |
1591 | APIC_BASE, apic_phys); | 1605 | APIC_BASE, apic_phys); |
1592 | |||
1593 | /* | 1606 | /* |
1594 | * Fetch the APIC ID of the BSP in case we have a | 1607 | * Fetch the APIC ID of the BSP in case we have a |
1595 | * default configuration (or the MP table is broken). | 1608 | * default configuration (or the MP table is broken). |
1596 | */ | 1609 | */ |
1597 | if (boot_cpu_physical_apicid == -1U) | 1610 | new_apicid = read_apic_id(); |
1598 | boot_cpu_physical_apicid = read_apic_id(); | 1611 | if (boot_cpu_physical_apicid != new_apicid) { |
1599 | 1612 | boot_cpu_physical_apicid = new_apicid; | |
1600 | /* lets check if we may to NOP'ify apic operations */ | 1613 | apic_version[new_apicid] = |
1601 | if (!cpu_has_apic) { | 1614 | GET_APIC_VERSION(apic_read(APIC_LVR)); |
1602 | pr_info("APIC: disable apic facility\n"); | ||
1603 | apic_disable(); | ||
1604 | } | 1615 | } |
1605 | } | 1616 | } |
1606 | 1617 | ||