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 = { From patchwork Fri Jun 22 10:19:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 139598 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp691865lji; Fri, 22 Jun 2018 03:20:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcyysUk+WnILnPicvuLsG9/e6Le51nnKtmwaBpE+nMfv6Raagh8Wg4ego5SQpMBBflu8jFg X-Received: by 2002:a0c:8f12:: with SMTP id z18-v6mr782383qvd.222.1529662818567; Fri, 22 Jun 2018 03:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529662818; cv=none; d=google.com; s=arc-20160816; b=tkpP1VgyTxYkYi5a3ZCWLyHxZJBwZUhAUibMTZMoLMPWCqkadZajzHHDTQ65u9SC9O wQXdwLFb0rSJd5rBEBKBOCjGRYLEi15jgT4t7NbQd8hnUQ5JBfZOak3crR06zDz4cZ8w rpZFoi3qWVs5DDlv6srTBq/2gwvWvuy3qXdMjwIOKxkGf+IA9SBcTTJT9h5V3BrJjsY1 kkjEh3I8uSZUcK8XWgOyrG4ZYdOoNCja6mC0ZMv8U7aiAWSAzFGc4dVeQQoKI4FB/LbU B5hzCh7bik79djvm87fm5XFfQGrraoAU3S2Qrydr73j1tntmfHi2pkrumxcj+0U9cNkg QGeg== 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=J+zgYZQrPK2QbN3yDa9AYYaSwhV0F4NORdjz3pXirU4=; b=WXXO0LucUOzLzhvnLBif1Adv3NDvp/ocrJ+6Ng7mYr6xIyDLMDZKer65kzwEiEf7uD HZikszasxnqYjtnJzw4Fb4uLjfMz4OimdyWv9/AN360syJGGsAyXR4xdKBEPhJJBwflV kqog6ON9J4IILWyWB6DbHghyDy/3+Fz0x94HBD9DPsm/6Qh/f7wYJa3BcLj7dPpc6v1l NA5HXfAw2R+vxojxEDYnZF3qihXDpYkLB7Y592d0jBqkydDZoeUBeRIcqovv/9jjdR7A IcPHqPTorpeWK81hlV4v/hAFfzo9pxRlMag1BozKYmx5bKkEsTt1MTO3poWF1HC+nBX2 d2zg== 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 f68-v6si1616757qke.181.2018.06.22.03.20.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Jun 2018 03:20:18 -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]:60580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWJAv-0000p7-V9 for patch@linaro.org; Fri, 22 Jun 2018 06:20:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWJA9-0000Ok-U0 for qemu-devel@nongnu.org; Fri, 22 Jun 2018 06:19:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWJA6-0005dO-O5 for qemu-devel@nongnu.org; Fri, 22 Jun 2018 06:19:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40796 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 1fWJA1-0005Yg-6A; Fri, 22 Jun 2018 06:19:21 -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 B78FB6167F; Fri, 22 Jun 2018 10:19:20 +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 6D52711166E1; Fri, 22 Jun 2018 10:19:19 +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:07 +0200 Message-Id: <1529662749-32069-4-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:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 22 Jun 2018 10:19:20 +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 3/5] hw/arm/boot: introduce fdt_add_memory_node helper 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 We introduce an helper to create a memory node. Also we nop existing /memory node in numa and non numa case. Signed-off-by: Eric Auger Signed-off-by: Shameer Kolothum --- the nop related change should disappear if the following series lands upstream: [PATCH v2 0/3] ARM virt: Silence dtc warnings --- hw/arm/boot.c | 70 +++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 31 deletions(-) -- 2.5.5 diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 1e48166..cc425ce 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -413,6 +413,36 @@ static void set_kernel_args_old(const struct arm_boot_info *info, } } +static int fdt_add_memory_node(void *fdt, uint32_t acells, hwaddr mem_base, + uint32_t scells, hwaddr mem_len, + int numa_node_id) +{ + char *nodename = NULL; + int ret; + + nodename = g_strdup_printf("/memory@%" PRIx64, mem_base); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); + ret = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", acells, mem_base, + scells, mem_len); + if (ret < 0) { + fprintf(stderr, "couldn't set %s/reg\n", nodename); + goto out; + } + if (numa_node_id < 0) { + goto out; + } + + ret = qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", numa_node_id); + if (ret < 0) { + fprintf(stderr, "couldn't set %s/numa-node-id\n", nodename); + } + +out: + g_free(nodename); + return ret; +} + static void fdt_add_psci_node(void *fdt) { uint32_t cpu_suspend_fn; @@ -492,7 +522,6 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, void *fdt = NULL; int size, rc; uint32_t acells, scells; - char *nodename; unsigned int i; hwaddr mem_base, mem_len; @@ -545,49 +574,28 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, "RAM size > 4GB\n"); goto fail; } + /* + * Turn the /memory node created before into a NOP node, then create + * /memory@addr nodes. + */ + qemu_fdt_nop_node(fdt, "/memory"); if (nb_numa_nodes > 0) { - /* - * Turn the /memory node created before into a NOP node, then create - * /memory@addr nodes for all numa nodes respectively. - */ - qemu_fdt_nop_node(fdt, "/memory"); mem_base = binfo->loader_start; for (i = 0; i < nb_numa_nodes; i++) { mem_len = numa_info[i].node_mem; - nodename = g_strdup_printf("/memory@%" PRIx64, mem_base); - qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); - rc = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", - acells, mem_base, - scells, mem_len); + rc = fdt_add_memory_node(fdt, acells, mem_base, + scells, mem_len, i); if (rc < 0) { - fprintf(stderr, "couldn't set %s/reg for node %d\n", nodename, - i); goto fail; } - qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", i); mem_base += mem_len; - g_free(nodename); } } else { - Error *err = NULL; - - rc = fdt_path_offset(fdt, "/memory"); + rc = fdt_add_memory_node(fdt, acells, binfo->loader_start, + scells, binfo->ram_size, -1); if (rc < 0) { - qemu_fdt_add_subnode(fdt, "/memory"); - } - - if (!qemu_fdt_getprop(fdt, "/memory", "device_type", NULL, &err)) { - qemu_fdt_setprop_string(fdt, "/memory", "device_type", "memory"); - } - - rc = qemu_fdt_setprop_sized_cells(fdt, "/memory", "reg", - acells, binfo->loader_start, - scells, binfo->ram_size); - if (rc < 0) { - fprintf(stderr, "couldn't set /memory/reg\n"); goto fail; } } From patchwork Fri Jun 22 10:19:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 139600 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp695472lji; Fri, 22 Jun 2018 03:24:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcsRILIamWfsEKS85SlqcygvpaYZmjAxzK52krj6hgBxK571XjYCxX1ubeUkjXFuT7NkzeO X-Received: by 2002:a37:7f02:: with SMTP id a2-v6mr743897qkd.138.1529663085083; Fri, 22 Jun 2018 03:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529663085; cv=none; d=google.com; s=arc-20160816; b=QnAwkuDwbVoJCeSEF92fMhS3l6gpOgH29eKzLwEo7xmGF633uEzCRrNLmC/AD1IX0a egtHrKuekdVNCW55G0eyncIFZzY0QGyrF+8NKs6k5zk9DviaoK+friaZkKZw4P57zDzo 1PBjMGf6OLtLy56hsbfw6qLVHF6ha6lIT2TDBylZCCEtbY+VmCPdsLINz11YHNVU/6KF MBFm7xzfb4t0/iupBt316rAcZVTlbc6jFhYmBo4yj1NPIwt7vzT9mN4xLz2W/Q6+nYBb zOPkeSez2UbjJm0fsGapH/E3BV4mwkQIEiwLz7yN5jQDbW1kGQwh2TwqsaUzQ8jd1muu t2hw== 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=542jOdhmn3/4bBPVYZ7JsY5enZ+MatkrlxwjSKzLuPw=; b=VMRfOKIME5I5vmlnwQvELdBymcuaNQCQuhSafbT6juyavL+472721s3QETK3EBveNU OAo2dTzVVafFnNGIR9tcOflkeWSN51S0jHxQ+DJYU08MflwTeWFlHdlOKyrCIQnBud4Z /jGVQOAy53Kf6auEFn2FlzRmfn8/3tluLvQtpHurTiWMS6IVdHWMq9usDWjXwppz1N37 nNEuIyWUB3DFdzJ93NRFNtAOa505HrrO/eLKq5m/550KQJVB13g23DGxiXeFZii2uzMW YbXoLVJbaz0qRD8PCot7tsJ0lOplFwFPnL9XxY1jH791EyHGORHgu1js77hgsYBeu41C SiMw== 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 i1-v6si1289523qvm.27.2018.06.22.03.24.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Jun 2018 03:24:45 -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]:60609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWJFE-00046Q-Kg for patch@linaro.org; Fri, 22 Jun 2018 06:24:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWJA9-0000Ol-Ud for qemu-devel@nongnu.org; Fri, 22 Jun 2018 06:19:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWJA6-0005dT-Pf for qemu-devel@nongnu.org; Fri, 22 Jun 2018 06:19:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57204 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 1fWJA2-0005ab-R9; Fri, 22 Jun 2018 06:19:22 -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 45FF28151D6F; Fri, 22 Jun 2018 10:19:22 +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 F11C011166E1; Fri, 22 Jun 2018 10:19:20 +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:08 +0200 Message-Id: <1529662749-32069-5-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.8]); Fri, 22 Jun 2018 10:19:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 22 Jun 2018 10:19:22 +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 4/5] hw/arm/boot: Expose the PC-DIMM nodes in the DT 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 add memory nodes corresponding to PC-DIMM regions. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger --- hw/arm/boot.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) -- 2.5.5 diff --git a/hw/arm/boot.c b/hw/arm/boot.c index cc425ce..81668bd 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -19,6 +19,7 @@ #include "sysemu/numa.h" #include "hw/boards.h" #include "hw/loader.h" +#include "hw/mem/memory-device.h" #include "elf.h" #include "sysemu/device_tree.h" #include "qemu/config-file.h" @@ -516,6 +517,37 @@ static void fdt_add_psci_node(void *fdt) qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn); } +static int fdt_add_hotpluggable_memory_nodes(void *fdt, + uint64_t base, uint64_t len, + uint32_t acells, uint32_t scells) { + MemoryDeviceInfoList *info_list = qmp_memory_device_list(); + MemoryDeviceInfoList *info; + uint64_t end, cur, size; + MemoryDeviceInfo *mi; + PCDIMMDeviceInfo *di; + bool is_nvdimm; + int ret; + + end = base + len; + for (cur = base, info = info_list; cur < end; + cur += size, info = info->next) { + if (!info) { + break; + } + mi = info->value; + is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM); + di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; + + ret = fdt_add_memory_node(fdt, acells, di->addr, + scells, di->size, di->node); + if (ret < 0) { + return ret; + } + size = di->size; + } + return 0; +} + int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, hwaddr addr_limit, AddressSpace *as) { @@ -600,6 +632,14 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } } + rc = fdt_add_hotpluggable_memory_nodes(fdt, binfo->device_memory_start, + binfo->device_memory_size, + acells, scells); + if (rc < 0) { + fprintf(stderr, "couldn't add hotpluggable memory nodes\n"); + goto fail; + } + rc = fdt_path_offset(fdt, "/chosen"); if (rc < 0) { qemu_fdt_add_subnode(fdt, "/chosen"); From patchwork Fri Jun 22 10:19:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 139601 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp695647lji; Fri, 22 Jun 2018 03:24:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcn/40R0sdlBzfETW2zLBAIW9LivAJBS/zmANVnY98On10bJ2zVuRph5rKWW+ww7IQrUM0D X-Received: by 2002:ae9:dfc2:: with SMTP id t185-v6mr749942qkf.274.1529663097483; Fri, 22 Jun 2018 03:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529663097; cv=none; d=google.com; s=arc-20160816; b=oZgDK4U0RuDTOPnACVsDZegJr7Y8uDRiyB31EXntv6bJrv+Ew8X1IB3jNyIAi1uScT AdSPyNkAZdsG2lBMkt/x0kf5vAEFYoyueWamqT0kUKLfxzImF6U3IQbqPjsITeRGE+qS icKs4VPc/iyw5/As/eTB0B4TnL3w1Bdc07BA6VOb5rX3n2n4TfXVlcoom05fwg5fuqnZ 3ja7KscdwfwjyHAFc6UnHAc7dIRQ/XkghkPWfKo8xde8wYwzT+j7/N2cvz2Nj409DGcZ xBbMgvtCpzkk2VXQJ3AVuOEYi14nUjqW9VIlxLKOKGamQ6mtiBRi+JSuuJRoRUdUzPJj V4cw== 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=+AZKtL6yT1pOR1b02x+ymA4c4RnumPFmyHFs25QXu2k=; b=ftUt7jiCA4Z5WuSGKBgs6KVDmPOFidsWAmdwF+8UcVrMEQHT+uUCBReleZgTkGW7Ip d5CMKVo1e4/Fy/SNbksJKz6Vz5tq5TB04NOjUdngYj0Y+flnIrxRMADUEiJ7y09lc+K8 RLINMZ78yoyn+5JcCCAZcRFOoEI5oPs2jLvAe0Xy2NywMTqrgL1CjdKuxCGJh2VAELM/ xCShm5CYtDwtKIfIm+YChC07LzpIdyOSdwcxepby1jLnUzO/O8qduIDdCWotgK/asReT 9EehZycald2k50l42CDA6f7t9NW/Tv0nuYtoOTKhpN86xM2xTwWn2OZ2noFkLs/JP/ld 2iZw== 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 a22-v6si6658321qkj.109.2018.06.22.03.24.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Jun 2018 03:24:57 -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]:60610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWJFR-00047L-11 for patch@linaro.org; Fri, 22 Jun 2018 06:24:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWJA9-0000Oi-Te for qemu-devel@nongnu.org; Fri, 22 Jun 2018 06:19:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWJA6-0005dJ-OA for qemu-devel@nongnu.org; Fri, 22 Jun 2018 06:19:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48640 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 1fWJA4-0005c9-86; Fri, 22 Jun 2018 06:19:24 -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 C64804023132; Fri, 22 Jun 2018 10:19:23 +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 7EA4B11166E1; Fri, 22 Jun 2018 10:19:22 +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:09 +0200 Message-Id: <1529662749-32069-6-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.6]); Fri, 22 Jun 2018 10:19:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 22 Jun 2018 10:19:23 +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 5/5] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT 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 Generate Memory Affinity Structures for PC-DIMM ranges. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger --- hw/arm/virt-acpi-build.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) -- 2.5.5 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 74f5744..38a6886 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -43,6 +43,7 @@ #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" +#include "hw/mem/memory-device.h" #include "sysemu/numa.h" #include "kvm_arm.h" @@ -532,6 +533,35 @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) "SPCR", table_data->len - spcr_start, 2, NULL, NULL); } +static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base, + uint64_t len, int default_node) +{ + MemoryDeviceInfoList *info_list = qmp_memory_device_list(); + AcpiSratMemoryAffinity *numamem; + MemoryDeviceInfoList *info; + MemoryDeviceInfo *mi; + PCDIMMDeviceInfo *di; + uint64_t end = base + len, cur, size; + + for (cur = base, info = info_list; cur < end; + cur += size, info = info->next) { + bool is_nvdimm; + + if (!info) { + break; + } + numamem = acpi_data_push(table_data, sizeof(*numamem)); + + mi = info->value; + is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM); + di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; + + build_srat_memory(numamem, di->addr, di->size, + 0, MEM_AFFINITY_ENABLED); + size = di->size; + } +} + static void build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { @@ -564,6 +594,10 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) mem_base += numa_info[i].node_mem; } + build_srat_hotpluggable_memory(table_data, + vms->bootinfo.device_memory_start, + vms->bootinfo.device_memory_size , 0); + build_header(linker, table_data, (void *)(table_data->data + srat_start), "SRAT", table_data->len - srat_start, 3, NULL, NULL); }