qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
	Eric Auger <eric.auger@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: [PULL 02/19] hw/acpi: Make ACPI IO address space configurable
Date: Sat, 5 Oct 2019 17:58:43 -0400	[thread overview]
Message-ID: <20190918130633.4872-2-shameerali.kolothum.thodi@huawei.com> (raw)
Message-ID: <20191005215843.xJXeu83lRlrSa4jcfYkbC_GTvwDt-Y_gQ4oyyh0uiBg@z> (raw)
In-Reply-To: <20191005215508.28754-1-mst@redhat.com>

From: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>

This is in preparation for adding support for ARM64 platforms
where it doesn't use port mapped IO for ACPI IO space. We are
making changes so that MMIO region can be accommodated
and board can pass the base address into the aml build function.

Also move few MEMORY_* definitions to header so that other memory
hotplug event signalling mechanisms (eg. Generic Event Device on
HW-reduced acpi platforms) can use the same from their respective
event handler code.

Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20190918130633.4872-2-shameerali.kolothum.thodi@huawei.com>
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/acpi/memory_hotplug.c         | 33 ++++++++++++++------------------
 hw/i386/acpi-build.c             |  7 ++++++-
 hw/i386/pc.c                     |  3 +++
 include/hw/acpi/memory_hotplug.h |  9 +++++++--
 include/hw/i386/pc.h             |  3 +++
 5 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 9483d66e86..9b0b150f4f 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -30,12 +30,7 @@
 #define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
 #define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
 #define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
-#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
 #define MEMORY_HOTPLUG_DEVICE        "MHPD"
-#define MEMORY_HOTPLUG_IO_LEN         24
-#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
-
-static uint16_t memhp_io_base;
 
 static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
 {
@@ -210,7 +205,7 @@ static const MemoryRegionOps acpi_memory_hotplug_ops = {
 };
 
 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
-                              MemHotplugState *state, uint16_t io_base)
+                              MemHotplugState *state, hwaddr io_base)
 {
     MachineState *machine = MACHINE(qdev_get_machine());
 
@@ -219,12 +214,10 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
         return;
     }
 
-    assert(!memhp_io_base);
-    memhp_io_base = io_base;
     state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count);
     memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, state,
                           "acpi-mem-hotplug", MEMORY_HOTPLUG_IO_LEN);
-    memory_region_add_subregion(as, memhp_io_base, &state->io);
+    memory_region_add_subregion(as, io_base, &state->io);
 }
 
 /**
@@ -343,7 +336,8 @@ const VMStateDescription vmstate_memory_hotplug = {
 
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
                               const char *res_root,
-                              const char *event_handler_method)
+                              const char *event_handler_method,
+                              AmlRegionSpace rs, hwaddr memhp_io_base)
 {
     int i;
     Aml *ifctx;
@@ -352,10 +346,6 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
     Aml *mem_ctrl_dev;
     char *mhp_res_path;
 
-    if (!memhp_io_base) {
-        return;
-    }
-
     mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
     mem_ctrl_dev = aml_device("%s", mhp_res_path);
     {
@@ -366,14 +356,19 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
             aml_name_decl("_UID", aml_string("Memory hotplug resources")));
 
         crs = aml_resource_template();
-        aml_append(crs,
-            aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
-                   MEMORY_HOTPLUG_IO_LEN)
-        );
+        if (rs == AML_SYSTEM_IO) {
+            aml_append(crs,
+                aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
+                       MEMORY_HOTPLUG_IO_LEN)
+            );
+        } else {
+            aml_append(crs, aml_memory32_fixed(memhp_io_base,
+                            MEMORY_HOTPLUG_IO_LEN, AML_READ_WRITE));
+        }
         aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
 
         aml_append(mem_ctrl_dev, aml_operation_region(
-            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
+            MEMORY_HOTPLUG_IO_REGION, rs,
             aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN)
         );
 
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 4e0f9f425a..1d077a7cb7 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1888,7 +1888,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
                        "\\_SB.PCI0", "\\_GPE._E02");
     }
-    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0", "\\_GPE._E03");
+
+    if (pcms->memhp_io_base && nr_mem) {
+        build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
+                                 "\\_GPE._E03", AML_SYSTEM_IO,
+                                 pcms->memhp_io_base);
+    }
 
     scope =  aml_scope("_GPE");
     {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index bcda50efcc..4b1904237e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1766,6 +1766,9 @@ void pc_memory_init(PCMachineState *pcms,
 
     /* Init default IOAPIC address space */
     pcms->ioapic_as = &address_space_memory;
+
+    /* Init ACPI memory hotplug IO base address */
+    pcms->memhp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
 }
 
 /*
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 77c65765d6..dfe9cf3fde 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -5,6 +5,10 @@
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/aml-build.h"
 
+#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
+#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
+#define MEMORY_HOTPLUG_IO_LEN         24
+
 /**
  * MemStatus:
  * @is_removing: the memory device in slot has been requested to be ejected.
@@ -29,7 +33,7 @@ typedef struct MemHotplugState {
 } MemHotplugState;
 
 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
-                              MemHotplugState *state, uint16_t io_base);
+                              MemHotplugState *state, hwaddr io_base);
 
 void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st,
                          DeviceState *dev, Error **errp);
@@ -48,5 +52,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
                               const char *res_root,
-                              const char *event_handler_method);
+                              const char *event_handler_method,
+                              AmlRegionSpace rs, hwaddr memhp_io_base);
 #endif
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 6df4f4b6fb..37bfd95113 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -70,6 +70,9 @@ struct PCMachineState {
     /* Address space used by IOAPIC device. All IOAPIC interrupts
      * will be translated to MSI messages in the address space. */
     AddressSpace *ioapic_as;
+
+    /* ACPI Memory hotplug IO base address */
+    hwaddr memhp_io_base;
 };
 
 #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
-- 
MST



  parent reply	other threads:[~2019-10-05 22:01 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18 13:06 [Qemu-devel] [PATCH-for-4.2 v11 00/11] ARM virt: ACPI memory hotplug support Shameer Kolothum
2019-09-18 13:06 ` Shameer Kolothum [this message]
2019-10-05 21:58   ` [PULL 02/19] hw/acpi: Make ACPI IO address space configurable Michael S. Tsirkin
2019-09-18 13:06 ` [Qemu-devel] [PATCH-for-4.2 v11 02/11] hw/acpi: Do not create memory hotplug method when handler is not defined Shameer Kolothum
2019-10-05 21:58   ` [PULL 03/19] " Michael S. Tsirkin
2019-09-18 13:06 ` [Qemu-devel] [PATCH-for-4.2 v11 03/11] hw/acpi: Add ACPI Generic Event Device Support Shameer Kolothum
2019-09-25 15:03   ` Igor Mammedov
2019-10-05 21:58   ` [PULL 04/19] " Michael S. Tsirkin
2019-09-18 13:06 ` [Qemu-devel] [PATCH-for-4.2 v11 04/11] hw/arm/virt: Add memory hotplug framework Shameer Kolothum
2019-10-05 21:58   ` [PULL 05/19] " Michael S. Tsirkin
2019-09-18 13:06 ` [Qemu-devel] [PATCH-for-4.2 v11 05/11] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot Shameer Kolothum
2019-09-25 15:06   ` Igor Mammedov
2019-10-05 21:59   ` [PULL 06/19] " Michael S. Tsirkin
2019-09-18 13:06 ` [Qemu-devel] [PATCH-for-4.2 v11 06/11] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT Shameer Kolothum
2019-10-05 21:59   ` [PULL 07/19] " Michael S. Tsirkin
2019-09-18 13:06 ` [Qemu-devel] [PATCH-for-4.2 v11 07/11] hw/arm: Factor out powerdown notifier from GPIO Shameer Kolothum
2019-10-05 21:59   ` [PULL 08/19] " Michael S. Tsirkin
2019-09-18 13:06 ` [Qemu-devel] [PATCH-for-4.2 v11 08/11] hw/arm: Use GED for system_powerdown event Shameer Kolothum
2019-10-05 21:59   ` [PULL 09/19] " Michael S. Tsirkin
2019-09-18 13:06 ` [Qemu-devel] [PATCH-for-4.2 v11 09/11] docs/specs: Add ACPI GED documentation Shameer Kolothum
2019-09-25 15:09   ` Igor Mammedov
2019-10-05 21:59   ` [PULL 10/19] " Michael S. Tsirkin
2019-09-18 13:06 ` [Qemu-devel] [PATCH-for-4.2 v11 10/11] tests: Update ACPI tables list for upcoming arm/virt tests Shameer Kolothum
2019-09-25 15:11   ` Igor Mammedov
2019-10-05 21:59   ` [PULL 11/19] " Michael S. Tsirkin
2019-09-18 13:06 ` [Qemu-devel] [PATCH-for-4.2 v11 11/11] tests: Add bios tests to arm/virt Shameer Kolothum
2019-09-25 15:26   ` Michael S. Tsirkin
2019-09-25 17:36     ` Igor Mammedov
2019-10-05 21:59   ` [PULL 14/19] " Michael S. Tsirkin
2019-09-19  4:53 ` [Qemu-devel] [PATCH-for-4.2 v11 00/11] ARM virt: ACPI memory hotplug support no-reply
2019-09-19 20:36 ` no-reply
2019-09-20 15:49 ` no-reply
2019-09-25 15:28 ` Michael S. Tsirkin
2019-09-25 15:37   ` Igor Mammedov
2019-09-25 16:20     ` Michael S. Tsirkin
2019-09-27 10:37       ` Peter Maydell
2019-09-25 15:30 ` Michael S. Tsirkin
2019-09-30 10:51 [PATCH v4 0/3] Add virtio-fs Dr. David Alan Gilbert (git)
2019-09-30 10:51 ` [PATCH v4 1/3] virtio: Add virtio_fs linux headers Dr. David Alan Gilbert (git)
2019-10-05 22:00   ` [PULL 17/19] " Michael S. Tsirkin
2019-09-30 10:51 ` [PATCH v4 2/3] virtio: add vhost-user-fs base device Dr. David Alan Gilbert (git)
2019-09-30 11:06   ` Marc-André Lureau
2019-10-01 17:29     ` Dr. David Alan Gilbert
2019-10-02 15:07       ` Marc-André Lureau
2019-10-05 22:00   ` [PULL 18/19] " Michael S. Tsirkin
2019-10-07  5:57   ` Igor Mammedov
2019-10-07  7:28     ` Michael S. Tsirkin
2019-09-30 10:51 ` [PATCH v4 3/3] virtio: add vhost-user-fs-pci device Dr. David Alan Gilbert (git)
2019-10-05 22:00   ` [PULL 19/19] " Michael S. Tsirkin
2019-10-05 21:58 [PULL 00/19] virtio, vhost, acpi: features, fixes, tests Michael S. Tsirkin
2019-09-24 16:20 ` [PATCH v3] vhost-user: save features if the char dev is closed Adrian Moreno
2019-09-25  4:14   ` Jason Wang
2019-10-05 21:58   ` [PULL 01/19] " Michael S. Tsirkin
2019-10-05 21:59 ` [PULL 12/19] tests/acpi: add empty files Michael S. Tsirkin
2019-10-05 21:59 ` [PULL 13/19] tests: allow empty expected files Michael S. Tsirkin
2019-10-05 21:59 ` [PULL 15/19] tests: document how to update acpi tables Michael S. Tsirkin
2019-10-05 21:59 ` [PULL 16/19] tests/acpi: add expected tables for arm/virt Michael S. Tsirkin
2019-10-07 16:31 ` [PULL 00/19] virtio, vhost, acpi: features, fixes, tests Peter Maydell
2019-10-15 21:03   ` Michael S. Tsirkin
2019-10-17 15:48 ` Peter Maydell

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=20190918130633.4872-2-shameerali.kolothum.thodi@huawei.com \
    --to=mst@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=shameerali.kolothum.thodi@huawei.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).