All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/display/tcx: Init memory regions in realize
@ 2026-03-16 13:06 BALATON Zoltan
  2026-03-16 16:06 ` Peter Xu
  0 siblings, 1 reply; 15+ messages in thread
From: BALATON Zoltan @ 2026-03-16 13:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Xu, Mark Cave-Ayland, Peter Maydell,
	Philippe Mathieu-Daudé, Thomas Huth

Due to aux-ram-share property qemu_ram_alloc_internal dereferences
current_machine which is not set during init when inspecting the
device. This causes the qtest/device-introspect-test to fail since a
recent change to use memory_region_init_rom instead of global vmstate.
Fix it by removing the init method and move memory region creation in
realize.

Fixes: 653c4fa5b0 hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate
Reported by: Thomas Huth <thuth@redhat.com>
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/display/tcx.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/hw/display/tcx.c b/hw/display/tcx.c
index c8a4ac21ca..ea92a48400 100644
--- a/hw/display/tcx.c
+++ b/hw/display/tcx.c
@@ -751,10 +751,15 @@ static const GraphicHwOps tcx24_ops = {
     .gfx_update = tcx24_update_display,
 };
 
-static void tcx_initfn(Object *obj)
+static void tcx_realize(DeviceState *dev, Error **errp)
 {
-    SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
-    TCXState *s = TCX(obj);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+    TCXState *s = TCX(dev);
+    Object *obj = OBJECT(dev);
+    ram_addr_t vram_offset = 0;
+    int size, ret;
+    uint8_t *vram_base;
+    char *fcode_filename;
 
     memory_region_init_rom(&s->rom, obj, "tcx.prom", FCODE_MAX_ROM_SIZE,
                            &error_fatal);
@@ -804,16 +809,6 @@ static void tcx_initfn(Object *obj)
     memory_region_init_io(&s->alt, obj, &tcx_dummy_ops, s, "tcx.alt",
                           TCX_ALT_NREGS);
     sysbus_init_mmio(sbd, &s->alt);
-}
-
-static void tcx_realizefn(DeviceState *dev, Error **errp)
-{
-    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
-    TCXState *s = TCX(dev);
-    ram_addr_t vram_offset = 0;
-    int size, ret;
-    uint8_t *vram_base;
-    char *fcode_filename;
 
     memory_region_init_ram(&s->vram_mem, OBJECT(s), "tcx.vram",
                            s->vram_size * (1 + 4 + 4), &error_fatal);
@@ -887,7 +882,7 @@ static void tcx_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->realize = tcx_realizefn;
+    dc->realize = tcx_realize;
     device_class_set_legacy_reset(dc, tcx_reset);
     dc->vmsd = &vmstate_tcx;
     device_class_set_props(dc, tcx_properties);
@@ -897,7 +892,6 @@ static const TypeInfo tcx_info = {
     .name          = TYPE_TCX,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(TCXState),
-    .instance_init = tcx_initfn,
     .class_init    = tcx_class_init,
 };
 
-- 
2.41.3



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

end of thread, other threads:[~2026-03-17 14:24 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16 13:06 [PATCH] hw/display/tcx: Init memory regions in realize BALATON Zoltan
2026-03-16 16:06 ` Peter Xu
2026-03-16 16:23   ` Thomas Huth
2026-03-16 16:36     ` Peter Maydell
2026-03-16 17:49       ` Peter Xu
2026-03-16 21:45     ` Mark Cave-Ayland
2026-03-17  5:31       ` Thomas Huth
2026-03-16 18:10   ` BALATON Zoltan
2026-03-16 21:30     ` Peter Xu
2026-03-16 22:30       ` BALATON Zoltan
2026-03-17  5:41         ` Thomas Huth
2026-03-17  6:15           ` Thomas Huth
2026-03-17 10:17             ` BALATON Zoltan
2026-03-17 10:24               ` BALATON Zoltan
2026-03-17 14:24                 ` Peter Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.