[PATCH] PCI: per-platform IA64_{FIRST,LAST}_DEVICE_VECTOR definitions
authorMark Maule <maule@sgi.com>
Fri, 14 Apr 2006 21:03:49 +0000 (16:03 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 21 Jun 2006 18:59:59 +0000 (11:59 -0700)
Abstract IA64_FIRST_DEVICE_VECTOR/IA64_LAST_DEVICE_VECTOR since SN platforms
use a subset of the IA64 range.  Implement this by making the above macros
global variables which the platform can override in it setup code.

Also add a reserve_irq_vector() routine used by SN to mark a vector's as
in-use when that weren't allocated through assign_irq_vector().

Signed-off-by: Mark Maule <maule@sgi.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/ia64/kernel/irq_ia64.c
arch/ia64/sn/kernel/irq.c
drivers/pci/msi.c
include/asm-ia64/hw_irq.h

index 6c4d59fd03641dbd6ec0543f0f00095e844b7a6b..ef9a2b49307ae756ac58a8fb7f8c360aa2aca53a 100644 (file)
 
 #define IRQ_DEBUG      0
 
+/* These can be overridden in platform_irq_init */
+int ia64_first_device_vector = IA64_DEF_FIRST_DEVICE_VECTOR;
+int ia64_last_device_vector = IA64_DEF_LAST_DEVICE_VECTOR;
+
 /* default base addr of IPI table */
 void __iomem *ipi_base_addr = ((void __iomem *)
                               (__IA64_UNCACHED_OFFSET | IA64_IPI_DEFAULT_BASE_ADDR));
@@ -60,7 +64,7 @@ __u8 isa_irq_to_vector_map[16] = {
 };
 EXPORT_SYMBOL(isa_irq_to_vector_map);
 
-static unsigned long ia64_vector_mask[BITS_TO_LONGS(IA64_NUM_DEVICE_VECTORS)];
+static unsigned long ia64_vector_mask[BITS_TO_LONGS(IA64_MAX_DEVICE_VECTORS)];
 
 int
 assign_irq_vector (int irq)
@@ -89,6 +93,19 @@ free_irq_vector (int vector)
                printk(KERN_WARNING "%s: double free!\n", __FUNCTION__);
 }
 
+int
+reserve_irq_vector (int vector)
+{
+       int pos;
+
+       if (vector < IA64_FIRST_DEVICE_VECTOR ||
+           vector > IA64_LAST_DEVICE_VECTOR)
+               return -EINVAL;
+
+       pos = vector - IA64_FIRST_DEVICE_VECTOR;
+       return test_and_set_bit(pos, ia64_vector_mask);
+}
+
 #ifdef CONFIG_SMP
 #      define IS_RESCHEDULE(vec)       (vec == IA64_IPI_RESCHEDULE)
 #else
index c265e02f50364af608f34ed53cd0d47af4eb6f1f..db187f5cdae13bfdae59d2fcfa804de16ad7a66b 100644 (file)
@@ -202,6 +202,9 @@ void sn_irq_init(void)
        int i;
        irq_desc_t *base_desc = irq_desc;
 
+       ia64_first_device_vector = IA64_SN2_FIRST_DEVICE_VECTOR;
+       ia64_last_device_vector = IA64_SN2_LAST_DEVICE_VECTOR;
+
        for (i = 0; i < NR_IRQS; i++) {
                if (base_desc[i].handler == &no_irq_type) {
                        base_desc[i].handler = &irq_type_sn;
@@ -285,6 +288,7 @@ void sn_irq_fixup(struct pci_dev *pci_dev, struct sn_irq_info *sn_irq_info)
        /* link it into the sn_irq[irq] list */
        spin_lock(&sn_irq_info_lock);
        list_add_rcu(&sn_irq_info->list, sn_irq_lh[sn_irq_info->irq_irq]);
+       reserve_irq_vector(sn_irq_info->irq_irq);
        spin_unlock(&sn_irq_info_lock);
 
        register_intr_pda(sn_irq_info);
@@ -310,8 +314,11 @@ void sn_irq_unfixup(struct pci_dev *pci_dev)
        spin_lock(&sn_irq_info_lock);
        list_del_rcu(&sn_irq_info->list);
        spin_unlock(&sn_irq_info_lock);
+       if (list_empty(sn_irq_lh[sn_irq_info->irq_irq]))
+               free_irq_vector(sn_irq_info->irq_irq);
        call_rcu(&sn_irq_info->rcu, sn_irq_info_free);
        pci_dev_put(pci_dev);
+
 }
 
 static inline void
index 55ff52df5fe782c1a0f1855a064d16b9a9a227d3..f8105783da2f54d6a9e1a2eb80ad9ebe6d1aa80d 100644 (file)
@@ -35,7 +35,7 @@ static int nr_msix_devices;
 
 #ifndef CONFIG_X86_IO_APIC
 int vector_irq[NR_VECTORS] = { [0 ... NR_VECTORS - 1] = -1};
-u8 irq_vector[NR_IRQ_VECTORS] = { FIRST_DEVICE_VECTOR , 0 };
+u8 irq_vector[NR_IRQ_VECTORS];
 #endif
 
 static struct msi_ops *msi_ops;
@@ -383,6 +383,10 @@ static int msi_init(void)
                return status;
        }
 
+#ifndef CONFIG_X86_IO_APIC
+       irq_vector[0] = FIRST_DEVICE_VECTOR;
+#endif
+
        if (last_alloc_vector < 0) {
                pci_msi_enable = 0;
                printk(KERN_WARNING "PCI: No interrupt vectors available for MSI\n");
index 0cf119b42f7d5c4d1d25ce4eb0e55b9a849d52cb..ea8b8c407ab4a210f50b055c2030cb34222fdca0 100644 (file)
@@ -47,9 +47,19 @@ typedef u8 ia64_vector;
 #define IA64_CMC_VECTOR                        0x1f    /* corrected machine-check interrupt vector */
 /*
  * Vectors 0x20-0x2f are reserved for legacy ISA IRQs.
+ * Use vectors 0x30-0xe7 as the default device vector range for ia64.
+ * Platforms may choose to reduce this range in platform_irq_setup, but the
+ * platform range must fall within
+ *     [IA64_DEF_FIRST_DEVICE_VECTOR..IA64_DEF_LAST_DEVICE_VECTOR]
  */
-#define IA64_FIRST_DEVICE_VECTOR       0x30
-#define IA64_LAST_DEVICE_VECTOR                0xe7
+extern int ia64_first_device_vector;
+extern int ia64_last_device_vector;
+
+#define IA64_DEF_FIRST_DEVICE_VECTOR   0x30
+#define IA64_DEF_LAST_DEVICE_VECTOR    0xe7
+#define IA64_FIRST_DEVICE_VECTOR       ia64_first_device_vector
+#define IA64_LAST_DEVICE_VECTOR                ia64_last_device_vector
+#define IA64_MAX_DEVICE_VECTORS                (IA64_DEF_LAST_DEVICE_VECTOR - IA64_DEF_FIRST_DEVICE_VECTOR + 1)
 #define IA64_NUM_DEVICE_VECTORS                (IA64_LAST_DEVICE_VECTOR - IA64_FIRST_DEVICE_VECTOR + 1)
 
 #define IA64_MCA_RENDEZ_VECTOR         0xe8    /* MCA rendez interrupt */
@@ -83,6 +93,7 @@ extern struct hw_interrupt_type irq_type_ia64_lsapic; /* CPU-internal interrupt
 
 extern int assign_irq_vector (int irq);        /* allocate a free vector */
 extern void free_irq_vector (int vector);
+extern int reserve_irq_vector (int vector);
 extern void ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect);
 extern void register_percpu_irq (ia64_vector vec, struct irqaction *action);