From patchwork Fri Sep 2 02:55:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 75266 Delivered-To: patch@linaro.org Received: by 10.140.29.8 with SMTP id a8csp623767qga; Thu, 1 Sep 2016 19:58:49 -0700 (PDT) X-Received: by 10.157.41.150 with SMTP id n22mr18997870otb.165.1472785129881; Thu, 01 Sep 2016 19:58:49 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id l127si10158364oia.46.2016.09.01.19.58.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Sep 2016 19:58:49 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bfeem-0006pA-Dw; Fri, 02 Sep 2016 02:56:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bfeek-0006oy-T5 for xen-devel@lists.xen.org; Fri, 02 Sep 2016 02:56:38 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 6B/0B-08498-66AE8C75; Fri, 02 Sep 2016 02:56:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRWlGSWpSXmKPExsVi9XuGg27qqxP hBr/faVks+biYxYHR4+ju30wBjFGsmXlJ+RUJrBl/Z/9iLdjPX/H+/22mBsav3F2MXBxCAqcY JZ73LmGGcHYzSmxc+RvI4eRgE9CV+LhxCjuILSIgK7G6aw47SBGzwHVGiTvvt7GCJIQFAiUWv J/BAmKzCKhIHN25jAnE5hXwkNj99x2YLSGgIbGydwJYDaeAp8TbVZ/AhgoB1Tx+9QiqXlDi5M wnYDXMAhISB1+8YIboVZRoW3+SDcKWlDi44gYLyBESIGcf+/+GESJhKjHx6m+2CYyCs5DMmoV k1gJGplWMGsWpRWWpRbpGxnpJRZnpGSW5iZk5uoYGZnq5qcXFiempOYlJxXrJ+bmbGIFBygAE Oxj/zA88xCjJwaQkypv/5ES4EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQneHS+BcoJFqempFWmZO cB4gUlLcPAoifCuAEnzFhck5hZnpkOkTjEqSonz5oAkBEASGaV5cG2wGL3EKCslzMsIdIgQT0 FqUW5mCar8K0ZxDkYlYd4TIFN4MvNK4Ka/AlrMBLS45NpxkMUliQgpqQZGo9L/Lxu//jxzW/y ZwZ/qrt89kyerHa59MVnG7/b2hW7fDJdvevm+QipSYxLv/FwvNqsjbtfaz/xR2D7r+Lmqi3rX X/zvTUlIMXxYc/lXhojuWY69H7RCP87d6vaChflz6rulr17zTrxYIBTN2WnKarE8/L35mkj3t b4dbNlOEyLZ1z+YkcgyR4mlOCPRUIu5qDgRAFdmcGbMAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1472784993!4216229!1 X-Originating-IP: [58.251.152.64] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27957 invoked from network); 2 Sep 2016 02:56:36 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-15.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 2 Sep 2016 02:56:36 -0000 Received: from 172.24.1.60 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.60]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DQM36302; Fri, 02 Sep 2016 10:56:15 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Fri, 2 Sep 2016 10:56:05 +0800 From: Shannon Zhao To: Date: Fri, 2 Sep 2016 10:55:31 +0800 Message-ID: <1472784939-14404-9-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1472784939-14404-1-git-send-email-zhaoshenglong@huawei.com> References: <1472784939-14404-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0205.57C8EA4F.0084, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 35e55750088237a215c3ac9bd2406eb2 Cc: sstabellini@kernel.org, wei.liu2@citrix.com, ian.jackson@eu.citrix.com, peter.huangpeng@huawei.com, julien.grall@arm.com, shannon.zhao@linaro.org, boris.ostrovsky@oracle.com Subject: [Xen-devel] [PATCH v5 08/16] libxl/arm: Factor MPIDR computing codes out as a helper X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" From: Shannon Zhao Factor MPIDR computing codes out as a helper, so it could be shared between DT and ACPI. Signed-off-by: Shannon Zhao Acked-by: Julien Grall --- tools/libxl/libxl_arm.c | 8 +------- tools/libxl/libxl_arm.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index 333c9a1..2a4577c 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -309,13 +309,7 @@ static int make_cpus_node(libxl__gc *gc, void *fdt, int nr_cpus, for (i = 0; i < nr_cpus; i++) { const char *name; - /* - * According to ARM CPUs bindings, the reg field should match - * the MPIDR's affinity bits. We will use AFF0 and AFF1 when - * constructing the reg value of the guest at the moment, for it - * is enough for the current max vcpu number. - */ - mpidr_aff = (i & 0x0f) | (((i >> 4) & 0xff) << 8); + mpidr_aff = libxl__compute_mpdir(i); name = GCSPRINTF("cpu@%"PRIx64, mpidr_aff); res = fdt_begin_node(fdt, name); diff --git a/tools/libxl/libxl_arm.h b/tools/libxl/libxl_arm.h index 1c01177..a91ff93 100644 --- a/tools/libxl/libxl_arm.h +++ b/tools/libxl/libxl_arm.h @@ -24,6 +24,17 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, libxl__domain_build_state *state, struct xc_dom_image *dom); +static inline uint64_t libxl__compute_mpdir(unsigned int cpuid) +{ + /* + * According to ARM CPUs bindings, the reg field should match + * the MPIDR's affinity bits. We will use AFF0 and AFF1 when + * constructing the reg value of the guest at the moment, for it + * is enough for the current max vcpu number. + */ + return (cpuid & 0x0f) | (((cpuid >> 4) & 0xff) << 8); +} + /* * Local variables: * mode: C