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: 10783593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C4006C2 for ; Mon, 28 Jan 2019 11:09:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47C822A007 for ; Mon, 28 Jan 2019 11:09:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3660A2A1CD; Mon, 28 Jan 2019 11:09:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BCC6B2A007 for ; Mon, 28 Jan 2019 11:09:06 +0000 (UTC) Received: from localhost ([127.0.0.1]:57941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go4mn-0005Ki-Tq for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Jan 2019 06:09:05 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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" #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; }