x86: x2apic, IR: Clean up X86_X2APIC and INTR_REMAP config checks
Add x2apic_supported() to clean up CONFIG_X86_X2APIC checks. Fix CONFIG_INTR_REMAP checks. [ Impact: cleanup ] Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com> Cc: dwmw2@infradead.org Cc: Suresh Siddha <suresh.b.siddha@intel.com> Cc: Weidong Han <weidong.han@intel.com> LKML-Reference: <20090420200450.128993000@linux-os.sc.intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
committed by
Ingo Molnar
parent
667c5296cc
commit
fc1edaf9e7
@@ -107,8 +107,7 @@ extern u32 native_safe_apic_wait_icr_idle(void);
|
|||||||
extern void native_apic_icr_write(u32 low, u32 id);
|
extern void native_apic_icr_write(u32 low, u32 id);
|
||||||
extern u64 native_apic_icr_read(void);
|
extern u64 native_apic_icr_read(void);
|
||||||
|
|
||||||
#define EIM_8BIT_APIC_ID 0
|
extern int x2apic_mode;
|
||||||
#define EIM_32BIT_APIC_ID 1
|
|
||||||
|
|
||||||
#ifdef CONFIG_X86_X2APIC
|
#ifdef CONFIG_X86_X2APIC
|
||||||
/*
|
/*
|
||||||
@@ -166,7 +165,7 @@ static inline u64 native_x2apic_icr_read(void)
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int x2apic, x2apic_phys;
|
extern int x2apic_phys;
|
||||||
extern void check_x2apic(void);
|
extern void check_x2apic(void);
|
||||||
extern void enable_x2apic(void);
|
extern void enable_x2apic(void);
|
||||||
extern void x2apic_icr_write(u32 low, u32 id);
|
extern void x2apic_icr_write(u32 low, u32 id);
|
||||||
@@ -182,6 +181,8 @@ static inline int x2apic_enabled(void)
|
|||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define x2apic_supported() (cpu_has_x2apic)
|
||||||
#else
|
#else
|
||||||
static inline void check_x2apic(void)
|
static inline void check_x2apic(void)
|
||||||
{
|
{
|
||||||
@@ -194,9 +195,8 @@ static inline int x2apic_enabled(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define x2apic 0
|
|
||||||
#define x2apic_preenabled 0
|
#define x2apic_preenabled 0
|
||||||
|
#define x2apic_supported() 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void enable_IR_x2apic(void);
|
extern void enable_IR_x2apic(void);
|
||||||
|
@@ -161,7 +161,6 @@ extern int io_apic_set_pci_routing(int ioapic, int pin, int irq,
|
|||||||
extern int (*ioapic_renumber_irq)(int ioapic, int irq);
|
extern int (*ioapic_renumber_irq)(int ioapic, int irq);
|
||||||
extern void ioapic_init_mappings(void);
|
extern void ioapic_init_mappings(void);
|
||||||
|
|
||||||
#ifdef CONFIG_X86_64
|
|
||||||
extern struct IO_APIC_route_entry **alloc_ioapic_entries(void);
|
extern struct IO_APIC_route_entry **alloc_ioapic_entries(void);
|
||||||
extern void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries);
|
extern void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries);
|
||||||
extern int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
|
extern int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
|
||||||
@@ -169,7 +168,6 @@ extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
|
|||||||
extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
|
extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
|
||||||
extern void reinit_intr_remapped_IO_APIC(int intr_remapping,
|
extern void reinit_intr_remapped_IO_APIC(int intr_remapping,
|
||||||
struct IO_APIC_route_entry **ioapic_entries);
|
struct IO_APIC_route_entry **ioapic_entries);
|
||||||
#endif
|
|
||||||
|
|
||||||
extern void probe_nr_irqs_gsi(void);
|
extern void probe_nr_irqs_gsi(void);
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#ifndef _ASM_X86_IRQ_REMAPPING_H
|
#ifndef _ASM_X86_IRQ_REMAPPING_H
|
||||||
#define _ASM_X86_IRQ_REMAPPING_H
|
#define _ASM_X86_IRQ_REMAPPING_H
|
||||||
|
|
||||||
#define IRTE_DEST(dest) ((x2apic) ? dest : dest << 8)
|
#define IRTE_DEST(dest) ((x2apic_mode) ? dest : dest << 8)
|
||||||
|
|
||||||
#endif /* _ASM_X86_IRQ_REMAPPING_H */
|
#endif /* _ASM_X86_IRQ_REMAPPING_H */
|
||||||
|
@@ -134,8 +134,8 @@ static __init int setup_apicpmtimer(char *s)
|
|||||||
__setup("apicpmtimer", setup_apicpmtimer);
|
__setup("apicpmtimer", setup_apicpmtimer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int x2apic_mode;
|
||||||
#ifdef CONFIG_X86_X2APIC
|
#ifdef CONFIG_X86_X2APIC
|
||||||
int x2apic;
|
|
||||||
/* x2apic enabled before OS handover */
|
/* x2apic enabled before OS handover */
|
||||||
static int x2apic_preenabled;
|
static int x2apic_preenabled;
|
||||||
static int disable_x2apic;
|
static int disable_x2apic;
|
||||||
@@ -858,7 +858,7 @@ void clear_local_APIC(void)
|
|||||||
u32 v;
|
u32 v;
|
||||||
|
|
||||||
/* APIC hasn't been mapped yet */
|
/* APIC hasn't been mapped yet */
|
||||||
if (!x2apic && !apic_phys)
|
if (!x2apic_mode && !apic_phys)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
maxlvt = lapic_get_maxlvt();
|
maxlvt = lapic_get_maxlvt();
|
||||||
@@ -1330,7 +1330,7 @@ void check_x2apic(void)
|
|||||||
{
|
{
|
||||||
if (x2apic_enabled()) {
|
if (x2apic_enabled()) {
|
||||||
pr_info("x2apic enabled by BIOS, switching to x2apic ops\n");
|
pr_info("x2apic enabled by BIOS, switching to x2apic ops\n");
|
||||||
x2apic_preenabled = x2apic = 1;
|
x2apic_preenabled = x2apic_mode = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1338,7 +1338,7 @@ void enable_x2apic(void)
|
|||||||
{
|
{
|
||||||
int msr, msr2;
|
int msr, msr2;
|
||||||
|
|
||||||
if (!x2apic)
|
if (!x2apic_mode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rdmsr(MSR_IA32_APICBASE, msr, msr2);
|
rdmsr(MSR_IA32_APICBASE, msr, msr2);
|
||||||
@@ -1390,25 +1390,17 @@ void __init enable_IR_x2apic(void)
|
|||||||
mask_IO_APIC_setup(ioapic_entries);
|
mask_IO_APIC_setup(ioapic_entries);
|
||||||
mask_8259A();
|
mask_8259A();
|
||||||
|
|
||||||
#ifdef CONFIG_X86_X2APIC
|
ret = enable_intr_remapping(x2apic_supported());
|
||||||
if (cpu_has_x2apic)
|
|
||||||
ret = enable_intr_remapping(EIM_32BIT_APIC_ID);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
ret = enable_intr_remapping(EIM_8BIT_APIC_ID);
|
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto end_restore;
|
goto end_restore;
|
||||||
|
|
||||||
pr_info("Enabled Interrupt-remapping\n");
|
pr_info("Enabled Interrupt-remapping\n");
|
||||||
|
|
||||||
#ifdef CONFIG_X86_X2APIC
|
if (x2apic_supported() && !x2apic_mode) {
|
||||||
if (cpu_has_x2apic && !x2apic) {
|
x2apic_mode = 1;
|
||||||
x2apic = 1;
|
|
||||||
enable_x2apic();
|
enable_x2apic();
|
||||||
pr_info("Enabled x2apic\n");
|
pr_info("Enabled x2apic\n");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
end_restore:
|
end_restore:
|
||||||
if (ret)
|
if (ret)
|
||||||
@@ -1576,7 +1568,7 @@ void __init early_init_lapic_mapping(void)
|
|||||||
*/
|
*/
|
||||||
void __init init_apic_mappings(void)
|
void __init init_apic_mappings(void)
|
||||||
{
|
{
|
||||||
if (x2apic) {
|
if (x2apic_mode) {
|
||||||
boot_cpu_physical_apicid = read_apic_id();
|
boot_cpu_physical_apicid = read_apic_id();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2010,10 +2002,10 @@ static int lapic_suspend(struct sys_device *dev, pm_message_t state)
|
|||||||
|
|
||||||
local_irq_save(flags);
|
local_irq_save(flags);
|
||||||
disable_local_APIC();
|
disable_local_APIC();
|
||||||
#ifdef CONFIG_INTR_REMAP
|
|
||||||
if (intr_remapping_enabled)
|
if (intr_remapping_enabled)
|
||||||
disable_intr_remapping();
|
disable_intr_remapping();
|
||||||
#endif
|
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2023,8 +2015,6 @@ static int lapic_resume(struct sys_device *dev)
|
|||||||
unsigned int l, h;
|
unsigned int l, h;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int maxlvt;
|
int maxlvt;
|
||||||
|
|
||||||
#ifdef CONFIG_INTR_REMAP
|
|
||||||
int ret;
|
int ret;
|
||||||
struct IO_APIC_route_entry **ioapic_entries = NULL;
|
struct IO_APIC_route_entry **ioapic_entries = NULL;
|
||||||
|
|
||||||
@@ -2050,17 +2040,8 @@ static int lapic_resume(struct sys_device *dev)
|
|||||||
mask_8259A();
|
mask_8259A();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x2apic)
|
if (x2apic_mode)
|
||||||
enable_x2apic();
|
enable_x2apic();
|
||||||
#else
|
|
||||||
if (!apic_pm_state.active)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
local_irq_save(flags);
|
|
||||||
if (x2apic)
|
|
||||||
enable_x2apic();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
else {
|
else {
|
||||||
/*
|
/*
|
||||||
* Make sure the APICBASE points to the right address
|
* Make sure the APICBASE points to the right address
|
||||||
@@ -2098,18 +2079,12 @@ static int lapic_resume(struct sys_device *dev)
|
|||||||
apic_write(APIC_ESR, 0);
|
apic_write(APIC_ESR, 0);
|
||||||
apic_read(APIC_ESR);
|
apic_read(APIC_ESR);
|
||||||
|
|
||||||
#ifdef CONFIG_INTR_REMAP
|
|
||||||
if (intr_remapping_enabled) {
|
if (intr_remapping_enabled) {
|
||||||
if (x2apic)
|
reenable_intr_remapping(x2apic_mode);
|
||||||
reenable_intr_remapping(EIM_32BIT_APIC_ID);
|
|
||||||
else
|
|
||||||
reenable_intr_remapping(EIM_8BIT_APIC_ID);
|
|
||||||
|
|
||||||
unmask_8259A();
|
unmask_8259A();
|
||||||
restore_IO_APIC_setup(ioapic_entries);
|
restore_IO_APIC_setup(ioapic_entries);
|
||||||
free_ioapic_entries(ioapic_entries);
|
free_ioapic_entries(ioapic_entries);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
|
|
||||||
|
@@ -736,7 +736,6 @@ static int __init ioapic_pirq_setup(char *str)
|
|||||||
__setup("pirq=", ioapic_pirq_setup);
|
__setup("pirq=", ioapic_pirq_setup);
|
||||||
#endif /* CONFIG_X86_32 */
|
#endif /* CONFIG_X86_32 */
|
||||||
|
|
||||||
#ifdef CONFIG_INTR_REMAP
|
|
||||||
struct IO_APIC_route_entry **alloc_ioapic_entries(void)
|
struct IO_APIC_route_entry **alloc_ioapic_entries(void)
|
||||||
{
|
{
|
||||||
int apic;
|
int apic;
|
||||||
@@ -857,7 +856,6 @@ void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries)
|
|||||||
|
|
||||||
kfree(ioapic_entries);
|
kfree(ioapic_entries);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the IRQ entry number of a certain pin.
|
* Find the IRQ entry number of a certain pin.
|
||||||
|
@@ -50,7 +50,7 @@ static struct apic *apic_probe[] __initdata = {
|
|||||||
void __init default_setup_apic_routing(void)
|
void __init default_setup_apic_routing(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_X86_X2APIC
|
#ifdef CONFIG_X86_X2APIC
|
||||||
if (x2apic && (apic != &apic_x2apic_phys &&
|
if (x2apic_mode && (apic != &apic_x2apic_phys &&
|
||||||
#ifdef CONFIG_X86_UV
|
#ifdef CONFIG_X86_UV
|
||||||
apic != &apic_x2apic_uv_x &&
|
apic != &apic_x2apic_uv_x &&
|
||||||
#endif
|
#endif
|
||||||
|
@@ -158,6 +158,8 @@ static inline struct intel_iommu *map_ioapic_to_ir(int apic)
|
|||||||
}
|
}
|
||||||
#define irq_remapped(irq) (0)
|
#define irq_remapped(irq) (0)
|
||||||
#define enable_intr_remapping(mode) (-1)
|
#define enable_intr_remapping(mode) (-1)
|
||||||
|
#define disable_intr_remapping() (0)
|
||||||
|
#define reenable_intr_remapping(mode) (0)
|
||||||
#define intr_remapping_enabled (0)
|
#define intr_remapping_enabled (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user