From patchwork Tue Sep 10 14:49:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 19918 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 86886246A4 for ; Tue, 10 Sep 2013 14:49:45 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id gf11sf8899792vcb.6 for ; Tue, 10 Sep 2013 07:49:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; 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=J6RqzPlkQIT+DO6M+Hnub+crnLScERwb4iPE0KpOg+A=; b=FyH7SNTRAMAHKekuz6bq9r/57fVuivv7YV6i4gVQKBUAjpHYw09zc6knmVo77SxhhI ha7qt7b99RizWiZpFtdnn54eUe8WAIDyc+R6poMipmDvG1IJd8CuW6Uu8a/HtQf/1iev ijFB/a3bLphh5tD7nqMXp8Wxx1ZdGICa2xt/j5vqnrJH1dXQN/ht2K07VMZEWCYFAfyt 3j0AKyz0vD/YbwqGAJgq7vvuo6ZvrtQgpozX2BiVH2aEU7IcRhjeO0LmtGVDc5nPFAi1 Pd8grx7Z8MQNZh2SuEU8Kx54bcpNGJ2/YGVCKKiddRf1BOntkck9pN5ExgGHrcLaPP+g 8eLw== X-Received: by 10.236.103.199 with SMTP id f47mr741519yhg.54.1378824585312; Tue, 10 Sep 2013 07:49:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.62.72 with SMTP id w8ls2291737qer.2.gmail; Tue, 10 Sep 2013 07:49:45 -0700 (PDT) X-Received: by 10.220.140.69 with SMTP id h5mr23365045vcu.0.1378824585078; Tue, 10 Sep 2013 07:49:45 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id g7si4533620vcz.45.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 07:49:45 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jy13so4651878veb.34 for ; Tue, 10 Sep 2013 07:49:45 -0700 (PDT) X-Gm-Message-State: ALoCoQmmvllIyoG1u9PSpBt0g8B+0wSCPHVDEKAnIZwWsIl7RubuKTeaxzlx79TdsMGej3Z61BUu X-Received: by 10.58.19.162 with SMTP id g2mr23602506vee.12.1378824584994; Tue, 10 Sep 2013 07:49:44 -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 u4csp4668vcz; Tue, 10 Sep 2013 07:49:44 -0700 (PDT) X-Received: by 10.15.83.2 with SMTP id b2mr39840871eez.28.1378824583795; Tue, 10 Sep 2013 07:49:43 -0700 (PDT) Received: from mail-ea0-f176.google.com (mail-ea0-f176.google.com [209.85.215.176]) by mx.google.com with ESMTPS id f46si15326798eeo.99.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 07:49:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.176 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.215.176; Received: by mail-ea0-f176.google.com with SMTP id q16so3944479ead.35 for ; Tue, 10 Sep 2013 07:49:43 -0700 (PDT) X-Received: by 10.14.42.3 with SMTP id i3mr333025eeb.95.1378824583276; Tue, 10 Sep 2013 07:49:43 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id i1sm31911644eeg.0.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 07:49:42 -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 v3 16/27] xen/arm: Create a fake cpus node in dom0 device tree Date: Tue, 10 Sep 2013 15:49:04 +0100 Message-Id: <1378824555-16564-17-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1378824555-16564-1-git-send-email-julien.grall@linaro.org> References: <1378824555-16564-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.128.175 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 e3229c7..0f4d10e 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -331,6 +331,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) { @@ -419,6 +506,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; @@ -488,6 +576,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);