Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3711657imj; Tue, 12 Feb 2019 03:26:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IaH6XxUzR5zQ2gffb08KubnoAqDw3X/UxN58aa9y//VWud2d8+KTld1ggCNyDCCeyTbTyjB X-Received: by 2002:a62:560f:: with SMTP id k15mr3428822pfb.231.1549970794080; Tue, 12 Feb 2019 03:26:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549970794; cv=none; d=google.com; s=arc-20160816; b=vdsqnI1r6JvTFaSObQJDHz+YQXar24xkIq0RbS1tUrEfjGH9i/KDt9kxohu1e1Ptva 0VX9VH5TAeW08bh8bjNsip8trtgg6AwbkFMi5vkIQLAGnOY40Teuw5yxygqrGk9axax1 0/7ZRoLKkR9PXYikFdUR+NLy3w1H1dFlFN46/vO89Lsf8FYa3Zwjm+CaotFQdl87u1wc VbFOyOji8yQ3yo6RHFTjKjlPer8m8VLUgR2st2RfNKWSjYqYydZbxhwjU3A72xcO+XGV JlurCpceScOWkvtqyKoUV0e2MPSVoGtTrwcydFYf5bWSUdc72BhSo/GuahWcpfeIiDyq cSLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=mIAfL5itTGgunjl9ZMwCD+zKtP6R5yS6+hETUAo/HM8=; b=Co5jz7gKMA5mozAO779xH7P6T0NpwV2TXRsszJAze3XovseRM7u/KqP9Sf5NRKmGR6 RSv24A2DxFzry4i0UF631FvzZg/95waY5hCrW72FtdFciQLwT5tp/DX2sNSGinCN5vus OujI/+ys0jWdDx3u3nS4NJeW2Xoof6tD83f+Q8xUK0l3P7y/ZN6ZbVsLS5NYoYitUdc+ 0Fmewssi7NzZ5rqXfuIFIVljdTjqJboZIcM0+abfsKbTmgIQNJOLnBK13KMAA29Q/S2C N6+aNZzSxhtxca8Z88TlP3L28XIMKo87gbIhhR8jN4oWBGaLHEJhreZf2aor1i3NPhNQ g+eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=DRemO6fd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w19si5407587pfn.89.2019.02.12.03.26.18; Tue, 12 Feb 2019 03:26:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=DRemO6fd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729345AbfBLLKm (ORCPT + 99 others); Tue, 12 Feb 2019 06:10:42 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:42874 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729306AbfBLLKe (ORCPT ); Tue, 12 Feb 2019 06:10:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1549969890; x=1581505890; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=v+wMN1vSHaqQ4Gf9rESAfOfnesAaSkkEfWAzcw8Qr8g=; b=DRemO6fd9XUNkO41EAq/aZL9jHrz9Egmpiy9KIkeQ31Xj29tlYcQ/OCp qn65+EEVt7/4QaSlIUcNDHzDlD1hUMPlG7t3WQtPC9XLwC/X0YXUm783y l7ZE5AugfY2gGSP24W19CD0rtg3UMPXWHXzYTwKozr/gE1e6BbzB88wLN M9RkIooPUahxuG7cWvzMvWcypwWm2jydCieCUiOvbZiylSzpWv0A/Hyin GNwU9o2EjQPsaFqOL/IXlXiGWkL5koxroReCuBUa0PzOG7jx3Rm9vT7MH 5/0tDRs4G6SdP/BpSCFyiekek/Wo7Ip17TPGQJP8dLr89jVW1Ck70lR2S Q==; X-IronPort-AV: E=Sophos;i="5.58,361,1544457600"; d="scan'208";a="199201842" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2019 19:11:13 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 12 Feb 2019 02:50:59 -0800 Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip02.wdc.com with ESMTP; 12 Feb 2019 03:10:23 -0800 From: Atish Patra To: linux-riscv@lists.infradead.org Cc: Atish Patra , Alan Kao , Albert Ou , Andreas Schwab , Anup Patel , Daniel Lezcano , Dmitriy Cherkasov , Jason Cooper , Johan Hovold , linux-kernel@vger.kernel.org, Marc Zyngier , Palmer Dabbelt , Paul Walmsley , Rob Herring , Thomas Gleixner Subject: [v4 PATCH 8/8] RISC-V: Assign hwcap as per comman capabilities. Date: Tue, 12 Feb 2019 03:10:12 -0800 Message-Id: <1549969812-22502-9-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549969812-22502-1-git-send-email-atish.patra@wdc.com> References: <1549969812-22502-1-git-send-email-atish.patra@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, we set hwcap based on first valid hart from DT. This may not be correct always as that hart might not be current booting cpu or may have a different capability. Set hwcap as the capabilities supported by all possible harts with "okay" status. Signed-off-by: Atish Patra --- arch/riscv/kernel/cpufeature.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index e7a4701f..a1e4fb34 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -20,6 +20,7 @@ #include #include #include +#include unsigned long elf_hwcap __read_mostly; #ifdef CONFIG_FPU @@ -42,28 +43,30 @@ void riscv_fill_hwcap(void) elf_hwcap = 0; - /* - * We don't support running Linux on hertergenous ISA systems. For - * now, we just check the ISA of the first "okay" processor. - */ for_each_of_cpu_node(node) { - if (riscv_of_processor_hartid(node) >= 0) - break; - } - if (!node) { - pr_warn("Unable to find \"cpu\" devicetree entry\n"); - return; - } + unsigned long this_hwcap = 0; - if (of_property_read_string(node, "riscv,isa", &isa)) { - pr_warn("Unable to find \"riscv,isa\" devicetree entry\n"); - of_node_put(node); - return; - } - of_node_put(node); + if (riscv_of_processor_hartid(node) < 0) + continue; - for (i = 0; i < strlen(isa); ++i) - elf_hwcap |= isa2hwcap[(unsigned char)(isa[i])]; + if (of_property_read_string(node, "riscv,isa", &isa)) { + pr_warn("Unable to find \"riscv,isa\" devicetree entry\n"); + return; + } + + for (i = 0; i < strlen(isa); ++i) + this_hwcap |= isa2hwcap[(unsigned char)(isa[i])]; + + /* + * All "okay" hart should have same isa. Set HWCAP based on + * common capabilities of every "okay" hart, in case they don't + * have. + */ + if (elf_hwcap) + elf_hwcap &= this_hwcap; + else + elf_hwcap = this_hwcap; + } /* We don't support systems with F but without D, so mask those out * here. */ -- 2.7.4