From patchwork Wed Aug 28 14:47:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 19582 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f70.google.com (mail-qe0-f70.google.com [209.85.128.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A1FEB25E58 for ; Wed, 28 Aug 2013 14:48:36 +0000 (UTC) Received: by mail-qe0-f70.google.com with SMTP id a11sf7007712qen.9 for ; Wed, 28 Aug 2013 07:48:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state: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=8v+J9gxMQLelqH+SCmu1F4eyV9vV6MChMkU47+AXSbE=; b=BLGGNETkdHOEZGpFFhofVh1zx2r8SFiMKbZ803/f5ieSP1ckqG+28tfcwgcOGp4tn4 JQd/clvMWjoi8QqK5DVLhPAk43LvL7vfUW3rSKnOysw1Gr0IP2IHJBkZEnGRQtc7CvvD 4xZI8k1IcQl1yCx8boYTv5kV5mxSvhXhGqyGixaR7X/xNKwB4r5kMiWFks0LOM4D45xO OLzlho8NfE1O3eU9LMg8uUxksGD7RdEdBOCSloEpgHs7EKbbHHsj4Xl4ReJ4XQpjNbEl DNvEv+bTt7qYYTrnhVRk6r93CyC5xCiYvtbiIOjH7vAZqbGYtgF9tzsW22v/NtQyRUWb Kd0g== X-Received: by 10.236.17.161 with SMTP id j21mr1088088yhj.55.1377701316494; Wed, 28 Aug 2013 07:48:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.99.10 with SMTP id em10ls344380qeb.82.gmail; Wed, 28 Aug 2013 07:48:36 -0700 (PDT) X-Received: by 10.58.19.162 with SMTP id g2mr26281612vee.12.1377701316370; Wed, 28 Aug 2013 07:48:36 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id sy3si454175vdc.54.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Aug 2013 07:48:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 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.169; Received: by mail-vc0-f169.google.com with SMTP id ib11so4188080vcb.14 for ; Wed, 28 Aug 2013 07:48:36 -0700 (PDT) X-Gm-Message-State: ALoCoQnFtdlGLZtRhlBeFIW7PqNvbaR6qjhWn9ZTq4Udddd0NW80eMUNcc+HhDoMwCacoWBQlJnh X-Received: by 10.52.164.201 with SMTP id ys9mr511722vdb.39.1377701316261; Wed, 28 Aug 2013 07:48:36 -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 u4csp359964vcz; Wed, 28 Aug 2013 07:48:35 -0700 (PDT) X-Received: by 10.194.134.97 with SMTP id pj1mr3035490wjb.58.1377701315122; Wed, 28 Aug 2013 07:48:35 -0700 (PDT) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by mx.google.com with ESMTPS id fa19si1814490wid.70.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Aug 2013 07:48:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.175 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.212.175; Received: by mail-wi0-f175.google.com with SMTP id hi5so1361591wib.8 for ; Wed, 28 Aug 2013 07:48:34 -0700 (PDT) X-Received: by 10.194.3.78 with SMTP id a14mr2672631wja.77.1377701314469; Wed, 28 Aug 2013 07:48:34 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id a8sm5590498wie.6.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Aug 2013 07:48:33 -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 V1 20/29] xen/arm: Create a fake cpus node in dom0 device tree Date: Wed, 28 Aug 2013 15:47:34 +0100 Message-Id: <1377701263-3319-21-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1377701263-3319-1-git-send-email-julien.grall@linaro.org> References: <1377701263-3319-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.169 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 --- xen/arch/arm/domain_build.c | 91 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 4c936c1..21cd4e0 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -339,6 +339,92 @@ 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 + * TODO: Handle compatible per VCPU + */ + 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) { @@ -427,6 +513,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; @@ -496,6 +583,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);