x86: make 32 bit to use sparse_irq

but actually irq still needs to be less than NR_IRQS, because
interrupt[NR_IRQS] in entry.S.

need to enable per_cpu vector...

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Yinghai Lu 2008-08-19 20:50:27 -07:00 committed by Ingo Molnar
parent 0f978f4505
commit 199751d715
4 changed files with 79 additions and 30 deletions

View File

@ -34,7 +34,7 @@ config X86
select HAVE_GENERIC_DMA_COHERENT if X86_32 select HAVE_GENERIC_DMA_COHERENT if X86_32
select HAVE_EFFICIENT_UNALIGNED_ACCESS select HAVE_EFFICIENT_UNALIGNED_ACCESS
select HAVE_DYN_ARRAY select HAVE_DYN_ARRAY
select HAVE_SPARSE_IRQ if X86_64 select HAVE_SPARSE_IRQ
config ARCH_DEFCONFIG config ARCH_DEFCONFIG
string string

View File

@ -595,7 +595,6 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
struct irq_pin_list *entry; struct irq_pin_list *entry;
unsigned int apicid_value; unsigned int apicid_value;
cpumask_t tmp; cpumask_t tmp;
struct irq_desc *desc;
cfg = irq_cfg(irq); cfg = irq_cfg(irq);
@ -620,8 +619,7 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
break; break;
entry = entry->next; entry = entry->next;
} }
desc = irq_to_desc(irq); irq_to_desc(irq)->affinity = cpumask;
desc->affinity = cpumask;
spin_unlock_irqrestore(&ioapic_lock, flags); spin_unlock_irqrestore(&ioapic_lock, flags);
} }
@ -1055,8 +1053,6 @@ static int __assign_irq_vector(int irq)
int vector, offset; int vector, offset;
struct irq_cfg *cfg; struct irq_cfg *cfg;
BUG_ON((unsigned)irq >= nr_irqs);
cfg = irq_cfg(irq); cfg = irq_cfg(irq);
if (cfg->vector > 0) if (cfg->vector > 0)
return cfg->vector; return cfg->vector;
@ -1103,7 +1099,12 @@ static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
{ {
struct irq_desc *desc; struct irq_desc *desc;
desc = irq_to_desc(irq); /* first time to use this irq_desc */
if (irq < 16)
desc = irq_to_desc(irq);
else
desc = irq_to_desc_alloc(irq);
if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) || if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
trigger == IOAPIC_LEVEL) { trigger == IOAPIC_LEVEL) {
desc->status |= IRQ_LEVEL; desc->status |= IRQ_LEVEL;
@ -2330,16 +2331,19 @@ device_initcall(ioapic_init_sysfs);
/* /*
* Dynamic irq allocate and deallocation * Dynamic irq allocate and deallocation
*/ */
int create_irq(void) unsigned int create_irq_nr(unsigned int irq_want)
{ {
/* Allocate an unused irq */ /* Allocate an unused irq */
int irq, new, vector = 0; unsigned int irq, new, vector = 0;
unsigned long flags; unsigned long flags;
struct irq_cfg *cfg_new; struct irq_cfg *cfg_new;
irq = -ENOSPC; /* only can use bus/dev/fn.. when per_cpu vector is used */
irq_want = nr_irqs - 1;
irq = 0;
spin_lock_irqsave(&vector_lock, flags); spin_lock_irqsave(&vector_lock, flags);
for (new = (nr_irqs - 1); new >= 0; new--) { for (new = (nr_irqs - 1); new > 0; new--) {
if (platform_legacy_irq(new)) if (platform_legacy_irq(new))
continue; continue;
cfg_new = irq_cfg(new); cfg_new = irq_cfg(new);
@ -2354,13 +2358,18 @@ int create_irq(void)
} }
spin_unlock_irqrestore(&vector_lock, flags); spin_unlock_irqrestore(&vector_lock, flags);
if (irq >= 0) { if (irq > 0) {
set_intr_gate(vector, interrupt[irq]); set_intr_gate(vector, interrupt[irq]);
dynamic_irq_init(irq); dynamic_irq_init(irq);
} }
return irq; return irq;
} }
int create_irq(void)
{
return create_irq_nr(nr_irqs - 1);
}
void destroy_irq(unsigned int irq) void destroy_irq(unsigned int irq)
{ {
unsigned long flags; unsigned long flags;
@ -2415,7 +2424,6 @@ static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask)
unsigned int dest; unsigned int dest;
cpumask_t tmp; cpumask_t tmp;
int vector; int vector;
struct irq_desc *desc;
cpus_and(tmp, mask, cpu_online_map); cpus_and(tmp, mask, cpu_online_map);
if (cpus_empty(tmp)) if (cpus_empty(tmp))
@ -2435,8 +2443,7 @@ static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask)
msg.address_lo |= MSI_ADDR_DEST_ID(dest); msg.address_lo |= MSI_ADDR_DEST_ID(dest);
write_msi_msg(irq, &msg); write_msi_msg(irq, &msg);
desc = irq_to_desc(irq); irq_to_desc(irq)->affinity = mask;
desc->affinity = mask;
} }
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
@ -2455,13 +2462,31 @@ static struct irq_chip msi_chip = {
.retrigger = ioapic_retrigger_irq, .retrigger = ioapic_retrigger_irq,
}; };
static unsigned int build_irq_for_pci_dev(struct pci_dev *dev)
{
unsigned int irq;
irq = dev->bus->number;
irq <<= 8;
irq |= dev->devfn;
irq <<= 12;
return irq;
}
int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
{ {
struct msi_msg msg; struct msi_msg msg;
int irq, ret; int irq, ret;
irq = create_irq();
if (irq < 0) unsigned int irq_want;
return irq;
irq_want = build_irq_for_pci_dev(dev) + 0x100;
irq = create_irq_nr(irq_want);
if (irq == 0)
return -1;
ret = msi_compose_msg(dev, irq, &msg); ret = msi_compose_msg(dev, irq, &msg);
if (ret < 0) { if (ret < 0) {
@ -2510,7 +2535,6 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
{ {
unsigned int dest; unsigned int dest;
cpumask_t tmp; cpumask_t tmp;
struct irq_desc *desc;
cpus_and(tmp, mask, cpu_online_map); cpus_and(tmp, mask, cpu_online_map);
if (cpus_empty(tmp)) if (cpus_empty(tmp))
@ -2521,8 +2545,7 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
dest = cpu_mask_to_apicid(mask); dest = cpu_mask_to_apicid(mask);
target_ht_irq(irq, dest); target_ht_irq(irq, dest);
desc = irq_to_desc(irq); irq_to_desc(irq)->affinity = mask;
desc->affinity = mask;
} }
#endif #endif

View File

@ -224,9 +224,10 @@ unsigned int do_IRQ(struct pt_regs *regs)
struct pt_regs *old_regs; struct pt_regs *old_regs;
/* high bit used in ret_from_ code */ /* high bit used in ret_from_ code */
int overflow, irq = ~regs->orig_ax; int overflow, irq = ~regs->orig_ax;
struct irq_desc *desc = irq_to_desc(irq); struct irq_desc *desc;
if (unlikely((unsigned)irq >= nr_irqs)) { desc = irq_to_desc(irq);
if (unlikely(!desc)) {
printk(KERN_EMERG "%s: cannot handle IRQ %d\n", printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
__func__, irq); __func__, irq);
BUG(); BUG();
@ -263,6 +264,24 @@ int show_interrupts(struct seq_file *p, void *v)
int i = *(loff_t *) v, j; int i = *(loff_t *) v, j;
struct irqaction * action; struct irqaction * action;
unsigned long flags; unsigned long flags;
unsigned int entries;
struct irq_desc *desc;
int tail = 0;
#ifdef CONFIG_HAVE_SPARSE_IRQ
desc = (struct irq_desc *)v;
entries = -1U;
i = desc->irq;
if (!desc->next)
tail = 1;
#else
entries = nr_irqs - 1;
i = *(loff_t *) v;
if (i == nr_irqs)
tail = 1;
else
desc = irq_to_desc(i);
#endif
if (i == 0) { if (i == 0) {
seq_printf(p, " "); seq_printf(p, " ");
@ -271,9 +290,8 @@ int show_interrupts(struct seq_file *p, void *v)
seq_putc(p, '\n'); seq_putc(p, '\n');
} }
if (i < nr_irqs) { if (i <= entries) {
unsigned any_count = 0; unsigned any_count = 0;
struct irq_desc *desc = irq_to_desc(i);
spin_lock_irqsave(&desc->lock, flags); spin_lock_irqsave(&desc->lock, flags);
#ifndef CONFIG_SMP #ifndef CONFIG_SMP
@ -285,7 +303,7 @@ int show_interrupts(struct seq_file *p, void *v)
action = desc->action; action = desc->action;
if (!action && !any_count) if (!action && !any_count)
goto skip; goto skip;
seq_printf(p, "%3d: ",i); seq_printf(p, "%#x: ",i);
#ifndef CONFIG_SMP #ifndef CONFIG_SMP
seq_printf(p, "%10u ", kstat_irqs(i)); seq_printf(p, "%10u ", kstat_irqs(i));
#else #else
@ -304,7 +322,9 @@ int show_interrupts(struct seq_file *p, void *v)
seq_putc(p, '\n'); seq_putc(p, '\n');
skip: skip:
spin_unlock_irqrestore(&desc->lock, flags); spin_unlock_irqrestore(&desc->lock, flags);
} else if (i == nr_irqs) { }
if (tail) {
seq_printf(p, "NMI: "); seq_printf(p, "NMI: ");
for_each_online_cpu(j) for_each_online_cpu(j)
seq_printf(p, "%10u ", nmi_count(j)); seq_printf(p, "%10u ", nmi_count(j));
@ -396,15 +416,14 @@ void fixup_irqs(cpumask_t map)
{ {
unsigned int irq; unsigned int irq;
static int warned; static int warned;
struct irq_desc *desc;
for (irq = 0; irq < nr_irqs; irq++) { for_each_irq_desc(irq, desc) {
cpumask_t mask; cpumask_t mask;
struct irq_desc *desc;
if (irq == 2) if (irq == 2)
continue; continue;
desc = irq_to_desc(irq);
cpus_and(mask, desc->affinity, map); cpus_and(mask, desc->affinity, map);
if (any_online_cpu(mask) == NR_CPUS) { if (any_online_cpu(mask) == NR_CPUS) {
printk("Breaking affinity for irq %i\n", irq); printk("Breaking affinity for irq %i\n", irq);

View File

@ -69,6 +69,13 @@ void __init init_ISA_irqs (void)
* 16 old-style INTA-cycle interrupts: * 16 old-style INTA-cycle interrupts:
*/ */
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
/* first time call this irq_desc */
struct irq_desc *desc = irq_to_desc_alloc(i);
desc->status = IRQ_DISABLED;
desc->action = NULL;
desc->depth = 1;
set_irq_chip_and_handler_name(i, &i8259A_chip, set_irq_chip_and_handler_name(i, &i8259A_chip,
handle_level_irq, "XT"); handle_level_irq, "XT");
} }