qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io()
@ 2024-02-22 12:55 Philippe Mathieu-Daudé
  2024-02-22 12:55 ` [PULL 07/32] hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API Philippe Mathieu-Daudé
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-22 12:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
	Peter Maydell, Paolo Bonzini, Daniel P. Berrangé,
	Eduardo Habkost, Richard Henderson, Michael S. Tsirkin,
	Marcel Apfelbaum, Aleksandar Rikalo, Gerd Hoffmann, kvm

sysbus_add_io(...) is a simple wrapper to
memory_region_add_subregion(get_system_io(), ...).
It is used in 3 places; inline it directly.

Rationale: we want to move to an explicit I/O bus,
rather that an implicit one. Besides in heterogeneous
setup we can have more than one I/O bus.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20240216150441.45681-1-philmd@linaro.org>
[PMD: Include missing "exec/address-spaces.h" header]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/sysbus.h | 2 --
 hw/core/sysbus.c    | 6 ------
 hw/i386/kvmvapic.c  | 3 ++-
 hw/mips/mipssim.c   | 3 ++-
 hw/nvram/fw_cfg.c   | 6 ++++--
 5 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index 3564b7b6a2..14dbc22d0c 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -83,8 +83,6 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr);
 void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, hwaddr addr,
                              int priority);
 void sysbus_mmio_unmap(SysBusDevice *dev, int n);
-void sysbus_add_io(SysBusDevice *dev, hwaddr addr,
-                   MemoryRegion *mem);
 MemoryRegion *sysbus_address_space(SysBusDevice *dev);
 
 bool sysbus_realize(SysBusDevice *dev, Error **errp);
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 35f902b582..9f1d5b2d6d 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -298,12 +298,6 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev)
     return g_strdup(qdev_fw_name(dev));
 }
 
-void sysbus_add_io(SysBusDevice *dev, hwaddr addr,
-                       MemoryRegion *mem)
-{
-    memory_region_add_subregion(get_system_io(), addr, mem);
-}
-
 MemoryRegion *sysbus_address_space(SysBusDevice *dev)
 {
     return get_system_memory();
diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
index f2b0aff479..20b0300357 100644
--- a/hw/i386/kvmvapic.c
+++ b/hw/i386/kvmvapic.c
@@ -16,6 +16,7 @@
 #include "sysemu/hw_accel.h"
 #include "sysemu/kvm.h"
 #include "sysemu/runstate.h"
+#include "exec/address-spaces.h"
 #include "hw/i386/apic_internal.h"
 #include "hw/sysbus.h"
 #include "hw/boards.h"
@@ -727,7 +728,7 @@ static void vapic_realize(DeviceState *dev, Error **errp)
     VAPICROMState *s = VAPIC(dev);
 
     memory_region_init_io(&s->io, OBJECT(s), &vapic_ops, s, "kvmvapic", 2);
-    sysbus_add_io(sbd, VAPIC_IO_PORT, &s->io);
+    memory_region_add_subregion(get_system_io(), VAPIC_IO_PORT, &s->io);
     sysbus_init_ioports(sbd, VAPIC_IO_PORT, 2);
 
     option_rom[nb_option_roms].name = "kvmvapic.bin";
diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
index a12427b6c8..9170d6c474 100644
--- a/hw/mips/mipssim.c
+++ b/hw/mips/mipssim.c
@@ -28,6 +28,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu/datadir.h"
+#include "exec/address-spaces.h"
 #include "hw/clock.h"
 #include "hw/mips/mips.h"
 #include "hw/char/serial.h"
@@ -226,7 +227,7 @@ mips_mipssim_init(MachineState *machine)
         qdev_prop_set_uint8(dev, "endianness", DEVICE_LITTLE_ENDIAN);
         sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, env->irq[4]);
-        sysbus_add_io(SYS_BUS_DEVICE(dev), 0x3f8,
+        memory_region_add_subregion(get_system_io(), 0x3f8,
                       sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0));
     }
 
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index e85493d513..fc0263f349 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -27,6 +27,7 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/dma.h"
 #include "sysemu/reset.h"
+#include "exec/address-spaces.h"
 #include "hw/boards.h"
 #include "hw/nvram/fw_cfg.h"
 #include "hw/qdev-properties.h"
@@ -1142,6 +1143,7 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,
     SysBusDevice *sbd;
     FWCfgIoState *ios;
     FWCfgState *s;
+    MemoryRegion *iomem = get_system_io();
     bool dma_requested = dma_iobase && dma_as;
 
     dev = qdev_new(TYPE_FW_CFG_IO);
@@ -1155,7 +1157,7 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,
     sbd = SYS_BUS_DEVICE(dev);
     sysbus_realize_and_unref(sbd, &error_fatal);
     ios = FW_CFG_IO(dev);
-    sysbus_add_io(sbd, iobase, &ios->comb_iomem);
+    memory_region_add_subregion(iomem, iobase, &ios->comb_iomem);
 
     s = FW_CFG(dev);
 
@@ -1163,7 +1165,7 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,
         /* 64 bits for the address field */
         s->dma_as = dma_as;
         s->dma_addr = 0;
-        sysbus_add_io(sbd, dma_iobase, &s->dma_iomem);
+        memory_region_add_subregion(iomem, dma_iobase, &s->dma_iomem);
     }
 
     return s;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 07/32] hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API
  2024-02-22 12:55 [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io() Philippe Mathieu-Daudé
@ 2024-02-22 12:55 ` Philippe Mathieu-Daudé
  2024-02-22 12:55 ` [PULL 08/32] hw/ppc/pnv_bmc: Use qdev_new() " Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-22 12:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
	Zhao Liu, Nicholas Piggin, Daniel Henrique Barboza,
	Cédric Le Goater, David Gibson, Harsh Prateek Bora

Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Message-Id: <20240216110313.17039-4-philmd@linaro.org>
---
 hw/ppc/spapr_cpu_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 0c0fb3f1b0..40b7c52f7f 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -245,8 +245,7 @@ static void spapr_cpu_core_unrealize(DeviceState *dev)
              * spapr_cpu_core_realize(), make sure we only unrealize
              * vCPUs that have already been realized.
              */
-            if (object_property_get_bool(OBJECT(sc->threads[i]), "realized",
-                                         &error_abort)) {
+            if (qdev_is_realized(DEVICE(sc->threads[i]))) {
                 spapr_unrealize_vcpu(sc->threads[i], sc);
             }
             spapr_delete_vcpu(sc->threads[i]);
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 08/32] hw/ppc/pnv_bmc: Use qdev_new() instead of QOM API
  2024-02-22 12:55 [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io() Philippe Mathieu-Daudé
  2024-02-22 12:55 ` [PULL 07/32] hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API Philippe Mathieu-Daudé
@ 2024-02-22 12:55 ` Philippe Mathieu-Daudé
  2024-02-22 12:55 ` [PULL 09/32] hw/tricore/testboard: Use qdev_new() instead of QOM basic API Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-22 12:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
	Cédric Le Goater, Nicholas Piggin, Frédéric Barrat

Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20240216110313.17039-6-philmd@linaro.org>
---
 hw/ppc/pnv_bmc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/ppc/pnv_bmc.c b/hw/ppc/pnv_bmc.c
index 99f1e8d7f9..0c1274df21 100644
--- a/hw/ppc/pnv_bmc.c
+++ b/hw/ppc/pnv_bmc.c
@@ -269,13 +269,13 @@ void pnv_bmc_set_pnor(IPMIBmc *bmc, PnvPnor *pnor)
  */
 IPMIBmc *pnv_bmc_create(PnvPnor *pnor)
 {
-    Object *obj;
+    DeviceState *dev;
 
-    obj = object_new(TYPE_IPMI_BMC_SIMULATOR);
-    qdev_realize(DEVICE(obj), NULL, &error_fatal);
-    pnv_bmc_set_pnor(IPMI_BMC(obj), pnor);
+    dev = qdev_new(TYPE_IPMI_BMC_SIMULATOR);
+    qdev_realize(dev, NULL, &error_fatal);
+    pnv_bmc_set_pnor(IPMI_BMC(dev), pnor);
 
-    return IPMI_BMC(obj);
+    return IPMI_BMC(dev);
 }
 
 typedef struct ForeachArgs {
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 09/32] hw/tricore/testboard: Use qdev_new() instead of QOM basic API
  2024-02-22 12:55 [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io() Philippe Mathieu-Daudé
  2024-02-22 12:55 ` [PULL 07/32] hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API Philippe Mathieu-Daudé
  2024-02-22 12:55 ` [PULL 08/32] hw/ppc/pnv_bmc: Use qdev_new() " Philippe Mathieu-Daudé
@ 2024-02-22 12:55 ` Philippe Mathieu-Daudé
  2024-02-22 12:55 ` [PULL 19/32] hw/i386/pc_sysfw: Use qdev_is_realized() instead of QOM API Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-22 12:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
	Bastian Koppelmann

Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Message-Id: <20240216110313.17039-5-philmd@linaro.org>
---
 include/hw/tricore/tricore_testdevice.h | 3 ---
 hw/tricore/tricore_testboard.c          | 4 +---
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/include/hw/tricore/tricore_testdevice.h b/include/hw/tricore/tricore_testdevice.h
index 8b4fe15f24..2c57b62f22 100644
--- a/include/hw/tricore/tricore_testdevice.h
+++ b/include/hw/tricore/tricore_testdevice.h
@@ -25,12 +25,9 @@
     OBJECT_CHECK(TriCoreTestDeviceState, (obj), TYPE_TRICORE_TESTDEVICE)
 
 typedef struct {
-    /* <private> */
     SysBusDevice parent_obj;
 
-    /* <public> */
     MemoryRegion iomem;
-
 } TriCoreTestDeviceState;
 
 #endif
diff --git a/hw/tricore/tricore_testboard.c b/hw/tricore/tricore_testboard.c
index b6810e3be0..c29db8b451 100644
--- a/hw/tricore/tricore_testboard.c
+++ b/hw/tricore/tricore_testboard.c
@@ -89,9 +89,7 @@ static void tricore_testboard_init(MachineState *machine, int board_id)
     memory_region_add_subregion(sysmem, 0xf0050000, pcp_data);
     memory_region_add_subregion(sysmem, 0xf0060000, pcp_text);
 
-    test_dev = g_new(TriCoreTestDeviceState, 1);
-    object_initialize(test_dev, sizeof(TriCoreTestDeviceState),
-                      TYPE_TRICORE_TESTDEVICE);
+    test_dev = TRICORE_TESTDEVICE(qdev_new(TYPE_TRICORE_TESTDEVICE));
     memory_region_add_subregion(sysmem, 0xf0000000, &test_dev->iomem);
 
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 19/32] hw/i386/pc_sysfw: Use qdev_is_realized() instead of QOM API
  2024-02-22 12:55 [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io() Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2024-02-22 12:55 ` [PULL 09/32] hw/tricore/testboard: Use qdev_new() instead of QOM basic API Philippe Mathieu-Daudé
@ 2024-02-22 12:55 ` Philippe Mathieu-Daudé
  2024-02-22 12:55 ` [PULL 22/32] hw/acpi: Include missing 'qapi/qapi-types-acpi.h' generated header Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-22 12:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
	Zhao Liu, Paolo Bonzini, Richard Henderson, Eduardo Habkost,
	Michael S. Tsirkin, Marcel Apfelbaum

Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Message-Id: <20240216110313.17039-3-philmd@linaro.org>
---
 hw/i386/pc_sysfw.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index 2dcaa116ad..b02e285579 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -95,17 +95,15 @@ static void pc_system_flash_cleanup_unused(PCMachineState *pcms)
 {
     char *prop_name;
     int i;
-    Object *dev_obj;
 
     assert(PC_MACHINE_GET_CLASS(pcms)->pci_enabled);
 
     for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) {
-        dev_obj = OBJECT(pcms->flash[i]);
-        if (!object_property_get_bool(dev_obj, "realized", &error_abort)) {
+        if (!qdev_is_realized(DEVICE(pcms->flash[i]))) {
             prop_name = g_strdup_printf("pflash%d", i);
             object_property_del(OBJECT(pcms), prop_name);
             g_free(prop_name);
-            object_unparent(dev_obj);
+            object_unparent(OBJECT(pcms->flash[i]));
             pcms->flash[i] = NULL;
         }
     }
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 22/32] hw/acpi: Include missing 'qapi/qapi-types-acpi.h' generated header
  2024-02-22 12:55 [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io() Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2024-02-22 12:55 ` [PULL 19/32] hw/i386/pc_sysfw: Use qdev_is_realized() instead of QOM API Philippe Mathieu-Daudé
@ 2024-02-22 12:55 ` Philippe Mathieu-Daudé
  2024-02-22 12:55 ` [PULL 23/32] hw/acpi/cpu: Use CPUState typedef Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-22 12:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
	Zhao Liu, Michael S. Tsirkin, Igor Mammedov, Ani Sinha

ACPIOSTInfo is a QAPI generated structure:

  $ git grep -w ACPIOSTInfo
  qapi/acpi.json:81:# @ACPIOSTInfo:
  qapi/acpi.json:99:{ 'struct': 'ACPIOSTInfo',
  qapi/acpi.json:109:# Return a list of ACPIOSTInfo for devices that support status

Include the "qapi/qapi-types-acpi.h" header to avoid the following
errors when including "hw/acpi/cpu.h" or "hw/acpi/memory_hotplug.h"
elsewhere:

  include/hw/acpi/cpu.h:67:52: error: unknown type name 'ACPIOSTInfoList'
  void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list);
                                                     ^
  include/hw/acpi/memory_hotplug.h:51:55: error: unknown type name 'ACPIOSTInfoList'
  void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
                                                        ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Message-Id: <20240219141412.71418-2-philmd@linaro.org>
---
 include/hw/acpi/cpu.h            | 1 +
 include/hw/acpi/memory_hotplug.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
index bc901660fb..e011d01adf 100644
--- a/include/hw/acpi/cpu.h
+++ b/include/hw/acpi/cpu.h
@@ -12,6 +12,7 @@
 #ifndef ACPI_CPU_H
 #define ACPI_CPU_H
 
+#include "qapi/qapi-types-acpi.h"
 #include "hw/qdev-core.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/aml-build.h"
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index dfe9cf3fde..38841d7b06 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -1,6 +1,7 @@
 #ifndef QEMU_HW_ACPI_MEMORY_HOTPLUG_H
 #define QEMU_HW_ACPI_MEMORY_HOTPLUG_H
 
+#include "qapi/qapi-types-acpi.h"
 #include "hw/qdev-core.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/aml-build.h"
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 23/32] hw/acpi/cpu: Use CPUState typedef
  2024-02-22 12:55 [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io() Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2024-02-22 12:55 ` [PULL 22/32] hw/acpi: Include missing 'qapi/qapi-types-acpi.h' generated header Philippe Mathieu-Daudé
@ 2024-02-22 12:55 ` Philippe Mathieu-Daudé
  2024-02-22 12:55 ` [PULL 24/32] hw/acpi/ich9_tco: Include missing 'migration/vmstate.h' header Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-22 12:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
	Richard Henderson, Zhao Liu, Michael S. Tsirkin, Igor Mammedov,
	Ani Sinha

QEMU coding style recommend using structure typedefs:
https://www.qemu.org/docs/master/devel/style.html#typedefs

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Message-Id: <20240126220407.95022-2-philmd@linaro.org>
---
 include/hw/acpi/cpu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
index e011d01adf..e6e1a9ef59 100644
--- a/include/hw/acpi/cpu.h
+++ b/include/hw/acpi/cpu.h
@@ -20,7 +20,7 @@
 #include "hw/hotplug.h"
 
 typedef struct AcpiCpuStatus {
-    struct CPUState *cpu;
+    CPUState *cpu;
     uint64_t arch_id;
     bool is_inserting;
     bool is_removing;
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 24/32] hw/acpi/ich9_tco: Include missing 'migration/vmstate.h' header
  2024-02-22 12:55 [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io() Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2024-02-22 12:55 ` [PULL 23/32] hw/acpi/cpu: Use CPUState typedef Philippe Mathieu-Daudé
@ 2024-02-22 12:55 ` Philippe Mathieu-Daudé
  2024-02-22 12:55 ` [PULL 32/32] hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro Philippe Mathieu-Daudé
  2024-02-22 12:58 ` [PULL v2 00/32] Misc HW patches for 2024-02-22 Philippe Mathieu-Daudé
  8 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-22 12:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
	Zhao Liu, Michael S. Tsirkin, Igor Mammedov, Ani Sinha,
	Marcel Apfelbaum

We need the VMStateDescription structure definition from
"migration/vmstate.h" in order to declare vmstate_tco_io_sts.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Message-Id: <20240219141412.71418-4-philmd@linaro.org>
---
 include/hw/acpi/ich9_tco.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/hw/acpi/ich9_tco.h b/include/hw/acpi/ich9_tco.h
index c4393caee0..2562a7cf39 100644
--- a/include/hw/acpi/ich9_tco.h
+++ b/include/hw/acpi/ich9_tco.h
@@ -11,6 +11,7 @@
 #define HW_ACPI_TCO_H
 
 #include "exec/memory.h"
+#include "migration/vmstate.h"
 
 /* As per ICH9 spec, the internal timer has an error of ~0.6s on every tick */
 #define TCO_TICK_NSEC 600000000LL
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL 32/32] hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro
  2024-02-22 12:55 [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io() Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2024-02-22 12:55 ` [PULL 24/32] hw/acpi/ich9_tco: Include missing 'migration/vmstate.h' header Philippe Mathieu-Daudé
@ 2024-02-22 12:55 ` Philippe Mathieu-Daudé
  2024-02-22 12:58 ` [PULL v2 00/32] Misc HW patches for 2024-02-22 Philippe Mathieu-Daudé
  8 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-22 12:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, qemu-arm, qemu-ppc, Thomas Huth,
	Philippe Mathieu-Daudé, Clément Chigot, Frederic Konrad,
	Mark Cave-Ayland, Artyom Tarasenko

From: Thomas Huth <thuth@redhat.com>

leon3.c currently fails to compile with some compilers when the -Wvla
option has been enabled:

 ../hw/sparc/leon3.c: In function ‘leon3_cpu_reset’:
 ../hw/sparc/leon3.c:153:5: error: ISO C90 forbids variable length array
  ‘offset_must_be_zero’ [-Werror=vla]
   153 |     ResetData *s = (ResetData *)DO_UPCAST(ResetData, info[id], info);
       |     ^~~~~~~~~
 cc1: all warnings being treated as errors

Looking at this code, the DO_UPCAST macro is indeed used in a wrong way
here: DO_UPCAST is supposed to check that the second parameter is the
first entry of the struct that the first parameter indicates, but since
we use and index into the info[] array, this of course cannot work.

The intention here was likely rather to use the container_of() macro
instead, so switch the code accordingly.

Fixes: d65aba8286 ("hw/sparc/leon3: implement multiprocessor")
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240221180751.190489-1-thuth@redhat.com>
Tested-by: Clément Chigot <chigot@adacore.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/sparc/leon3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 4873b59b6c..6aaa04cb19 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -150,7 +150,7 @@ static void leon3_cpu_reset(void *opaque)
 {
     struct CPUResetData *info = (struct CPUResetData *) opaque;
     int id = info->id;
-    ResetData *s = (ResetData *)DO_UPCAST(ResetData, info[id], info);
+    ResetData *s = container_of(info, ResetData, info[id]);
     CPUState *cpu = CPU(s->info[id].cpu);
     CPUSPARCState *env = cpu_env(cpu);
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PULL v2 00/32] Misc HW patches for 2024-02-22
  2024-02-22 12:55 [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io() Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2024-02-22 12:55 ` [PULL 32/32] hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro Philippe Mathieu-Daudé
@ 2024-02-22 12:58 ` Philippe Mathieu-Daudé
  2024-02-23  9:43   ` Peter Maydell
  8 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-22 12:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-block, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé

The following changes since commit 760b4dcdddba4a40b9fa0eb78fdfc7eda7cb83d0:

  Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2024-02-20 10:11:08 +0000)

are available in the Git repository at:

  https://github.com/philmd/qemu.git tags/hw-misc-20240222

for you to fetch changes up to 7164f7e4028ad3b01a5f98c27482587b401ad420:

  hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro (2024-02-22 12:47:40 +0100)

Supersedes: <20240221211626.48190-1-philmd@linaro.org>

Following checkpatch.pl error ignored:

  ERROR: Macros with complex values should be enclosed in parenthesis
  #62: FILE: include/hw/ide/ide-dev.h:31:
  +#define DEFINE_IDE_DEV_PROPERTIES()                     \
  +    DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf),        \
  +    DEFINE_BLOCK_ERROR_PROPERTIES(IDEDrive, dev.conf),  \
  +    DEFINE_PROP_STRING("ver",  IDEDrive, dev.version),  \
  +    DEFINE_PROP_UINT64("wwn",  IDEDrive, dev.wwn, 0),   \
  +    DEFINE_PROP_STRING("serial",  IDEDrive, dev.serial),\
  +    DEFINE_PROP_STRING("model", IDEDrive, dev.model)

----------------------------------------------------------------
Misc HW patch queue

- Remove sysbus_add_io (Phil)
- Build PPC 4xx PCI host bridges once (Phil)
- Display QOM path while debugging SMBus targets (Joe)
- Simplify x86 PC code (Bernhard)
- Remove qemu_[un]register_reset() calls in x86 PC CMOS (Peter)
- Fix wiring of ICH9 LPC interrupts (Bernhard)
- Split core IDE as device / bus / dma (Thomas)
- Prefer QDev API over QOM for devices (Phil)
- Fix invalid use of DO_UPCAST() in Leon3 (Thomas)

----------------------------------------------------------------

Bernhard Beschow (8):
  hw/i386/pc_piix: Share pc_cmos_init() invocation between pc and isapc
    machines
  hw/i386/x86: Turn apic_xrupt_override into class attribute
  hw/i386/pc: Merge pc_guest_info_init() into pc_machine_initfn()
  hw/i386/pc: Defer smbios_set_defaults() to machine_done
  hw/i386/pc: Confine system flash handling to pc_sysfw
  hw/i386/pc_sysfw: Inline pc_system_flash_create() and remove it
  hw/i386/pc_q35: Populate interrupt handlers before realizing LPC PCI
    function
  hw/isa/meson.build: Sort alphabetically

Joe Komlodi (1):
  hw/i2c/smbus_slave: Add object path on error prints

Peter Maydell (2):
  hw/i386/pc: Store pointers to IDE buses in PCMachineState
  hw/i386/pc: Do pc_cmos_init_late() from pc_machine_done()

Philippe Mathieu-Daudé (13):
  hw/input/pckbd: Open-code i8042_setup_a20_line() wrapper
  hw/sysbus: Inline and remove sysbus_add_io()
  hw/ppc/ppc4xx_pci: Remove unused "hw/ppc/ppc.h" header
  hw/ppc/ppc4xx_pci: Extract PCI host definitions to
    hw/pci-host/ppc4xx.h
  hw/ppc/ppc4xx_pci: Move ppc4xx_pci.c to hw/pci-host/
  hw/ppc/ppc440_pcix: Move ppc440_pcix.c to hw/pci-host/
  hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API
  hw/ppc/pnv_bmc: Use qdev_new() instead of QOM API
  hw/tricore/testboard: Use qdev_new() instead of QOM basic API
  hw/i386/pc_sysfw: Use qdev_is_realized() instead of QOM API
  hw/acpi: Include missing 'qapi/qapi-types-acpi.h' generated header
  hw/acpi/cpu: Use CPUState typedef
  hw/acpi/ich9_tco: Include missing 'migration/vmstate.h' header

Thomas Huth (8):
  hw/ide: Add the possibility to disable the CompactFlash device in the
    build
  hw/ide: Split qdev.c into ide-bus.c and ide-dev.c
  hw/ide: Move IDE DMA related definitions to a separate header
    ide-dma.h
  hw/ide: Move IDE device related definitions to ide-dev.h
  hw/ide: Move IDE bus related definitions to a new header ide-bus.h
  hw/ide: Remove the include/hw/ide.h legacy file
  hw/ide: Stop exposing internal.h to non-IDE files
  hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro

 MAINTAINERS                             |   5 +-
 hw/i386/fw_cfg.h                        |   3 +-
 include/hw/acpi/cpu.h                   |   3 +-
 include/hw/acpi/ich9_tco.h              |   1 +
 include/hw/acpi/memory_hotplug.h        |   1 +
 include/hw/i386/pc.h                    |   9 +-
 include/hw/i386/x86.h                   |   3 +-
 include/hw/ide.h                        |   9 -
 include/hw/ide/ide-bus.h                |  42 +++++
 include/hw/ide/ide-dev.h                | 184 +++++++++++++++++++++
 include/hw/ide/ide-dma.h                |  37 +++++
 include/hw/ide/internal.h               | 211 +-----------------------
 include/hw/ide/pci.h                    |   2 +-
 include/hw/input/i8042.h                |   1 -
 include/hw/pci-host/ppc4xx.h            |  17 ++
 include/hw/ppc/ppc4xx.h                 |   5 -
 include/hw/sysbus.h                     |   2 -
 include/hw/tricore/tricore_testdevice.h |   3 -
 hw/core/sysbus.c                        |   6 -
 hw/i2c/smbus_slave.c                    |   8 +-
 hw/i386/acpi-common.c                   |   3 +-
 hw/i386/fw_cfg.c                        |  12 +-
 hw/i386/kvmvapic.c                      |   3 +-
 hw/i386/pc.c                            |  60 +++----
 hw/i386/pc_piix.c                       |  31 +---
 hw/i386/pc_q35.c                        |  22 +--
 hw/i386/pc_sysfw.c                      |  23 +--
 hw/ide/cf.c                             |  58 +++++++
 hw/ide/cmd646.c                         |   1 +
 hw/ide/ide-bus.c                        | 111 +++++++++++++
 hw/ide/{qdev.c => ide-dev.c}            | 137 +--------------
 hw/ide/pci.c                            |   1 +
 hw/ide/piix.c                           |   1 +
 hw/ide/sii3112.c                        |   1 +
 hw/ide/via.c                            |   1 +
 hw/input/pckbd.c                        |   5 -
 hw/mips/mipssim.c                       |   3 +-
 hw/nvram/fw_cfg.c                       |   6 +-
 hw/{ppc => pci-host}/ppc440_pcix.c      |   3 +-
 hw/{ppc => pci-host}/ppc4xx_pci.c       |   3 +-
 hw/pci-host/ppce500.c                   |   2 +-
 hw/ppc/pnv_bmc.c                        |  10 +-
 hw/ppc/ppc440_bamboo.c                  |   1 +
 hw/ppc/ppc440_uc.c                      |   1 +
 hw/ppc/sam460ex.c                       |   1 +
 hw/ppc/spapr_cpu_core.c                 |   3 +-
 hw/sparc/leon3.c                        |   2 +-
 hw/tricore/tricore_testboard.c          |   4 +-
 hw/arm/Kconfig                          |   2 +
 hw/ide/Kconfig                          |  32 ++--
 hw/ide/meson.build                      |   4 +-
 hw/isa/meson.build                      |   2 +-
 hw/pci-host/Kconfig                     |   8 +
 hw/pci-host/meson.build                 |   2 +
 hw/pci-host/trace-events                |  12 ++
 hw/ppc/Kconfig                          |   3 +-
 hw/ppc/meson.build                      |   3 +-
 hw/ppc/trace-events                     |  12 --
 58 files changed, 607 insertions(+), 534 deletions(-)
 delete mode 100644 include/hw/ide.h
 create mode 100644 include/hw/ide/ide-bus.h
 create mode 100644 include/hw/ide/ide-dev.h
 create mode 100644 include/hw/ide/ide-dma.h
 create mode 100644 include/hw/pci-host/ppc4xx.h
 create mode 100644 hw/ide/cf.c
 create mode 100644 hw/ide/ide-bus.c
 rename hw/ide/{qdev.c => ide-dev.c} (67%)
 rename hw/{ppc => pci-host}/ppc440_pcix.c (99%)
 rename hw/{ppc => pci-host}/ppc4xx_pci.c (99%)

-- 
2.41.0



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PULL v2 00/32] Misc HW patches for 2024-02-22
  2024-02-22 12:58 ` [PULL v2 00/32] Misc HW patches for 2024-02-22 Philippe Mathieu-Daudé
@ 2024-02-23  9:43   ` Peter Maydell
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2024-02-23  9:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, qemu-block, qemu-arm, qemu-ppc

On Thu, 22 Feb 2024 at 12:58, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> The following changes since commit 760b4dcdddba4a40b9fa0eb78fdfc7eda7cb83d0:
>
>   Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2024-02-20 10:11:08 +0000)
>
> are available in the Git repository at:
>
>   https://github.com/philmd/qemu.git tags/hw-misc-20240222
>
> for you to fetch changes up to 7164f7e4028ad3b01a5f98c27482587b401ad420:
>
>   hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro (2024-02-22 12:47:40 +0100)
>
> Supersedes: <20240221211626.48190-1-philmd@linaro.org>
>
> Following checkpatch.pl error ignored:
>
>   ERROR: Macros with complex values should be enclosed in parenthesis
>   #62: FILE: include/hw/ide/ide-dev.h:31:
>   +#define DEFINE_IDE_DEV_PROPERTIES()                     \
>   +    DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf),        \
>   +    DEFINE_BLOCK_ERROR_PROPERTIES(IDEDrive, dev.conf),  \
>   +    DEFINE_PROP_STRING("ver",  IDEDrive, dev.version),  \
>   +    DEFINE_PROP_UINT64("wwn",  IDEDrive, dev.wwn, 0),   \
>   +    DEFINE_PROP_STRING("serial",  IDEDrive, dev.serial),\
>   +    DEFINE_PROP_STRING("model", IDEDrive, dev.model)
>
> ----------------------------------------------------------------
> Misc HW patch queue
>
> - Remove sysbus_add_io (Phil)
> - Build PPC 4xx PCI host bridges once (Phil)
> - Display QOM path while debugging SMBus targets (Joe)
> - Simplify x86 PC code (Bernhard)
> - Remove qemu_[un]register_reset() calls in x86 PC CMOS (Peter)
> - Fix wiring of ICH9 LPC interrupts (Bernhard)
> - Split core IDE as device / bus / dma (Thomas)
> - Prefer QDev API over QOM for devices (Phil)
> - Fix invalid use of DO_UPCAST() in Leon3 (Thomas)
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/9.0
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-02-23  9:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-22 12:55 [PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io() Philippe Mathieu-Daudé
2024-02-22 12:55 ` [PULL 07/32] hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API Philippe Mathieu-Daudé
2024-02-22 12:55 ` [PULL 08/32] hw/ppc/pnv_bmc: Use qdev_new() " Philippe Mathieu-Daudé
2024-02-22 12:55 ` [PULL 09/32] hw/tricore/testboard: Use qdev_new() instead of QOM basic API Philippe Mathieu-Daudé
2024-02-22 12:55 ` [PULL 19/32] hw/i386/pc_sysfw: Use qdev_is_realized() instead of QOM API Philippe Mathieu-Daudé
2024-02-22 12:55 ` [PULL 22/32] hw/acpi: Include missing 'qapi/qapi-types-acpi.h' generated header Philippe Mathieu-Daudé
2024-02-22 12:55 ` [PULL 23/32] hw/acpi/cpu: Use CPUState typedef Philippe Mathieu-Daudé
2024-02-22 12:55 ` [PULL 24/32] hw/acpi/ich9_tco: Include missing 'migration/vmstate.h' header Philippe Mathieu-Daudé
2024-02-22 12:55 ` [PULL 32/32] hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro Philippe Mathieu-Daudé
2024-02-22 12:58 ` [PULL v2 00/32] Misc HW patches for 2024-02-22 Philippe Mathieu-Daudé
2024-02-23  9:43   ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).