From patchwork Fri Jun 22 10:19:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 139599 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp693544lji; Fri, 22 Jun 2018 03:22:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdJTPKPZgiT121JOsryVTvxxqX39VwJbnmtQ63dx0oupPET7MjP/WL4j+74oBOh7UDZIE6u X-Received: by 2002:a0c:96ed:: with SMTP id b42-v6mr780004qvd.135.1529662942711; Fri, 22 Jun 2018 03:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529662942; cv=none; d=google.com; s=arc-20160816; b=Ww55P7PF/Nm8AMt1fejesdmTLGy29M0aCzeM6HSXKfSzyrI7zBtwtomQbrtQFcRK1y ChaNQNTNoc8s7HKYODOb4+ENs1Dwut59XWUN9IpCr4DIJyCO5o6ZgABbaYFZFb2VNmht 8imnvbfnKaCMvrKal8qQS4mRBDyjAtHRwxYc1NuGV8xF2Nt1EN8GLwShFHIaIZuuXCcB EhnkzlF/aNo1qA3WXDz37yFNxjpmmOjuI1UY49DtkKBDZboNxGq2GbFGKPybVabK2kmc kYkPQ+n8hw4SeCn/fmn252obbYP0vPCQwhqM993JE88KpViqqtSWpfdwmDfYiOimq1uQ 673w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=iXTmnGRvbR5cSdLyHfw/M+q2PZBIBZRcqmFLNUDsWLk=; b=PzeU5JatV5zO66bdpgbc8HG5ps/EqUKb8jUU6J5KV4G+6Q8wdOJ5IXyB/2aVgWvQnF CtOKynnKupeUdK3ayRtxKiaUFbm6dK4q3H3Mo8A4OhdF0Ty++br1YupWjQpZ0218IcWz SDZ3t+A/hAnRpxjn8IhyMHpUECx4RpsSbmXCQpaa6wdsgubwiDwjxv5Cj+Pmx1h8qotP 0bYMkeWzJVMe0svDBWUb9XG1Cq9sVszdgpXYGP8EigiUaE/iazMdDBeDJGqxpdvv8uwQ mA//r0BKaPv8DFpZniwlH42GOmPIMky8Wuq4h2I5VH7FBhyJopGfAMJb0Q3ayHLZ5wq6 qqOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j2-v6si7498354qvd.102.2018.06.22.03.22.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Jun 2018 03:22:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:60594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWJCw-0002lN-4W for patch@linaro.org; Fri, 22 Jun 2018 06:22:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWJA3-0000Jf-BO for qemu-devel@nongnu.org; Fri, 22 Jun 2018 06:19:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWJA2-0005aL-9m for qemu-devel@nongnu.org; Fri, 22 Jun 2018 06:19:23 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40780 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fWJ9z-0005YA-KI; Fri, 22 Jun 2018 06:19:19 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 355C27CBBA; Fri, 22 Jun 2018 10:19:19 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-106.ams2.redhat.com [10.36.117.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF62C11166E1; Fri, 22 Jun 2018 10:19:17 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com Date: Fri, 22 Jun 2018 12:19:06 +0200 Message-Id: <1529662749-32069-3-git-send-email-eric.auger@redhat.com> In-Reply-To: <1529662749-32069-1-git-send-email-eric.auger@redhat.com> References: <1529662749-32069-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 22 Jun 2018 10:19:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 22 Jun 2018 10:19:19 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC 2/5] hw/arm/virt: Add pc-dimm mem 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Shameer Kolothum This patch adds the the PC-DIMM hot-plug/hot-unplug infrastructure in machvirt. Signed-off-by: Eric Auger Signed-off-by: Shameer Kolothum Signed-off-by: Kwangwoo Lee --- default-configs/arm-softmmu.mak | 2 ++ hw/arm/virt.c | 53 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) -- 2.5.5 diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index 7cf73d2..0840a56 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -151,3 +151,5 @@ CONFIG_PCI_DESIGNWARE=y CONFIG_STRONGARM=y CONFIG_HIGHBANK=y CONFIG_MUSICPAL=y +CONFIG_MEM_HOTPLUG=y + diff --git a/hw/arm/virt.c b/hw/arm/virt.c index a251054..a6e3b3d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -60,6 +60,7 @@ #include "standard-headers/linux/input.h" #include "hw/arm/smmuv3.h" #include "hw/acpi/acpi.h" +#include "hw/mem/pc-dimm.h" #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -1723,6 +1724,40 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) return ms->possible_cpus; } +static void virt_dimm_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + PCDIMMDevice *dimm = PC_DIMM(dev); + PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); + Error *local_err = NULL; + MemoryRegion *mr; + uint64_t align; + + mr = ddc->get_memory_region(dimm, &local_err); + if (local_err) { + goto out; + } + + if (memory_region_get_alignment(mr)) { + align = memory_region_get_alignment(mr); + } else { + /* by default we align on 64KB page size */ + align = SZ_64K; + } + + pc_dimm_memory_plug(dev, MACHINE(hotplug_dev), align, &local_err); + +out: + error_propagate(errp, local_err); +} + +static void virt_dimm_unplug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + pc_dimm_memory_unplug(dev, MACHINE(hotplug_dev)); + object_unparent(OBJECT(dev)); +} + static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1734,12 +1769,27 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, SYS_BUS_DEVICE(dev)); } } + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_dimm_plug(hotplug_dev, dev, errp); + } +} + +static void virt_machine_device_unplug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_dimm_unplug(hotplug_dev, dev, errp); + } else { + 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); } @@ -1800,6 +1850,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) assert(!mc->get_hotplug_handler); mc->get_hotplug_handler = virt_machine_get_hotplug_handler; hc->plug = virt_machine_device_plug_cb; + hc->unplug = virt_machine_device_unplug_cb; } static const TypeInfo virt_machine_info = {