qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Huacai Chen" <chenhuacai@kernel.org>,
	"Beniamino Galvani" <b.galvani@gmail.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	qemu-arm@nongnu.org,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Eric Farman" <farman@linux.ibm.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-s390x@nongnu.org,
	"Strahinja Jankovic" <strahinja.p.jankovic@gmail.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Song Gao" <gaosong@loongson.cn>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Peter Xu" <peterx@redhat.com>, "Sergio Lopez" <slp@redhat.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>
Subject: [PATCH v2 06/12] hw/acpi: Realize ACPI_GED sysbus device before accessing it
Date: Thu, 19 Oct 2023 09:16:04 +0200	[thread overview]
Message-ID: <20231019071611.98885-7-philmd@linaro.org> (raw)
In-Reply-To: <20231019071611.98885-1-philmd@linaro.org>

sysbus_mmio_map() should not be called on unrealized device.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/arm/virt.c       | 3 +--
 hw/i386/microvm.c   | 2 +-
 hw/loongarch/virt.c | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 15e74249f9..02c7a7ff3c 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -647,13 +647,12 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms)
 
     dev = qdev_new(TYPE_ACPI_GED);
     qdev_prop_set_uint32(dev, "ged-event", event);
+    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
     sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].base);
     sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].base);
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(vms->gic, irq));
 
-    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
-
     return dev;
 }
 
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index b9c93039e2..ca55aecc3b 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -206,12 +206,12 @@ static void microvm_devices_init(MicrovmMachineState *mms)
     if (x86_machine_is_acpi_enabled(x86ms)) {
         DeviceState *dev = qdev_new(TYPE_ACPI_GED);
         qdev_prop_set_uint32(dev, "ged-event", ACPI_GED_PWR_DOWN_EVT);
+        sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
         sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, GED_MMIO_BASE);
         /* sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, GED_MMIO_BASE_MEMHP); */
         sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, GED_MMIO_BASE_REGS);
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
                            x86ms->gsi[GED_MMIO_IRQ]);
-        sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
         x86ms->acpi_dev = HOTPLUG_HANDLER(dev);
     }
 
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index 2952fe452e..4b7dc67a2d 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -412,6 +412,7 @@ static DeviceState *create_acpi_ged(DeviceState *pch_pic, LoongArchMachineState
     }
     dev = qdev_new(TYPE_ACPI_GED);
     qdev_prop_set_uint32(dev, "ged-event", event);
+    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
     /* ged event */
     sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, VIRT_GED_EVT_ADDR);
@@ -422,7 +423,6 @@ static DeviceState *create_acpi_ged(DeviceState *pch_pic, LoongArchMachineState
 
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
                        qdev_get_gpio_in(pch_pic, VIRT_SCI_IRQ - VIRT_GSI_BASE));
-    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
     return dev;
 }
 
-- 
2.41.0



  parent reply	other threads:[~2023-10-19  7:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-19  7:15 [PATCH v2 00/12] hw: Strengthen SysBus & QBus API Philippe Mathieu-Daudé
2023-10-19  7:15 ` [PATCH v2 01/12] hw/i386/amd_iommu: Do not use SysBus API to map local MMIO region Philippe Mathieu-Daudé
2023-10-20  3:33   ` Zhao Liu
2023-10-19  7:16 ` [PATCH v2 02/12] hw/i386/intel_iommu: " Philippe Mathieu-Daudé
2023-10-20  3:35   ` Zhao Liu
2023-10-19  7:16 ` [PATCH v2 03/12] hw/misc/allwinner-dramc: Move sysbus_mmio_map call from init -> realize Philippe Mathieu-Daudé
2023-10-19  7:34   ` Thomas Huth
2023-10-19  7:16 ` [PATCH v2 04/12] hw/misc/allwinner-dramc: Do not use SysBus API to map local MMIO region Philippe Mathieu-Daudé
2023-10-19  7:44   ` Thomas Huth
2023-10-19  7:16 ` [PATCH v2 05/12] hw/pci-host/bonito: " Philippe Mathieu-Daudé
2023-10-19  7:26   ` Thomas Huth
2023-10-19  7:38     ` Philippe Mathieu-Daudé
2023-10-19  7:16 ` Philippe Mathieu-Daudé [this message]
2023-10-19  7:16 ` [PATCH v2 07/12] hw/arm/virt: Realize ARM_GICV2M sysbus device before accessing it Philippe Mathieu-Daudé
2023-10-19  7:16 ` [PATCH v2 08/12] hw/isa: Realize ISA BUS " Philippe Mathieu-Daudé
2023-10-19  7:16 ` [PATCH v2 09/12] hw/s390x/css-bridge: Realize " Philippe Mathieu-Daudé
2023-10-19  7:46   ` Thomas Huth
2023-10-20 14:21   ` Eric Farman
2023-10-19  7:16 ` [PATCH v2 10/12] hw/qdev: Ensure parent device is not realized before adding bus Philippe Mathieu-Daudé
2023-10-19  7:16 ` [PATCH v2 11/12] hw/sysbus: Ensure device is not realized before adding MMIO region Philippe Mathieu-Daudé
2023-10-19  7:16 ` [PATCH v2 12/12] hw/sysbus: Ensure device is realized before mapping it Philippe Mathieu-Daudé
2023-10-19  7:32 ` [PATCH v2 00/12] hw: Strengthen SysBus & QBus API Thomas Huth
2023-10-19  7:35   ` Philippe Mathieu-Daudé
2023-10-19 21:40 ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231019071611.98885-7-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=armbru@redhat.com \
    --cc=b.galvani@gmail.com \
    --cc=berrange@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=chenhuacai@kernel.org \
    --cc=david@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=farman@linux.ibm.com \
    --cc=gaosong@loongson.cn \
    --cc=iii@linux.ibm.com \
    --cc=jasowang@redhat.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=slp@redhat.com \
    --cc=strahinja.p.jankovic@gmail.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).