From patchwork Fri Sep 4 15:05:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 53114 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id F17A422E23 for ; Fri, 4 Sep 2015 15:16:44 +0000 (UTC) Received: by wisv5 with SMTP id v5sf7468448wis.0 for ; Fri, 04 Sep 2015 08:16:44 -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:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=OzmYyhX44IITmrpO13NbJt2DfQ1JB23BWbE/KhAb4zc=; b=PowOXPTYgSZQLd6qIcFAoQIA+IHD5ehanue3SwRDCZx9IjS2zbbKU/eDuUEbJGOaiV ghORBc8DOY9Zd0+6TRMOGN3Pp3Q4/2N6se5zspmYAdTFRQt5YmJYj9O0Z+tVhLCbepd6 RMEXFw02cT38FbEIkz/xoIxqAxFlb46Pb+xJy5f20xVs624zV+8UBJKF2pCHfvCYkxPw Xel1RPnaPLeFAd6AawotiPbN2YpBPxsp8OQHItrkJxLDCz29Et2FZx0ikKVtVkZvzzfN 5g2aelsievZapHGo8maA5MnUP0g4WYVKVQZBjgEVIWTVg0xcXOdIMwQNLucbSlwQteZI LXQw== X-Gm-Message-State: ALoCoQk6I15pMvuOGNNFdqf/0225eM7fRwOYyRe3EvbFuItviz+zsMo5xgmvU7JKZSHX8TLrmPeN X-Received: by 10.180.96.226 with SMTP id dv2mr1239060wib.2.1441379804325; Fri, 04 Sep 2015 08:16:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.202 with SMTP id p10ls340618lae.95.gmail; Fri, 04 Sep 2015 08:16:44 -0700 (PDT) X-Received: by 10.152.5.201 with SMTP id u9mr4244081lau.26.1441379804155; Fri, 04 Sep 2015 08:16:44 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id 9si2549186lao.146.2015.09.04.08.16.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Sep 2015 08:16:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbcjc2 with SMTP id jc2so13100680lbc.0 for ; Fri, 04 Sep 2015 08:16:44 -0700 (PDT) X-Received: by 10.112.141.136 with SMTP id ro8mr4214732lbb.88.1441379804050; Fri, 04 Sep 2015 08:16:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.164.42 with SMTP id yn10csp2051500lbb; Fri, 4 Sep 2015 08:16:43 -0700 (PDT) X-Received: by 10.140.95.73 with SMTP id h67mr6136845qge.14.1441379803002; Fri, 04 Sep 2015 08:16:43 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 62si3085572qkr.114.2015.09.04.08.16.42 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 04 Sep 2015 08:16:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:60626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXsjJ-00024Q-Fm for patch@linaro.org; Fri, 04 Sep 2015 11:16:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXsZE-0000B8-Gg for qemu-devel@nongnu.org; Fri, 04 Sep 2015 11:06:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXsZ8-0000qi-KO for qemu-devel@nongnu.org; Fri, 04 Sep 2015 11:06:16 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:35023) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXsZ8-0000iE-CI for qemu-devel@nongnu.org; Fri, 04 Sep 2015 11:06:10 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZXsYv-0006GW-AD for qemu-devel@nongnu.org; Fri, 04 Sep 2015 16:05:57 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 4 Sep 2015 16:05:56 +0100 Message-Id: <1441379156-23939-28-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1441379156-23939-1-git-send-email-peter.maydell@linaro.org> References: <1441379156-23939-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 27/27] arm/virt: Add full-sized CPU affinity handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Pavel Fedin At least with KVM, currently there's no reason why QEMU would not be capable of handling Aff3 != 0. This commit fixes up FDT creation in such a case. Signed-off-by: Pavel Fedin Message-id: eef5a86e6d9a313780dbc23b35fcb65df42a3e9e.1441366248.git.p.fedin@samsung.com [PMM: folded two overlong lines] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/virt.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 60736c2..91e45e0 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -288,9 +288,32 @@ static void fdt_add_timer_nodes(const VirtBoardInfo *vbi) static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi) { int cpu; + int addr_cells = 1; + + /* + * From Documentation/devicetree/bindings/arm/cpus.txt + * On ARM v8 64-bit systems value should be set to 2, + * that corresponds to the MPIDR_EL1 register size. + * If MPIDR_EL1[63:32] value is equal to 0 on all CPUs + * in the system, #address-cells can be set to 1, since + * MPIDR_EL1[63:32] bits are not used for CPUs + * identification. + * + * Here we actually don't know whether our system is 32- or 64-bit one. + * The simplest way to go is to examine affinity IDs of all our CPUs. If + * at least one of them has Aff3 populated, we set #address-cells to 2. + */ + for (cpu = 0; cpu < vbi->smp_cpus; cpu++) { + ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); + + if (armcpu->mp_affinity & ARM_AFF3_MASK) { + addr_cells = 2; + break; + } + } qemu_fdt_add_subnode(vbi->fdt, "/cpus"); - qemu_fdt_setprop_cell(vbi->fdt, "/cpus", "#address-cells", 0x1); + qemu_fdt_setprop_cell(vbi->fdt, "/cpus", "#address-cells", addr_cells); qemu_fdt_setprop_cell(vbi->fdt, "/cpus", "#size-cells", 0x0); for (cpu = vbi->smp_cpus - 1; cpu >= 0; cpu--) { @@ -307,7 +330,14 @@ static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi) "enable-method", "psci"); } - qemu_fdt_setprop_cell(vbi->fdt, nodename, "reg", armcpu->mp_affinity); + if (addr_cells == 2) { + qemu_fdt_setprop_u64(vbi->fdt, nodename, "reg", + armcpu->mp_affinity); + } else { + qemu_fdt_setprop_cell(vbi->fdt, nodename, "reg", + armcpu->mp_affinity); + } + g_free(nodename); } }