Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4026218imc; Sun, 24 Feb 2019 19:36:05 -0800 (PST) X-Google-Smtp-Source: AHgI3IZqtRC6QvbxhwzChAR3Aa9aPdKIfC1rNon3W3odHtl+7zco803QHYXEl2Ju6DUvJ9fB91SL X-Received: by 2002:a17:902:7d89:: with SMTP id a9mr17785927plm.33.1551065765196; Sun, 24 Feb 2019 19:36:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551065765; cv=none; d=google.com; s=arc-20160816; b=vnNLaeY1MmGSjUQnsq99TCTChO96dFE2imY8AF1QUs+El45TaEni6NNDu9m7QQTlKv hfmO/8sNjr1cJS+GcAgAy/sHS6VlPMkgfi/h2wtTHch9P/L5WyVdX2XJaMSoEmwDPKDN K/ZT8+3jn4PdFrCfg2K9wnuNhHpvctE/tS0tOI4ktUGypEI2XfC5CEbOUrplQqHLJR6L Xnu0Y7qWgHAdnIYcApOArEepO6sRUlO1zOA5n1e1Z1zF/IUCb2PW24n8XHvVJVEuplJi +SmUta+/eFLJNcMvnAP9okvO1J0odmlyiBvCxzi3dJjNXh181uslTFc9/6Yvq83tLdkj UU0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=xzg/QasZL4jzzrPuVbjB9SpdePZwSQI9y9MgCV95T6I=; b=boFEsXnUh9JxL0TOSzi4v6MvraJvOIn+K1rfIgImE3iUhf42b7VBYHnHo6dZSHNykp RD6Z2ZEownyx23RmA7qnuXFOOzVrCiQBhr2Y+ELJe7UcgmleRcvINmzGlRgdmQ8tO7pL xFmyyXhSPi/iOg6ZWOofGYmhlOQ2MKU0rNpDo4yg7cCBpbchIdBtJTLYuzBuQfwyKwbh +EWnXGwiqVN1/SLQGQGfm8c2/KSJHr+RTyRd5F2mRfayk4KFpfbMo7ONloRPJhP8GnDe yc81l8SDrVtKArGK0x+ilYqu2gc/kXNPtcn5YyIiuWcUUzJGe6Zh0520uDK5UcXlRb5e S1kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=iF6Nt54b; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g132si8720307pfc.240.2019.02.24.19.35.49; Sun, 24 Feb 2019 19:36:05 -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=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=iF6Nt54b; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728450AbfBYDfa (ORCPT + 99 others); Sun, 24 Feb 2019 22:35:30 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36857 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728166AbfBYDfa (ORCPT ); Sun, 24 Feb 2019 22:35:30 -0500 Received: by mail-wr1-f66.google.com with SMTP id o17so8256776wrw.3 for ; Sun, 24 Feb 2019 19:35:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xzg/QasZL4jzzrPuVbjB9SpdePZwSQI9y9MgCV95T6I=; b=iF6Nt54bBd5lpxIvsmhHHR92DIyyr977XxWN/aFRi5RwYaCwOt+QTruISVgsjyWX31 LBY/X6TMwD2Q6tTeE15N/z0hLXRrKKY/Qja1K5UpyrtMCqNR2TqjpMbKL5xbGR8zjVOQ mg/PBUb7/+aoa248IYFtDJeZoGDFVqFiXitOT9owWCtrZr+L24ckl1CPbHTBJQ0+gX/s dZv7EUjZMj+mCWWVeEGOeGdX3QZyWUN2PQiHWdroNweeFrHUFLbND39fAF6K3KwzLN+d b/eWz8Dmawg6M78yWgPD6dBsEk57G88nMbcv9WsbU/Fmb3HnWnYhth+hTr3dYhpvl6AO KANg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xzg/QasZL4jzzrPuVbjB9SpdePZwSQI9y9MgCV95T6I=; b=MPO9KU5YINiucGXLHDIS5tiOmthJFuxITVlKcmsbtRSM1ppGXJVoAXUpQWL6yaHLVd TPdX7oB+5Z5q4bjFuIn3tPMrpbj6JpbVXx7DOTqW2DLhhY7SuNNlhLHKHAQJe+5miSQf d2gaD/bGWZG7W+jqr4XyWcIniJo5//e3nJh7iUy8cFE9UAlOJuaqckr5NbhUOVpqEzIS nUeJ2e1r1MQ0NYvfjSsFnmK6PuMJ8/5UPztGyDHleBuZCIjgbu5SdJaMgzLzjnA6k4Qd r5Y49JtTHjYJ8ywSwz7KXk0OYjTohFfhyHP44sZkTAsb4fwZgFT5cJxY45PY30r2X023 4VTg== X-Gm-Message-State: AHQUAuakT34e4c7goJZV7l63IPqrpLC88gTIGncQKsKOONjlwHmMlNRr aiD/re7du043lJEuTt2g7vI5CDK5jjbbEjvaPNFxAA== X-Received: by 2002:a5d:52ca:: with SMTP id r10mr11250812wrv.187.1551065728456; Sun, 24 Feb 2019 19:35:28 -0800 (PST) MIME-Version: 1.0 References: <1550864500-13652-1-git-send-email-atish.patra@wdc.com> <1550864500-13652-7-git-send-email-atish.patra@wdc.com> In-Reply-To: <1550864500-13652-7-git-send-email-atish.patra@wdc.com> From: Anup Patel Date: Mon, 25 Feb 2019 09:05:17 +0530 Message-ID: Subject: Re: [v6 PATCH 6/6] RISC-V: Assign hwcap as per comman capabilities. To: Atish Patra Cc: linux-riscv@lists.infradead.org, Alan Kao , Albert Ou , Andreas Schwab , Dmitriy Cherkasov , Johan Hovold , "linux-kernel@vger.kernel.org List" , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 23, 2019 at 1:11 AM Atish Patra wrote: > > 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..bc29b010 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"); > + continue; > + } > + > + 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 > Looks good to me. Reviewed-by: Anup Patel Regards, Anup