ppc-e500: Adding pci-pin to irq callback and some cleanup
cover ppc-e500: Adding pci-pin to irq callback and some cleanup
First patch is doing some cleanup and second patch adds the PCI-PIN (INT[A-D]) to its interrupt number mapping callback. This is required to support pci device passthrough using VFIO.
Bharat Bhushan (2):
ppc-e500: some pci related cleanup
ppc-e500: implement PCI INTx routing
hw/pci-host/ppce500.c | 34 +++++++++++++++++++++++++--------- hw/ppc/e500.c | 12 +++++++----- 2 files changed, 32 insertions(+), 14 deletions(-)
PATCH 1/2 ppc-e500: some pci related cleanup
- Use PCI_NUM_PINS rather than hardcoding
- use "pin" wherever possible
--- hw/pci-host/ppce500.c | 16 ++++++++-------- hw/ppc/e500.c | 12 +++++++----- 2 files changed, 15 insertions(+), 13 deletions(-)
hw/pci-host/ppce500.c +8 -8
@@ -87,7 +87,7 @@ struct PPCE500PCIState {struct pci_outbound pob[PPCE500_PCI_NR_POBS ];struct pci_inbound pib[PPCE500_PCI_NR_PIBS ];uint32_t gasket_time; -qemu_irq irq[4 ]; +qemu_irq irq[PCI_NUM_PINS ];uint32_t first_slot;/* mmio maps */ MemoryRegion container;
@@ -252,26 +252,26 @@ static const MemoryRegionOps e500_pci_reg_ops = { .endianness = DEVICE_BIG_ENDIAN, }; -static int mpc85xx_pci_map_irq (PCIDevice *pci_dev,int irq_num) +static int mpc85xx_pci_map_irq (PCIDevice *pci_dev,int pin) {int devno = pci_dev->devfn >>3 ;int ret; - ret =ppce500_pci_map_irq_slot (devno, irq_num); + ret =ppce500_pci_map_irq_slot (devno, pin);pci_debug ("%s: devfn %x irq %d -> %d devno:%x\n" , __func__, - pci_dev->devfn, irq_num, ret, devno); + pci_dev->devfn, pin, ret, devno);return ret; } -static void mpc85xx_pci_set_irq (void *opaque,int irq_num,int level) +static void mpc85xx_pci_set_irq (void *opaque,int pin,int level) { -qemu_irq *pic = opaque; +qemu_irq *irq = opaque; -pci_debug ("%s: PCI irq %d, level:%d\n" , __func__, irq_num, level); +pci_debug ("%s: PCI irq %d, level:%d\n" , __func__, pin , level); -qemu_set_irq (pic[irq_num], level); +qemu_set_irq (irq[pin], level); }static const VMStateDescription vmstate_pci_outbound = {
hw/ppc/e500.c +7 -5
@@ -611,7 +611,9 @@ void ppce500_init(QEMUMachineInitArgs *args, PPCE500Params *params)target_long initrd_size =0 ;target_ulong cur_base =0 ;int i; -unsigned int pci_irq_nrs[4 ] = {1 ,2 ,3 ,4 }; +/* irq num for pin INTA, INTB, INTC and INTD is 1, 2, 3 and +* 4 respectively */ +unsigned int pci_irq_nrs[PCI_NUM_PINS ] = {1 ,2 ,3 ,4 };qemu_irq **irqs, *mpic;DeviceState *dev;CPUPPCState *firstenv =NULL ;
@@ -713,10 +715,10 @@ void ppce500_init(QEMUMachineInitArgs *args, PPCE500Params *params)qdev_prop_set_uint32 (dev,"first_slot" , params->pci_first_slot);qdev_init_nofail (dev); s =SYS_BUS_DEVICE (dev); -sysbus_connect_irq (s,0 , mpic[pci_irq_nrs[0 ]]); -sysbus_connect_irq (s,1 , mpic[pci_irq_nrs[1 ]]); -sysbus_connect_irq (s,2 , mpic[pci_irq_nrs[2 ]]); -sysbus_connect_irq (s,3 , mpic[pci_irq_nrs[3 ]]); +for (i =0 ; i <PCI_NUM_PINS ; i++) { +sysbus_connect_irq (s, i, mpic[pci_irq_nrs[i]]); + } +memory_region_add_subregion (ccsr_addr_space,MPC8544_PCI_REGS_OFFSET ,sysbus_mmio_get_region (s,0 ));
Signature · 1 line
1.7.0.4
PATCH 2/2 ppc-e500: implement PCI INTx routing
In reply to Bharat BhushanThis patch adds pci pin to irq_num routing callback.
This callback is called from pci_device_route_intx_to_irq to find which pci device maps to which irq. This is used for pci-device passthrough using vfio.
Also without this patch we gets below warning
"
PCI: Bug - unimplemented PCI INTx routing (e500-pcihost)
qemu-system-ppc64: PCI: Bug - unimplemented PCI INTx routing (e500-pcihost)
"
and Legacy interrupt does not work with pci device passthrough.
--- hw/pci-host/ppce500.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-)
hw/pci-host/ppce500.c +18 -2
@@ -88,6 +88,7 @@ struct PPCE500PCIState {struct pci_inbound pib[PPCE500_PCI_NR_PIBS ];uint32_t gasket_time;qemu_irq irq[PCI_NUM_PINS ]; +uint32_t irq_num[PCI_NUM_PINS ];uint32_t first_slot;/* mmio maps */ MemoryRegion container;
@@ -267,13 +268,26 @@ static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int pin)static void mpc85xx_pci_set_irq (void *opaque,int pin,int level) { -qemu_irq *irq = opaque; +PPCE500PCIState *s = opaque; +qemu_irq *pic = s->irq;pci_debug ("%s: PCI irq %d, level:%d\n" , __func__, pin , level);qemu_set_irq (irq[pin], level); } +static PCIINTxRoute e500_route_intx_pin_to_irq (void *opaque,int pin) +{ +PCIINTxRoute route; +PPCE500PCIState *s = opaque; + + route.mode =PCI_INTX_ENABLED ; + route.irq = s->irq_num[pin]; + +pci_debug ("%s: PCI irq-pin = %d, irq_num= %d\n" , __func__, pin, route.irq); +return route; +} +static const VMStateDescription vmstate_pci_outbound = { .name ="pci_outbound" , .version_id =0 ,
@@ -350,12 +364,13 @@ static int e500_pcihost_initfn(SysBusDevice *dev)for (i =0 ; i <ARRAY_SIZE (s->irq); i++) {sysbus_init_irq (dev, &s->irq[i]); + s->irq_num[i] = i +1 ; }memory_region_init (&s->pio,OBJECT (s),"pci-pio" ,PCIE500_PCI_IOLEN ); b =pci_register_bus (DEVICE (dev),NULL , mpc85xx_pci_set_irq, - mpc85xx_pci_map_irq, s->irq, address_space_mem, + mpc85xx_pci_map_irq, s, address_space_mem, &s->pio,PCI_DEVFN (s->first_slot,0 ),4 ,TYPE_PCI_BUS ); h->bus = b;
@@ -373,6 +388,7 @@ static int e500_pcihost_initfn(SysBusDevice *dev)memory_region_add_subregion (&s->container,PCIE500_REG_BASE , &s->iomem);sysbus_init_mmio (dev, &s->container);sysbus_init_mmio (dev, &s->pio); +pci_bus_set_route_irq_fn (b, e500_route_intx_pin_to_irq);return 0 ; }
Signature · 1 line
1.7.0.4
Re: [Qemu-devel] [PATCH 2/2] ppc-e500: implement PCI INTx routing
Quoted 59 lines · Bharat Bhushan
This patch adds pci pin to
irq_numrouting callback.
This callback is called frompci_device_route_intx_to_irqto find which pci device maps to which irq. This is used for pci-device passthrough using vfio.Also without this patch we gets below warning
"
PCI: Bug - unimplemented PCI INTx routing (e500-pcihost)
qemu-system-ppc64: PCI: Bug - unimplemented PCI INTx routing (e500-pcihost)
"
and Legacy interrupt does not work with pci device passthrough.Signed-off-by Bharat Bhushan <[email protected]>---
hw/pci-host/ppce500.c| 20 ++++++++++++++++++--1 files changed, 18 insertions(+), 2 deletions(-)hw/pci-host/ppce500.c +15
-1@@ -88,6 +88,7 @@ struct PPCE500PCIState {struct pci_inbound pib[PPCE500_PCI_NR_PIBS ];uint32_t gasket_time;qemu_irq irq[PCI_NUM_PINS ]; +uint32_t irq_num[PCI_NUM_PINS ];uint32_t first_slot;/* mmio maps */ MemoryRegion container;@@ -267,13 +268,26 @@ static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int pin)static void mpc85xx_pci_set_irq (void *opaque,int pin,int level) { -qemu_irq *irq = opaque; +PPCE500PCIState *s = opaque; +qemu_irq *pic = s->irq;pci_debug ("%s: PCI irq %d, level:%d\n" , __func__, pin , level);qemu_set_irq (irq[pin], level); } +static PCIINTxRoute e500_route_intx_pin_to_irq (void *opaque,int pin) +{ +PCIINTxRoute route; +PPCE500PCIState *s = opaque; + + route.mode =PCI_INTX_ENABLED ; + route.irq = s->irq_num[pin]; + +pci_debug ("%s: PCI irq-pin = %d, irq_num= %d\n" , __func__, pin, route.irq); +return route; +} +static const VMStateDescription vmstate_pci_outbound = { .name ="pci_outbound" , .version_id =0 ,
hw/pci-host/ppce500.c static int e500_pcihost_initfn(SysBusDevice *dev) · line 367
Quoted 4 lines
hw/pci-host/ppce500.c +1
-0@@ -350,12 +364,13 @@ static int e500_pcihost_initfn(SysBusDevice *dev)for (i =0 ; i <ARRAY_SIZE (s->irq); i++) {sysbus_init_irq (dev, &s->irq[i]); + s->irq_num[i] = i +1 ;
I still don't like how you duplicate the logic which MPIC irq line is associated with which pci host controller irq line. Please pass this information into the pcihost object somehow from ppce500_init() so that it's only at a single spot.
If you like, you can just use qom/qdev properties for that, but it needs to be configured from the outside.
Alex
Re: [Qemu-devel] [PATCH 2/2] ppc-e500: implement PCI INTx routing
Quoted 84 lines
-----Original Message-----
From: Alexander Graf [mailto:[email protected]]
Sent: Friday, December 20, 2013 4:01 PM
To: Bhushan Bharat-R65777
Cc: Michael S. Tsirkin; Wood Scott-B07421; qemu-ppc; QEMU Developers; Bhushan Bharat-R65777
Subject: Re: [PATCH 2/2] ppc-e500: implement PCI INTx routingQuoted 3 lines · Bharat Bhushan
This patch adds pci pin to
irq_numrouting callback.
This callback is called frompci_device_route_intx_to_irqto find which pci device maps to which irq. This is used for pci-device passthroughusing vfio.
Quoted 39 lines
Also without this patch we gets below warning
"
PCI: Bug - unimplemented PCI INTx routing (e500-pcihost)
qemu-system-ppc64: PCI: Bug - unimplemented PCI INTx routing
(e500-pcihost) "
and Legacy interrupt does not work with pci device passthrough.Signed-off-by Bharat Bhushan <[email protected]>---
hw/pci-host/ppce500.c| 20 ++++++++++++++++++--1 files changed, 18 insertions(+), 2 deletions(-)hw/pci-host/ppce500.c index renamed from hw/pci-host/ppce500.c +0
-071e5ca9..ffea782 100644
hw/pci-host/ppce500.c +3
-1@@ -88,6 +88,7 @@ struct PPCE500PCIState {struct pci_inbound pib[PPCE500_PCI_NR_PIBS ];uint32_t gasket_time;qemu_irq irq[PCI_NUM_PINS ]; +uint32_t irq_num[PCI_NUM_PINS ];uint32_t first_slot;/* mmio maps */ MemoryRegion container;@@ -267,13 +268,26 @@ static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int pin)static void mpc85xx_pci_set_irq (void *opaque,int pin,int level) { -qemu_irq *irq = opaque; +PPCE500PCIState *s = opaque; +qemu_irq *pic = s->irq;pci_debug ("%s: PCI irq %d, level:%d\n" , __func__, pin , level);qemu_set_irq (irq[pin], level); }hw/pci-host/ppce500.c static int mpc85xx_pci_map_irq(PCIDevice · line 287
Quoted 10 lines
hw/pci-host/ppce500.c +9
-0+static PCIINTxRoute e500_route_intx_pin_to_irq (void *opaque,int pin) +{ +PCIINTxRoute route; +PPCE500PCIState *s = opaque; + + route.mode =PCI_INTX_ENABLED ; + route.irq = s->irq_num[pin]; + + pci_debug("%s: PCI irq-pin = %d, irq_num= %d\n", __func__, pin,route.irq);
hw/pci-host/ppce500.c static int e500_pcihost_initfn(SysBusDevice · line 368
Quoted 12 lines
hw/pci-host/ppce500.c +4
-0+return route; +} +static const VMStateDescription vmstate_pci_outbound = { .name ="pci_outbound" , .version_id =0 ,@@ -350,12 +364,13 @@ static int e500_pcihost_initfn(SysBusDevice *dev)for (i =0 ; i <ARRAY_SIZE (s->irq); i++) {sysbus_init_irq (dev, &s->irq[i]); + s->irq_num[i] = i +1 ;I still don't like how you duplicate the logic which MPIC irq line is associated with which pci host controller irq line. Please pass this information into the pcihost object somehow from
ppce500_init()so that it's only at a single spot.
Quoted 2 lines
If you like, you can just use qom/qdev properties for that, but it needs to be configured from the outside.
Ok :)
I thought we guys agreed that let this patch come as is and Anthony's work will help globally.
Thanks
-Bharat
Quoted 5 lines
Alex
Re: [Qemu-devel] [PATCH 2/2] ppc-e500: implement PCI INTx routing
In reply to Alexander GrafQuoted 69 lines · Alexander Graf
Quoted 59 lines · Bharat Bhushan
This patch adds pci pin to
irq_numrouting callback.
This callback is called frompci_device_route_intx_to_irqto find which pci device maps to which irq. This is used for pci-device passthrough using vfio.Also without this patch we gets below warning
"
PCI: Bug - unimplemented PCI INTx routing (e500-pcihost)
qemu-system-ppc64: PCI: Bug - unimplemented PCI INTx routing (e500-pcihost)
"
and Legacy interrupt does not work with pci device passthrough.Signed-off-by Bharat Bhushan <[email protected]>---
hw/pci-host/ppce500.c| 20 ++++++++++++++++++--1 files changed, 18 insertions(+), 2 deletions(-)hw/pci-host/ppce500.c +15
-1@@ -88,6 +88,7 @@ struct PPCE500PCIState {struct pci_inbound pib[PPCE500_PCI_NR_PIBS ];uint32_t gasket_time;qemu_irq irq[PCI_NUM_PINS ]; +uint32_t irq_num[PCI_NUM_PINS ];uint32_t first_slot;/* mmio maps */ MemoryRegion container;@@ -267,13 +268,26 @@ static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int pin)static void mpc85xx_pci_set_irq (void *opaque,int pin,int level) { -qemu_irq *irq = opaque; +PPCE500PCIState *s = opaque; +qemu_irq *pic = s->irq;pci_debug ("%s: PCI irq %d, level:%d\n" , __func__, pin , level);qemu_set_irq (irq[pin], level); } +static PCIINTxRoute e500_route_intx_pin_to_irq (void *opaque,int pin) +{ +PCIINTxRoute route; +PPCE500PCIState *s = opaque; + + route.mode =PCI_INTX_ENABLED ; + route.irq = s->irq_num[pin]; + +pci_debug ("%s: PCI irq-pin = %d, irq_num= %d\n" , __func__, pin, route.irq); +return route; +} +static const VMStateDescription vmstate_pci_outbound = { .name ="pci_outbound" , .version_id =0 ,hw/pci-host/ppce500.c static int e500_pcihost_initfn(SysBusDevice *dev) · line 367
Quoted 4 lines
hw/pci-host/ppce500.c +1
-0@@ -350,12 +364,13 @@ static int e500_pcihost_initfn(SysBusDevice *dev)for (i =0 ; i <ARRAY_SIZE (s->irq); i++) {sysbus_init_irq (dev, &s->irq[i]); + s->irq_num[i] = i +1 ;I still don't like how you duplicate the logic which MPIC irq line is associated with which pci host controller irq line. Please pass this information into the pcihost object somehow from
ppce500_init()so that it's only at a single spot.
Quoted 4 lines
If you like, you can just use qom/qdev properties for that, but it needs to be configured from the outside.
Alex
Maybe just call ppce500_pci_map_irq_slot instead of using irq_num?
Re: [Qemu-devel] [PATCH 2/2] ppc-e500: implement PCI INTx routing
Quoted 74 lines
Am 22.12.2013 um 12:31 schrieb "Michael S. Tsirkin" <[email protected]>:
Quoted 70 lines · Alexander Graf
Quoted 62 lines · Bharat Bhushan
This patch adds pci pin to
irq_numrouting callback.
This callback is called frompci_device_route_intx_to_irqto find which pci device maps to which irq. This is used for pci-device passthrough using vfio.Also without this patch we gets below warning
"
PCI: Bug - unimplemented PCI INTx routing (e500-pcihost)
qemu-system-ppc64: PCI: Bug - unimplemented PCI INTx routing (e500-pcihost) "
and Legacy interrupt does not work with pci device passthrough.Signed-off-by Bharat Bhushan <[email protected]>---
hw/pci-host/ppce500.c| 20 ++++++++++++++++++--1 files changed, 18 insertions(+), 2 deletions(-)hw/pci-host/ppce500.c +15
-1@@ -88,6 +88,7 @@ struct PPCE500PCIState {struct pci_inbound pib[PPCE500_PCI_NR_PIBS ];uint32_t gasket_time;qemu_irq irq[PCI_NUM_PINS ]; +uint32_t irq_num[PCI_NUM_PINS ];uint32_t first_slot;/* mmio maps */ MemoryRegion container;@@ -267,13 +268,26 @@ static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int pin)static void mpc85xx_pci_set_irq (void *opaque,int pin,int level) { -qemu_irq *irq = opaque; +PPCE500PCIState *s = opaque; +qemu_irq *pic = s->irq;pci_debug ("%s: PCI irq %d, level:%d\n" , __func__, pin , level);qemu_set_irq (irq[pin], level); } +static PCIINTxRoute e500_route_intx_pin_to_irq (void *opaque,int pin) +{ +PCIINTxRoute route; +PPCE500PCIState *s = opaque; + + route.mode =PCI_INTX_ENABLED ; + route.irq = s->irq_num[pin]; + +pci_debug ("%s: PCI irq-pin = %d, irq_num= %d\n" , __func__, pin, route.irq); +return route; +} +static const VMStateDescription vmstate_pci_outbound = { .name ="pci_outbound" , .version_id =0 ,hw/pci-host/ppce500.c static int e500_pcihost_initfn(SysBusDevice *dev) · line 367
Quoted 4 lines
hw/pci-host/ppce500.c +1
-0@@ -350,12 +364,13 @@ static int e500_pcihost_initfn(SysBusDevice *dev)for (i =0 ; i <ARRAY_SIZE (s->irq); i++) {sysbus_init_irq (dev, &s->irq[i]); + s->irq_num[i] = i +1 ;I still don't like how you duplicate the logic which MPIC irq line is associated with which pci host controller irq line. Please pass this information into the pcihost object somehow from
ppce500_init()so that it's only at a single spot.
Quoted 7 lines
Quoted 4 lines
If you like, you can just use qom/qdev properties for that, but it needs to be configured from the outside.
Alex
Maybe just call
ppce500_pci_map_irq_slotinstead of usingirq_num?
That'd be a step into the wrong direction. Wiring is a configuration thing.
Alex