Move Fuloong2e PCI IRQ mapping to board code
cover Move Fuloong2e PCI IRQ mapping to board code
This is a follow-up on [1] '[PATCH 0/8] hw/pci-host/bonito: Housekeeping' which resolves a coupling of the Bonito north bridge with the Fuloong2e machine. Since [2] '[PATCH v2 0/3] Decouple INTx-to-LNKx routing from south bridges' is already in the mips-next queue this cleanup can now be done.
[1] https://patchew.org/QEMU/[email protected]/
[2] https://patchew.org/QEMU/[email protected]/
Based-on: <[email protected]>
"[PATCH v2 0/3] Decouple INTx-to-LNKx routing from south bridges"
Based-on: <[email protected]>
"[PATCH 0/8] hw/pci-host/bonito: Housekeeping"
Bernhard Beschow (2):
hw/pci-host/bonito: Inline pci_register_root_bus() hw/pci-host/bonito: Map PCI IRQs in board code
include/hw/pci-host/bonito.h | 2 ++ hw/mips/fuloong2e.c | 22 ++++++++++++++++++++++ hw/pci-host/bonito.c | 31 ++++--------------------------- 3 files changed, 28 insertions(+), 27 deletions(-)
Signature · 1 line
2.39.0
PATCH 1/2 hw/pci-host/bonito: Inline pci_register_root_bus()
pci_bonito_map_irq() is board-specific but has to be implemented in the north bridge because pci_register_root_bus() wants a pci_map_irq_fn. Inline pci_register_root_bus() so we can move pci_bonito_map_irq() to board code in the next step.
--- hw/pci-host/bonito.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
hw/pci-host/bonito.c +5 -4
@@ -631,10 +631,11 @@ static void bonito_host_realize(DeviceState *dev, Error **errp)sysbus_init_irq (SYS_BUS_DEVICE (dev), &bs->irq);memory_region_init (&bs->pci_mem,OBJECT (dev),"pci.mem" ,BONITO_PCIHI_SIZE ); - phb->bus =pci_register_root_bus (dev,"pci" , - pci_bonito_set_irq, pci_bonito_map_irq, - dev, &bs->pci_mem,get_system_io (), -PCI_DEVFN (5 ,0 ),32 ,TYPE_PCI_BUS ); + + phb->bus =pci_root_bus_new (dev,"pci" , &bs->pci_mem,get_system_io (), +PCI_DEVFN (5 ,0 ),TYPE_PCI_BUS ); +pci_bus_irqs (phb->bus, pci_bonito_set_irq, dev,32 ); +pci_bus_map_irqs (phb->bus, pci_bonito_map_irq);for (size_t i =0 ; i <3 ; i++) {char *name =g_strdup_printf ("pci.lomem%zu" , i);
Signature · 1 line
2.39.0
PATCH 2/2 hw/pci-host/bonito: Map PCI IRQs in board code
In reply to Bernhard BeschowPCI IRQ mapping is board specific, as could be seen by pci_bonito_map_irq(). So move it to board code and rename it.
--- include/hw/pci-host/bonito.h | 2 ++ hw/mips/fuloong2e.c | 22 ++++++++++++++++++++++ hw/pci-host/bonito.c | 24 ------------------------ 3 files changed, 24 insertions(+), 24 deletions(-)
include/hw/pci-host/bonito.h +2 -0
@@ -12,6 +12,8 @@#include "qom/object.h" +#define BONITO_IRQ_BASE 32 +#define TYPE_BONITO_PCI_HOST_BRIDGE "Bonito-pcihost"OBJECT_DECLARE_SIMPLE_TYPE (BonitoState,BONITO_PCI_HOST_BRIDGE )
hw/mips/fuloong2e.c +22 -0
@@ -200,6 +200,27 @@ static void main_cpu_reset(void *opaque) } } +/* Map the original irq (0~3) to bonito irq (16~47, but 16~31 are unused) */ +static int pci_fuloong2e_map_irq (PCIDevice *pci_dev,int irq_num) +{ +int slot; + + slot =PCI_SLOT (pci_dev->devfn); + +switch (slot) { +case 5 :/* FULOONG2E_VIA_SLOT, SouthBridge, IDE, USB, ACPI, AC97, MC97 */ +return irq_num %4 +BONITO_IRQ_BASE ; +case 6 :/* FULOONG2E_ATI_SLOT, VGA */ +return 4 +BONITO_IRQ_BASE ; +case 7 :/* FULOONG2E_RTL_SLOT, RTL8139 */ +return 5 +BONITO_IRQ_BASE ; + case 8 ... 12: /* PCI slot 1 to 4 */ +return (slot -8 + irq_num) +6 +BONITO_IRQ_BASE ; +default :/* Unknown device, don't do any translation */ +return irq_num; + } +} +/* Network support */ static void network_init (PCIBus *pci_bus) {
@@ -297,6 +318,7 @@ static void mips_fuloong2e_init(MachineState *machine)sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , env->irq[2 ]); pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci" )); +pci_bus_map_irqs (pci_bus, pci_fuloong2e_map_irq);/* South bridge -> IP5 */ pci_dev = pci_create_simple_multifunction(pci_bus,
hw/pci-host/bonito.c +0 -24
@@ -548,8 +548,6 @@ static const MemoryRegionOps bonito_spciconf_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -#define BONITO_IRQ_BASE 32 -static void pci_bonito_set_irq (void *opaque,int irq_num,int level) {BonitoState *s = opaque;
@@ -567,27 +565,6 @@ static void pci_bonito_set_irq(void *opaque, int irq_num, int level) } } -/* map the original irq (0~3) to bonito irq (16~47, but 16~31 are unused) */ -static int pci_bonito_map_irq (PCIDevice *pci_dev,int irq_num) -{ -int slot; - - slot =PCI_SLOT (pci_dev->devfn); - -switch (slot) { -case 5 :/* FULOONG2E_VIA_SLOT, SouthBridge, IDE, USB, ACPI, AC97, MC97 */ -return irq_num %4 +BONITO_IRQ_BASE ; -case 6 :/* FULOONG2E_ATI_SLOT, VGA */ -return 4 +BONITO_IRQ_BASE ; -case 7 :/* FULOONG2E_RTL_SLOT, RTL8139 */ -return 5 +BONITO_IRQ_BASE ; - case 8 ... 12: /* PCI slot 1 to 4 */ -return (slot -8 + irq_num) +6 +BONITO_IRQ_BASE ; -default :/* Unknown device, don't do any translation */ -return irq_num; - } -} -static void bonito_reset_hold (Object *obj) {PCIBonitoState *s =PCI_BONITO (obj);
@@ -635,7 +612,6 @@ static void bonito_host_realize(DeviceState *dev, Error **errp) phb->bus =pci_root_bus_new (dev,"pci" , &bs->pci_mem,get_system_io (),PCI_DEVFN (5 ,0 ),TYPE_PCI_BUS );pci_bus_irqs (phb->bus, pci_bonito_set_irq, dev,32 ); -pci_bus_map_irqs (phb->bus, pci_bonito_map_irq);for (size_t i =0 ; i <3 ; i++) {char *name =g_strdup_printf ("pci.lomem%zu" , i);
Signature · 1 line
2.39.0
Quoted 9 lines · Bernhard Beschow
Bernhard Beschow (2):
hw/pci-host/bonito: Inlinepci_register_root_bus()hw/pci-host/bonito: Map PCI IRQs in board codeinclude/hw/pci-host/bonito.h | 2 ++ hw/mips/fuloong2e.c | 22 ++++++++++++++++++++++ hw/pci-host/bonito.c | 31 ++++--------------------------- 3 files changed, 28 insertions(+), 27 deletions(-)
Series:
Am 5. Januar 2023 16:32:16 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 6 lines · Bernhard Beschow
Quoted 5 lines
Bernhard Beschow (2):
hw/pci-host/bonito: Inlinepci_register_root_bus()hw/pci-host/bonito: Map PCI IRQs in board code
Quoted 8 lines
Quoted 5 lines
include/hw/pci-host/bonito.h | 2 ++ hw/mips/fuloong2e.c | 22 ++++++++++++++++++++++ hw/pci-host/bonito.c | 31 ++++--------------------------- 3 files changed, 28 insertions(+), 27 deletions(-)Series:
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Ping
Quoted 3 lines · Bernhard Beschow
Bernhard Beschow (2):
hw/pci-host/bonito: Inlinepci_register_root_bus()hw/pci-host/bonito: Map PCI IRQs in board code
Thanks, queued to mips-next.
Am 16. Oktober 2023 09:05:00 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 7 lines · Bernhard Beschow
Quoted 4 lines
Bernhard Beschow (2):
hw/pci-host/bonito: Inlinepci_register_root_bus()hw/pci-host/bonito: Map PCI IRQs in board codeThanks, queued to mips-next.
Ping. I think it's not merged into master yet, is it?