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");