From patchwork Thu Mar 21 10:47:43 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: 160765 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp642655jan; Thu, 21 Mar 2019 03:51:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFTHL/y/GgsK1gh4h//2cLPWjy/XnO/b3qBZNAmBARCmusQFT6Aep05t+1D+umxGVjDe9/ X-Received: by 2002:adf:f48d:: with SMTP id l13mr2247531wro.2.1553165478569; Thu, 21 Mar 2019 03:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553165478; cv=none; d=google.com; s=arc-20160816; b=yY5ZFZarwDkq6se9eO3qJp8getNnB+LhrEMnbb5huLpP52bAC3f0pyyxI9AXXiA9Ks 3XNYXB/pnK/LVUX4wMwhyMOJCAnwzp2w29iHZXlvQwA8hBQtT5km5F6bE26rVX/qdnFl QAWh7p6h1nrVa6pmy2yV8rUlYuran1yWjC/Wst7smVfIuZ9p276B1KwcxosND6zuyim1 kV1L9xLF+JmERQ8PQO186RWR2BfooJpPOVXH8g5DkRGqqfIusDHG37ObXRO97klvMaYD TkNz+UegbRw3Qk1gWbG/ZtukzLZaBC7GG1CQx3VksT9cWBdAhjYVNUdptje1I5PjU0LH h+VA== 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=fA3zYJegmny2VbWNybrNR5q3ICUNxSl0RPBG8H8xrZg=; b=zvgFHxDdiTcVRExHtJhli/sbvXFsGQvbwrCjSxVry7W0pYnBcSekV8dJU+0fJfltuI GFjKWU7vP10or3MHIakAsTdh+LdyCW1vX1Rpjt2+xEVdJ6N+DCxTma26cmYo4/2YGlqA QWnQaHADqOFheIc5HMSdkWX4sHoKuh/W3UpP30eo4Sks3rpJcffBvtyhOZ70s5yi7Mr6 jK9KORUPRyIeY0ZyMpkuXgieeOF6NN/epts5sJWLdpB4dY+GMzJqwcvfVH7CxqHKJBMn p4RPm0YG0vE6DoWh6xVDXGkbkLXjC06nQumj2O8AbGatqOLiHkkh9o2VUiINV3MBxsUM HGcw== 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 j18si3091468wrs.420.2019.03.21.03.51.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:51:18 -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]:34697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vI2-0004Tc-Nq for patch@linaro.org; Thu, 21 Mar 2019 06:51:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHX-0004Og-Vn for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vG8-0003Lq-QK for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:49:17 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2253 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vG7-000322-3F; Thu, 21 Mar 2019 06:49:15 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C864B518F006BC5AD6DD; Thu, 21 Mar 2019 18:49:12 +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:49:03 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:43 +0000 Message-ID: <20190321104745.28068-9-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.191 Subject: [Qemu-devel] [PATCH v3 08/10] 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: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This patch adds memory nodes corresponding to PC-DIMM regions. This is an opt-in feature and needs to be enabled("fdt=on") when Guest is booted with DT. NVDIMM and ACPI_NVDIMM configs are not yet set for ARM so we don't need to care about NVDIMM at this stage. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger Signed-off-by: Shameer Kolothum --- hw/arm/boot.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) -- 2.7.4 diff --git a/hw/arm/boot.c b/hw/arm/boot.c index a830655..5b9a994 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" @@ -522,6 +523,41 @@ 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, + uint32_t acells, uint32_t scells) { + MemoryDeviceInfoList *info, *info_list = qmp_memory_device_list(); + MemoryDeviceInfo *mi; + int ret = 0; + + for (info = info_list; info != NULL; info = info->next) { + mi = info->value; + switch (mi->type) { + case MEMORY_DEVICE_INFO_KIND_DIMM: + { + PCDIMMDeviceInfo *di = mi->u.dimm.data; + + ret = fdt_add_memory_node(fdt, acells, di->addr, + scells, di->size, di->node); + if (ret) { + fprintf(stderr, + "couldn't add PCDIMM /memory@%"PRIx64" node\n", + di->addr); + goto out; + } + break; + } + default: + fprintf(stderr, "%s memory nodes are not yet supported\n", + MemoryDeviceInfoKind_str(mi->type)); + ret = -ENOENT; + goto out; + } + } +out: + qapi_free_MemoryDeviceInfoList(info_list); + return ret; +} + int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, hwaddr addr_limit, AddressSpace *as) { @@ -621,6 +657,14 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } } + if (object_property_get_bool(OBJECT(qdev_get_machine()), "fdt", NULL)) { + rc = fdt_add_hotpluggable_memory_nodes(fdt, 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");