ia64/xen-unstable

changeset 19179:501bc4129e41

x86: Move interrupt vector management from io_apic.c to irq.c

Signed-off-by: Espen Skoglund <espen.skoglund@netronome.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Feb 06 10:40:00 2009 +0000 (2009-02-06)
parents 9dacc3722159
children 4fcf4c9c9751
files xen/arch/x86/io_apic.c xen/arch/x86/irq.c
line diff
     1.1 --- a/xen/arch/x86/io_apic.c	Fri Feb 06 10:39:10 2009 +0000
     1.2 +++ b/xen/arch/x86/io_apic.c	Fri Feb 06 10:40:00 2009 +0000
     1.3 @@ -49,7 +49,6 @@ atomic_t irq_mis_count;
     1.4  static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
     1.5  
     1.6  static DEFINE_SPINLOCK(ioapic_lock);
     1.7 -static DEFINE_SPINLOCK(vector_lock);
     1.8  
     1.9  int skip_ioapic_setup;
    1.10  
    1.11 @@ -89,9 +88,6 @@ static struct irq_pin_list {
    1.12  };
    1.13  static int irq_2_pin_free_entry = NR_IRQS;
    1.14  
    1.15 -int vector_irq[NR_VECTORS] __read_mostly = {
    1.16 -    [0 ... NR_VECTORS - 1] = FREE_TO_ASSIGN};
    1.17 -
    1.18  /*
    1.19   * The common case is 1:1 IRQ<->pin mappings. Sometimes there are
    1.20   * shared ISA-space IRQs, so we have to support them. We are super
    1.21 @@ -669,56 +665,6 @@ static inline int IO_APIC_irq_trigger(in
    1.22  /* irq_vectors is indexed by the sum of all RTEs in all I/O APICs. */
    1.23  u8 irq_vector[NR_IRQS] __read_mostly;
    1.24  
    1.25 -int free_irq_vector(int vector)
    1.26 -{
    1.27 -    int irq;
    1.28 -
    1.29 -    BUG_ON((vector > LAST_DYNAMIC_VECTOR) || (vector < FIRST_DYNAMIC_VECTOR));
    1.30 -
    1.31 -    spin_lock(&vector_lock);
    1.32 -    if ((irq = vector_irq[vector]) == AUTO_ASSIGN)
    1.33 -        vector_irq[vector] = FREE_TO_ASSIGN;
    1.34 -    spin_unlock(&vector_lock);
    1.35 -
    1.36 -    return (irq == AUTO_ASSIGN) ? 0 : -EINVAL;
    1.37 -}
    1.38 -
    1.39 -int assign_irq_vector(int irq)
    1.40 -{
    1.41 -    static unsigned current_vector = FIRST_DYNAMIC_VECTOR;
    1.42 -    unsigned vector;
    1.43 -
    1.44 -    BUG_ON(irq >= NR_IRQS);
    1.45 -
    1.46 -    spin_lock(&vector_lock);
    1.47 -
    1.48 -    if ((irq != AUTO_ASSIGN) && (IO_APIC_VECTOR(irq) > 0)) {
    1.49 -        spin_unlock(&vector_lock);
    1.50 -        return IO_APIC_VECTOR(irq);
    1.51 -    }
    1.52 -
    1.53 -    vector = current_vector;
    1.54 -    while (vector_irq[vector] != FREE_TO_ASSIGN) {
    1.55 -        vector += 8;
    1.56 -        if (vector > LAST_DYNAMIC_VECTOR)
    1.57 -            vector = FIRST_DYNAMIC_VECTOR + ((vector + 1) & 7);
    1.58 -
    1.59 -        if (vector == current_vector) {
    1.60 -            spin_unlock(&vector_lock);
    1.61 -            return -ENOSPC;
    1.62 -        }
    1.63 -    }
    1.64 -
    1.65 -    current_vector = vector;
    1.66 -    vector_irq[vector] = irq;
    1.67 -    if (irq != AUTO_ASSIGN)
    1.68 -        IO_APIC_VECTOR(irq) = vector;
    1.69 -
    1.70 -    spin_unlock(&vector_lock);
    1.71 -
    1.72 -    return vector;
    1.73 -}
    1.74 -
    1.75  static struct hw_interrupt_type ioapic_level_type;
    1.76  static struct hw_interrupt_type ioapic_edge_type;
    1.77  
     2.1 --- a/xen/arch/x86/irq.c	Fri Feb 06 10:39:10 2009 +0000
     2.2 +++ b/xen/arch/x86/irq.c	Fri Feb 06 10:40:00 2009 +0000
     2.3 @@ -27,6 +27,11 @@ boolean_param("noirqbalance", opt_noirqb
     2.4  
     2.5  irq_desc_t irq_desc[NR_VECTORS];
     2.6  
     2.7 +static DEFINE_SPINLOCK(vector_lock);
     2.8 +int vector_irq[NR_VECTORS] __read_mostly = {
     2.9 +    [0 ... NR_VECTORS - 1] = FREE_TO_ASSIGN
    2.10 +};
    2.11 +
    2.12  static void __do_IRQ_guest(int vector);
    2.13  
    2.14  void no_action(int cpl, void *dev_id, struct cpu_user_regs *regs) { }
    2.15 @@ -54,6 +59,56 @@ struct hw_interrupt_type no_irq_type = {
    2.16  
    2.17  atomic_t irq_err_count;
    2.18  
    2.19 +int free_irq_vector(int vector)
    2.20 +{
    2.21 +    int irq;
    2.22 +
    2.23 +    BUG_ON((vector > LAST_DYNAMIC_VECTOR) || (vector < FIRST_DYNAMIC_VECTOR));
    2.24 +
    2.25 +    spin_lock(&vector_lock);
    2.26 +    if ((irq = vector_irq[vector]) == AUTO_ASSIGN)
    2.27 +        vector_irq[vector] = FREE_TO_ASSIGN;
    2.28 +    spin_unlock(&vector_lock);
    2.29 +
    2.30 +    return (irq == AUTO_ASSIGN) ? 0 : -EINVAL;
    2.31 +}
    2.32 +
    2.33 +int assign_irq_vector(int irq)
    2.34 +{
    2.35 +    static unsigned current_vector = FIRST_DYNAMIC_VECTOR;
    2.36 +    unsigned vector;
    2.37 +
    2.38 +    BUG_ON(irq >= NR_IRQS);
    2.39 +
    2.40 +    spin_lock(&vector_lock);
    2.41 +
    2.42 +    if ((irq != AUTO_ASSIGN) && (IO_APIC_VECTOR(irq) > 0)) {
    2.43 +        spin_unlock(&vector_lock);
    2.44 +        return IO_APIC_VECTOR(irq);
    2.45 +    }
    2.46 +
    2.47 +    vector = current_vector;
    2.48 +    while (vector_irq[vector] != FREE_TO_ASSIGN) {
    2.49 +        vector += 8;
    2.50 +        if (vector > LAST_DYNAMIC_VECTOR)
    2.51 +            vector = FIRST_DYNAMIC_VECTOR + ((vector + 1) & 7);
    2.52 +
    2.53 +        if (vector == current_vector) {
    2.54 +            spin_unlock(&vector_lock);
    2.55 +            return -ENOSPC;
    2.56 +        }
    2.57 +    }
    2.58 +
    2.59 +    current_vector = vector;
    2.60 +    vector_irq[vector] = irq;
    2.61 +    if (irq != AUTO_ASSIGN)
    2.62 +        IO_APIC_VECTOR(irq) = vector;
    2.63 +
    2.64 +    spin_unlock(&vector_lock);
    2.65 +
    2.66 +    return vector;
    2.67 +}
    2.68 +
    2.69  asmlinkage void do_IRQ(struct cpu_user_regs *regs)
    2.70  {
    2.71      unsigned int      vector = regs->entry_vector;