From patchwork Fri Sep 13 12:49:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 20040 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7ED1028E98 for ; Fri, 13 Sep 2013 12:50:00 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id 1sf1184713qec.8 for ; Fri, 13 Sep 2013 05:50:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=T6Q6bXF6PXuSmDye65yELMz53/EUoh7OyGfmt4zrVic=; b=D3/7qzH2gz93JRuhIYxicikuc5Z8dodHIRviYVzydUemhcYTCHPoe7+31UVSYQ5e+C aQns6acM9dF17/M5YignKBA8AtEwGxvWJyhgbbd5nMkIm26G/cdOHnE2teHXYFGQSyrO V2nd1PM12c6eUefZOTXQlJYgMgxV4BgxjaU/DVF0jZ9428GlhfN3w2Q4AAJQZ+59IJCa 0ZHbWxQbApoFI0t1ZsgWJkmfioQHz6CFyiMfAR4dbHjzXmtBGgOauKqAYTz+f0nK1gmE M5Vh2LmMJEbAAnCEnis4mpqEK9jQIQme0IfIG2M0T7mvZxdmevai1lEWrJYMgKykcw94 wNIA== X-Gm-Message-State: ALoCoQmBl72TKl81iOxR6tRIux6FVb9whrMYyzDGCdbUc0WRepJ3fKP7aIMH9tchmcLBbPaDgiAz X-Received: by 10.236.24.195 with SMTP id x43mr4980720yhx.3.1379076600045; Fri, 13 Sep 2013 05:50:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.209 with SMTP id x17ls1206054qeu.83.gmail; Fri, 13 Sep 2013 05:49:59 -0700 (PDT) X-Received: by 10.52.166.200 with SMTP id zi8mr130063vdb.38.1379076599785; Fri, 13 Sep 2013 05:49:59 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id c8si3080277vcq.63.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:49:59 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hf12so910689vcb.27 for ; Fri, 13 Sep 2013 05:49:59 -0700 (PDT) X-Received: by 10.52.165.131 with SMTP id yy3mr5888471vdb.25.1379076599692; Fri, 13 Sep 2013 05:49:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp78784vcz; Fri, 13 Sep 2013 05:49:59 -0700 (PDT) X-Received: by 10.14.10.2 with SMTP id 2mr2747291eeu.63.1379076598444; Fri, 13 Sep 2013 05:49:58 -0700 (PDT) Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by mx.google.com with ESMTPS id x45si2538514eey.306.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:49:58 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.44 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.44; Received: by mail-ee0-f44.google.com with SMTP id b47so556347eek.17 for ; Fri, 13 Sep 2013 05:49:58 -0700 (PDT) X-Received: by 10.15.32.136 with SMTP id a8mr2762335eev.71.1379076597923; Fri, 13 Sep 2013 05:49:57 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id p5sm14678420eeg.5.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:49:57 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Cc: stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, patches@linaro.org, andre.przywara@linaro.org, Julien Grall Subject: [PATCH v4 16/27] xen/arm: Create a fake cpus node in dom0 device tree Date: Fri, 13 Sep 2013 13:49:23 +0100 Message-Id: <1379076574-28316-17-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1379076574-28316-1-git-send-email-julien.grall@linaro.org> References: <1379076574-28316-1-git-send-email-julien.grall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The number of cpus in dom0 can be different compare to the real number of physical cpus. For the moment, Xen assumes that the cpus are identical. Signed-off-by: Julien Grall Acked-by: Ian Campbell --- Changes in v3: - for_each_child was renamed to dt_for_each_child - improve comment in the code --- xen/arch/arm/domain_build.c | 92 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index e1333a4..036155e 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -352,6 +352,93 @@ static int make_psci_node(void *fdt, const struct dt_device_node *parent) return res; } +static int make_cpus_node(const struct domain *d, void *fdt, + const struct dt_device_node *parent) +{ + int res; + const struct dt_device_node *cpus = dt_find_node_by_path("/cpus"); + const struct dt_device_node *npcpu; + unsigned int cpu; + const void *compatible = NULL; + u32 len; + /* Placeholder for cpu@ + a 32-bit number + \0 */ + char buf[15]; + + DPRINT("Create cpus node\n"); + + if ( !cpus ) + { + dprintk(XENLOG_ERR, "Missing /cpus node in the device tree?\n"); + return -ENOENT; + } + + /* + * Get the compatible property of CPUs from the device tree. + * We are assuming that all CPUs are the same so we are just look + * for the first one. + * TODO: Handle compatible per VCPU + */ + dt_for_each_child_node(cpus, npcpu) + { + if ( dt_device_type_is_equal(npcpu, "cpu") ) + { + compatible = dt_get_property(npcpu, "compatible", &len); + break; + } + } + + if ( !compatible ) + { + dprintk(XENLOG_ERR, "Can't find cpu in the device tree?\n"); + return -ENOENT; + } + + /* See Linux Documentation/devicetree/booting-without-of.txt + * section III.5.b + */ + res = fdt_begin_node(fdt, "cpus"); + if ( res ) + return res; + + res = fdt_property_cell(fdt, "#address-cells", 1); + if ( res ) + return res; + + res = fdt_property_cell(fdt, "#size-cells", 0); + if ( res ) + return res; + + for ( cpu = 0; cpu < d->max_vcpus; cpu++ ) + { + DPRINT("Create cpu@%u node\n", cpu); + + snprintf(buf, sizeof(buf), "cpu@%u", cpu); + res = fdt_begin_node(fdt, buf); + if ( res ) + return res; + + res = fdt_property(fdt, "compatible", compatible, len); + if ( res ) + return res; + + res = fdt_property_string(fdt, "device_type", "cpu"); + if ( res ) + return res; + + res = fdt_property_cell(fdt, "reg", cpu); + if ( res ) + return res; + + res = fdt_end_node(fdt); + if ( res ) + return res; + } + + res = fdt_end_node(fdt); + + return res; +} + /* Map the device in the domain */ static int map_device(struct domain *d, const struct dt_device_node *dev) { @@ -440,6 +527,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, DT_MATCH_COMPATIBLE("xen,xen"), DT_MATCH_COMPATIBLE("xen,multiboot-module"), DT_MATCH_COMPATIBLE("arm,psci"), + DT_MATCH_PATH("/cpus"), { /* sentinel */ }, }; const struct dt_device_node *child; @@ -509,6 +597,10 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, res = make_psci_node(kinfo->fdt, np); if ( res ) return res; + + res = make_cpus_node(d, kinfo->fdt, np); + if ( res ) + return res; } res = fdt_end_node(kinfo->fdt);