ia64/xen-unstable

changeset 18820:6468257e9e62

Properly distinguish irq and vector spaces

This makes sure that there are no assumptions about NR_IRQS==NR_VECTORS
anymore, and it also renames various variables to properly reflect
what they represent.

While coded correctly, I wonder whether dump_irqs() shouldn't iterate
over the vector space rather than the irq space, so that MSI entries
are also processed.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Nov 20 14:22:54 2008 +0000 (2008-11-20)
parents db7a713071fe
children 935bd48f096a
files xen/arch/x86/i8259.c xen/arch/x86/io_apic.c xen/arch/x86/irq.c xen/arch/x86/msi.c xen/include/asm-ia64/hvm/irq.h xen/include/asm-ia64/linux/asm/irq.h xen/include/asm-x86/msi.h xen/include/xen/irq.h
line diff
     1.1 --- a/xen/arch/x86/i8259.c	Thu Nov 20 14:21:17 2008 +0000
     1.2 +++ b/xen/arch/x86/i8259.c	Thu Nov 20 14:22:54 2008 +0000
     1.3 @@ -390,7 +390,7 @@ void __init init_IRQ(void)
     1.4  
     1.5      init_8259A(0);
     1.6  
     1.7 -    for ( i = 0; i < NR_IRQS; i++ )
     1.8 +    for ( i = 0; i < NR_VECTORS; i++ )
     1.9      {
    1.10          irq_desc[i].status  = IRQ_DISABLED;
    1.11          irq_desc[i].handler = &no_irq_type;
     2.1 --- a/xen/arch/x86/io_apic.c	Thu Nov 20 14:21:17 2008 +0000
     2.2 +++ b/xen/arch/x86/io_apic.c	Thu Nov 20 14:22:54 2008 +0000
     2.3 @@ -1547,20 +1547,10 @@ static struct hw_interrupt_type ioapic_l
     2.4      .set_affinity 	= set_ioapic_affinity_vector,
     2.5  };
     2.6  
     2.7 -static void mask_msi_vector(unsigned int vector)
     2.8 -{
     2.9 -    mask_msi_irq(vector);
    2.10 -}
    2.11 -
    2.12 -static void unmask_msi_vector(unsigned int vector)
    2.13 -{
    2.14 -    unmask_msi_irq(vector);
    2.15 -}
    2.16 -
    2.17  static unsigned int startup_msi_vector(unsigned int vector)
    2.18  {
    2.19      dprintk(XENLOG_INFO, "startup msi vector %x\n", vector);
    2.20 -    unmask_msi_irq(vector);
    2.21 +    unmask_msi_vector(vector);
    2.22      return 0;
    2.23  }
    2.24  
    2.25 @@ -1576,13 +1566,13 @@ static void end_msi_vector(unsigned int 
    2.26  static void shutdown_msi_vector(unsigned int vector)
    2.27  {
    2.28      dprintk(XENLOG_INFO, "shutdown msi vector %x\n", vector);
    2.29 -    mask_msi_irq(vector);
    2.30 +    mask_msi_vector(vector);
    2.31  }
    2.32  
    2.33  static void set_msi_affinity_vector(unsigned int vector, cpumask_t cpu_mask)
    2.34  {
    2.35      set_native_irq_info(vector, cpu_mask);
    2.36 -    set_msi_irq_affinity(vector, cpu_mask);
    2.37 +    set_msi_affinity(vector, cpu_mask);
    2.38  }
    2.39  
    2.40  /*
     3.1 --- a/xen/arch/x86/irq.c	Thu Nov 20 14:21:17 2008 +0000
     3.2 +++ b/xen/arch/x86/irq.c	Thu Nov 20 14:22:54 2008 +0000
     3.3 @@ -24,7 +24,7 @@
     3.4  int opt_noirqbalance = 0;
     3.5  boolean_param("noirqbalance", opt_noirqbalance);
     3.6  
     3.7 -irq_desc_t irq_desc[NR_IRQS];
     3.8 +irq_desc_t irq_desc[NR_VECTORS];
     3.9  
    3.10  static void __do_IRQ_guest(int vector);
    3.11  
    3.12 @@ -206,7 +206,7 @@ struct pending_eoi {
    3.13  static DEFINE_PER_CPU(struct pending_eoi, pending_eoi[NR_VECTORS]);
    3.14  #define pending_eoi_sp(p) ((p)[NR_VECTORS-1].vector)
    3.15  
    3.16 -static struct timer irq_guest_eoi_timer[NR_IRQS];
    3.17 +static struct timer irq_guest_eoi_timer[NR_VECTORS];
    3.18  static void irq_guest_eoi_timer_fn(void *data)
    3.19  {
    3.20      irq_desc_t *desc = data;
    3.21 @@ -1006,28 +1006,30 @@ static int __init setup_dump_irqs(void)
    3.22  
    3.23  void fixup_irqs(cpumask_t map)
    3.24  {
    3.25 -    unsigned int irq, sp;
    3.26 +    unsigned int vector, sp;
    3.27      static int warned;
    3.28      irq_guest_action_t *action;
    3.29      struct pending_eoi *peoi;
    3.30  
    3.31      /* Direct all future interrupts away from this CPU. */
    3.32 -    for ( irq = 0; irq < NR_IRQS; irq++ )
    3.33 +    for ( vector = 0; vector < NR_VECTORS; vector++ )
    3.34      {
    3.35          cpumask_t mask;
    3.36 -        if ( irq == 2 )
    3.37 +        if ( vector_to_irq(vector) == 2 )
    3.38              continue;
    3.39  
    3.40 -        cpus_and(mask, irq_desc[irq].affinity, map);
    3.41 +        cpus_and(mask, irq_desc[vector].affinity, map);
    3.42          if ( any_online_cpu(mask) == NR_CPUS )
    3.43          {
    3.44 -            printk("Breaking affinity for irq %i\n", irq);
    3.45 +            printk("Breaking affinity for vector %u (irq %i)\n",
    3.46 +                   vector, vector_to_irq(vector));
    3.47              mask = map;
    3.48          }
    3.49 -        if ( irq_desc[irq].handler->set_affinity )
    3.50 -            irq_desc[irq].handler->set_affinity(irq, mask);
    3.51 -        else if ( irq_desc[irq].action && !(warned++) )
    3.52 -            printk("Cannot set affinity for irq %i\n", irq);
    3.53 +        if ( irq_desc[vector].handler->set_affinity )
    3.54 +            irq_desc[vector].handler->set_affinity(vector, mask);
    3.55 +        else if ( irq_desc[vector].action && !(warned++) )
    3.56 +            printk("Cannot set affinity for irq %u (irq %i)\n",
    3.57 +                   vector, vector_to_irq(vector));
    3.58      }
    3.59  
    3.60      /* Service any interrupts that beat us in the re-direction race. */
    3.61 @@ -1036,11 +1038,11 @@ void fixup_irqs(cpumask_t map)
    3.62      local_irq_disable();
    3.63  
    3.64      /* Clean up cpu_eoi_map of every interrupt to exclude this CPU. */
    3.65 -    for ( irq = 0; irq < NR_IRQS; irq++ )
    3.66 +    for ( vector = 0; vector < NR_VECTORS; vector++ )
    3.67      {
    3.68 -        if ( !(irq_desc[irq].status & IRQ_GUEST) )
    3.69 +        if ( !(irq_desc[vector].status & IRQ_GUEST) )
    3.70              continue;
    3.71 -        action = (irq_guest_action_t *)irq_desc[irq].action;
    3.72 +        action = (irq_guest_action_t *)irq_desc[vector].action;
    3.73          cpu_clear(smp_processor_id(), action->cpu_eoi_map);
    3.74      }
    3.75  
     4.1 --- a/xen/arch/x86/msi.c	Thu Nov 20 14:21:17 2008 +0000
     4.2 +++ b/xen/arch/x86/msi.c	Thu Nov 20 14:22:54 2008 +0000
     4.3 @@ -212,9 +212,9 @@ static void write_msi_msg(struct msi_des
     4.4      entry->msg = *msg;
     4.5  }
     4.6  
     4.7 -void set_msi_irq_affinity(unsigned int irq, cpumask_t mask)
     4.8 +void set_msi_affinity(unsigned int vector, cpumask_t mask)
     4.9  {
    4.10 -    struct msi_desc *desc = irq_desc[irq].msi_desc;
    4.11 +    struct msi_desc *desc = irq_desc[vector].msi_desc;
    4.12      struct msi_msg msg;
    4.13      unsigned int dest;
    4.14  
    4.15 @@ -227,7 +227,7 @@ void set_msi_irq_affinity(unsigned int i
    4.16      if ( !desc )
    4.17          return;
    4.18  
    4.19 -    ASSERT(spin_is_locked(&irq_desc[irq].lock));
    4.20 +    ASSERT(spin_is_locked(&irq_desc[vector].lock));
    4.21      spin_lock(&desc->dev->lock);
    4.22      read_msi_msg(desc, &msg);
    4.23  
    4.24 @@ -276,9 +276,9 @@ static void msix_set_enable(struct pci_d
    4.25      }
    4.26  }
    4.27  
    4.28 -static void msix_flush_writes(unsigned int irq)
    4.29 +static void msix_flush_writes(unsigned int vector)
    4.30  {
    4.31 -    struct msi_desc *entry = irq_desc[irq].msi_desc;
    4.32 +    struct msi_desc *entry = irq_desc[vector].msi_desc;
    4.33  
    4.34      BUG_ON(!entry || !entry->dev);
    4.35      switch (entry->msi_attrib.type) {
    4.36 @@ -305,11 +305,11 @@ int msi_maskable_irq(const struct msi_de
    4.37             || entry->msi_attrib.maskbit;
    4.38  }
    4.39  
    4.40 -static void msi_set_mask_bit(unsigned int irq, int flag)
    4.41 +static void msi_set_mask_bit(unsigned int vector, int flag)
    4.42  {
    4.43 -    struct msi_desc *entry = irq_desc[irq].msi_desc;
    4.44 +    struct msi_desc *entry = irq_desc[vector].msi_desc;
    4.45  
    4.46 -    ASSERT(spin_is_locked(&irq_desc[irq].lock));
    4.47 +    ASSERT(spin_is_locked(&irq_desc[vector].lock));
    4.48      BUG_ON(!entry || !entry->dev);
    4.49      switch (entry->msi_attrib.type) {
    4.50      case PCI_CAP_ID_MSI:
    4.51 @@ -342,16 +342,16 @@ static void msi_set_mask_bit(unsigned in
    4.52      entry->msi_attrib.masked = !!flag;
    4.53  }
    4.54  
    4.55 -void mask_msi_irq(unsigned int irq)
    4.56 +void mask_msi_vector(unsigned int vector)
    4.57  {
    4.58 -    msi_set_mask_bit(irq, 1);
    4.59 -    msix_flush_writes(irq);
    4.60 +    msi_set_mask_bit(vector, 1);
    4.61 +    msix_flush_writes(vector);
    4.62  }
    4.63  
    4.64 -void unmask_msi_irq(unsigned int irq)
    4.65 +void unmask_msi_vector(unsigned int vector)
    4.66  {
    4.67 -    msi_set_mask_bit(irq, 0);
    4.68 -    msix_flush_writes(irq);
    4.69 +    msi_set_mask_bit(vector, 0);
    4.70 +    msix_flush_writes(vector);
    4.71  }
    4.72  
    4.73  static struct msi_desc* alloc_msi_entry(void)
     5.1 --- a/xen/include/asm-ia64/hvm/irq.h	Thu Nov 20 14:21:17 2008 +0000
     5.2 +++ b/xen/include/asm-ia64/hvm/irq.h	Thu Nov 20 14:22:54 2008 +0000
     5.3 @@ -24,7 +24,6 @@
     5.4  
     5.5  #include <xen/irq.h>
     5.6  
     5.7 -#define NR_VECTORS 256
     5.8  #define VIOAPIC_NUM_PINS  48
     5.9  
    5.10  #include <xen/hvm/irq.h>
     6.1 --- a/xen/include/asm-ia64/linux/asm/irq.h	Thu Nov 20 14:21:17 2008 +0000
     6.2 +++ b/xen/include/asm-ia64/linux/asm/irq.h	Thu Nov 20 14:22:54 2008 +0000
     6.3 @@ -11,6 +11,7 @@
     6.4   * 02/29/00     D.Mosberger	moved most things into hw_irq.h
     6.5   */
     6.6  
     6.7 +#define NR_VECTORS	256
     6.8  #define NR_IRQS		256
     6.9  #define NR_IRQ_VECTORS	NR_IRQS
    6.10  
     7.1 --- a/xen/include/asm-x86/msi.h	Thu Nov 20 14:21:17 2008 +0000
     7.2 +++ b/xen/include/asm-x86/msi.h	Thu Nov 20 14:22:54 2008 +0000
     7.3 @@ -69,9 +69,9 @@ struct msi_msg {
     7.4  };
     7.5  
     7.6  /* Helper functions */
     7.7 -extern void mask_msi_irq(unsigned int irq);
     7.8 -extern void unmask_msi_irq(unsigned int irq);
     7.9 -extern void set_msi_irq_affinity(unsigned int irq, cpumask_t mask);
    7.10 +extern void mask_msi_vector(unsigned int vector);
    7.11 +extern void unmask_msi_vector(unsigned int vector);
    7.12 +extern void set_msi_affinity(unsigned int vector, cpumask_t mask);
    7.13  extern int pci_enable_msi(struct msi_info *msi);
    7.14  extern void pci_disable_msi(int vector);
    7.15  extern void pci_cleanup_msi(struct pci_dev *pdev);
     8.1 --- a/xen/include/xen/irq.h	Thu Nov 20 14:21:17 2008 +0000
     8.2 +++ b/xen/include/xen/irq.h	Thu Nov 20 14:22:54 2008 +0000
     8.3 @@ -61,7 +61,7 @@ typedef struct {
     8.4      cpumask_t affinity;
     8.5  } __cacheline_aligned irq_desc_t;
     8.6  
     8.7 -extern irq_desc_t irq_desc[NR_IRQS];
     8.8 +extern irq_desc_t irq_desc[NR_VECTORS];
     8.9  
    8.10  extern int setup_irq(unsigned int, struct irqaction *);
    8.11  extern void free_irq(unsigned int);
    8.12 @@ -81,13 +81,16 @@ extern void pirq_guest_unbind(struct dom
    8.13  extern irq_desc_t *domain_spin_lock_irq_desc(
    8.14      struct domain *d, int irq, unsigned long *pflags);
    8.15  
    8.16 -static inline void set_native_irq_info(int irq, cpumask_t mask)
    8.17 +static inline void set_native_irq_info(unsigned int vector, cpumask_t mask)
    8.18  {
    8.19 -    irq_desc[irq].affinity = mask;
    8.20 +    irq_desc[vector].affinity = mask;
    8.21  }
    8.22  
    8.23 +#ifdef irq_to_vector
    8.24  static inline void set_irq_info(int irq, cpumask_t mask)
    8.25  {
    8.26 -    set_native_irq_info(irq, mask);
    8.27 +    set_native_irq_info(irq_to_vector(irq), mask);
    8.28  }
    8.29 +#endif
    8.30 +
    8.31  #endif /* __XEN_IRQ_H__ */