mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
x86/irq: Probe for PIC presence before allocating descs for legacy IRQs
Commitd32932d02e
("x86/irq: Convert IOAPIC to use hierarchical irqdomain interfaces") brought a regression for Hyper-V Gen2 instances. These instances don't have i8259 legacy PIC but they use legacy IRQs for serial port, rtc, and acpi. With this commit included we end up with these IRQs not initialized. Earlier, there was a special workaround for legacy IRQs in mp_map_pin_to_irq() doing mp_irqdomain_map() without looking at nr_legacy_irqs() and now we fail in __irq_domain_alloc_irqs() when irq_domain_alloc_descs() returns -EEXIST. The essence of the issue seems to be that early_irq_init() calls arch_probe_nr_irqs() to figure out the number of legacy IRQs before we probe for i8259 and gets 16. Later when init_8259A() is called we switch to NULL legacy PIC and nr_legacy_irqs() starts to return 0 but we already have 16 descs allocated. Solve the issue by separating i8259 probe from init and calling it in arch_probe_nr_irqs() before we actually use nr_legacy_irqs() information. Fixes:d32932d02e
("x86/irq: Convert IOAPIC to use hierarchical irqdomain interfaces") Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Cc: Jiang Liu <jiang.liu@linux.intel.com> Cc: K. Y. Srinivasan <kys@microsoft.com> Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/1446543614-3621-1-git-send-email-vkuznets@redhat.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
354dbaa7ff
commit
8c058b0b9c
@ -60,6 +60,7 @@ struct legacy_pic {
|
|||||||
void (*mask_all)(void);
|
void (*mask_all)(void);
|
||||||
void (*restore_mask)(void);
|
void (*restore_mask)(void);
|
||||||
void (*init)(int auto_eoi);
|
void (*init)(int auto_eoi);
|
||||||
|
int (*probe)(void);
|
||||||
int (*irq_pending)(unsigned int irq);
|
int (*irq_pending)(unsigned int irq);
|
||||||
void (*make_irq)(unsigned int irq);
|
void (*make_irq)(unsigned int irq);
|
||||||
};
|
};
|
||||||
|
@ -361,7 +361,11 @@ int __init arch_probe_nr_irqs(void)
|
|||||||
if (nr < nr_irqs)
|
if (nr < nr_irqs)
|
||||||
nr_irqs = nr;
|
nr_irqs = nr;
|
||||||
|
|
||||||
return nr_legacy_irqs();
|
/*
|
||||||
|
* We don't know if PIC is present at this point so we need to do
|
||||||
|
* probe() to get the right number of legacy IRQs.
|
||||||
|
*/
|
||||||
|
return legacy_pic->probe();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_X86_IO_APIC
|
#ifdef CONFIG_X86_IO_APIC
|
||||||
|
@ -295,16 +295,11 @@ static void unmask_8259A(void)
|
|||||||
raw_spin_unlock_irqrestore(&i8259A_lock, flags);
|
raw_spin_unlock_irqrestore(&i8259A_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_8259A(int auto_eoi)
|
static int probe_8259A(void)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
unsigned char probe_val = ~(1 << PIC_CASCADE_IR);
|
unsigned char probe_val = ~(1 << PIC_CASCADE_IR);
|
||||||
unsigned char new_val;
|
unsigned char new_val;
|
||||||
|
|
||||||
i8259A_auto_eoi = auto_eoi;
|
|
||||||
|
|
||||||
raw_spin_lock_irqsave(&i8259A_lock, flags);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see if we have a PIC.
|
* Check to see if we have a PIC.
|
||||||
* Mask all except the cascade and read
|
* Mask all except the cascade and read
|
||||||
@ -312,16 +307,28 @@ static void init_8259A(int auto_eoi)
|
|||||||
* have a PIC, we will read 0xff as opposed to the
|
* have a PIC, we will read 0xff as opposed to the
|
||||||
* value we wrote.
|
* value we wrote.
|
||||||
*/
|
*/
|
||||||
|
raw_spin_lock_irqsave(&i8259A_lock, flags);
|
||||||
|
|
||||||
outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-2 */
|
outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-2 */
|
||||||
outb(probe_val, PIC_MASTER_IMR);
|
outb(probe_val, PIC_MASTER_IMR);
|
||||||
new_val = inb(PIC_MASTER_IMR);
|
new_val = inb(PIC_MASTER_IMR);
|
||||||
if (new_val != probe_val) {
|
if (new_val != probe_val) {
|
||||||
printk(KERN_INFO "Using NULL legacy PIC\n");
|
printk(KERN_INFO "Using NULL legacy PIC\n");
|
||||||
legacy_pic = &null_legacy_pic;
|
legacy_pic = &null_legacy_pic;
|
||||||
raw_spin_unlock_irqrestore(&i8259A_lock, flags);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
raw_spin_unlock_irqrestore(&i8259A_lock, flags);
|
||||||
|
return nr_legacy_irqs();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void init_8259A(int auto_eoi)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
|
i8259A_auto_eoi = auto_eoi;
|
||||||
|
|
||||||
|
raw_spin_lock_irqsave(&i8259A_lock, flags);
|
||||||
|
|
||||||
outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */
|
outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -379,6 +386,10 @@ static int legacy_pic_irq_pending_noop(unsigned int irq)
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static int legacy_pic_probe(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct legacy_pic null_legacy_pic = {
|
struct legacy_pic null_legacy_pic = {
|
||||||
.nr_legacy_irqs = 0,
|
.nr_legacy_irqs = 0,
|
||||||
@ -388,6 +399,7 @@ struct legacy_pic null_legacy_pic = {
|
|||||||
.mask_all = legacy_pic_noop,
|
.mask_all = legacy_pic_noop,
|
||||||
.restore_mask = legacy_pic_noop,
|
.restore_mask = legacy_pic_noop,
|
||||||
.init = legacy_pic_int_noop,
|
.init = legacy_pic_int_noop,
|
||||||
|
.probe = legacy_pic_probe,
|
||||||
.irq_pending = legacy_pic_irq_pending_noop,
|
.irq_pending = legacy_pic_irq_pending_noop,
|
||||||
.make_irq = legacy_pic_uint_noop,
|
.make_irq = legacy_pic_uint_noop,
|
||||||
};
|
};
|
||||||
@ -400,6 +412,7 @@ struct legacy_pic default_legacy_pic = {
|
|||||||
.mask_all = mask_8259A,
|
.mask_all = mask_8259A,
|
||||||
.restore_mask = unmask_8259A,
|
.restore_mask = unmask_8259A,
|
||||||
.init = init_8259A,
|
.init = init_8259A,
|
||||||
|
.probe = probe_8259A,
|
||||||
.irq_pending = i8259A_irq_pending,
|
.irq_pending = i8259A_irq_pending,
|
||||||
.make_irq = make_8259A_irq,
|
.make_irq = make_8259A_irq,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user