Generic PCIe host bridge legacy interrupts routing support
cover Generic PCIe host bridge legacy interrupts routing support
This patch adds:
- Function to determine an irq number from qemu_irq.
- Function to determine and route legacy interrupts to a VM.
Pranavkumar Sawargaonkar (2):
hw: irq: Add API to get irq number from qemu_irq
pci: GPEX: Add support to route legacy interrupts
hw/core/irq.c | 9 +++++++++ hw/pci-host/gpex.c | 12 ++++++++++++ include/hw/irq.h | 1 + 3 files changed, 22 insertions(+)
Signature · 1 line
1.9.1
PATCH 1/2 hw: irq: Add API to get irq number from qemu_irq
This patch adds a new function to get irq number from qemu irq.
--- hw/core/irq.c | 9 +++++++++ include/hw/irq.h | 1 + 2 files changed, 10 insertions(+)
hw/core/irq.c +9 -0
@@ -35,6 +35,15 @@ struct IRQState {int n; }; +int qemu_get_irq_num (qemu_irq irq) +{ +if (!irq) { +return -1 ; + } + +return irq->n; +} +void qemu_set_irq (qemu_irq irq,int level) {if (!irq)
include/hw/irq.h +1 -0
@@ -9,6 +9,7 @@ typedef struct IRQState *qemu_irq;typedef void (*qemu_irq_handler )(void *opaque,int n,int level); +int qemu_get_irq_num (qemu_irq irq);void qemu_set_irq (qemu_irq irq,int level);static inline void qemu_irq_raise (qemu_irq irq)
Signature · 1 line
1.9.1
PATCH 2/2 pci: GPEX: Add support to route legacy interrupts
In reply to Pranavkumar SawargaonkarThis patch adds routine to route legacy interrupts to VM.
--- hw/pci-host/gpex.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
hw/pci-host/gpex.c +12 -0
@@ -42,6 +42,17 @@ static void gpex_set_irq(void *opaque, int irq_num, int level)qemu_set_irq (s->irq[irq_num], level); } +static PCIINTxRoute gpex_route_intx_pin_to_irq (void *opaque,int pin) +{ +PCIINTxRoute route; +GPEXHost *s = opaque; + + route.mode =PCI_INTX_ENABLED ; + route.irq =qemu_get_irq_num (s->irq[pin]); + +return route; +} +static void gpex_host_realize (DeviceState *dev,Error **errp) {PCIHostState *pci =PCI_HOST_BRIDGE (dev);
@@ -66,6 +77,7 @@ static void gpex_host_realize(DeviceState *dev, Error **errp) &s->io_ioport, 0, 4, TYPE_PCIE_BUS);qdev_set_parent_bus (DEVICE (&s->gpex_root),BUS (pci->bus)); +pci_bus_set_route_irq_fn (pci->bus, gpex_route_intx_pin_to_irq);qdev_init_nofail (DEVICE (&s->gpex_root)); }
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH 2/2] pci: GPEX: Add support to route legacy interrupts
Quoted 4 lines · Pranavkumar Sawargaonkar
This patch adds routine to route legacy interrupts to VM.
Signed-off-by Pranavkumar Sawargaonkar <[email protected]>Signed-off-by Tushar Jagad <[email protected]>
I don't think the device model should have awareness of any global irq number spaces. Can you move this into the board model instead? Then you also don't need the first patch.
Alex
Quoted 34 lines
--- hw/pci-host/gpex.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)hw/pci-host/gpex.c +12
-0@@ -42,6 +42,17 @@ static void gpex_set_irq(void *opaque, int irq_num, int level)qemu_set_irq (s->irq[irq_num], level); } +static PCIINTxRoute gpex_route_intx_pin_to_irq (void *opaque,int pin) +{ +PCIINTxRoute route; +GPEXHost *s = opaque; + + route.mode =PCI_INTX_ENABLED ; + route.irq =qemu_get_irq_num (s->irq[pin]); + +return route; +} +static void gpex_host_realize (DeviceState *dev,Error **errp) {PCIHostState *pci =PCI_HOST_BRIDGE (dev);@@ -66,6 +77,7 @@ static void gpex_host_realize(DeviceState *dev, Error **errp) &s->io_ioport, 0, 4, TYPE_PCIE_BUS);qdev_set_parent_bus (DEVICE (&s->gpex_root),BUS (pci->bus)); +pci_bus_set_route_irq_fn (pci->bus, gpex_route_intx_pin_to_irq);qdev_init_nofail (DEVICE (&s->gpex_root)); }
Quoted 3 lines · Pranavkumar Sawargaonkar
This patch adds:
- Function to determine an irq number fromqemu_irq.
- Function to determine and route legacy interrupts to a VM.
Can you describe in more detail what this patch series is supposed to do, please? Interrupt routing already works fine, via the interrupt controller...
thanks
-- PMM
Hi PMM,
Quoted 9 lines · Peter Maydell
Quoted 3 lines · Pranavkumar Sawargaonkar
This patch adds:
- Function to determine an irq number fromqemu_irq.
- Function to determine and route legacy interrupts to a VM.Can you describe in more detail what this patch series is supposed to do, please? Interrupt routing already works fine, via the interrupt controller...
GPEX driver is not registering a callback to route INTx and pci_device_route_intx_to_irq() throws a following warning "PCI: Bug - unimplemented PCI INTx routing".
It also returns -1 as an interrupt number as well as marking it as a disabled one.
Hence to complete the GPEX driver in terms of INTx routing I have added this patch but at the same time routing works without this patchset :) .
Quoted 3 lines
thanks
-- PMM
Thanks,
Pranav