• K
    xen: Find an unbound irq number in reverse order (high to low). · 3a69e916
    Konrad Rzeszutek Wilk 提交于
    In earlier Xen Linux kernels, the IRQ mapping was a straight 1:1 and the
    find_unbound_irq started looking around 256 for open IRQs and up. IRQs
    from 0 to 255 were reserved for PCI devices.  Previous to this patch,
    the 'find_unbound_irq'  started looking at get_nr_hw_irqs() number.
    For privileged  domain where the ACPI information is available that
    returns the upper-bound of what the GSIs. For non-privileged PV domains,
    where ACPI is no-existent the get_nr_hw_irqs() reports the IRQ_LEGACY (16).
    With PCI passthrough enabled, and with PCI cards that have IRQs pinned
    to a higher number than 16 we collide with previously allocated IRQs.
    Specifically the PCI IRQs collide with the IPI's for Xen functions
    (as they are allocated earlier).
    For example:
    
    00:00.11 USB Controller: ATI Technologies Inc SB700 USB OHCI1 Controller (prog-if 10 [OHCI])
    	...
    	Interrupt: pin A routed to IRQ 18
    
    [root@localhost ~]# cat /proc/interrupts | head
               CPU0       CPU1       CPU2
     16:      38186          0          0   xen-dyn-virq      timer0
     17:        149          0          0   xen-dyn-ipi       spinlock0
     18:        962          0          0   xen-dyn-ipi       resched0
    
    and when the USB controller is loaded, the kernel reports:
    IRQ handler type mismatch for IRQ 18
    current handler: resched0
    
    One way to fix this is to reverse the logic when looking for un-used
    IRQ numbers and start with the highest available number. With that,
    we would get:
    
               CPU0       CPU1       CPU2
    ... snip ..
    292:         35          0          0   xen-dyn-ipi       callfunc0
    293:       3992          0          0   xen-dyn-ipi       resched0
    294:        224          0          0   xen-dyn-ipi       spinlock0
    295:      57183          0          0   xen-dyn-virq      timer0
    NMI:          0          0          0   Non-maskable interrupts
    .. snip ..
    
    And interrupts for PCI cards are now accessible.
    
    This patch also includes the fix, found by Ian Campbell, titled
    "xen: fix off-by-one error in find_unbound_irq."
    
    [v2: Added an explanation in the code]
    [v3: Rebased on top of tip/irq/core]
    Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: NJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
    3a69e916
events.c 28.8 KB