From patchwork Tue Aug 16 10:25:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 73990 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1918198qga; Tue, 16 Aug 2016 03:29:03 -0700 (PDT) X-Received: by 10.107.39.65 with SMTP id n62mr37721676ion.94.1471343343610; Tue, 16 Aug 2016 03:29:03 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 82si3243730ion.13.2016.08.16.03.29.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Aug 2016 03:29:03 -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 1bZbaB-0001wq-9m; Tue, 16 Aug 2016 10:26:55 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZba9-0001wi-Tl for xen-devel@lists.xen.org; Tue, 16 Aug 2016 10:26:54 +0000 Received: from [193.109.254.147] by server-1.bemta-6.messagelabs.com id 8B/8E-21406-D6AE2B75; Tue, 16 Aug 2016 10:26:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsVi9XuGg27Oq03 hBmuXSlgs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBnTPz1iL5jDV7H1wESWBsZO7i5GLg4hgVOM Elt2HWOFcPYwSqzZtI+5i5GTg01AV+LjxinsILaIgKzE6q457CBFzALXGSXuvN/GCpIQFgiUu LtxAVgDi4CqxJQVPYwgNq+Ah8TH3Q/BbAkBDYmVvRNYuhg5ODgFPCWuTWEDCQsBlZyeuZAVol xQ4uTMJywgNrOAhMTBFy+YIVoVJdrWn2SDsCUlDq64wQJygwTI1Xv+LWCHSJhKPFy9nmkCo+A sJLNmIZm1gJFpFaNGcWpRWWqRrqGZXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZG YIgyAMEOxvsbAw4xSnIwKYnyzpy4MVyILyk/pTIjsTgjvqg0J7X4EKMMB4eSBG/Qy03hQoJFq empFWmZOcBogUlLcPAoifB+fwGU5i0uSMwtzkyHSJ1iVJQS510KkhAASWSU5sG1wSL0EqOslD AvI9AhQjwFqUW5mSWo8q8YxTkYlYR5D4JM4cnMK4Gb/gpoMRPQYn3pDSCLSxIRUlINjI6Fm5N PXzhoFGj4u3d26G+zjTyBi95vcG2w9HurV5XA0eXe/SJ3QdEBiz07z0etmVR1yrb0olXRtOSQ 61LczyalfNPgF7goqbFJ5puk0d8893j3U58aX6gUPdxwRpdZh9PGd/6xjewvmybfMWk88/LrZ O2IrTm2gf57vK3N3TLU2H8u/JnloMRSnJFoqMVcVJwIABsyURvLAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1471343207!54223819!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 40453 invoked from network); 16 Aug 2016 10:26:51 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-10.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 16 Aug 2016 10:26:51 -0000 Received: from 172.24.1.36 (EHLO szxeml434-hub.china.huawei.com) ([172.24.1.36]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DPP02655; Tue, 16 Aug 2016 18:26:20 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml434-hub.china.huawei.com (10.82.67.225) with Microsoft SMTP Server id 14.3.235.1; Tue, 16 Aug 2016 18:25:37 +0800 From: Shannon Zhao To: Date: Tue, 16 Aug 2016 18:25:05 +0800 Message-ID: <1471343113-10652-9-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1471343113-10652-1-git-send-email-zhaoshenglong@huawei.com> References: <1471343113-10652-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.0A090201.57B2EA4E.005B, 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: 0a2f4ff169e15d69754ccd80f86c4416 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 v4 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 8c7fc09..fa0497c 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 fe1c05f..5c8fbc6 100644 --- a/tools/libxl/libxl_arm.h +++ b/tools/libxl/libxl_arm.h @@ -35,6 +35,17 @@ static inline int libxl__prepare_acpi(libxl__gc *gc, } #endif +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