Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3716166imj; Tue, 12 Feb 2019 03:31:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IbzvfyQv1rVwj4M1654K63XUSjDZeaIBZAjwjEEcdSlSgN+rpwgOlLjDQtPg+SYg4pkyUF5 X-Received: by 2002:a63:8948:: with SMTP id v69mr3304536pgd.140.1549971081476; Tue, 12 Feb 2019 03:31:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549971081; cv=none; d=google.com; s=arc-20160816; b=xrK8zcWwsMvGK+YhnAzAYyHikUIJ582KwOXGOJBz7yqaMtoMCCcZjmJXgwZJO/Pf+Y vTTRozXl3UVpWxqm+JgaO3zZM01/t2jvBJWSQtXZbMJRRRREpQSivi/kGva/imfL2GZq xZLU/GCk5o5Cw32mMAgzz4HwQSdkFAz71dsGzYfr5DEH/XnCkWTHE8VUO3PqnC+zmP3w VdpvkeQX1WJmdQfXi+eHPJKul/CwHlav6xMG0pyN0zwSk7sZtfT1i/rGffbzCUfS7n99 HW7pxQY7ClpN5YfhH3PeN/1nuzXhL7d+FOAL3rcwOD7tWQjZspY1pgmNBs3bsogq+ops OSKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=lhvGX1o+vxxf5Lqqc1aR1wxCxsaRLfHTlWErhsSrynQ=; b=RSoOFU3NalRaICiG9XSKRvFCD9sPKMomUuHkX8DobpHOPtoxQLZ70PvI/sjUvmqSsm s8SkFJgsvmNd85jOM/T/s/TanFecYYsJHfoQoa/UYcctNLztx8YFeCbZcSQSBXxD/CpY 2hnNUfF9uSNJ8bU3/uLpUTM0AO5jS5DUfDYaSK7bQvWmDzSOIAHkos/E6nYOAYoRDp56 nxMcrT94AZWc1a/pvny9i3i0cms9ykl9XkublreXVJzPVXYmmWOE98UFJe7oqM4uf3mU t3hdroppFMmQw3FgImvU0nzknd7micv+PFC5mw/P/2Jg+9Mcx/xh+qJC4WQ1Jkg8DpAP dtmg== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q15si12252450pgc.475.2019.02.12.03.31.05; Tue, 12 Feb 2019 03:31:21 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728949AbfBLLZp (ORCPT + 99 others); Tue, 12 Feb 2019 06:25:45 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:45414 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727312AbfBLLZp (ORCPT ); Tue, 12 Feb 2019 06:25:45 -0500 Received: by mail-lf1-f67.google.com with SMTP id b20so1675279lfa.12 for ; Tue, 12 Feb 2019 03:25:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=lhvGX1o+vxxf5Lqqc1aR1wxCxsaRLfHTlWErhsSrynQ=; b=ql8q21EJHu+HyapG10aBJnJLgoVTVTLZWFaz9EuESFxkh01rw6pJ1CXZ7VRwTnhfVw qcNGaNT7xwuGe7KbF/CJS0FeaHgirvEe/EMYqT4DI6/6SC870h8sx4hKFoxzdY0cS1+k LSJ0XbDzLVUu0vLK2b3/cDqqbFSxzVX5YHfP4GchbCQeaQwqWlHzyUcw9p8dEVi/kgTv Qa79d6KEZWFgJ9rTacu0kiHNh1DEA8Z+UYdstguZJAxgshwSGvq7E+6vY3bScbwOaJYE QxGfiB2P9231kYqLs5kGhgfZXe4CnITnVMxenAnYgfOxTSvli6k6Fj3PmoQksgsu89JY h+qg== X-Gm-Message-State: AHQUAua9VgItFfIIMwtZ1EDT66oprhWdEMUmG71KRh5Q1YcPxuIcFXqg b8W5K76N6d6IF0vo1mqM8Vdt0loI X-Received: by 2002:a19:4f15:: with SMTP id d21mr2099389lfb.86.1549970741912; Tue, 12 Feb 2019 03:25:41 -0800 (PST) Received: from xi.terra (c-74bee655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.190.116]) by smtp.gmail.com with ESMTPSA id v29-v6sm2618417ljd.44.2019.02.12.03.25.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 03:25:41 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1gtWBy-00053z-HI; Tue, 12 Feb 2019 12:25:34 +0100 Date: Tue, 12 Feb 2019 12:25:34 +0100 From: Johan Hovold To: Atish Patra Cc: linux-riscv@lists.infradead.org, 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: Re: [v4 PATCH 8/8] RISC-V: Assign hwcap as per comman capabilities. Message-ID: <20190212112534.GB28278@localhost> References: <1549969812-22502-1-git-send-email-atish.patra@wdc.com> <1549969812-22502-9-git-send-email-atish.patra@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1549969812-22502-9-git-send-email-atish.patra@wdc.com> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 12, 2019 at 03:10:12AM -0800, 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..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; Did you want "continue" here to continue processing the other harts? Note that you currently leak the device node when returning. Johan