QEMU how-to allocate specific IRQ number for PCI device?

905 Views Asked by At

I'm running qemu-system-x86_64 with my new pci device. And i want to use IRQ 17 (Since driver from kernel listen for IRQ 17). But my PCI device take IRQ 10 or 11. base on interrupt_pin(A,B,C,E). Then i want to send irq to kernel module by qemu_irq_pulse.

This is how i allocate irq:

pci_config_set_interrupt_pin(pci_dev->config, 1);
d->irq = pci_allocate_irq(pci_dev)


root@hostname:~# cat /proc/interrupts 
           CPU0       
  0:         48   IO-APIC   2-edge      timer
  1:          9   IO-APIC   1-edge      i8042
  4:       1440   IO-APIC   4-edge      ttyS0
  8:          1   IO-APIC   8-edge      rtc0
  9:          0   IO-APIC   9-fasteoi   acpi
 12:        125   IO-APIC  12-edge      i8042
 24:        773   PCI-MSI 512000-edge      ahci[0000:00:1f.2]
 25:        355   PCI-MSI 32768-edge      eth0-rx-0
 26:        160   PCI-MSI 32769-edge      eth0-tx-0
 27:          1   PCI-MSI 32770-edge      eth0

lspci -nk -vv:
00:1f.3 0880: 10de:0101 (rev 01)
    Subsystem: 1af4:1100
    Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
    Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
    Interrupt: pin A routed to IRQ 10
    Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit+
        Address: 0000000000000000  Data: 0000

Kernel driver failed to request irq since it trying to attach to IRQ 17. I don't want to change kernel side.

This is what i want to see:
root@hostname:~# cat /proc/interrupts 
           CPU0       
  0:       2213   IO-APIC   
 17:          0   IO-APIC  17-fasteoi   some_kernel_driver_name

How to allocate interrupt 17 for PCI device in qemu?

1

There are 1 best solutions below

0
On

Im not sure it is correct answer but for me it helps: Add to ACPI:

irqs = 17;
aml_append(crs, aml_interrupt(AML_CONSUMER, AML_EDGE,
    AML_ACTIVE_HIGH, AML_SHARED,
    &irqs, 1));

Also PCI interrupt number looks like somehow depends on PCI vendor_id and device_id.