From patchwork Mon Jan 28 11:05:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 156705 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3297640jaa; Mon, 28 Jan 2019 03:10:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN5AbeMUN4NVldj9r6eVH1LbAYBF7GOoyBm4qbK+bEBbe/+NQrpqj0zhcs2EU29xcc4bpl0/ X-Received: by 2002:a5d:68c3:: with SMTP id p3mr21808648wrw.34.1548673815968; Mon, 28 Jan 2019 03:10:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548673815; cv=none; d=google.com; s=arc-20160816; b=eO4OXYz/cylU9ae6VRsVAC2jh2OZPMFTb6053kiXRYvDJ8/yJkydXir4WcdEPoKkSL /02lBUO7WvVVHcqREfqbor3KvR1HkSgRRkeo4JiuVOBX4kJDfmVkcIkN658Q7zp2D61a IED5IV+SdJ86284cHGq0i6vup6ktN4u7gs1f7IdjhPwNyUNvswOFcoMRRXw8RAIioKOU /1SuqxTTGFvGbp2oNpx+jdeA08ZpOc0Qr7a1NoUMxbJDUF54CuuazhO7DfwWfpczQ4PJ kEYoS2UdmEKDRH4XoZre2GPbaEv/Igq1SNyI/Csy5DhFFNJhqygikEyVX1Rt1C+HjOrM t9wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=Z9RCDKHTLl473egDrWKfRjaj4/RAn70tszqNv1yS6Iw=; b=c/tWaja3Luvcf2wMoJ7cWDKmbZZv7rCM5xbV20dDUx4TzC3H7UUtpbWFC/dSx9lKua wy4FPN5o+B5WPqMEk+8bH9yNE+59NLX2zqHmtFeDedNu81qWZ2A3HYfMrwPpqmdfymNI mu300/FX6yROUI45jqdbjBHiOaANay/I5wtr7dNbtAeikdE67Wy66DHyV5dq7rLIpbkw WHK9Mr76mLAi+7DnT+zsQ2o6yfGOKRXcO+JPB9Rf8wxL/iFvC4H3An3y1nC2KibTJdJ4 /IFkCv8V8+7d54c8G3729MoVMIQUdftj0WoPdnFSs4SifQB4oQ9rtoN6mUSd341FZ2Kn q3rA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m25si45200001wmg.68.2019.01.28.03.10.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 03:10:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:57939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go4nu-00054k-Sz for patch@linaro.org; Mon, 28 Jan 2019 06:10:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go4kt-0003o0-77 for qemu-devel@nongnu.org; Mon, 28 Jan 2019 06:07:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1go4kq-00046f-Gd for qemu-devel@nongnu.org; Mon, 28 Jan 2019 06:07:06 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:33556 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1go4ki-00043q-Jg; Mon, 28 Jan 2019 06:06:58 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C1CA0769E03B966D799F; Mon, 28 Jan 2019 19:06:53 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.408.0; Mon, 28 Jan 2019 19:06:42 +0800 From: Shameer Kolothum To: , , , , , Date: Mon, 28 Jan 2019 11:05:43 +0000 Message-ID: <20190128110545.20644-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190128110545.20644-1-shameerali.kolothum.thodi@huawei.com> References: <20190128110545.20644-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [RFC PATCH 1/4] hw:acpi: Make ACPI IO address space configurable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@huawei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is in preparation for adding support for ARM64 platforms where it doesn't use port mapped IO for ACPI IO space. Also add a flag to identify hw reduced ACPI platforms as they might use GPIO hw for signaling ACPI platform events. Signed-off-by: Shameer Kolothum --- hw/acpi/memory_hotplug.c | 13 ++++++++----- hw/i386/acpi-build.c | 3 ++- include/hw/acpi/memory_hotplug.h | 6 ++++-- 3 files changed, 14 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 921cad2..05f1d45 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -34,7 +34,7 @@ #define MEMORY_HOTPLUG_IO_LEN 24 #define MEMORY_DEVICES_CONTAINER "\\_SB.MHPC" -static uint16_t memhp_io_base; +static hwaddr memhp_io_base; static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev) { @@ -208,7 +208,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()); @@ -279,7 +279,9 @@ void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st, mdev->is_enabled = true; if (dev->hotplugged) { mdev->is_inserting = true; - acpi_send_event(DEVICE(hotplug_dev), ACPI_MEMORY_HOTPLUG_STATUS); + if (!mem_st->hw_reduced_acpi) { + acpi_send_event(DEVICE(hotplug_dev), ACPI_MEMORY_HOTPLUG_STATUS); + } } } @@ -341,7 +343,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) { int i; Aml *ifctx; @@ -371,7 +374,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, 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 2e21a31..b62c1a3 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1852,7 +1852,8 @@ 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"); + build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0", + "\\_GPE._E03", AML_SYSTEM_IO); scope = aml_scope("_GPE"); { diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h index 77c6576..ec56579 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -26,10 +26,11 @@ typedef struct MemHotplugState { uint32_t selector; uint32_t dev_count; MemStatus *devs; + bool hw_reduced_acpi; /*true for hw reduced acpi platform */ } 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 +49,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); #endif From patchwork Mon Jan 28 11:05:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 156707 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3300657jaa; Mon, 28 Jan 2019 03:13:23 -0800 (PST) X-Google-Smtp-Source: ALg8bN7hdzsTQwOexwYR06lsSiJgleOleqICqX4QZfs574F6AYHOOWDVVAk47IVi5tlTrL4tk3QO X-Received: by 2002:a5d:4ac7:: with SMTP id y7mr20282125wrs.196.1548674003752; Mon, 28 Jan 2019 03:13:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548674003; cv=none; d=google.com; s=arc-20160816; b=zytMWV/8cUY8erkvSviBFrW1YrmH/h9FPCGMkQLDblw7i2L8HTQdrGIO5aX1k9vEc7 6kpCMMPjFML+ejHLLdz4psaiMuQX/BqBpUXVXNKC2ebcedQYoKqDn0jnn9hfXjMdcqTn D4PtChzhsGRYCjxyh6gzDGNtv2c1X95/5YlIgSp61XsixTiRCv5CgVwTh9TgOFSMobSu 1dLc1VoVjTneI7SVPnoUDw7UGnFIBOqjkCiLjgtFGScJAIeW7Q5A2sO+3CSFRO0K86mG c/tANWfGnIyJ9pL19uQH7tYFxgw88l8wC+U/hHYSa12qsqhg+9+inyHNUSpnKRjqXNzK xsVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=aR0r5asjFPEFHAm4Cs3hkg1fvrnfRmZtCtjEpIs4Kcw=; b=Rt2PuPSZYXMK8a1Kd5M8BUGF5sxAzxEJfvSUI8+E96B5n9Qt7dDERDB7OFxoNp3SFp uf7XUeIRxZbP66TjfP1JtH7h2pxdXE1ZJ2sCw/CEmHl+IPQ40O5EqCP8UoeG6rt92naU nae9UL/QZoum+ulTXjqbKC1rEGRkvS9gLa0F+mMQy1FD7X/hd8l9ZYlxag3T60K6/Zi7 677F7F8wSPjI7ubODDrEfSt2Y9p2ofuyf5fq58OjiBJ+XY2JfY2gRMTbHHd7aSGe4qhP y6GcMSGr+3fZIaA2NQOp0p1j9QeNMCmIkH08v0JdxF7qMqQeaKrT77QUEkOL57jg938r bsww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h124si46063315wmf.39.2019.01.28.03.13.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 03:13:23 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:58015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go4qw-0007tY-LD for patch@linaro.org; Mon, 28 Jan 2019 06:13:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go4l0-0003t3-9h for qemu-devel@nongnu.org; Mon, 28 Jan 2019 06:07:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1go4kx-00049s-Om for qemu-devel@nongnu.org; Mon, 28 Jan 2019 06:07:14 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:33554 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1go4ki-00043p-Is; Mon, 28 Jan 2019 06:06:58 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id BA4BABAE56610C0C2D5; Mon, 28 Jan 2019 19:06:53 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.408.0; Mon, 28 Jan 2019 19:06:45 +0800 From: Shameer Kolothum To: , , , , , Date: Mon, 28 Jan 2019 11:05:44 +0000 Message-ID: <20190128110545.20644-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190128110545.20644-1-shameerali.kolothum.thodi@huawei.com> References: <20190128110545.20644-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [RFC PATCH 2/4] hw/arm/virt: Add GPIO based pcdimm hotplug ACPI event support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@huawei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This adds support for using PL061 GPIO controller pin to trigger pcdimm hotplug event to guest. Signed-off-by: Shameer Kolothum --- default-configs/arm-softmmu.mak | 1 + hw/arm/virt-acpi-build.c | 28 ++++++++++++++++++++++++---- hw/arm/virt.c | 37 +++++++++++++++++++++++++++++++++---- include/hw/arm/virt.h | 14 ++++++++++++++ 4 files changed, 72 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index 5deabc1..ebbc67b 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -163,3 +163,4 @@ CONFIG_MEM_DEVICE=y CONFIG_DIMM=y CONFIG_NVDIMM=y CONFIG_ACPI_NVDIMM=y +CONFIG_ACPI_MEMORY_HOTPLUG=y diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index ab30e28..eedd323 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -40,6 +40,7 @@ #include "hw/loader.h" #include "hw/hw.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/memory_hotplug.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" @@ -327,8 +328,10 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, } static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, - uint32_t gpio_irq) + uint32_t gpio_irq, VirtMachineState *vms) { + uint32_t pin_list[1]; + Aml *dev = aml_device("GPO0"); aml_append(dev, aml_name_decl("_HID", aml_string("ARMH0061"))); aml_append(dev, aml_name_decl("_ADR", aml_int(0))); @@ -342,11 +345,21 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, aml_append(dev, aml_name_decl("_CRS", crs)); Aml *aei = aml_resource_template(); - /* Pin 3 for power button */ - const uint32_t pin_list[1] = {3}; + + /* GPIO Interrupt connection descriptor for power button */ + pin_list[0] = GPIO_PWRB; aml_append(aei, aml_gpio_int(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH, AML_EXCLUSIVE, AML_PULL_UP, 0, pin_list, 1, "GPO0", NULL, 0)); + + if (vms->acpi_memhp_state.is_enabled) { + /* GPIO Interrupt connection descriptor for pc-dimm hotplug */ + pin_list[0] = GPIO_PCDIMM; + aml_append(aei, aml_gpio_int(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH, + AML_EXCLUSIVE, AML_PULL_UP, 0, pin_list, + 1, "GPO0", NULL, 0)); + } + aml_append(dev, aml_name_decl("_AEI", aei)); /* _E03 is handle for power button */ @@ -735,6 +748,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) Aml *scope, *dsdt; const MemMapEntry *memmap = vms->memmap; const int *irqmap = vms->irqmap; + MachineState *ms = MACHINE(vms); + uint32_t nr_mem = ms->ram_slots; dsdt = init_aml_allocator(); /* Reserve space for header */ @@ -756,11 +771,16 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE), vms->highmem, vms->highmem_ecam); acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], - (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); + (irqmap[VIRT_GPIO] + ARM_SPI_BASE), vms); acpi_dsdt_add_power_button(scope); aml_append(dsdt, scope); + if (vms->acpi_memhp_state.is_enabled) { + build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.GPO0", + "\\_SB.GPO0._E02", AML_SYSTEM_MEMORY); + } + /* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); build_header(linker, table_data, diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 8c6dd59..884960d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -173,6 +173,9 @@ static const char *valid_cpus[] = { ARM_CPU_TYPE_NAME("max"), }; +static QLIST_HEAD(, GPIODevice) gpio_devices = + QLIST_HEAD_INITIALIZER(gpio_devices); + static bool cpu_type_valid(const char *cpu) { int i; @@ -740,11 +743,34 @@ static void create_rtc(const VirtMachineState *vms, qemu_irq *pic) g_free(nodename); } -static DeviceState *gpio_key_dev; +static DeviceState *virt_get_gpio_dev(int pin) +{ + GPIODevice *gpio_dev; + + QLIST_FOREACH(gpio_dev, &gpio_devices, next) { + if (pin == gpio_dev->pin_num) { + return gpio_dev->dev; + } + } + return NULL; +} + +static void virt_create_gpio_dev(DeviceState *pl061_dev, int pin) +{ + GPIODevice *gpio_dev; + + gpio_dev = g_malloc0(sizeof(*gpio_dev)); + gpio_dev->dev = sysbus_create_simple("gpio-key", -1, + qdev_get_gpio_in(pl061_dev, pin)); + gpio_dev->pin_num = pin; + QLIST_INSERT_HEAD(&gpio_devices, gpio_dev, next); +} + static void virt_powerdown_req(Notifier *n, void *opaque) { + DeviceState *dev = virt_get_gpio_dev(GPIO_PWRB); /* use gpio Pin 3 for power button event */ - qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); + qemu_set_irq(qdev_get_gpio_in(dev, 0), 1); } static Notifier virt_system_powerdown_notifier = { @@ -777,8 +803,11 @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) qemu_fdt_setprop_string(vms->fdt, nodename, "clock-names", "apb_pclk"); qemu_fdt_setprop_cell(vms->fdt, nodename, "phandle", phandle); - gpio_key_dev = sysbus_create_simple("gpio-key", -1, - qdev_get_gpio_in(pl061_dev, 3)); + virt_create_gpio_dev(pl061_dev, GPIO_PWRB); + + if (vms->acpi_memhp_state.is_enabled) { + virt_create_gpio_dev(pl061_dev, GPIO_PCDIMM); + } qemu_fdt_add_subnode(vms->fdt, "/gpio-keys"); qemu_fdt_setprop_string(vms->fdt, "/gpio-keys", "compatible", "gpio-keys"); qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#size-cells", 0); diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 6bb7f92..ef39ce6 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -38,6 +38,7 @@ #include "sysemu/kvm.h" #include "hw/intc/arm_gicv3_common.h" #include "hw/mem/nvdimm.h" +#include "hw/acpi/memory_hotplug.h" #define NUM_GICV2M_SPIS 64 #define NUM_VIRTIO_TRANSPORTS 32 @@ -136,8 +137,21 @@ typedef struct { hwaddr high_io_base; bool extended_memmap; AcpiNVDIMMState acpi_nvdimm_state; + MemHotplugState acpi_memhp_state; } VirtMachineState; +/* GPIO pins for ACPI events */ +enum { + GPIO_PCDIMM = 2, + GPIO_PWRB, +}; + +typedef struct GPIODevice { + DeviceState *dev; + int pin_num; + QLIST_ENTRY(GPIODevice) next; +} GPIODevice; + #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) #define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") From patchwork Mon Jan 28 11:05:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 156706 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3297974jaa; Mon, 28 Jan 2019 03:10:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN5KR/0tHzpMgeD2GU0IGxKPdPETOEkyn7QCKLRREUglVZQH7FYzlu8ApEmuINLdFo8V6TPX X-Received: by 2002:a1c:1d81:: with SMTP id d123mr16208200wmd.112.1548673833666; Mon, 28 Jan 2019 03:10:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548673833; cv=none; d=google.com; s=arc-20160816; b=mcyK7RmGq7MNaIOS76U3AwXU5JFwkMUASMiymEo4iLdr/2aBpnAxmgSegn/0AAUsfd f3XyJ32t33/KBL2FcGMmlZMG6XDiqXCoyFIVMcUO9XF7X8jtvs3eStz8J+NoS27kSmaj SFepzEaE53KWKqbnC7aBBzIeYRQN9KStSMVq5OflEmeR8FQGF7nk4pGQScAaEr3kp9+1 mvqxlcdPf7c/V6LKg8Umknu2O0S2COXPX+lHher61w7s+wsHkYqh9lH1/d7aRThPgU78 LOXp69O1wadR6jqjm+regpdw67A9+78sKd2DYt/62wfCkZIRouY9ugylQFEY86wSfokw FvIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=KvZxo5x/BCgRYbg0IbVFilSp+tj7rJxZ7buifNClvZw=; b=he1nN1v1Xu7bLP/xZMA4QtELUN1wfogOg98jRBr2cRv+r6PzqghqB+847N70fwm8+z +Uq55e02e/D9pNnswndJsYpyF+V4O00bn7ohd4bJQIoJFVzYCJDLVvSq90xsZE73DC7i rQy4KRpC7drYzCAO3gvtM6rK2OwboKHHd7AecUCv/Do3p2t31ZC6Q+tfIJjSyMUf9yTg uN9n+FrvuUro6s2gJ8n8Ll0ujT661m9N/TAe5IhJ/Zy1IaBLcosJzyvJgK2Sr59pk2Yu Gh9bgOlaxJV2qYH9ONc8DpO3H+6/h6ltwLbUezo0pxf1u4gsR0ZdIeRug7oTlaK4OjbR sQDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h25si45476485wmb.160.2019.01.28.03.10.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 03:10:33 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:57941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go4oC-0005Ki-Hh for patch@linaro.org; Mon, 28 Jan 2019 06:10:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go4l5-0003we-54 for qemu-devel@nongnu.org; Mon, 28 Jan 2019 06:07:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1go4l4-0004Fv-83 for qemu-devel@nongnu.org; Mon, 28 Jan 2019 06:07:19 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2174 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1go4l0-00044k-F6; Mon, 28 Jan 2019 06:07:14 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id CA9DBE647A6015494704; Mon, 28 Jan 2019 19:06:58 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.408.0; Mon, 28 Jan 2019 19:06:48 +0800 From: Shameer Kolothum To: , , , , , Date: Mon, 28 Jan 2019 11:05:45 +0000 Message-ID: <20190128110545.20644-4-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190128110545.20644-1-shameerali.kolothum.thodi@huawei.com> References: <20190128110545.20644-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [RFC PATCH 3/4] hw/arm/virt: Enable pc-dimm hotplug support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@huawei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" pc-dimm memory hotplug is enabled using GPIO(Pin 2) based ACPI event. Hot removal functionality is not yet supported. Signed-off-by: Shameer Kolothum --- hw/arm/virt.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 884960d..cf64554 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -62,6 +62,7 @@ #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/pc-hotplug.h" #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -1651,7 +1652,14 @@ static void machvirt_init(MachineState *machine) nvdimm_init_acpi_state(acpi_nvdimm_state, sysmem, vms->fw_cfg, OBJECT(vms)); } + if (vms->acpi_memhp_state.is_enabled) { + MemHotplugState *state = &vms->acpi_memhp_state; + hwaddr base; + state->hw_reduced_acpi = true; + base = vms->memmap[VIRT_ACPI_IO].base + ACPI_MEMORY_HOTPLUG_BASE; + acpi_memory_hotplug_init(sysmem, OBJECT(vms), state, base); + } vms->bootinfo.ram_size = machine->ram_size; vms->bootinfo.kernel_filename = machine->kernel_filename; vms->bootinfo.kernel_cmdline = machine->kernel_cmdline; @@ -1819,6 +1827,20 @@ static void virt_set_nvdimm_persistence(Object *obj, const char *value, nvdimm_state->persistence_string = g_strdup(value); } +static bool virt_get_memhp_support(Object *obj, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + return vms->acpi_memhp_state.is_enabled; +} + +static void virt_set_memhp_support(Object *obj, bool value, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + vms->acpi_memhp_state.is_enabled = value; +} + static CpuInstanceProperties virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) { @@ -1863,8 +1885,8 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); - if (dev->hotplugged) { - error_setg(errp, "memory hotplug is not supported"); + if (dev->hotplugged && is_nvdimm) { + error_setg(errp, "nvdimm hotplug is not supported"); } if (is_nvdimm && !vms->acpi_nvdimm_state.is_enabled) { @@ -1875,6 +1897,22 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); } +static void virt_memhp_send_event(HotplugHandler *hotplug_dev, DeviceState *dev, + Error **errp) +{ + DeviceState *gpio_dev; + VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); + + gpio_dev = virt_get_gpio_dev(GPIO_PCDIMM); + if (!gpio_dev) { + error_setg(errp, "No dev interface to send hotplug event"); + return; + } + acpi_memory_plug_cb(hotplug_dev, &vms->acpi_memhp_state, + dev, errp); + qemu_set_irq(qdev_get_gpio_in(gpio_dev, 0), 1); +} + static void virt_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1891,6 +1929,10 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev, nvdimm_plug(&vms->acpi_nvdimm_state); } + if (dev->hotplugged && !is_nvdimm) { + virt_memhp_send_event(hotplug_dev, dev, errp); + } + out: error_propagate(errp, local_err); } @@ -1898,6 +1940,11 @@ out: static void virt_memory_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + if (dev->hotplugged) { + error_setg(errp, "memory hot unplug is not supported"); + return; + } + pc_dimm_unplug(PC_DIMM(dev), MACHINE(hotplug_dev)); object_unparent(OBJECT(dev)); } @@ -2085,6 +2132,12 @@ static void virt_instance_init(Object *obj) "Set NVDIMM persistence" "Valid values are cpu and mem-ctrl", NULL); + vms->acpi_memhp_state.is_enabled = true; + object_property_add_bool(obj, "memory-hotplug-support", + virt_get_memhp_support, + virt_set_memhp_support, + NULL); + vms->irqmap = a15irqmap; } From patchwork Mon Jan 28 11:10:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 156708 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3305528jaa; Mon, 28 Jan 2019 03:18:47 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib88f/RdTRaml65AKkO7M59fUuPRguMj4f7rJtRmuIHmi6sq5nY69kZyaqsAFQdvmUvht03 X-Received: by 2002:a1c:c282:: with SMTP id s124mr6102851wmf.105.1548674327576; Mon, 28 Jan 2019 03:18:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548674327; cv=none; d=google.com; s=arc-20160816; b=KY1tMsiZkqWX0aY0ghbOlr+Xllk1SYw6kGhCNQ3EuMefjjUCbex38W5L7ySoEGkrAc nv9Q+uE7jbCLoTUWgnKGbE+pjLKgTxgmsxKrF+xq6L286S9cmzPQiUQZF4aYaWR7pKwm gESJRPf4kzbo9uax9vvVudqHpMGgHxos8hyOXxp/btPqMrXCmQ9eUt+JwP6JRLrZRW/Y AJF1skRE3EuLVK4Nk3PE1MeFQ3M93vaHsd2y0qFr/b9vrIpT3bvSQhjSHE/gwVsbS28x f7tcTzzGBHPwHLjymgxCSTtigTiC83IeW8cUOGDLaV1u2JpjcaEIDZo28kBuXCCsHw/N 8luQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:message-id :date:to:from; bh=Y9mVPmP44DJuzJzCOOZiZ8KRZDbll8aUQqzI1xUyp3E=; b=w65U3Ddi2eWI2+53x5s4SsQdXRKgast4YG9S8qctCicE0j1tVIP8PnloboRLcBsKj8 JG+nZ5Y3rvBBgvUP1P+29yzJDTfUICQK4dJs+ex/SNEL+12fB+0oW3bv5643G5okYvYO KyPXc6I8jj9kpE2Z0jBVjNIYQXrsHeyY03CU2bA9be3XlE3ntDsBjXZ0lkETsHDoNNOn v/NwltsIUnuqa84/DcQDPJ0VedJ5YES3OJjgz5YoDZSrqgocYFYhEAY0gdOoK4J7BX11 +cBmajd9SM03Yv/feqSM4Z1jzwoC7cT6KbINPAfpp1SIIB+B0MI6atkJSNuc+KVkviaD buiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q6si51878498wma.72.2019.01.28.03.18.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 03:18:47 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:58102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go4wA-0003LD-H5 for patch@linaro.org; Mon, 28 Jan 2019 06:18:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go4oe-00076t-19 for qemu-devel@nongnu.org; Mon, 28 Jan 2019 06:11:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1go4od-0005zT-1R for qemu-devel@nongnu.org; Mon, 28 Jan 2019 06:11:00 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:44278 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1go4oa-0005yH-IT; Mon, 28 Jan 2019 06:10:56 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 84BBA9CE554F3BADC9E2; Mon, 28 Jan 2019 19:10:53 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.408.0; Mon, 28 Jan 2019 19:10:43 +0800 From: Shameer Kolothum To: , , , , , Date: Mon, 28 Jan 2019 11:10:31 +0000 Message-ID: <20190128111031.6176-1-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.35 Subject: [Qemu-devel] [RFC PATCH 4/4] hw/arm/virt: Add nvdimm hotplug support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@huawei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" nvdimm hotplug is enabled using GPIO(Pin 4) based ACPI event. Hot removal functionality is not yet supported. Signed-off-by: Shameer Kolothum --- hw/arm/virt-acpi-build.c | 17 +++++++++++++++++ hw/arm/virt.c | 29 ++++++++++++++++++----------- include/hw/arm/virt.h | 1 + 3 files changed, 36 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index eedd323..132414c 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -360,6 +360,14 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, 1, "GPO0", NULL, 0)); } + if (vms->acpi_nvdimm_state.is_enabled) { + /* GPIO Interrupt connection descriptor for NVDIMM hotplug */ + pin_list[0] = GPIO_NVDIMM; + aml_append(aei, aml_gpio_int(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH, + AML_EXCLUSIVE, AML_PULL_UP, 0, pin_list, + 1, "GPO0", NULL, 0)); + } + aml_append(dev, aml_name_decl("_AEI", aei)); /* _E03 is handle for power button */ @@ -367,6 +375,15 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, aml_append(method, aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE), aml_int(0x80))); aml_append(dev, method); + + if (vms->acpi_nvdimm_state.is_enabled) { + /* _E04 is for nvdimm hotplug*/ + method = aml_method("_E04", 0, AML_NOTSERIALIZED); + aml_append(method, aml_notify(aml_name("\\_SB.NVDR"), + aml_int(0x80))); + aml_append(dev, method); + } + aml_append(scope, dev); } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index cf64554..71e7886 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -809,6 +809,11 @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) if (vms->acpi_memhp_state.is_enabled) { virt_create_gpio_dev(pl061_dev, GPIO_PCDIMM); } + + if (vms->acpi_nvdimm_state.is_enabled) { + virt_create_gpio_dev(pl061_dev, GPIO_NVDIMM); + } + qemu_fdt_add_subnode(vms->fdt, "/gpio-keys"); qemu_fdt_setprop_string(vms->fdt, "/gpio-keys", "compatible", "gpio-keys"); qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#size-cells", 0); @@ -1885,10 +1890,6 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); - if (dev->hotplugged && is_nvdimm) { - error_setg(errp, "nvdimm hotplug is not supported"); - } - if (is_nvdimm && !vms->acpi_nvdimm_state.is_enabled) { error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'"); return; @@ -1898,19 +1899,25 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, } static void virt_memhp_send_event(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp) + bool is_nvdimm, Error **errp) { DeviceState *gpio_dev; VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); - gpio_dev = virt_get_gpio_dev(GPIO_PCDIMM); + gpio_dev = (is_nvdimm) ? virt_get_gpio_dev(GPIO_NVDIMM) : + virt_get_gpio_dev(GPIO_PCDIMM); if (!gpio_dev) { error_setg(errp, "No dev interface to send hotplug event"); return; } - acpi_memory_plug_cb(hotplug_dev, &vms->acpi_memhp_state, - dev, errp); - qemu_set_irq(qdev_get_gpio_in(gpio_dev, 0), 1); + + if (is_nvdimm) { + qemu_set_irq(qdev_get_gpio_in(gpio_dev, 0), 1); + } else { + acpi_memory_plug_cb(hotplug_dev, &vms->acpi_memhp_state, + dev, errp); + qemu_set_irq(qdev_get_gpio_in(gpio_dev, 0), 1); + } } static void virt_memory_plug(HotplugHandler *hotplug_dev, @@ -1929,8 +1936,8 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev, nvdimm_plug(&vms->acpi_nvdimm_state); } - if (dev->hotplugged && !is_nvdimm) { - virt_memhp_send_event(hotplug_dev, dev, errp); + if (dev->hotplugged) { + virt_memhp_send_event(hotplug_dev, dev, is_nvdimm, errp); } out: diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index ef39ce6..70ee2f2 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -144,6 +144,7 @@ typedef struct { enum { GPIO_PCDIMM = 2, GPIO_PWRB, + GPIO_NVDIMM, }; typedef struct GPIODevice {