hw/sysbus: Spring cleanups (part 1)
v2 cover hw/sysbus: Spring cleanups (part 1)
- Use proper SysBus accessors
Since v1:
- Reduce series
Philippe Mathieu-Daudé (7):
hw/sysbus: Use memory_region_name()
hw/i386/microvm: Use proper SysBus accessors hw/i386/ioapic: Use proper SysBus accessors hw/timer/hpet: Use proper SysBus accessors hw/acpi/cxl: Use proper SysBus accessors hw/ppc/e500: Use proper SysBus accessors hw/pci-bridge/pci_expander_bridge: Use proper SysBus accessors
hw/acpi/cxl.c | 2 +- hw/core/sysbus.c | 2 +- hw/i386/kvm/ioapic.c | 3 ++- hw/i386/microvm-dt.c | 6 ++++-- hw/pci-bridge/pci_expander_bridge.c | 6 +++--- hw/ppc/e500.c | 2 +- hw/timer/hpet.c | 3 ++- 7 files changed, 14 insertions(+), 10 deletions(-)
Signature · 1 line
2.51.0
PATCH v2 1/7 hw/sysbus: Use memory_region_name()
MemoryRegion::name is kind of internal. Use the proper memory_region_name() accessor, which might return a different name.
--- hw/core/sysbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/sysbus.c +1 -1
@@ -154,7 +154,7 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr)int sysbus_mmio_map_name (SysBusDevice *dev,const char *name,hwaddr addr) {for (int i =0 ; i < dev->num_mmio; i++) { -if (!strcmp (dev->mmio[i].memory->name, name)) { +if (!strcmp (memory_region_name (dev->mmio[i].memory), name)) {sysbus_mmio_map (dev, i, addr);return i; }
Signature · 1 line
2.51.0
Re: [PATCH v2 1/7] hw/sysbus: Use memory_region_name()
Quoted 6 lines · Philippe Mathieu-Daudé
MemoryRegion::nameis kind of internal. Use the propermemory_region_name()accessor, which might return a different name.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 18 lines
--- hw/core/sysbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/core/sysbus.c +1
-2@@ -154,7 +154,7 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr)int sysbus_mmio_map_name (SysBusDevice *dev,const char *name,hwaddr addr) {for (int i =0 ; i < dev->num_mmio; i++) { -if (!strcmp (dev->mmio[i].memory->name, name)) { +if (!strcmp (memory_region_name (dev->mmio[i].memory), name)) {sysbus_mmio_map (dev, i, addr);return i; } --
Quoted 3 lines
2.51.0
--
Marc-André Lureau
PATCH v2 2/7 hw/i386/microvm: Use proper SysBus accessors
In reply to Philippe Mathieu-DaudéSysBusDevice::mmio[] is kind of internal. Use the proper sysbus_mmio_get_region() accessor.
--- hw/i386/microvm-dt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/i386/microvm-dt.c +4 -2
@@ -71,7 +71,8 @@ static void dt_add_virtio(MicrovmMachineState *mms, VirtIOMMIOProxy *mmio)return ; } -hwaddr base = dev->mmio[0 ].addr; +MemoryRegion *mr =sysbus_mmio_get_region (dev,0 ); +hwaddr base = mr->addr;hwaddr size =512 ;unsigned index = (base -VIRTIO_MMIO_BASE ) / size;uint32_t irq = mms->virtio_irq_base + index;
@@ -150,7 +151,8 @@ static void dt_add_pcie(MicrovmMachineState *mms)static void dt_add_ioapic (MicrovmMachineState *mms,SysBusDevice *dev) { -hwaddr base = dev->mmio[0 ].addr; +MemoryRegion *mr =sysbus_mmio_get_region (dev,0 ); +hwaddr base = mr->addr;char *nodename;uint32_t ph;int index;
Signature · 1 line
2.51.0
PATCH v2 3/7 hw/i386/ioapic: Use proper SysBus accessors
In reply to Philippe Mathieu-DaudéSysBusDevice::mmio[] is kind of internal. Use the proper sysbus_mmio_get_region() accessor.
--- hw/i386/kvm/ioapic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/i386/kvm/ioapic.c +2 -1
@@ -80,6 +80,7 @@ static void kvm_ioapic_put(IOAPICCommonState *s) {struct kvm_irqchip chip;struct kvm_ioapic_state *kioapic; +MemoryRegion *mr =sysbus_mmio_get_region (s->busdev,0 );int ret, i; chip.chip_id =KVM_IRQCHIP_IOAPIC ;
@@ -87,7 +88,7 @@ static void kvm_ioapic_put(IOAPICCommonState *s) kioapic->id = s->id; kioapic->ioregsel = s->ioregsel; - kioapic->base_address = s->busdev.mmio[0 ].addr; + kioapic->base_address = mr->addr; kioapic->irr = s->irr;for (i =0 ; i <IOAPIC_NUM_PINS ; i++) { kioapic->redirtbl[i].bits = s->ioredtbl[i];
Signature · 1 line
2.51.0
PATCH v2 4/7 hw/timer/hpet: Use proper SysBus accessors
In reply to Philippe Mathieu-DaudéSysBusDevice::mmio[] is kind of internal. Use the proper sysbus_mmio_get_region() accessor.
--- hw/timer/hpet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/timer/hpet.c +2 -1
@@ -655,6 +655,7 @@ static void hpet_reset(DeviceState *d) {HPETState *s =HPET (d);SysBusDevice *sbd =SYS_BUS_DEVICE (d); +MemoryRegion *mr =sysbus_mmio_get_region (sbd,0 );int i;for (i =0 ; i < s->num_timers; i++) {
@@ -677,7 +678,7 @@ static void hpet_reset(DeviceState *d) s->hpet_offset =0ULL ; s->config =0ULL ; hpet_fw_cfg.hpet[s->hpet_id].event_timer_block_id = (uint32_t )s->capability; - hpet_fw_cfg.hpet[s->hpet_id].address = sbd->mmio[0 ].addr; + hpet_fw_cfg.hpet[s->hpet_id].address = mr->addr;/* to document that the RTC lowers its output on reset as well */ s->rtc_irq_level =0 ;
Signature · 1 line
2.51.0
PATCH v2 5/7 hw/acpi/cxl: Use proper SysBus accessors
In reply to Philippe Mathieu-DaudéSysBusDevice::mmio[] is kind of internal. Use the proper sysbus_mmio_get_region() accessor.
--- hw/acpi/cxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/acpi/cxl.c +1 -1
@@ -104,7 +104,7 @@ static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl) {PXBDev *pxb =PXB_DEV (cxl);SysBusDevice *sbd =SYS_BUS_DEVICE (cxl->cxl_host_bridge); -struct MemoryRegion *mr = sbd->mmio[0 ].memory; +MemoryRegion *mr =sysbus_mmio_get_region (sbd,0 );/* Type */ build_append_int_noprefix (table_data,0 ,1 );
Signature · 1 line
2.51.0
PATCH v2 6/7 hw/ppc/e500: Use proper SysBus accessors
In reply to Philippe Mathieu-DaudéSysBusDevice::mmio[] is kind of internal. Use the proper sysbus_mmio_get_region() accessor.
--- hw/ppc/e500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/e500.c +1 -1
@@ -887,7 +887,7 @@ static DeviceState *ppce500_init_mpic(PPCE500MachineState *pms, s =SYS_BUS_DEVICE (dev);memory_region_add_subregion (ccsr,MPC8544_MPIC_REGS_OFFSET , - s->mmio[0 ].memory); +sysbus_mmio_get_region (s,0 ));return dev; }
Signature · 1 line
2.51.0
Re: [PATCH v2 6/7] hw/ppc/e500: Use proper SysBus accessors
Quoted 4 lines · Philippe Mathieu-Daudé
SysBusDevice::mmio[] is kind of internal. Use the proper
sysbus_mmio_get_region()accessor.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 18 lines
---
hw/ppc/e500.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)hw/ppc/e500.c +1
-1@@ -887,7 +887,7 @@ static DeviceState *ppce500_init_mpic(PPCE500MachineState *pms, s =SYS_BUS_DEVICE (dev);memory_region_add_subregion (ccsr,MPC8544_MPIC_REGS_OFFSET , - s->mmio[0 ].memory); +sysbus_mmio_get_region (s,0 ));return dev; }
PATCH v2 7/7 hw/pci-bridge/pci_expander_bridge: Use proper SysBus accessors
In reply to Philippe Mathieu-DaudéSysBusDevice::mmio[] is kind of internal. Use the proper sysbus_mmio_get_region() accessor.
--- hw/pci-bridge/pci_expander_bridge.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/pci-bridge/pci_expander_bridge.c +3 -3
@@ -157,9 +157,9 @@ static char *pxb_host_ofw_unit_address(const SysBusDevice *dev) main_host =PCI_HOST_BRIDGE (pxb_dev_base->parent_bus->parent); main_host_sbd =SYS_BUS_DEVICE (main_host); -if (main_host_sbd->num_mmio >0 ) { -return g_strdup_printf (HWADDR_FMT_plx",%x" , - main_host_sbd->mmio[0 ].addr, position +1 ); +if (sysbus_has_mmio (main_host_sbd,0 )) { +MemoryRegion *mr =sysbus_mmio_get_region (main_host_sbd,0 ); +return g_strdup_printf (HWADDR_FMT_plx",%x" , mr->addr, position +1 ); }if (main_host_sbd->num_pio >0 ) { return g_strdup_printf("i%04x,%x",
Signature · 1 line
2.51.0
Hi
Quoted 6 lines · Philippe Mathieu-Daudé
- Use proper SysBus accessors
Since v1:
- Reduce series
Quoted 9 lines
Philippe Mathieu-Daudé (7):
hw/sysbus: Usememory_region_name()
hw/i386/microvm: Use proper SysBus accessors hw/i386/ioapic: Use proper SysBus accessors hw/timer/hpet: Use proper SysBus accessors hw/acpi/cxl: Use proper SysBus accessors hw/ppc/e500: Use proper SysBus accessors hw/pci-bridge/pci_expander_bridge: Use proper SysBus accessors
There are a bunch of compilation issues that I will let you address for v3.
It looks like it should be possible to remove the "addr" field from SysBusDevice.mmio. On the surface it looks redundante with MemoryRegion.addr. I might be missing something.
Quoted 13 lines
hw/acpi/cxl.c | 2 +- hw/core/sysbus.c | 2 +- hw/i386/kvm/ioapic.c | 3 ++- hw/i386/microvm-dt.c | 6 ++++-- hw/pci-bridge/pci_expander_bridge.c | 6 +++--- hw/ppc/e500.c | 2 +- hw/timer/hpet.c | 3 ++- 7 files changed, 14 insertions(+), 10 deletions(-)--
2.51.0
Signature · 1 line
Marc-André Lureau
Quoted 21 lines · Marc-André Lureau
Hi
Quoted 6 lines · Philippe Mathieu-Daudé
- Use proper SysBus accessors
Since v1:
- Reduce seriesQuoted 9 lines
Philippe Mathieu-Daudé (7):
hw/sysbus: Usememory_region_name()
hw/i386/microvm: Use proper SysBus accessors hw/i386/ioapic: Use proper SysBus accessors hw/timer/hpet: Use proper SysBus accessors hw/acpi/cxl: Use proper SysBus accessors hw/ppc/e500: Use proper SysBus accessors hw/pci-bridge/pci_expander_bridge: Use proper SysBus accessors
Quoted 5 lines
There are a bunch of compilation issues that I will let you address for v3.
It looks like it should be possible to remove the "addr" field from SysBusDevice.mmio. On the surface it looks redundante with MemoryRegion.addr. I might be missing something.
Yes, I think they'll always be the same value. But MemoryRegion::addr is private data of MemoryRegion and there's no 'get' function provided; SysBus shouldn't be reaching inside an MR struct to look at its internals.
(There is a memory_region_set_address(), so we could I guess provide a memory_region_get_address() ?)
-- PMM
Quoted 29 lines · Peter Maydell
Quoted 21 lines · Marc-André Lureau
Hi
Quoted 6 lines · Philippe Mathieu-Daudé
- Use proper SysBus accessors
Since v1:
- Reduce seriesQuoted 9 lines
Philippe Mathieu-Daudé (7):
hw/sysbus: Usememory_region_name()
hw/i386/microvm: Use proper SysBus accessors hw/i386/ioapic: Use proper SysBus accessors hw/timer/hpet: Use proper SysBus accessors hw/acpi/cxl: Use proper SysBus accessors hw/ppc/e500: Use proper SysBus accessors hw/pci-bridge/pci_expander_bridge: Use proper SysBus accessorsQuoted 5 lines
There are a bunch of compilation issues that I will let you address for v3.
It looks like it should be possible to remove the "addr" field from SysBusDevice.mmio. On the surface it looks redundante with MemoryRegion.addr. I might be missing something.
Quoted 7 lines
Yes, I think they'll always be the same value. But
MemoryRegion::addris private data of MemoryRegion and there's no 'get' function provided; SysBus shouldn't be reaching inside an MR struct to look at its internals.(There is a
memory_region_set_address(), so we could I guess provide amemory_region_get_address()?)
OK, thanks!
Quoted 20 lines · Marc-André Lureau
Hi
Quoted 6 lines · Philippe Mathieu-Daudé
- Use proper SysBus accessors
Since v1:
- Reduce seriesQuoted 9 lines
Philippe Mathieu-Daudé (7):
hw/sysbus: Usememory_region_name()
hw/i386/microvm: Use proper SysBus accessors hw/i386/ioapic: Use proper SysBus accessors hw/timer/hpet: Use proper SysBus accessors hw/acpi/cxl: Use proper SysBus accessors hw/ppc/e500: Use proper SysBus accessors hw/pci-bridge/pci_expander_bridge: Use proper SysBus accessors
Quoted 1 line
There are a bunch of compilation issues that I will let you address for v3.
Sorry, this is based on my latest PR:
https://github.com/philmd/qemu/releases/tag/hw-misc-20251028
Based-on: <[email protected]>