Commit e589c9e1 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'x86-apic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 apic updates from Thomas Gleixner:
 "After stopping the full x86/apic branch, I took some time to go
  through the first block of patches again, which are mostly cleanups
  and preparatory work for the irqdomain conversion and ioapic hotplug
  support.

  Unfortunaly one of the real problematic commits was right at the
  beginning, so I rebased this portion of the pending patches without
  the offenders.

  It would be great to get this into 3.19.  That makes reworking the
  problematic parts simpler.  The usual tip testing did not unearth any
  issues and it is fully bisectible now.

  I'm pretty confident that this wont affect the calmness of the xmas
  season.

  Changes:
   - Split the convoluted io_apic.c code into domain specific parts
     (vector, ioapic, msi, htirq)
   - Introduce proper helper functions to retrieve irq specific data
     instead of open coded dereferencing of pointers
   - Preparatory work for ioapic hotplug and irqdomain conversion
   - Removal of the non functional pci-ioapic driver
   - Removal of unused irq entry stubs
   - Make native_smp_prepare_cpus() preemtible to avoid GFP_ATOMIC
     allocations for everything which is called from there.
   - Small cleanups and fixes"

* 'x86-apic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (36 commits)
  iommu/amd: Use helpers to access irq_cfg data structure associated with IRQ
  iommu/vt-d: Use helpers to access irq_cfg data structure associated with IRQ
  x86: irq_remapping: Use helpers to access irq_cfg data structure associated with IRQ
  x86, irq: Use helpers to access irq_cfg data structure associated with IRQ
  x86, irq: Make MSI and HT_IRQ indepenent of X86_IO_APIC
  x86, irq: Move IRQ initialization routines from io_apic.c into vector.c
  x86, irq: Move IOAPIC related declarations from hw_irq.h into io_apic.h
  x86, irq: Move HT IRQ related code from io_apic.c into htirq.c
  x86, irq: Move PCI MSI related code from io_apic.c into msi.c
  x86, irq: Replace printk(KERN_LVL) with pr_lvl() utilities
  x86, irq: Make UP version of irq_complete_move() an inline stub
  x86, irq: Move local APIC related code from io_apic.c into vector.c
  x86, irq: Introduce helpers to access struct irq_cfg
  x86, irq: Protect __clear_irq_vector() with vector_lock
  x86, irq: Rename local APIC related functions in io_apic.c as apic_xxx()
  x86, irq: Refine hw_irq.h to prepare for irqdomain support
  x86, irq: Convert irq_2_pin list to generic list
  x86, irq: Kill useless parameter 'irq_attr' of IO_APIC_get_PCI_irq_vector()
  x86, irq, acpi: Get rid of special handling of GSI for ACPI SCI
  x86, irq: Introduce helper to check whether an IOAPIC has been registered
  ...
parents 4bb9374e 719b530c
...@@ -883,11 +883,11 @@ config X86_UP_IOAPIC ...@@ -883,11 +883,11 @@ config X86_UP_IOAPIC
config X86_LOCAL_APIC config X86_LOCAL_APIC
def_bool y def_bool y
depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC || PCI_MSI depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC || PCI_MSI
select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
config X86_IO_APIC config X86_IO_APIC
def_bool y def_bool X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_IOAPIC
depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_IOAPIC || PCI_MSI depends on X86_LOCAL_APIC
select GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
select IRQ_DOMAIN select IRQ_DOMAIN
config X86_REROUTE_FOR_BROKEN_BOOT_IRQS config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
......
...@@ -94,30 +94,7 @@ extern void trace_call_function_single_interrupt(void); ...@@ -94,30 +94,7 @@ extern void trace_call_function_single_interrupt(void);
#define trace_kvm_posted_intr_ipi kvm_posted_intr_ipi #define trace_kvm_posted_intr_ipi kvm_posted_intr_ipi
#endif /* CONFIG_TRACING */ #endif /* CONFIG_TRACING */
/* IOAPIC */ #ifdef CONFIG_IRQ_REMAP
#define IO_APIC_IRQ(x) (((x) >= NR_IRQS_LEGACY) || ((1<<(x)) & io_apic_irqs))
extern unsigned long io_apic_irqs;
extern void setup_IO_APIC(void);
extern void disable_IO_APIC(void);
struct io_apic_irq_attr {
int ioapic;
int ioapic_pin;
int trigger;
int polarity;
};
static inline void set_io_apic_irq_attr(struct io_apic_irq_attr *irq_attr,
int ioapic, int ioapic_pin,
int trigger, int polarity)
{
irq_attr->ioapic = ioapic;
irq_attr->ioapic_pin = ioapic_pin;
irq_attr->trigger = trigger;
irq_attr->polarity = polarity;
}
/* Intel specific interrupt remapping information */ /* Intel specific interrupt remapping information */
struct irq_2_iommu { struct irq_2_iommu {
struct intel_iommu *iommu; struct intel_iommu *iommu;
...@@ -131,14 +108,12 @@ struct irq_2_irte { ...@@ -131,14 +108,12 @@ struct irq_2_irte {
u16 devid; /* Device ID for IRTE table */ u16 devid; /* Device ID for IRTE table */
u16 index; /* Index into IRTE table*/ u16 index; /* Index into IRTE table*/
}; };
#endif /* CONFIG_IRQ_REMAP */
#ifdef CONFIG_X86_LOCAL_APIC
struct irq_data;
/*
* This is performance-critical, we want to do it O(1)
*
* Most irqs are mapped 1:1 with pins.
*/
struct irq_cfg { struct irq_cfg {
struct irq_pin_list *irq_2_pin;
cpumask_var_t domain; cpumask_var_t domain;
cpumask_var_t old_domain; cpumask_var_t old_domain;
u8 vector; u8 vector;
...@@ -150,18 +125,39 @@ struct irq_cfg { ...@@ -150,18 +125,39 @@ struct irq_cfg {
struct irq_2_irte irq_2_irte; struct irq_2_irte irq_2_irte;
}; };
#endif #endif
union {
#ifdef CONFIG_X86_IO_APIC
struct {
struct list_head irq_2_pin;
};
#endif
};
}; };
extern struct irq_cfg *irq_cfg(unsigned int irq);
extern struct irq_cfg *irqd_cfg(struct irq_data *irq_data);
extern struct irq_cfg *alloc_irq_and_cfg_at(unsigned int at, int node);
extern void lock_vector_lock(void);
extern void unlock_vector_lock(void);
extern int assign_irq_vector(int, struct irq_cfg *, const struct cpumask *); extern int assign_irq_vector(int, struct irq_cfg *, const struct cpumask *);
extern void clear_irq_vector(int irq, struct irq_cfg *cfg);
extern void setup_vector_irq(int cpu);
#ifdef CONFIG_SMP
extern void send_cleanup_vector(struct irq_cfg *); extern void send_cleanup_vector(struct irq_cfg *);
extern void irq_complete_move(struct irq_cfg *cfg);
#else
static inline void send_cleanup_vector(struct irq_cfg *c) { }
static inline void irq_complete_move(struct irq_cfg *c) { }
#endif
struct irq_data; extern int apic_retrigger_irq(struct irq_data *data);
int __ioapic_set_affinity(struct irq_data *, const struct cpumask *, extern void apic_ack_edge(struct irq_data *data);
unsigned int *dest_id); extern int apic_set_affinity(struct irq_data *data, const struct cpumask *mask,
extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin, struct io_apic_irq_attr *irq_attr); unsigned int *dest_id);
extern void setup_ioapic_dest(void); #else /* CONFIG_X86_LOCAL_APIC */
static inline void lock_vector_lock(void) {}
extern void enable_IO_APIC(void); static inline void unlock_vector_lock(void) {}
#endif /* CONFIG_X86_LOCAL_APIC */
/* Statistics */ /* Statistics */
extern atomic_t irq_err_count; extern atomic_t irq_err_count;
...@@ -185,7 +181,8 @@ extern __visible void smp_call_function_single_interrupt(struct pt_regs *); ...@@ -185,7 +181,8 @@ extern __visible void smp_call_function_single_interrupt(struct pt_regs *);
extern __visible void smp_invalidate_interrupt(struct pt_regs *); extern __visible void smp_invalidate_interrupt(struct pt_regs *);
#endif #endif
extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void); extern void (*__initconst interrupt[FIRST_SYSTEM_VECTOR
- FIRST_EXTERNAL_VECTOR])(void);
#ifdef CONFIG_TRACING #ifdef CONFIG_TRACING
#define trace_interrupt interrupt #define trace_interrupt interrupt
#endif #endif
...@@ -195,17 +192,6 @@ extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void); ...@@ -195,17 +192,6 @@ extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
typedef int vector_irq_t[NR_VECTORS]; typedef int vector_irq_t[NR_VECTORS];
DECLARE_PER_CPU(vector_irq_t, vector_irq); DECLARE_PER_CPU(vector_irq_t, vector_irq);
extern void setup_vector_irq(int cpu);
#ifdef CONFIG_X86_IO_APIC
extern void lock_vector_lock(void);
extern void unlock_vector_lock(void);
extern void __setup_vector_irq(int cpu);
#else
static inline void lock_vector_lock(void) {}
static inline void unlock_vector_lock(void) {}
static inline void __setup_vector_irq(int cpu) {}
#endif
#endif /* !ASSEMBLY_ */ #endif /* !ASSEMBLY_ */
......
...@@ -132,6 +132,10 @@ extern int noioapicquirk; ...@@ -132,6 +132,10 @@ extern int noioapicquirk;
/* -1 if "noapic" boot option passed */ /* -1 if "noapic" boot option passed */
extern int noioapicreroute; extern int noioapicreroute;
extern unsigned long io_apic_irqs;
#define IO_APIC_IRQ(x) (((x) >= NR_IRQS_LEGACY) || ((1 << (x)) & io_apic_irqs))
/* /*
* If we use the IO-APIC for IRQ routing, disable automatic * If we use the IO-APIC for IRQ routing, disable automatic
* assignment of PCI IRQ's. * assignment of PCI IRQ's.
...@@ -139,18 +143,15 @@ extern int noioapicreroute; ...@@ -139,18 +143,15 @@ extern int noioapicreroute;
#define io_apic_assign_pci_irqs \ #define io_apic_assign_pci_irqs \
(mp_irq_entries && !skip_ioapic_setup && io_apic_irqs) (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
struct io_apic_irq_attr;
struct irq_cfg; struct irq_cfg;
extern void ioapic_insert_resources(void); extern void ioapic_insert_resources(void);
extern int arch_early_ioapic_init(void);
extern int native_setup_ioapic_entry(int, struct IO_APIC_route_entry *, extern int native_setup_ioapic_entry(int, struct IO_APIC_route_entry *,
unsigned int, int, unsigned int, int,
struct io_apic_irq_attr *); struct io_apic_irq_attr *);
extern void eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg); extern void eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg);
extern void native_compose_msi_msg(struct pci_dev *pdev,
unsigned int irq, unsigned int dest,
struct msi_msg *msg, u8 hpet_id);
extern void native_eoi_ioapic_pin(int apic, int pin, int vector); extern void native_eoi_ioapic_pin(int apic, int pin, int vector);
extern int save_ioapic_entries(void); extern int save_ioapic_entries(void);
...@@ -160,6 +161,13 @@ extern int restore_ioapic_entries(void); ...@@ -160,6 +161,13 @@ extern int restore_ioapic_entries(void);
extern void setup_ioapic_ids_from_mpc(void); extern void setup_ioapic_ids_from_mpc(void);
extern void setup_ioapic_ids_from_mpc_nocheck(void); extern void setup_ioapic_ids_from_mpc_nocheck(void);
struct io_apic_irq_attr {
int ioapic;
int ioapic_pin;
int trigger;
int polarity;
};
enum ioapic_domain_type { enum ioapic_domain_type {
IOAPIC_DOMAIN_INVALID, IOAPIC_DOMAIN_INVALID,
IOAPIC_DOMAIN_LEGACY, IOAPIC_DOMAIN_LEGACY,
...@@ -188,8 +196,10 @@ extern int mp_find_ioapic_pin(int ioapic, u32 gsi); ...@@ -188,8 +196,10 @@ extern int mp_find_ioapic_pin(int ioapic, u32 gsi);
extern u32 mp_pin_to_gsi(int ioapic, int pin); extern u32 mp_pin_to_gsi(int ioapic, int pin);
extern int mp_map_gsi_to_irq(u32 gsi, unsigned int flags); extern int mp_map_gsi_to_irq(u32 gsi, unsigned int flags);
extern void mp_unmap_irq(int irq); extern void mp_unmap_irq(int irq);
extern void __init mp_register_ioapic(int id, u32 address, u32 gsi_base, extern int mp_register_ioapic(int id, u32 address, u32 gsi_base,
struct ioapic_domain_cfg *cfg); struct ioapic_domain_cfg *cfg);
extern int mp_unregister_ioapic(u32 gsi_base);
extern int mp_ioapic_registered(u32 gsi_base);
extern int mp_irqdomain_map(struct irq_domain *domain, unsigned int virq, extern int mp_irqdomain_map(struct irq_domain *domain, unsigned int virq,
irq_hw_number_t hwirq); irq_hw_number_t hwirq);
extern void mp_irqdomain_unmap(struct irq_domain *domain, unsigned int virq); extern void mp_irqdomain_unmap(struct irq_domain *domain, unsigned int virq);
...@@ -227,19 +237,25 @@ static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned ...@@ -227,19 +237,25 @@ static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned
extern void io_apic_eoi(unsigned int apic, unsigned int vector); extern void io_apic_eoi(unsigned int apic, unsigned int vector);
extern bool mp_should_keep_irq(struct device *dev); extern void setup_IO_APIC(void);
extern void enable_IO_APIC(void);
extern void disable_IO_APIC(void);
extern void setup_ioapic_dest(void);
extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin);
extern void print_IO_APICs(void);
#else /* !CONFIG_X86_IO_APIC */ #else /* !CONFIG_X86_IO_APIC */
#define IO_APIC_IRQ(x) 0
#define io_apic_assign_pci_irqs 0 #define io_apic_assign_pci_irqs 0
#define setup_ioapic_ids_from_mpc x86_init_noop #define setup_ioapic_ids_from_mpc x86_init_noop
static inline void ioapic_insert_resources(void) { } static inline void ioapic_insert_resources(void) { }
static inline int arch_early_ioapic_init(void) { return 0; }
static inline void print_IO_APICs(void) {}
#define gsi_top (NR_IRQS_LEGACY) #define gsi_top (NR_IRQS_LEGACY)
static inline int mp_find_ioapic(u32 gsi) { return 0; } static inline int mp_find_ioapic(u32 gsi) { return 0; }
static inline u32 mp_pin_to_gsi(int ioapic, int pin) { return UINT_MAX; } static inline u32 mp_pin_to_gsi(int ioapic, int pin) { return UINT_MAX; }
static inline int mp_map_gsi_to_irq(u32 gsi, unsigned int flags) { return gsi; } static inline int mp_map_gsi_to_irq(u32 gsi, unsigned int flags) { return gsi; }
static inline void mp_unmap_irq(int irq) { } static inline void mp_unmap_irq(int irq) { }
static inline bool mp_should_keep_irq(struct device *dev) { return 1; }
static inline int save_ioapic_entries(void) static inline int save_ioapic_entries(void)
{ {
...@@ -262,7 +278,6 @@ static inline void disable_ioapic_support(void) { } ...@@ -262,7 +278,6 @@ static inline void disable_ioapic_support(void) { }
#define native_io_apic_print_entries NULL #define native_io_apic_print_entries NULL
#define native_ioapic_set_affinity NULL #define native_ioapic_set_affinity NULL
#define native_setup_ioapic_entry NULL #define native_setup_ioapic_entry NULL
#define native_compose_msi_msg NULL
#define native_eoi_ioapic_pin NULL #define native_eoi_ioapic_pin NULL
#endif #endif
......
...@@ -126,6 +126,12 @@ ...@@ -126,6 +126,12 @@
#define NR_VECTORS 256 #define NR_VECTORS 256
#ifdef CONFIG_X86_LOCAL_APIC
#define FIRST_SYSTEM_VECTOR LOCAL_TIMER_VECTOR
#else
#define FIRST_SYSTEM_VECTOR NR_VECTORS
#endif
#define FPU_IRQ 13 #define FPU_IRQ 13
#define FIRST_VM86_IRQ 3 #define FIRST_VM86_IRQ 3
......
...@@ -96,12 +96,15 @@ extern void pci_iommu_alloc(void); ...@@ -96,12 +96,15 @@ extern void pci_iommu_alloc(void);
#ifdef CONFIG_PCI_MSI #ifdef CONFIG_PCI_MSI
/* implemented in arch/x86/kernel/apic/io_apic. */ /* implemented in arch/x86/kernel/apic/io_apic. */
struct msi_desc; struct msi_desc;
void native_compose_msi_msg(struct pci_dev *pdev, unsigned int irq,
unsigned int dest, struct msi_msg *msg, u8 hpet_id);
int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
void native_teardown_msi_irq(unsigned int irq); void native_teardown_msi_irq(unsigned int irq);
void native_restore_msi_irqs(struct pci_dev *dev); void native_restore_msi_irqs(struct pci_dev *dev);
int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,
unsigned int irq_base, unsigned int irq_offset); unsigned int irq_base, unsigned int irq_offset);
#else #else
#define native_compose_msi_msg NULL
#define native_setup_msi_irqs NULL #define native_setup_msi_irqs NULL
#define native_teardown_msi_irq NULL #define native_teardown_msi_irq NULL
#endif #endif
......
...@@ -93,6 +93,8 @@ extern raw_spinlock_t pci_config_lock; ...@@ -93,6 +93,8 @@ extern raw_spinlock_t pci_config_lock;
extern int (*pcibios_enable_irq)(struct pci_dev *dev); extern int (*pcibios_enable_irq)(struct pci_dev *dev);
extern void (*pcibios_disable_irq)(struct pci_dev *dev); extern void (*pcibios_disable_irq)(struct pci_dev *dev);
extern bool mp_should_keep_irq(struct device *dev);
struct pci_raw_ops { struct pci_raw_ops {
int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn, int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn,
int reg, int len, u32 *val); int reg, int len, u32 *val);
......
...@@ -76,6 +76,19 @@ int acpi_fix_pin2_polarity __initdata; ...@@ -76,6 +76,19 @@ int acpi_fix_pin2_polarity __initdata;
static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
#endif #endif
/*
* Locks related to IOAPIC hotplug
* Hotplug side:
* ->device_hotplug_lock
* ->acpi_ioapic_lock
* ->ioapic_lock
* Interrupt mapping side:
* ->acpi_ioapic_lock
* ->ioapic_mutex
* ->ioapic_lock
*/
static DEFINE_MUTEX(acpi_ioapic_lock);
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Boot-time Configuration Boot-time Configuration
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
...@@ -395,10 +408,6 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger, ...@@ -395,10 +408,6 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger,
if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC) if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
return gsi; return gsi;
/* Don't set up the ACPI SCI because it's already set up */
if (acpi_gbl_FADT.sci_interrupt == gsi)
return mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC);
trigger = trigger == ACPI_EDGE_SENSITIVE ? 0 : 1; trigger = trigger == ACPI_EDGE_SENSITIVE ? 0 : 1;
polarity = polarity == ACPI_ACTIVE_HIGH ? 0 : 1; polarity = polarity == ACPI_ACTIVE_HIGH ? 0 : 1;
node = dev ? dev_to_node(dev) : NUMA_NO_NODE; node = dev ? dev_to_node(dev) : NUMA_NO_NODE;
...@@ -411,7 +420,8 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger, ...@@ -411,7 +420,8 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger,
if (irq < 0) if (irq < 0)
return irq; return irq;
if (enable_update_mptable) /* Don't set up the ACPI SCI because it's already set up */
if (enable_update_mptable && acpi_gbl_FADT.sci_interrupt != gsi)
mp_config_acpi_gsi(dev, gsi, trigger, polarity); mp_config_acpi_gsi(dev, gsi, trigger, polarity);
return irq; return irq;
...@@ -424,9 +434,6 @@ static void mp_unregister_gsi(u32 gsi) ...@@ -424,9 +434,6 @@ static void mp_unregister_gsi(u32 gsi)
if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC) if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
return; return;
if (acpi_gbl_FADT.sci_interrupt == gsi)
return;
irq = mp_map_gsi_to_irq(gsi, 0); irq = mp_map_gsi_to_irq(gsi, 0);
if (irq > 0) if (irq > 0)
mp_unmap_irq(irq); mp_unmap_irq(irq);
...@@ -609,8 +616,10 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp) ...@@ -609,8 +616,10 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) { if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
*irqp = gsi; *irqp = gsi;
} else { } else {
mutex_lock(&acpi_ioapic_lock);
irq = mp_map_gsi_to_irq(gsi, irq = mp_map_gsi_to_irq(gsi,
IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK); IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
mutex_unlock(&acpi_ioapic_lock);
if (irq < 0) if (irq < 0)
return -1; return -1;
*irqp = irq; *irqp = irq;
...@@ -650,7 +659,9 @@ static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi, ...@@ -650,7 +659,9 @@ static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,
int irq = gsi; int irq = gsi;
#ifdef CONFIG_X86_IO_APIC #ifdef CONFIG_X86_IO_APIC
mutex_lock(&acpi_ioapic_lock);
irq = mp_register_gsi(dev, gsi, trigger, polarity); irq = mp_register_gsi(dev, gsi, trigger, polarity);
mutex_unlock(&acpi_ioapic_lock);
#endif #endif
return irq; return irq;
...@@ -659,7 +670,9 @@ static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi, ...@@ -659,7 +670,9 @@ static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,
static void acpi_unregister_gsi_ioapic(u32 gsi) static void acpi_unregister_gsi_ioapic(u32 gsi)
{ {
#ifdef CONFIG_X86_IO_APIC #ifdef CONFIG_X86_IO_APIC
mutex_lock(&acpi_ioapic_lock);
mp_unregister_gsi(gsi); mp_unregister_gsi(gsi);
mutex_unlock(&acpi_ioapic_lock);
#endif #endif
} }
...@@ -690,6 +703,7 @@ void acpi_unregister_gsi(u32 gsi) ...@@ -690,6 +703,7 @@ void acpi_unregister_gsi(u32 gsi)
} }
EXPORT_SYMBOL_GPL(acpi_unregister_gsi); EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
#ifdef CONFIG_X86_LOCAL_APIC
static void __init acpi_set_irq_model_ioapic(void) static void __init acpi_set_irq_model_ioapic(void)
{ {
acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC; acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
...@@ -697,6 +711,7 @@ static void __init acpi_set_irq_model_ioapic(void) ...@@ -697,6 +711,7 @@ static void __init acpi_set_irq_model_ioapic(void)
__acpi_unregister_gsi = acpi_unregister_gsi_ioapic; __acpi_unregister_gsi = acpi_unregister_gsi_ioapic;
acpi_ioapic = 1; acpi_ioapic = 1;
} }
#endif
/* /*
* ACPI based hotplug support for CPU * ACPI based hotplug support for CPU
...@@ -759,20 +774,74 @@ EXPORT_SYMBOL(acpi_unmap_lsapic); ...@@ -759,20 +774,74 @@ EXPORT_SYMBOL(acpi_unmap_lsapic);
int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
{ {
/* TBD */ int ret = -ENOSYS;
return -EINVAL; #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
} int ioapic_id;
u64 addr;
struct ioapic_domain_cfg cfg = {
.type = IOAPIC_DOMAIN_DYNAMIC,
.ops = &acpi_irqdomain_ops,
};
ioapic_id = acpi_get_ioapic_id(handle, gsi_base, &addr);
if (ioapic_id < 0) {
unsigned long long uid;
acpi_status status;
status = acpi_evaluate_integer(handle, METHOD_NAME__UID,
NULL, &uid);
if (ACPI_FAILURE(status)) {
acpi_handle_warn(handle, "failed to get IOAPIC ID.\n");
return -EINVAL;
}
ioapic_id = (int)uid;
}
mutex_lock(&acpi_ioapic_lock);
ret = mp_register_ioapic(ioapic_id, phys_addr, gsi_base, &cfg);
mutex_unlock(&acpi_ioapic_lock);
#endif
return ret;
}
EXPORT_SYMBOL(acpi_register_ioapic); EXPORT_SYMBOL(acpi_register_ioapic);
int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base) int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
{ {
/* TBD */ int ret = -ENOSYS;
return -EINVAL;
}
#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
mutex_lock(&acpi_ioapic_lock);
ret = mp_unregister_ioapic(gsi_base);
mutex_unlock(&acpi_ioapic_lock);
#endif
return ret;
}
EXPORT_SYMBOL(acpi_unregister_ioapic); EXPORT_SYMBOL(acpi_unregister_ioapic);
/**
* acpi_ioapic_registered - Check whether IOAPIC assoicatied with @gsi_base
* has been registered
* @handle: ACPI handle of the IOAPIC deivce
* @gsi_base: GSI base associated with the IOAPIC
*
* Assume caller holds some type of lock to serialize acpi_ioapic_registered()
* with acpi_register_ioapic()/acpi_unregister_ioapic().
*/
int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base)
{
int ret = 0;
#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
mutex_lock(&acpi_ioapic_lock);
ret = mp_ioapic_registered(gsi_base);
mutex_unlock(&acpi_ioapic_lock);
#endif
return ret;
}
static int __init acpi_parse_sbf(struct acpi_table_header *table) static int __init acpi_parse_sbf(struct acpi_table_header *table)
{ {
struct acpi_table_boot *sb; struct acpi_table_boot *sb;
...@@ -1185,7 +1254,9 @@ static void __init acpi_process_madt(void) ...@@ -1185,7 +1254,9 @@ static void __init acpi_process_madt(void)
/* /*
* Parse MADT IO-APIC entries * Parse MADT IO-APIC entries
*/ */
mutex_lock(&acpi_ioapic_lock);
error = acpi_parse_madt_ioapic_entries(); error = acpi_parse_madt_ioapic_entries();
mutex_unlock(&acpi_ioapic_lock);
if (!error) { if (!error) {
acpi_set_irq_model_ioapic(); acpi_set_irq_model_ioapic();
......
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
# Makefile for local APIC drivers and for the IO-APIC code # Makefile for local APIC drivers and for the IO-APIC code
# #
obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o ipi.o obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o ipi.o vector.o
obj-y += hw_nmi.o obj-y += hw_nmi.o
obj-$(CONFIG_X86_IO_APIC) += io_apic.o obj-$(CONFIG_X86_IO_APIC) += io_apic.o
obj-$(CONFIG_PCI_MSI) += msi.o
obj-$(CONFIG_HT_IRQ) += htirq.o
obj-$(CONFIG_SMP) += ipi.o obj-$(CONFIG_SMP) += ipi.o
ifeq ($(CONFIG_X86_64),y) ifeq ($(CONFIG_X86_64),y)
......
...@@ -196,7 +196,7 @@ static int disable_apic_timer __initdata; ...@@ -196,7 +196,7 @@ static int disable_apic_timer __initdata;
int local_apic_timer_c2_ok; int local_apic_timer_c2_ok;
EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok); EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok);
int first_system_vector = 0xfe; int first_system_vector = FIRST_SYSTEM_VECTOR;
/* /*
* Debug level, exported for io_apic.c * Debug level, exported for io_apic.c
...@@ -1930,7 +1930,7 @@ int __init APIC_init_uniprocessor(void) ...@@ -1930,7 +1930,7 @@ int __init APIC_init_uniprocessor(void)
/* /*
* This interrupt should _never_ happen with our APIC/SMP architecture * This interrupt should _never_ happen with our APIC/SMP architecture
*/ */
static inline void __smp_spurious_interrupt(void) static inline void __smp_spurious_interrupt(u8 vector)
{ {
u32 v; u32 v;
...@@ -1939,30 +1939,32 @@ static inline void __smp_spurious_interrupt(void) ...@@ -1939,30 +1939,32 @@ static inline void __smp_spurious_interrupt(void)
* if it is a vectored one. Just in case... * if it is a vectored one. Just in case...
* Spurious interrupts should not be ACKed. * Spurious interrupts should not be ACKed.
*/ */
v = apic_read(APIC_ISR + ((SPURIOUS_APIC_VECTOR & ~0x1f) >> 1)); v = apic_read(APIC_ISR + ((vector & ~0x1f) >> 1));
if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f))) if (v & (1 << (vector & 0x1f)))
ack_APIC_irq(); ack_APIC_irq();
inc_irq_stat(irq_spurious_count); inc_irq_stat(irq_spurious_count);
/* see sw-dev-man vol 3, chapter 7.4.13.5 */ /* see sw-dev-man vol 3, chapter 7.4.13.5 */
pr_info("spurious APIC interrupt on CPU#%d, " pr_info("spurious APIC interrupt through vector %02x on CPU#%d, "
"should never happen.\n", smp_processor_id()); "should never happen.\n", vector, smp_processor_id());
} }
__visible void smp_spurious_interrupt(struct pt_regs *regs) __visible void smp_spurious_interrupt(struct pt_regs *regs)
{ {
entering_irq(); entering_irq();
__smp_spurious_interrupt(); __smp_spurious_interrupt(~regs->orig_ax);
exiting_irq(); exiting_irq();
} }
__visible void smp_trace_spurious_interrupt(struct pt_regs *regs) __visible void smp_trace_spurious_interrupt(struct pt_regs *regs)
{ {
u8 vector = ~regs->orig_ax;
entering_irq(); entering_irq();
trace_spurious_apic_entry(SPURIOUS_APIC_VECTOR); trace_spurious_apic_entry(vector);
__smp_spurious_interrupt(); __smp_spurious_interrupt(vector);
trace_spurious_apic_exit(SPURIOUS_APIC_VECTOR); trace_spurious_apic_exit(vector);
exiting_irq(); exiting_irq();
} }
......
/*
* Support Hypertransport IRQ
*
* Copyright (C) 1997, 1998, 1999, 2000, 2009 Ingo Molnar, Hajnalka Szabo
* Moved from arch/x86/kernel/apic/io_apic.c.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/pci.h>
#include <linux/htirq.h>
#include <asm/hw_irq.h>
#include <asm/apic.h>
#include <asm/hypertransport.h>
/*
* Hypertransport interrupt support
*/
static void target_ht_irq(unsigned int irq, unsigned int dest, u8 vector)
{
struct ht_irq_msg msg;
fetch_ht_irq_msg(irq, &msg);
msg.address_lo &= ~(HT_IRQ_LOW_VECTOR_MASK | HT_IRQ_LOW_DEST_ID_MASK);
msg.address_hi &= ~(HT_IRQ_HIGH_DEST_ID_MASK);
msg.address_lo |= HT_IRQ_LOW_VECTOR(vector) | HT_IRQ_LOW_DEST_ID(dest);
msg.address_hi |= HT_IRQ_HIGH_DEST_ID(dest);
write_ht_irq_msg(irq, &msg);
}
static int
ht_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)
{
struct irq_cfg *cfg = irqd_cfg(data);
unsigned int dest;
int ret;
ret = apic_set_affinity(data, mask, &dest);
if (ret)
return ret;
target_ht_irq(data->irq, dest, cfg->vector);
return IRQ_SET_MASK_OK_NOCOPY;
}
static struct irq_chip ht_irq_chip = {
.name = "PCI-HT",
.irq_mask = mask_ht_irq,
.irq_unmask = unmask_ht_irq,
.irq_ack = apic_ack_edge,
.irq_set_affinity = ht_set_affinity,
.irq_retrigger = apic_retrigger_irq,
.flags = IRQCHIP_SKIP_SET_WAKE,
};
int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
{
struct irq_cfg *cfg;
struct ht_irq_msg msg;
unsigned dest;
int err;
if (disable_apic)
return -ENXIO;
cfg = irq_cfg(irq);
err = assign_irq_vector(irq, cfg, apic->target_cpus());
if (err)
return err;
err = apic->cpu_mask_to_apicid_and(cfg->domain,
apic->target_cpus(), &dest);
if (err)
return err;
msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest);
msg.address_lo =
HT_IRQ_LOW_BASE |
HT_IRQ_LOW_DEST_ID(dest) |
HT_IRQ_LOW_VECTOR(cfg->vector) |
((apic->irq_dest_mode == 0) ?
HT_IRQ_LOW_DM_PHYSICAL :
HT_IRQ_LOW_DM_LOGICAL) |
HT_IRQ_LOW_RQEOI_EDGE |
((apic->irq_delivery_mode != dest_LowestPrio) ?
HT_IRQ_LOW_MT_FIXED :
HT_IRQ_LOW_MT_ARBITRATED) |
HT_IRQ_LOW_IRQ_MASKED;
write_ht_irq_msg(irq, &msg);
irq_set_chip_and_handler_name(irq, &ht_irq_chip,
handle_edge_irq, "edge");
dev_dbg(&dev->dev, "irq %d for HT\n", irq);
return 0;
}
This diff is collapsed.
/*
* Support of MSI, HPET and DMAR interrupts.
*
* Copyright (C) 1997, 1998, 1999, 2000, 2009 Ingo Molnar, Hajnalka Szabo
* Moved from arch/x86/kernel/apic/io_apic.c.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/dmar.h>
#include <linux/hpet.h>
#include <linux/msi.h>
#include <asm/msidef.h>
#include <asm/hpet.h>
#include <asm/hw_irq.h>
#include <asm/apic.h>
#include <asm/irq_remapping.h>
void native_compose_msi_msg(struct pci_dev *pdev,
unsigned int irq, unsigned int dest,
struct msi_msg *msg, u8 hpet_id)
{
struct irq_cfg *cfg = irq_cfg(irq);
msg->address_hi = MSI_ADDR_BASE_HI;
if (x2apic_enabled())
msg->address_hi |= MSI_ADDR_EXT_DEST_ID(dest);
msg->address_lo =
MSI_ADDR_BASE_LO |
((apic->irq_dest_mode == 0) ?
MSI_ADDR_DEST_MODE_PHYSICAL :
MSI_ADDR_DEST_MODE_LOGICAL) |
((apic->irq_delivery_mode != dest_LowestPrio) ?
MSI_ADDR_REDIRECTION_CPU :
MSI_ADDR_REDIRECTION_LOWPRI) |
MSI_ADDR_DEST_ID(dest);
msg->data =
MSI_DATA_TRIGGER_EDGE |
MSI_DATA_LEVEL_ASSERT |
((apic->irq_delivery_mode != dest_LowestPrio) ?
MSI_DATA_DELIVERY_FIXED :
MSI_DATA_DELIVERY_LOWPRI) |
MSI_DATA_VECTOR(cfg->vector);
}
static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq,
struct msi_msg *msg, u8 hpet_id)
{
struct irq_cfg *cfg;
int err;
unsigned dest;
if (disable_apic)
return -ENXIO;
cfg = irq_cfg(irq);
err = assign_irq_vector(irq, cfg, apic->target_cpus());
if (err)
return err;
err = apic->cpu_mask_to_apicid_and(cfg->domain,
apic->target_cpus(), &dest);
if (err)
return err;
x86_msi.compose_msi_msg(pdev, irq, dest, msg, hpet_id);
return 0;
}
static int
msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)
{
struct irq_cfg *cfg = irqd_cfg(data);
struct msi_msg msg;
unsigned int dest;
int ret;
ret = apic_set_affinity(data, mask, &dest);
if (ret)
return ret;
__get_cached_msi_msg(data->msi_desc, &msg);
msg.data &= ~MSI_DATA_VECTOR_MASK;
msg.data |= MSI_DATA_VECTOR(cfg->vector);
msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
msg.address_lo |= MSI_ADDR_DEST_ID(dest);
__pci_write_msi_msg(data->msi_desc, &msg);
return IRQ_SET_MASK_OK_NOCOPY;
}
/*
* IRQ Chip for MSI PCI/PCI-X/PCI-Express Devices,
* which implement the MSI or MSI-X Capability Structure.
*/
static struct irq_chip msi_chip = {
.name = "PCI-MSI",
.irq_unmask = pci_msi_unmask_irq,
.irq_mask = pci_msi_mask_irq,
.irq_ack = apic_ack_edge,
.irq_set_affinity = msi_set_affinity,
.irq_retrigger = apic_retrigger_irq,
.flags = IRQCHIP_SKIP_SET_WAKE,
};
int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,
unsigned int irq_base, unsigned int irq_offset)
{
struct irq_chip *chip = &msi_chip;
struct msi_msg msg;
unsigned int irq = irq_base + irq_offset;
int ret;
ret = msi_compose_msg(dev, irq, &msg, -1);
if (ret < 0)
return ret;
irq_set_msi_desc_off(irq_base, irq_offset, msidesc);
/*
* MSI-X message is written per-IRQ, the offset is always 0.
* MSI message denotes a contiguous group of IRQs, written for 0th IRQ.
*/
if (!irq_offset)
pci_write_msi_msg(irq, &msg);
setup_remapped_irq(irq, irq_cfg(irq), chip);
irq_set_chip_and_handler_name(irq, chip, handle_edge_irq, "edge");
dev_dbg(&dev->dev, "irq %d for MSI/MSI-X\n", irq);
return 0;
}
int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
struct msi_desc *msidesc;
unsigned int irq;
int node, ret;
/* Multiple MSI vectors only supported with interrupt remapping */
if (type == PCI_CAP_ID_MSI && nvec > 1)
return 1;
node = dev_to_node(&dev->dev);
list_for_each_entry(msidesc, &dev->msi_list, list) {
irq = irq_alloc_hwirq(node);
if (!irq)
return -ENOSPC;
ret = setup_msi_irq(dev, msidesc, irq, 0);
if (ret < 0) {
irq_free_hwirq(irq);
return ret;
}
}
return 0;
}
void native_teardown_msi_irq(unsigned int irq)
{
irq_free_hwirq(irq);
}
#ifdef CONFIG_DMAR_TABLE
static int
dmar_msi_set_affinity(struct irq_data *data, const struct cpumask *mask,
bool force)
{
struct irq_cfg *cfg = irqd_cfg(data);
unsigned int dest, irq = data->irq;
struct msi_msg msg;
int ret;
ret = apic_set_affinity(data, mask, &dest);
if (ret)
return ret;
dmar_msi_read(irq, &msg);
msg.data &= ~MSI_DATA_VECTOR_MASK;
msg.data |= MSI_DATA_VECTOR(cfg->vector);
msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
msg.address_lo |= MSI_ADDR_DEST_ID(dest);
msg.address_hi = MSI_ADDR_BASE_HI | MSI_ADDR_EXT_DEST_ID(dest);
dmar_msi_write(irq, &msg);
return IRQ_SET_MASK_OK_NOCOPY;
}
static struct irq_chip dmar_msi_type = {
.name = "DMAR_MSI",
.irq_unmask = dmar_msi_unmask,
.irq_mask = dmar_msi_mask,
.irq_ack = apic_ack_edge,
.irq_set_affinity = dmar_msi_set_affinity,
.irq_retrigger = apic_retrigger_irq,
.flags = IRQCHIP_SKIP_SET_WAKE,
};
int arch_setup_dmar_msi(unsigned int irq)
{
int ret;
struct msi_msg msg;
ret = msi_compose_msg(NULL, irq, &msg, -1);
if (ret < 0)
return ret;
dmar_msi_write(irq, &msg);
irq_set_chip_and_handler_name(irq, &dmar_msi_type, handle_edge_irq,
"edge");
return 0;
}
#endif
/*
* MSI message composition
*/
#ifdef CONFIG_HPET_TIMER
static int hpet_msi_set_affinity(struct irq_data *data,
const struct cpumask *mask, bool force)
{
struct irq_cfg *cfg = irqd_cfg(data);
struct msi_msg msg;
unsigned int dest;
int ret;
ret = apic_set_affinity(data, mask, &dest);
if (ret)
return ret;
hpet_msi_read(data->handler_data, &msg);
msg.data &= ~MSI_DATA_VECTOR_MASK;
msg.data |= MSI_DATA_VECTOR(cfg->vector);
msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
msg.address_lo |= MSI_ADDR_DEST_ID(dest);
hpet_msi_write(data->handler_data, &msg);
return IRQ_SET_MASK_OK_NOCOPY;
}
static struct irq_chip hpet_msi_type = {
.name = "HPET_MSI",
.irq_unmask = hpet_msi_unmask,
.irq_mask = hpet_msi_mask,
.irq_ack = apic_ack_edge,
.irq_set_affinity = hpet_msi_set_affinity,
.irq_retrigger = apic_retrigger_irq,
.flags = IRQCHIP_SKIP_SET_WAKE,
};
int default_setup_hpet_msi(unsigned int irq, unsigned int id)
{
struct irq_chip *chip = &hpet_msi_type;
struct msi_msg msg;
int ret;
ret = msi_compose_msg(NULL, irq, &msg, id);
if (ret < 0)
return ret;
hpet_msi_write(irq_get_handler_data(irq), &msg);
irq_set_status_flags(irq, IRQ_MOVE_PCNTXT);
setup_remapped_irq(irq, irq_cfg(irq), chip);
irq_set_chip_and_handler_name(irq, chip, handle_edge_irq, "edge");
return 0;
}
#endif
This diff is collapsed.
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <asm/nmi.h> #include <asm/nmi.h>
#include <asm/hw_irq.h> #include <asm/hw_irq.h>
#include <asm/apic.h> #include <asm/apic.h>
#include <asm/io_apic.h>
#include <asm/hpet.h> #include <asm/hpet.h>
#include <linux/kdebug.h> #include <linux/kdebug.h>
#include <asm/cpu.h> #include <asm/cpu.h>
......
...@@ -732,10 +732,10 @@ ENTRY(interrupt) ...@@ -732,10 +732,10 @@ ENTRY(interrupt)
ENTRY(irq_entries_start) ENTRY(irq_entries_start)
RING0_INT_FRAME RING0_INT_FRAME
vector=FIRST_EXTERNAL_VECTOR vector=FIRST_EXTERNAL_VECTOR
.rept (NR_VECTORS-FIRST_EXTERNAL_VECTOR+6)/7 .rept (FIRST_SYSTEM_VECTOR-FIRST_EXTERNAL_VECTOR+6)/7
.balign 32 .balign 32
.rept 7 .rept 7
.if vector < NR_VECTORS .if vector < FIRST_SYSTEM_VECTOR
.if vector <> FIRST_EXTERNAL_VECTOR .if vector <> FIRST_EXTERNAL_VECTOR
CFI_ADJUST_CFA_OFFSET -4 CFI_ADJUST_CFA_OFFSET -4
.endif .endif
......
...@@ -740,10 +740,10 @@ ENTRY(interrupt) ...@@ -740,10 +740,10 @@ ENTRY(interrupt)
ENTRY(irq_entries_start) ENTRY(irq_entries_start)
INTR_FRAME INTR_FRAME
vector=FIRST_EXTERNAL_VECTOR vector=FIRST_EXTERNAL_VECTOR
.rept (NR_VECTORS-FIRST_EXTERNAL_VECTOR+6)/7 .rept (FIRST_SYSTEM_VECTOR-FIRST_EXTERNAL_VECTOR+6)/7
.balign 32 .balign 32
.rept 7 .rept 7
.if vector < NR_VECTORS .if vector < FIRST_SYSTEM_VECTOR
.if vector <> FIRST_EXTERNAL_VECTOR .if vector <> FIRST_EXTERNAL_VECTOR
CFI_ADJUST_CFA_OFFSET -8 CFI_ADJUST_CFA_OFFSET -8
.endif .endif
......
...@@ -99,32 +99,9 @@ void __init init_IRQ(void) ...@@ -99,32 +99,9 @@ void __init init_IRQ(void)
x86_init.irqs.intr_init(); x86_init.irqs.intr_init();
} }
/*
* Setup the vector to irq mappings.
*/
void setup_vector_irq(int cpu)
{
#ifndef CONFIG_X86_IO_APIC
int irq;
/*
* On most of the platforms, legacy PIC delivers the interrupts on the
* boot cpu. But there are certain platforms where PIC interrupts are
* delivered to multiple cpu's. If the legacy IRQ is handled by the
* legacy PIC, for the new cpu that is coming online, setup the static
* legacy vector to irq mapping:
*/
for (irq = 0; irq < nr_legacy_irqs(); irq++)
per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
#endif
__setup_vector_irq(cpu);
}
static void __init smp_intr_init(void) static void __init smp_intr_init(void)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
/* /*
* The reschedule interrupt is a CPU-to-CPU reschedule-helper * The reschedule interrupt is a CPU-to-CPU reschedule-helper
* IPI, driven by wakeup. * IPI, driven by wakeup.
...@@ -144,7 +121,6 @@ static void __init smp_intr_init(void) ...@@ -144,7 +121,6 @@ static void __init smp_intr_init(void)
/* IPI used for rebooting/stopping */ /* IPI used for rebooting/stopping */
alloc_intr_gate(REBOOT_VECTOR, reboot_interrupt); alloc_intr_gate(REBOOT_VECTOR, reboot_interrupt);
#endif
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
} }
...@@ -159,7 +135,7 @@ static void __init apic_intr_init(void) ...@@ -159,7 +135,7 @@ static void __init apic_intr_init(void)
alloc_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt); alloc_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt);
#endif #endif
#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC) #ifdef CONFIG_X86_LOCAL_APIC
/* self generated IPI for local APIC timer */ /* self generated IPI for local APIC timer */
alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt); alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
...@@ -197,10 +173,17 @@ void __init native_init_IRQ(void) ...@@ -197,10 +173,17 @@ void __init native_init_IRQ(void)
* 'special' SMP interrupts) * 'special' SMP interrupts)
*/ */
i = FIRST_EXTERNAL_VECTOR; i = FIRST_EXTERNAL_VECTOR;
for_each_clear_bit_from(i, used_vectors, NR_VECTORS) { #ifndef CONFIG_X86_LOCAL_APIC
#define first_system_vector NR_VECTORS
#endif
for_each_clear_bit_from(i, used_vectors, first_system_vector) {
/* IA32_SYSCALL_VECTOR could be used in trap_init already. */ /* IA32_SYSCALL_VECTOR could be used in trap_init already. */
set_intr_gate(i, interrupt[i - FIRST_EXTERNAL_VECTOR]); set_intr_gate(i, interrupt[i - FIRST_EXTERNAL_VECTOR]);
} }
#ifdef CONFIG_X86_LOCAL_APIC
for_each_clear_bit_from(i, used_vectors, NR_VECTORS)
set_intr_gate(i, spurious_interrupt);
#endif
if (!acpi_ioapic && !of_ioapic && nr_legacy_irqs()) if (!acpi_ioapic && !of_ioapic && nr_legacy_irqs())
setup_irq(2, &irq2); setup_irq(2, &irq2);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>
#include <asm/apic.h> #include <asm/apic.h>
#include <asm/io_apic.h>
#include <asm/cpufeature.h> #include <asm/cpufeature.h>
#include <asm/desc.h> #include <asm/desc.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>
#include <asm/io_apic.h>
#include <asm/debugreg.h> #include <asm/debugreg.h>
#include <asm/kexec-bzimage64.h> #include <asm/kexec-bzimage64.h>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <acpi/reboot.h> #include <acpi/reboot.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/apic.h> #include <asm/apic.h>
#include <asm/io_apic.h>
#include <asm/desc.h> #include <asm/desc.h>
#include <asm/hpet.h> #include <asm/hpet.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
......
...@@ -1084,7 +1084,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) ...@@ -1084,7 +1084,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
{ {
unsigned int i; unsigned int i;
preempt_disable();
smp_cpu_index_default(); smp_cpu_index_default();
/* /*
...@@ -1102,22 +1101,19 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) ...@@ -1102,22 +1101,19 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
} }
set_cpu_sibling_map(0); set_cpu_sibling_map(0);
if (smp_sanity_check(max_cpus) < 0) { if (smp_sanity_check(max_cpus) < 0) {
pr_info("SMP disabled\n"); pr_info("SMP disabled\n");
disable_smp(); disable_smp();
goto out; return;
} }
default_setup_apic_routing(); default_setup_apic_routing();
preempt_disable();
if (read_apic_id() != boot_cpu_physical_apicid) { if (read_apic_id() != boot_cpu_physical_apicid) {
panic("Boot APIC ID in local APIC unexpected (%d vs %d)", panic("Boot APIC ID in local APIC unexpected (%d vs %d)",
read_apic_id(), boot_cpu_physical_apicid); read_apic_id(), boot_cpu_physical_apicid);
/* Or can we switch back to PIC here? */ /* Or can we switch back to PIC here? */
} }
preempt_enable();
connect_bsp_APIC(); connect_bsp_APIC();
...@@ -1151,8 +1147,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) ...@@ -1151,8 +1147,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
uv_system_init(); uv_system_init();
set_mtrr_aps_delayed_init(); set_mtrr_aps_delayed_init();
out:
preempt_enable();
} }
void arch_enable_nonboot_cpus_begin(void) void arch_enable_nonboot_cpus_begin(void)
......
...@@ -841,7 +841,7 @@ static void __init lguest_init_IRQ(void) ...@@ -841,7 +841,7 @@ static void __init lguest_init_IRQ(void)
{ {
unsigned int i; unsigned int i;
for (i = FIRST_EXTERNAL_VECTOR; i < NR_VECTORS; i++) { for (i = FIRST_EXTERNAL_VECTOR; i < FIRST_SYSTEM_VECTOR; i++) {
/* Some systems map "vectors" to interrupts weirdly. Not us! */ /* Some systems map "vectors" to interrupts weirdly. Not us! */
__this_cpu_write(vector_irq[i], i - FIRST_EXTERNAL_VECTOR); __this_cpu_write(vector_irq[i], i - FIRST_EXTERNAL_VECTOR);
if (i != SYSCALL_VECTOR) if (i != SYSCALL_VECTOR)
......
...@@ -210,6 +210,9 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev) ...@@ -210,6 +210,9 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
{ {
int polarity; int polarity;
if (dev->irq_managed && dev->irq > 0)
return 0;
if (intel_mid_identify_cpu() == INTEL_MID_CPU_CHIP_TANGIER) if (intel_mid_identify_cpu() == INTEL_MID_CPU_CHIP_TANGIER)
polarity = 0; /* active high */ polarity = 0; /* active high */
else else
...@@ -224,13 +227,18 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev) ...@@ -224,13 +227,18 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
if (mp_map_gsi_to_irq(dev->irq, IOAPIC_MAP_ALLOC) < 0) if (mp_map_gsi_to_irq(dev->irq, IOAPIC_MAP_ALLOC) < 0)
return -EBUSY; return -EBUSY;
dev->irq_managed = 1;
return 0; return 0;
} }
static void intel_mid_pci_irq_disable(struct pci_dev *dev) static void intel_mid_pci_irq_disable(struct pci_dev *dev)
{ {
if (!mp_should_keep_irq(&dev->dev) && dev->irq > 0) if (!mp_should_keep_irq(&dev->dev) && dev->irq_managed &&
dev->irq > 0) {
mp_unmap_irq(dev->irq); mp_unmap_irq(dev->irq);
dev->irq_managed = 0;
}
} }
struct pci_ops intel_mid_pci_ops = { struct pci_ops intel_mid_pci_ops = {
......
...@@ -1200,11 +1200,12 @@ static int pirq_enable_irq(struct pci_dev *dev) ...@@ -1200,11 +1200,12 @@ static int pirq_enable_irq(struct pci_dev *dev)
#ifdef CONFIG_X86_IO_APIC #ifdef CONFIG_X86_IO_APIC
struct pci_dev *temp_dev; struct pci_dev *temp_dev;
int irq; int irq;
struct io_apic_irq_attr irq_attr;
if (dev->irq_managed && dev->irq > 0)
return 0;
irq = IO_APIC_get_PCI_irq_vector(dev->bus->number, irq = IO_APIC_get_PCI_irq_vector(dev->bus->number,
PCI_SLOT(dev->devfn), PCI_SLOT(dev->devfn), pin - 1);
pin - 1, &irq_attr);
/* /*
* Busses behind bridges are typically not listed in the MP-table. * Busses behind bridges are typically not listed in the MP-table.
* In this case we have to look up the IRQ based on the parent bus, * In this case we have to look up the IRQ based on the parent bus,
...@@ -1218,7 +1219,7 @@ static int pirq_enable_irq(struct pci_dev *dev) ...@@ -1218,7 +1219,7 @@ static int pirq_enable_irq(struct pci_dev *dev)
pin = pci_swizzle_interrupt_pin(dev, pin); pin = pci_swizzle_interrupt_pin(dev, pin);
irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number, irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number,
PCI_SLOT(bridge->devfn), PCI_SLOT(bridge->devfn),
pin - 1, &irq_attr); pin - 1);
if (irq >= 0) if (irq >= 0)
dev_warn(&dev->dev, "using bridge %s " dev_warn(&dev->dev, "using bridge %s "
"INT %c to get IRQ %d\n", "INT %c to get IRQ %d\n",
...@@ -1228,6 +1229,7 @@ static int pirq_enable_irq(struct pci_dev *dev) ...@@ -1228,6 +1229,7 @@ static int pirq_enable_irq(struct pci_dev *dev)
} }
dev = temp_dev; dev = temp_dev;
if (irq >= 0) { if (irq >= 0) {
dev->irq_managed = 1;
dev->irq = irq; dev->irq = irq;
dev_info(&dev->dev, "PCI->APIC IRQ transform: " dev_info(&dev->dev, "PCI->APIC IRQ transform: "
"INT %c -> IRQ %d\n", 'A' + pin - 1, irq); "INT %c -> IRQ %d\n", 'A' + pin - 1, irq);
...@@ -1254,11 +1256,24 @@ static int pirq_enable_irq(struct pci_dev *dev) ...@@ -1254,11 +1256,24 @@ static int pirq_enable_irq(struct pci_dev *dev)
return 0; return 0;
} }
bool mp_should_keep_irq(struct device *dev)
{
if (dev->power.is_prepared)
return true;
#ifdef CONFIG_PM
if (dev->power.runtime_status == RPM_SUSPENDING)
return true;
#endif
return false;
}
static void pirq_disable_irq(struct pci_dev *dev) static void pirq_disable_irq(struct pci_dev *dev)
{ {
if (io_apic_assign_pci_irqs && !mp_should_keep_irq(&dev->dev) && if (io_apic_assign_pci_irqs && !mp_should_keep_irq(&dev->dev) &&
dev->irq) { dev->irq_managed && dev->irq) {
mp_unmap_irq(dev->irq); mp_unmap_irq(dev->irq);
dev->irq = 0; dev->irq = 0;
dev->irq_managed = 0;
} }
} }
...@@ -131,7 +131,7 @@ arch_enable_uv_irq(char *irq_name, unsigned int irq, int cpu, int mmr_blade, ...@@ -131,7 +131,7 @@ arch_enable_uv_irq(char *irq_name, unsigned int irq, int cpu, int mmr_blade,
unsigned long mmr_offset, int limit) unsigned long mmr_offset, int limit)
{ {
const struct cpumask *eligible_cpu = cpumask_of(cpu); const struct cpumask *eligible_cpu = cpumask_of(cpu);
struct irq_cfg *cfg = irq_get_chip_data(irq); struct irq_cfg *cfg = irq_cfg(irq);
unsigned long mmr_value; unsigned long mmr_value;
struct uv_IO_APIC_route_entry *entry; struct uv_IO_APIC_route_entry *entry;
int mmr_pnode, err; int mmr_pnode, err;
...@@ -198,13 +198,13 @@ static int ...@@ -198,13 +198,13 @@ static int
uv_set_irq_affinity(struct irq_data *data, const struct cpumask *mask, uv_set_irq_affinity(struct irq_data *data, const struct cpumask *mask,
bool force) bool force)
{ {
struct irq_cfg *cfg = data->chip_data; struct irq_cfg *cfg = irqd_cfg(data);
unsigned int dest; unsigned int dest;
unsigned long mmr_value, mmr_offset; unsigned long mmr_value, mmr_offset;
struct uv_IO_APIC_route_entry *entry; struct uv_IO_APIC_route_entry *entry;
int mmr_pnode; int mmr_pnode;
if (__ioapic_set_affinity(data, mask, &dest)) if (apic_set_affinity(data, mask, &dest))
return -1; return -1;
mmr_value = 0; mmr_value = 0;
......
...@@ -413,6 +413,9 @@ int acpi_pci_irq_enable(struct pci_dev *dev) ...@@ -413,6 +413,9 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
return 0; return 0;
} }
if (dev->irq_managed && dev->irq > 0)
return 0;
entry = acpi_pci_irq_lookup(dev, pin); entry = acpi_pci_irq_lookup(dev, pin);
if (!entry) { if (!entry) {
/* /*
...@@ -456,6 +459,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev) ...@@ -456,6 +459,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
return rc; return rc;
} }
dev->irq = rc; dev->irq = rc;
dev->irq_managed = 1;
if (link) if (link)
snprintf(link_desc, sizeof(link_desc), " -> Link[%s]", link); snprintf(link_desc, sizeof(link_desc), " -> Link[%s]", link);
...@@ -478,7 +482,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev) ...@@ -478,7 +482,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
u8 pin; u8 pin;
pin = dev->pin; pin = dev->pin;
if (!pin) if (!pin || !dev->irq_managed || dev->irq <= 0)
return; return;
/* Keep IOAPIC pin configuration when suspending */ /* Keep IOAPIC pin configuration when suspending */
...@@ -506,6 +510,9 @@ void acpi_pci_irq_disable(struct pci_dev *dev) ...@@ -506,6 +510,9 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
*/ */
dev_dbg(&dev->dev, "PCI INT %c disabled\n", pin_name(pin)); dev_dbg(&dev->dev, "PCI INT %c disabled\n", pin_name(pin));
if (gsi >= 0 && dev->irq > 0) if (gsi >= 0) {
acpi_unregister_gsi(gsi); acpi_unregister_gsi(gsi);
dev->irq = 0;
dev->irq_managed = 0;
}
} }
...@@ -125,13 +125,12 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) ...@@ -125,13 +125,12 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
} }
header = (struct acpi_subtable_header *)obj->buffer.pointer; header = (struct acpi_subtable_header *)obj->buffer.pointer;
if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { if (header->type == ACPI_MADT_TYPE_LOCAL_APIC)
map_lapic_id(header, acpi_id, &apic_id); map_lapic_id(header, acpi_id, &apic_id);
} else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC)
map_lsapic_id(header, type, acpi_id, &apic_id); map_lsapic_id(header, type, acpi_id, &apic_id);
} else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) { else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC)
map_x2apic_id(header, type, acpi_id, &apic_id); map_x2apic_id(header, type, acpi_id, &apic_id);
}
exit: exit:
kfree(buffer.pointer); kfree(buffer.pointer);
...@@ -164,7 +163,7 @@ int acpi_map_cpuid(int apic_id, u32 acpi_id) ...@@ -164,7 +163,7 @@ int acpi_map_cpuid(int apic_id, u32 acpi_id)
* For example, * For example,
* *
* Scope (_PR) * Scope (_PR)
* { * {
* Processor (CPU0, 0x00, 0x00000410, 0x06) {} * Processor (CPU0, 0x00, 0x00000410, 0x06) {}
* Processor (CPU1, 0x01, 0x00000410, 0x06) {} * Processor (CPU1, 0x01, 0x00000410, 0x06) {}
* Processor (CPU2, 0x02, 0x00000410, 0x06) {} * Processor (CPU2, 0x02, 0x00000410, 0x06) {}
......
...@@ -200,7 +200,7 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares, ...@@ -200,7 +200,7 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares,
status = acpi_resource_to_address64(ares, &addr); status = acpi_resource_to_address64(ares, &addr);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
return true; return false;
res->start = addr.minimum; res->start = addr.minimum;
res->end = addr.maximum; res->end = addr.maximum;
......
...@@ -4071,7 +4071,7 @@ static int setup_ioapic_entry(int irq, struct IO_APIC_route_entry *entry, ...@@ -4071,7 +4071,7 @@ static int setup_ioapic_entry(int irq, struct IO_APIC_route_entry *entry,
int devid; int devid;
int ret; int ret;
cfg = irq_get_chip_data(irq); cfg = irq_cfg(irq);
if (!cfg) if (!cfg)
return -EINVAL; return -EINVAL;
...@@ -4134,7 +4134,7 @@ static int set_affinity(struct irq_data *data, const struct cpumask *mask, ...@@ -4134,7 +4134,7 @@ static int set_affinity(struct irq_data *data, const struct cpumask *mask,
if (!config_enabled(CONFIG_SMP)) if (!config_enabled(CONFIG_SMP))
return -1; return -1;
cfg = data->chip_data; cfg = irqd_cfg(data);
irq = data->irq; irq = data->irq;
irte_info = &cfg->irq_2_irte; irte_info = &cfg->irq_2_irte;
...@@ -4172,7 +4172,7 @@ static int free_irq(int irq) ...@@ -4172,7 +4172,7 @@ static int free_irq(int irq)
struct irq_2_irte *irte_info; struct irq_2_irte *irte_info;
struct irq_cfg *cfg; struct irq_cfg *cfg;
cfg = irq_get_chip_data(irq); cfg = irq_cfg(irq);
if (!cfg) if (!cfg)
return -EINVAL; return -EINVAL;
...@@ -4191,7 +4191,7 @@ static void compose_msi_msg(struct pci_dev *pdev, ...@@ -4191,7 +4191,7 @@ static void compose_msi_msg(struct pci_dev *pdev,
struct irq_cfg *cfg; struct irq_cfg *cfg;
union irte irte; union irte irte;
cfg = irq_get_chip_data(irq); cfg = irq_cfg(irq);
if (!cfg) if (!cfg)
return; return;
...@@ -4220,7 +4220,7 @@ static int msi_alloc_irq(struct pci_dev *pdev, int irq, int nvec) ...@@ -4220,7 +4220,7 @@ static int msi_alloc_irq(struct pci_dev *pdev, int irq, int nvec)
if (!pdev) if (!pdev)
return -EINVAL; return -EINVAL;
cfg = irq_get_chip_data(irq); cfg = irq_cfg(irq);
if (!cfg) if (!cfg)
return -EINVAL; return -EINVAL;
...@@ -4240,7 +4240,7 @@ static int msi_setup_irq(struct pci_dev *pdev, unsigned int irq, ...@@ -4240,7 +4240,7 @@ static int msi_setup_irq(struct pci_dev *pdev, unsigned int irq,
if (!pdev) if (!pdev)
return -EINVAL; return -EINVAL;
cfg = irq_get_chip_data(irq); cfg = irq_cfg(irq);
if (!cfg) if (!cfg)
return -EINVAL; return -EINVAL;
...@@ -4263,7 +4263,7 @@ static int alloc_hpet_msi(unsigned int irq, unsigned int id) ...@@ -4263,7 +4263,7 @@ static int alloc_hpet_msi(unsigned int irq, unsigned int id)
struct irq_cfg *cfg; struct irq_cfg *cfg;
int index, devid; int index, devid;
cfg = irq_get_chip_data(irq); cfg = irq_cfg(irq);
if (!cfg) if (!cfg)
return -EINVAL; return -EINVAL;
......
...@@ -54,7 +54,7 @@ static int __init parse_ioapics_under_ir(void); ...@@ -54,7 +54,7 @@ static int __init parse_ioapics_under_ir(void);
static struct irq_2_iommu *irq_2_iommu(unsigned int irq) static struct irq_2_iommu *irq_2_iommu(unsigned int irq)
{ {
struct irq_cfg *cfg = irq_get_chip_data(irq); struct irq_cfg *cfg = irq_cfg(irq);
return cfg ? &cfg->irq_2_iommu : NULL; return cfg ? &cfg->irq_2_iommu : NULL;
} }
...@@ -85,7 +85,7 @@ static int alloc_irte(struct intel_iommu *iommu, int irq, u16 count) ...@@ -85,7 +85,7 @@ static int alloc_irte(struct intel_iommu *iommu, int irq, u16 count)
{ {
struct ir_table *table = iommu->ir_table; struct ir_table *table = iommu->ir_table;
struct irq_2_iommu *irq_iommu = irq_2_iommu(irq); struct irq_2_iommu *irq_iommu = irq_2_iommu(irq);
struct irq_cfg *cfg = irq_get_chip_data(irq); struct irq_cfg *cfg = irq_cfg(irq);
unsigned int mask = 0; unsigned int mask = 0;
unsigned long flags; unsigned long flags;
int index; int index;
...@@ -153,7 +153,7 @@ static int map_irq_to_irte_handle(int irq, u16 *sub_handle) ...@@ -153,7 +153,7 @@ static int map_irq_to_irte_handle(int irq, u16 *sub_handle)
static int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index, u16 subhandle) static int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index, u16 subhandle)
{ {
struct irq_2_iommu *irq_iommu = irq_2_iommu(irq); struct irq_2_iommu *irq_iommu = irq_2_iommu(irq);
struct irq_cfg *cfg = irq_get_chip_data(irq); struct irq_cfg *cfg = irq_cfg(irq);
unsigned long flags; unsigned long flags;
if (!irq_iommu) if (!irq_iommu)
...@@ -1050,7 +1050,7 @@ static int ...@@ -1050,7 +1050,7 @@ static int
intel_ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask, intel_ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
bool force) bool force)
{ {
struct irq_cfg *cfg = data->chip_data; struct irq_cfg *cfg = irqd_cfg(data);
unsigned int dest, irq = data->irq; unsigned int dest, irq = data->irq;
struct irte irte; struct irte irte;
int err; int err;
...@@ -1105,7 +1105,7 @@ static void intel_compose_msi_msg(struct pci_dev *pdev, ...@@ -1105,7 +1105,7 @@ static void intel_compose_msi_msg(struct pci_dev *pdev,
u16 sub_handle = 0; u16 sub_handle = 0;
int ir_index; int ir_index;
cfg = irq_get_chip_data(irq); cfg = irq_cfg(irq);
ir_index = map_irq_to_irte_handle(irq, &sub_handle); ir_index = map_irq_to_irte_handle(irq, &sub_handle);
BUG_ON(ir_index == -1); BUG_ON(ir_index == -1);
......
...@@ -298,7 +298,7 @@ static int set_remapped_irq_affinity(struct irq_data *data, ...@@ -298,7 +298,7 @@ static int set_remapped_irq_affinity(struct irq_data *data,
void free_remapped_irq(int irq) void free_remapped_irq(int irq)
{ {
struct irq_cfg *cfg = irq_get_chip_data(irq); struct irq_cfg *cfg = irq_cfg(irq);
if (!remap_ops || !remap_ops->free_irq) if (!remap_ops || !remap_ops->free_irq)
return; return;
...@@ -311,7 +311,7 @@ void compose_remapped_msi_msg(struct pci_dev *pdev, ...@@ -311,7 +311,7 @@ void compose_remapped_msi_msg(struct pci_dev *pdev,
unsigned int irq, unsigned int dest, unsigned int irq, unsigned int dest,
struct msi_msg *msg, u8 hpet_id) struct msi_msg *msg, u8 hpet_id)
{ {
struct irq_cfg *cfg = irq_get_chip_data(irq); struct irq_cfg *cfg = irq_cfg(irq);
if (!irq_remapped(cfg)) if (!irq_remapped(cfg))
native_compose_msi_msg(pdev, irq, dest, msg, hpet_id); native_compose_msi_msg(pdev, irq, dest, msg, hpet_id);
...@@ -364,7 +364,7 @@ static void ir_ack_apic_edge(struct irq_data *data) ...@@ -364,7 +364,7 @@ static void ir_ack_apic_edge(struct irq_data *data)
static void ir_ack_apic_level(struct irq_data *data) static void ir_ack_apic_level(struct irq_data *data)
{ {
ack_APIC_irq(); ack_APIC_irq();
eoi_ioapic_irq(data->irq, data->chip_data); eoi_ioapic_irq(data->irq, irqd_cfg(data));
} }
static void ir_print_prefix(struct irq_data *data, struct seq_file *p) static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
......
...@@ -67,7 +67,7 @@ config XEN_PCIDEV_FRONTEND ...@@ -67,7 +67,7 @@ config XEN_PCIDEV_FRONTEND
config HT_IRQ config HT_IRQ
bool "Interrupts on hypertransport devices" bool "Interrupts on hypertransport devices"
default y default y
depends on PCI && X86_LOCAL_APIC && X86_IO_APIC depends on PCI && X86_LOCAL_APIC
help help
This allows native hypertransport devices to use interrupts. This allows native hypertransport devices to use interrupts.
...@@ -110,13 +110,6 @@ config PCI_PASID ...@@ -110,13 +110,6 @@ config PCI_PASID
If unsure, say N. If unsure, say N.
config PCI_IOAPIC
bool "PCI IO-APIC hotplug support" if X86
depends on PCI
depends on ACPI
depends on X86_IO_APIC
default !X86
config PCI_LABEL config PCI_LABEL
def_bool y if (DMI || ACPI) def_bool y if (DMI || ACPI)
select NLS select NLS
......
...@@ -13,8 +13,6 @@ obj-$(CONFIG_PCI_QUIRKS) += quirks.o ...@@ -13,8 +13,6 @@ obj-$(CONFIG_PCI_QUIRKS) += quirks.o
# Build PCI Express stuff if needed # Build PCI Express stuff if needed
obj-$(CONFIG_PCIEPORTBUS) += pcie/ obj-$(CONFIG_PCIEPORTBUS) += pcie/
obj-$(CONFIG_PCI_IOAPIC) += ioapic.o
# Build the PCI Hotplug drivers if we were asked to # Build the PCI Hotplug drivers if we were asked to
obj-$(CONFIG_HOTPLUG_PCI) += hotplug/ obj-$(CONFIG_HOTPLUG_PCI) += hotplug/
ifdef CONFIG_HOTPLUG_PCI ifdef CONFIG_HOTPLUG_PCI
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/wait.h> #include <linux/wait.h>
#include "../pci.h" #include "../pci.h"
#include <asm/pci_x86.h> /* for struct irq_routing_table */ #include <asm/pci_x86.h> /* for struct irq_routing_table */
#include <asm/io_apic.h>
#include "ibmphp.h" #include "ibmphp.h"
#define attn_on(sl) ibmphp_hpc_writeslot (sl, HPC_SLOT_ATTNON) #define attn_on(sl) ibmphp_hpc_writeslot (sl, HPC_SLOT_ATTNON)
...@@ -155,13 +156,10 @@ int ibmphp_init_devno(struct slot **cur_slot) ...@@ -155,13 +156,10 @@ int ibmphp_init_devno(struct slot **cur_slot)
for (loop = 0; loop < len; loop++) { for (loop = 0; loop < len; loop++) {
if ((*cur_slot)->number == rtable->slots[loop].slot && if ((*cur_slot)->number == rtable->slots[loop].slot &&
(*cur_slot)->bus == rtable->slots[loop].bus) { (*cur_slot)->bus == rtable->slots[loop].bus) {
struct io_apic_irq_attr irq_attr;
(*cur_slot)->device = PCI_SLOT(rtable->slots[loop].devfn); (*cur_slot)->device = PCI_SLOT(rtable->slots[loop].devfn);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
(*cur_slot)->irq[i] = IO_APIC_get_PCI_irq_vector((int) (*cur_slot)->bus, (*cur_slot)->irq[i] = IO_APIC_get_PCI_irq_vector((int) (*cur_slot)->bus,
(int) (*cur_slot)->device, i, (int) (*cur_slot)->device, i);
&irq_attr);
debug("(*cur_slot)->irq[0] = %x\n", debug("(*cur_slot)->irq[0] = %x\n",
(*cur_slot)->irq[0]); (*cur_slot)->irq[0]);
......
/*
* IOAPIC/IOxAPIC/IOSAPIC driver
*
* Copyright (C) 2009 Fujitsu Limited.
* (c) Copyright 2009 Hewlett-Packard Development Company, L.P.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/*
* This driver manages PCI I/O APICs added by hotplug after boot. We try to
* claim all I/O APIC PCI devices, but those present at boot were registered
* when we parsed the ACPI MADT, so we'll fail when we try to re-register
* them.
*/
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/acpi.h>
#include <linux/slab.h>
struct ioapic {
acpi_handle handle;
u32 gsi_base;
};
static int ioapic_probe(struct pci_dev *dev, const struct pci_device_id *ent)
{
acpi_handle handle;
acpi_status status;
unsigned long long gsb;
struct ioapic *ioapic;
int ret;
char *type;
struct resource *res;
handle = ACPI_HANDLE(&dev->dev);
if (!handle)
return -EINVAL;
status = acpi_evaluate_integer(handle, "_GSB", NULL, &gsb);
if (ACPI_FAILURE(status))
return -EINVAL;
/*
* The previous code in acpiphp evaluated _MAT if _GSB failed, but
* ACPI spec 4.0 sec 6.2.2 requires _GSB for hot-pluggable I/O APICs.
*/
ioapic = kzalloc(sizeof(*ioapic), GFP_KERNEL);
if (!ioapic)
return -ENOMEM;
ioapic->handle = handle;
ioapic->gsi_base = (u32) gsb;
if (dev->class == PCI_CLASS_SYSTEM_PIC_IOAPIC)
type = "IOAPIC";
else
type = "IOxAPIC";
ret = pci_enable_device(dev);
if (ret < 0)
goto exit_free;
pci_set_master(dev);
if (pci_request_region(dev, 0, type))
goto exit_disable;
res = &dev->resource[0];
if (acpi_register_ioapic(ioapic->handle, res->start, ioapic->gsi_base))
goto exit_release;
pci_set_drvdata(dev, ioapic);
dev_info(&dev->dev, "%s at %pR, GSI %u\n", type, res, ioapic->gsi_base);
return 0;
exit_release:
pci_release_region(dev, 0);
exit_disable:
pci_disable_device(dev);
exit_free:
kfree(ioapic);
return -ENODEV;
}
static void ioapic_remove(struct pci_dev *dev)
{
struct ioapic *ioapic = pci_get_drvdata(dev);
acpi_unregister_ioapic(ioapic->handle, ioapic->gsi_base);
pci_release_region(dev, 0);
pci_disable_device(dev);
kfree(ioapic);
}
static const struct pci_device_id ioapic_devices[] = {
{ PCI_DEVICE_CLASS(PCI_CLASS_SYSTEM_PIC_IOAPIC, ~0) },
{ PCI_DEVICE_CLASS(PCI_CLASS_SYSTEM_PIC_IOXAPIC, ~0) },
{ }
};
MODULE_DEVICE_TABLE(pci, ioapic_devices);
static struct pci_driver ioapic_driver = {
.name = "ioapic",
.id_table = ioapic_devices,
.probe = ioapic_probe,
.remove = ioapic_remove,
};
static int __init ioapic_init(void)
{
return pci_register_driver(&ioapic_driver);
}
module_init(ioapic_init);
MODULE_LICENSE("GPL");
...@@ -153,6 +153,7 @@ int acpi_unmap_lsapic(int cpu); ...@@ -153,6 +153,7 @@ int acpi_unmap_lsapic(int cpu);
int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base); int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base); int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base);
void acpi_irq_stats_init(void); void acpi_irq_stats_init(void);
extern u32 acpi_irq_handled; extern u32 acpi_irq_handled;
extern u32 acpi_irq_not_handled; extern u32 acpi_irq_not_handled;
......
...@@ -349,6 +349,7 @@ struct pci_dev { ...@@ -349,6 +349,7 @@ struct pci_dev {
unsigned int __aer_firmware_first:1; unsigned int __aer_firmware_first:1;
unsigned int broken_intx_masking:1; unsigned int broken_intx_masking:1;
unsigned int io_window_1k:1; /* Intel P2P bridge 1K I/O windows */ unsigned int io_window_1k:1; /* Intel P2P bridge 1K I/O windows */
unsigned int irq_managed:1;
pci_dev_flags_t dev_flags; pci_dev_flags_t dev_flags;
atomic_t enable_cnt; /* pci_enable_device has been called */ atomic_t enable_cnt; /* pci_enable_device has been called */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment