[RFC -tip] x86,apic -- reduce disable_apic usage

From: Cyrill Gorcunov
Date: Sun Jul 05 2009 - 12:20:56 EST


Here is an attempt to bring more consistency for apic
presence check. I hope I covered all the code flows.
Though it's RFC. Please review and test if possible.

-- Cyrill
---
Instead of messing with (cpu_has_apic|disable_apic)
to check if we have apic functional, better to distinguish
them by logical kind. cpu_has_apic -- to check if we may
use apic functionality, disable_apic -- to note that
apic was disabled via command line.

Other interesting (and a side one) issue I guess is that
X86_FEATURE_APIC feature bit is always cleared if apic
disabled via command line but not the reverse.

Eventually this allow us to save a few lines of code.

Also:

1) No need to clear bit twice in APIC_init_uniprocessor.
cpu_has_apic check for boot_cpu_data bit anyway.
2) Don't check for disable_apic in print_all_ICs. It's
already set. Always.
3) Don't set disable_apic if there is no MPS support built in
with acpi enabled. Even having SMP built kernel we're
protected by acpi_lapic check in smp_sanity_check.
At least we should be.

Signed-off-by: Cyrill Gorcunov <gorcunov@xxxxxxxxxx>
---
arch/x86/kernel/apic/apic.c | 3 +--
arch/x86/kernel/apic/io_apic.c | 6 +++---
arch/x86/kernel/setup.c | 6 +-----
3 files changed, 5 insertions(+), 10 deletions(-)

Index: linux-2.6.git/arch/x86/kernel/apic/apic.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/apic/apic.c
+++ linux-2.6.git/arch/x86/kernel/apic/apic.c
@@ -1173,7 +1173,7 @@ void __cpuinit setup_local_APIC(void)
unsigned int value;
int i, j;

- if (disable_apic) {
+ if (!cpu_has_apic) {
arch_disable_smp_support();
return;
}
@@ -1651,7 +1651,6 @@ int __init APIC_init_uniprocessor(void)
APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) {
pr_err("BIOS bug, local APIC 0x%x not detected!...\n",
boot_cpu_physical_apicid);
- clear_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
return -1;
}
#endif
Index: linux-2.6.git/arch/x86/kernel/apic/io_apic.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/apic/io_apic.c
+++ linux-2.6.git/arch/x86/kernel/apic/io_apic.c
@@ -1884,7 +1884,7 @@ __apicdebuginit(int) print_all_ICs(void)
print_PIC();

/* don't print out if apic is not there */
- if (!cpu_has_apic || disable_apic)
+ if (!cpu_has_apic)
return 0;

print_all_local_APICs();
@@ -3261,7 +3261,7 @@ static int msi_compose_msg(struct pci_de
int err;
unsigned dest;

- if (disable_apic)
+ if (!cpu_has_apic)
return -ENXIO;

cfg = irq_cfg(irq);
@@ -3714,7 +3714,7 @@ int arch_setup_ht_irq(unsigned int irq,
struct irq_cfg *cfg;
int err;

- if (disable_apic)
+ if (!cpu_has_apic)
return -ENXIO;

cfg = irq_cfg(irq);
Index: linux-2.6.git/arch/x86/kernel/setup.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/setup.c
+++ linux-2.6.git/arch/x86/kernel/setup.c
@@ -795,12 +795,8 @@ void __init setup_arch(char **cmdline_p)
/* after early param, so could get panic from serial */
reserve_early_setup_data();

- if (acpi_mps_check()) {
-#ifdef CONFIG_X86_LOCAL_APIC
- disable_apic = 1;
-#endif
+ if (acpi_mps_check())
setup_clear_cpu_cap(X86_FEATURE_APIC);
- }

#ifdef CONFIG_PCI
if (pci_early_dump_regs)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/