qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 05/12] hw/pci-host/bonito: Do not use SysBus API to map lo


From: Thomas Huth
Subject: Re: [PATCH v2 05/12] hw/pci-host/bonito: Do not use SysBus API to map local MMIO region
Date: Thu, 19 Oct 2023 09:26:52 +0200
User-agent: Mozilla Thunderbird

On 19/10/2023 09.16, Philippe Mathieu-Daudé wrote:
There is no point in exposing an internal MMIO region via
SysBus and directly mapping it in the very same device.

Just map it without using the SysBus API.

Transformation done using the following coccinelle script:

   @@
   expression sbdev;
   expression index;
   expression addr;
   expression subregion;
   @@
   -    sysbus_init_mmio(sbdev, subregion);
        ... when != sbdev
   -    sysbus_mmio_map(sbdev, index, addr);
   +    memory_region_add_subregion(get_system_memory(), addr, subregion);

and manually adding the local 'host_mem' variable to
avoid multiple calls to get_system_memory().

Thanks for updating it!

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
  hw/pci-host/bonito.c | 32 ++++++++++++++++----------------
  1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index ee6cb85e97..96bd028671 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -654,10 +654,10 @@ static void bonito_host_realize(DeviceState *dev, Error 
**errp)
  static void bonito_pci_realize(PCIDevice *dev, Error **errp)
  {
      PCIBonitoState *s = PCI_BONITO(dev);
-    SysBusDevice *sysbus = SYS_BUS_DEVICE(s->pcihost);
      PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
      BonitoState *bs = s->pcihost;
      MemoryRegion *pcimem_alias = g_new(MemoryRegion, 1);
+    MemoryRegion *host_mem = get_system_memory();
/*
       * Bonito North Bridge, built on FPGA,
@@ -668,48 +668,48 @@ static void bonito_pci_realize(PCIDevice *dev, Error 
**errp)
      /* set the north bridge register mapping */
      memory_region_init_io(&s->iomem, OBJECT(s), &bonito_ops, s,
                            "north-bridge-register", BONITO_INTERNAL_REG_SIZE);
-    sysbus_init_mmio(sysbus, &s->iomem);
-    sysbus_mmio_map(sysbus, 0, BONITO_INTERNAL_REG_BASE);
+    memory_region_add_subregion(host_mem, BONITO_INTERNAL_REG_BASE,
+                                &s->iomem);
/* set the north bridge pci configure mapping */
      memory_region_init_io(&phb->conf_mem, OBJECT(s), &bonito_pciconf_ops, s,
                            "north-bridge-pci-config", BONITO_PCICONFIG_SIZE);
-    sysbus_init_mmio(sysbus, &phb->conf_mem);
-    sysbus_mmio_map(sysbus, 1, BONITO_PCICONFIG_BASE);
+    memory_region_add_subregion(host_mem, BONITO_PCICONFIG_BASE,
+                                &phb->conf_mem);
/* set the south bridge pci configure mapping */
      memory_region_init_io(&phb->data_mem, OBJECT(s), &bonito_spciconf_ops, s,
                            "south-bridge-pci-config", BONITO_SPCICONFIG_SIZE);
-    sysbus_init_mmio(sysbus, &phb->data_mem);
-    sysbus_mmio_map(sysbus, 2, BONITO_SPCICONFIG_BASE);
+    memory_region_add_subregion(host_mem, BONITO_SPCICONFIG_BASE,
+                                &phb->data_mem);
create_unimplemented_device("bonito", BONITO_REG_BASE, BONITO_REG_SIZE); memory_region_init_io(&s->iomem_ldma, OBJECT(s), &bonito_ldma_ops, s,
                            "ldma", 0x100);
-    sysbus_init_mmio(sysbus, &s->iomem_ldma);
-    sysbus_mmio_map(sysbus, 3, 0x1fe00200);
+    memory_region_add_subregion(host_mem, 0x1fe00200,
+                                &s->iomem_ldma);
/* PCI copier */
      memory_region_init_io(&s->iomem_cop, OBJECT(s), &bonito_cop_ops, s,
                            "cop", 0x100);
-    sysbus_init_mmio(sysbus, &s->iomem_cop);
-    sysbus_mmio_map(sysbus, 4, 0x1fe00300);
+    memory_region_add_subregion(host_mem, 0x1fe00300,
+                                &s->iomem_cop);

At least the above two hunks look like they could now fit into one line?

Anyway:
Reviewed-by: Thomas Huth <thuth@redhat.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]