From patchwork Thu Mar 21 10:47:39 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: 160775 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp654864jan; Thu, 21 Mar 2019 04:04:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsBoDR2YOxHDGGU+CNTD0iKKOkKz5JbRQjApBhUuagWKjrECJUxjLspN1LV89N/HkuYK2D X-Received: by 2002:a1c:f718:: with SMTP id v24mr1131339wmh.1.1553166270382; Thu, 21 Mar 2019 04:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553166270; cv=none; d=google.com; s=arc-20160816; b=YGrwW72cJp46ODDGa+fPxnLPxPXmU7Cd7+mtGkEVRtjtTvgizJImAujPjbvYtNW0Oa 2i7rp5zb+2xEYR7hfEPrucBtfzYD8uzvUbAiEL1Sq/TqATzDzBTVEAs6cyYvt1nEXNTo 0Ckf6esinIfKPlVr1cTC3AhLV5wpsJJLDR9DTYq8pq1JJdpmBeoWPYH44bPoesFtGySl dxpo4O1Mf4oMWNzFZ0ZaFgYERhFsMhuycSrr4lRNN2fjV3rHrkn4/QZYo/7oFh1yc9AX FL5WoLj4Qi+4gR290ywtywTEkkv71O0Xde/ZRWcCAw4Vbgkg6/Vc6acMuCM970TI8rU1 3y5A== 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=hHe1yv32FSB+KApKUMYSU/k3QsGmmIshgFGk3KhIvYY=; b=LotpbpUJw8jdZHmt/ok5HN7YJoWrW65W0CPNWY9KSD50QnI2RgZYwxHHlfdeXGdXj8 g8v+nQJYVI+vDQLvgk/AeFUYIP9BqeUySfX1mQRvqHKywYd8+7PK3xNEYXy1JVWkCjbW 5cKMNPY+AuDgPOC0pB4LRgmNz+tZJ+0NugyBQkR4resLD1aUnA7rlkf69PhTXrEG2aJn z9vBCMSwtyQSavco0d2eqT6g2mj7p8DGekWbLPZdF9W78/97/rw2WsDEwdPjBOzdt4ri HGPGWYVqJAOOHAlnMbv8eiUkLWWVb4Qm07ytYxDDJOeSgMbBU0Z6Q0biCujKkRXvYt5x wNCg== 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 d63si3177083wmf.30.2019.03.21.04.04.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 04:04:30 -0700 (PDT) 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]:34907 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vUr-00063K-FB for patch@linaro.org; Thu, 21 Mar 2019 07:04:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHh-0004Td-Pj for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vFu-0001mi-4Y for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:49:03 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:56388 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vFs-0001GN-04; Thu, 21 Mar 2019 06:49:00 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 97DC26E198EBD0991C00; Thu, 21 Mar 2019 18:48:57 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 18:48:50 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:39 +0000 Message-ID: <20190321104745.28068-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190321104745.28068-1-shameerali.kolothum.thodi@huawei.com> References: <20190321104745.28068-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.35 Subject: [Qemu-devel] [PATCH v3 04/10] hw/arm/virt: Add memory hotplug framework 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@hisilicon.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Eric Auger This patch adds the the memory hot-plug/hot-unplug infrastructure in machvirt. It is still not enabled as device memory is not yet reported to guest. Signed-off-by: Eric Auger Signed-off-by: Kwangwoo Lee Signed-off-by: Shameer Kolothum --- default-configs/arm-softmmu.mak | 3 +++ hw/arm/virt.c | 53 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index 2a7efc1..795cb89 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -159,3 +159,6 @@ CONFIG_MUSICPAL=y # for realview and versatilepb CONFIG_LSI_SCSI_PCI=y + +CONFIG_MEM_DEVICE=y +CONFIG_DIMM=y diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ce2664a..d0ff20d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -61,6 +61,8 @@ #include "hw/arm/smmuv3.h" #include "hw/acpi/acpi.h" #include "target/arm/internals.h" +#include "hw/mem/pc-dimm.h" +#include "hw/mem/nvdimm.h" #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -1806,6 +1808,42 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) return ms->possible_cpus; } +static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, + Error **errp) +{ + const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + + if (dev->hotplugged) { + error_setg(errp, "memory hotplug is not supported"); + } + + if (is_nvdimm) { + error_setg(errp, "nvdimm is not yet supported"); + return; + } + + pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); +} + +static void virt_memory_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); + Error *local_err = NULL; + + pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); + + error_propagate(errp, local_err); +} + +static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_pre_plug(hotplug_dev, dev, errp); + } +} + static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1817,12 +1855,23 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, SYS_BUS_DEVICE(dev)); } } + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_plug(hotplug_dev, dev, errp); + } +} + +static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + error_setg(errp, "device unplug request for unsupported device" + " type: %s", object_get_typename(OBJECT(dev))); } static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, DeviceState *dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) || + (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { return HOTPLUG_HANDLER(machine); } @@ -1886,7 +1935,9 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->kvm_type = virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler = virt_machine_get_hotplug_handler; + hc->pre_plug = virt_machine_device_pre_plug_cb; hc->plug = virt_machine_device_plug_cb; + hc->unplug_request = virt_machine_device_unplug_request_cb; } static void virt_instance_init(Object *obj)