提交 199751d7 编写于 作者: Y Yinghai Lu 提交者: Ingo Molnar

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: NYinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 0f978f45
......@@ -34,7 +34,7 @@ config X86
select HAVE_GENERIC_DMA_COHERENT if X86_32
select HAVE_EFFICIENT_UNALIGNED_ACCESS
select HAVE_DYN_ARRAY
select HAVE_SPARSE_IRQ if X86_64
select HAVE_SPARSE_IRQ
config ARCH_DEFCONFIG
string
......
......@@ -595,7 +595,6 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
struct irq_pin_list *entry;
unsigned int apicid_value;
cpumask_t tmp;
struct irq_desc *desc;
cfg = irq_cfg(irq);
......@@ -620,8 +619,7 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
break;
entry = entry->next;
}
desc = irq_to_desc(irq);
desc->affinity = cpumask;
irq_to_desc(irq)->affinity = cpumask;
spin_unlock_irqrestore(&ioapic_lock, flags);
}
......@@ -1055,8 +1053,6 @@ static int __assign_irq_vector(int irq)
int vector, offset;
struct irq_cfg *cfg;
BUG_ON((unsigned)irq >= nr_irqs);
cfg = irq_cfg(irq);
if (cfg->vector > 0)
return cfg->vector;
......@@ -1103,7 +1099,12 @@ static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
{
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)) ||
trigger == IOAPIC_LEVEL) {
desc->status |= IRQ_LEVEL;
......@@ -2330,16 +2331,19 @@ device_initcall(ioapic_init_sysfs);
/*
* Dynamic irq allocate and deallocation
*/
int create_irq(void)
unsigned int create_irq_nr(unsigned int irq_want)
{
/* Allocate an unused irq */
int irq, new, vector = 0;
unsigned int irq, new, vector = 0;
unsigned long flags;
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);
for (new = (nr_irqs - 1); new >= 0; new--) {
for (new = (nr_irqs - 1); new > 0; new--) {
if (platform_legacy_irq(new))
continue;
cfg_new = irq_cfg(new);
......@@ -2354,13 +2358,18 @@ int create_irq(void)
}
spin_unlock_irqrestore(&vector_lock, flags);
if (irq >= 0) {
if (irq > 0) {
set_intr_gate(vector, interrupt[irq]);
dynamic_irq_init(irq);
}
return irq;
}
int create_irq(void)
{
return create_irq_nr(nr_irqs - 1);
}
void destroy_irq(unsigned int irq)
{
unsigned long flags;
......@@ -2415,7 +2424,6 @@ static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask)
unsigned int dest;
cpumask_t tmp;
int vector;
struct irq_desc *desc;
cpus_and(tmp, mask, cpu_online_map);
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);
write_msi_msg(irq, &msg);
desc = irq_to_desc(irq);
desc->affinity = mask;
irq_to_desc(irq)->affinity = mask;
}
#endif /* CONFIG_SMP */
......@@ -2455,13 +2462,31 @@ static struct irq_chip msi_chip = {
.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)
{
struct msi_msg msg;
int irq, ret;
irq = create_irq();
if (irq < 0)
return irq;
unsigned int irq_want;
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);
if (ret < 0) {
......@@ -2510,7 +2535,6 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
{
unsigned int dest;
cpumask_t tmp;
struct irq_desc *desc;
cpus_and(tmp, mask, cpu_online_map);
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);
target_ht_irq(irq, dest);
desc = irq_to_desc(irq);
desc->affinity = mask;
irq_to_desc(irq)->affinity = mask;
}
#endif
......
......@@ -224,9 +224,10 @@ unsigned int do_IRQ(struct pt_regs *regs)
struct pt_regs *old_regs;
/* high bit used in ret_from_ code */
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",
__func__, irq);
BUG();
......@@ -263,6 +264,24 @@ int show_interrupts(struct seq_file *p, void *v)
int i = *(loff_t *) v, j;
struct irqaction * action;
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) {
seq_printf(p, " ");
......@@ -271,9 +290,8 @@ int show_interrupts(struct seq_file *p, void *v)
seq_putc(p, '\n');
}
if (i < nr_irqs) {
if (i <= entries) {
unsigned any_count = 0;
struct irq_desc *desc = irq_to_desc(i);
spin_lock_irqsave(&desc->lock, flags);
#ifndef CONFIG_SMP
......@@ -285,7 +303,7 @@ int show_interrupts(struct seq_file *p, void *v)
action = desc->action;
if (!action && !any_count)
goto skip;
seq_printf(p, "%3d: ",i);
seq_printf(p, "%#x: ",i);
#ifndef CONFIG_SMP
seq_printf(p, "%10u ", kstat_irqs(i));
#else
......@@ -304,7 +322,9 @@ int show_interrupts(struct seq_file *p, void *v)
seq_putc(p, '\n');
skip:
spin_unlock_irqrestore(&desc->lock, flags);
} else if (i == nr_irqs) {
}
if (tail) {
seq_printf(p, "NMI: ");
for_each_online_cpu(j)
seq_printf(p, "%10u ", nmi_count(j));
......@@ -396,15 +416,14 @@ void fixup_irqs(cpumask_t map)
{
unsigned int irq;
static int warned;
struct irq_desc *desc;
for (irq = 0; irq < nr_irqs; irq++) {
for_each_irq_desc(irq, desc) {
cpumask_t mask;
struct irq_desc *desc;
if (irq == 2)
continue;
desc = irq_to_desc(irq);
cpus_and(mask, desc->affinity, map);
if (any_online_cpu(mask) == NR_CPUS) {
printk("Breaking affinity for irq %i\n", irq);
......
......@@ -69,6 +69,13 @@ void __init init_ISA_irqs (void)
* 16 old-style INTA-cycle interrupts:
*/
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,
handle_level_irq, "XT");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册