From nobody Fri Nov 7 19:59:28 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548673788021648.3749826833422; Mon, 28 Jan 2019 03:09:48 -0800 (PST) Received: from localhost ([127.0.0.1]:57941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go4nM-0005Ki-7W for importer@patchew.org; Mon, 28 Jan 2019 06:09:40 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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(-) 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" =20 #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 =3D &vms->acpi_memhp_state; + hwaddr base; =20 + state->hw_reduced_acpi =3D true; + base =3D vms->memmap[VIRT_ACPI_IO].base + ACPI_MEMORY_HOTPLUG_BASE; + acpi_memory_hotplug_init(sysmem, OBJECT(vms), state, base); + } vms->bootinfo.ram_size =3D machine->ram_size; vms->bootinfo.kernel_filename =3D machine->kernel_filename; vms->bootinfo.kernel_cmdline =3D machine->kernel_cmdline; @@ -1819,6 +1827,20 @@ static void virt_set_nvdimm_persistence(Object *obj,= const char *value, nvdimm_state->persistence_string =3D g_strdup(value); } =20 +static bool virt_get_memhp_support(Object *obj, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + return vms->acpi_memhp_state.is_enabled; +} + +static void virt_set_memhp_support(Object *obj, bool value, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + vms->acpi_memhp_state.is_enabled =3D value; +} + static CpuInstanceProperties virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) { @@ -1863,8 +1885,8 @@ static void virt_memory_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); =20 - if (dev->hotplugged) { - error_setg(errp, "memory hotplug is not supported"); + if (dev->hotplugged && is_nvdimm) { + error_setg(errp, "nvdimm hotplug is not supported"); } =20 if (is_nvdimm && !vms->acpi_nvdimm_state.is_enabled) { @@ -1875,6 +1897,22 @@ static void virt_memory_pre_plug(HotplugHandler *hot= plug_dev, DeviceState *dev, pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); } =20 +static void virt_memhp_send_event(HotplugHandler *hotplug_dev, DeviceState= *dev, + Error **errp) +{ + DeviceState *gpio_dev; + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); + + gpio_dev =3D 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); } =20 + 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", N= ULL); =20 + vms->acpi_memhp_state.is_enabled =3D true; + object_property_add_bool(obj, "memory-hotplug-support", + virt_get_memhp_support, + virt_set_memhp_support, + NULL); + vms->irqmap =3D a15irqmap; } =20 --=20 2.7.4