Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1157550imj; Thu, 14 Feb 2019 02:07:59 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ1h5spcvXXctjKHWPtT+JGRH+POW/VUtp2deeciPwv5KnjTWxT+m5+4lS5HH/yyyEqk7yH X-Received: by 2002:a63:2c8a:: with SMTP id s132mr2990117pgs.440.1550138879094; Thu, 14 Feb 2019 02:07:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550138879; cv=none; d=google.com; s=arc-20160816; b=RmhKwhOQ65u9HW3xAV2l06+4niBGFnZTau8HF5VDywaUa9CHXN9WgMViyyMO0dDzWf yAiU4jrUglzbH3Ujkuerxfs2KJeTmNdQelbLEdmAUpGgP1BUDeD5Ols/zVTk2bWILZLp ED5KuPrrpOHFtx/R9I49zpFbrvyHEdfknfd9mltlUuiXjQewj4DNhucms8FLdnDA7IeD I5zc108KJ7sPwHgs3coaPdA3puD6YI8/qW7WCXyHJahQqfmOFExTFFkmPW956FVzL0nh MI4V22TOIPFfkSBl9XFUlqJ2ysPcvyfquIdU/rs0d3C0OxPkSzTtHurGzvGsLw/38MmY lKvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=uT75a19FaF87yjESbhIfkIe22b6AasUHkjMarqW5BsM=; b=0tdUPwbdceEvW4SlHl/697gNx/dymzlH2MDuIGQWHLPyd2jueGhONYASq7CqjwBJvl 7WZWHlpuRG6KgxSyKqLuWRHeVKWT92eacUwAQrvA1QvKNj9QfARmLliNAEfX5UlruCN5 ptJsxGDJUFw1rlgZ1MIuAmnzww4Ch9V+nbFwpoHoAaJ67vRezl0qGZYKINqpnCSgHo/e bIpc8c+5ofF9gYCrTCgJABIHJEj8bCXORypTSEP5fiaKrxr1n/5PHckKykNLdmL4dy+G tKVnV8bpQCCXoo/6ndgjf6y330PF1LAUEKhkoLwVaZMIJRHMrcNWDZPU9Qw7jibgRoaJ rIbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Y8n3YjHT; 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 x14si1948625plr.378.2019.02.14.02.07.43; Thu, 14 Feb 2019 02:07:59 -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=@sifive.com header.s=google header.b=Y8n3YjHT; 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 S1726869AbfBNAhy (ORCPT + 99 others); Wed, 13 Feb 2019 19:37:54 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42080 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725550AbfBNAhw (ORCPT ); Wed, 13 Feb 2019 19:37:52 -0500 Received: by mail-pf1-f193.google.com with SMTP id n74so2057189pfi.9 for ; Wed, 13 Feb 2019 16:37:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=uT75a19FaF87yjESbhIfkIe22b6AasUHkjMarqW5BsM=; b=Y8n3YjHTl49N3znm/rfydQpsP+i4dhNF+yLiTVb68qUi+tqEh7qNfIYu7j3s+Z54Qb ls3lh+BDhGxtxQzFHmJVUg6AOUbdqabyo/U9DYx3GzmmZYBHfFOAQ8XK07xT+Re2ZeLY G38Cns+n7+uqmC2jq4mvH/4ogqmf+9pC/jqygUHJHlHfOcUe1SoRQpw8FCsQrTOZYx93 ru/Rnm//RTemMMNmDJxMn3ft8mA28ENLQLxu47aBQ3yWZZJmP3DFP+deQ/+e3kbTAdZo 3E895dFSabqwv9tKzC/laTzC9nya64c/ZI3Lo/1/vVJF24jkvMiHuDseopRKHqZNxq7s r35w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=uT75a19FaF87yjESbhIfkIe22b6AasUHkjMarqW5BsM=; b=Ps3IuN6mM4Nc3VtWAQcqfo4ByKhtzTMNJ73ZClCAvB94LhXEe4RyJSb/xEYSKa4A63 WlNI3mQg0Wvj43ecAS6WK4kTfAP9/Up4mj8ft/Xhj33T6l5fcKEL3Fw6TTnjO5TUz0ph mshr4Ve6P18Q9h5BZwMSEhgnktMuG792Ce6/dpzE1qEwL9CafAb9iB65Aq8GJ4UcCFvH 1IDjiX8sBfRiz881wEhM6M+fjhMEIwH9wsZZlGFj7S7TftYiDhlP0oKMcOLKyayS4Rt/ Y6Lz7VHJxmqhh0+vnEr9WrecZ9nZdAhCgEWx3/FWuXWwpR122lHJYDbN1sPvY8vCGpkL NWSg== X-Gm-Message-State: AHQUAuYbfHpBBU30XUyK+ev2WsN6mgRsdPGBZqo+HRwuWda7EIOLi13B Ag5KFavaVaq5RP/ht7etVTNVhA== X-Received: by 2002:a65:424c:: with SMTP id d12mr1000124pgq.126.1550104671315; Wed, 13 Feb 2019 16:37:51 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id e128sm643789pfe.67.2019.02.13.16.37.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 16:37:50 -0800 (PST) Date: Wed, 13 Feb 2019 16:37:50 -0800 (PST) X-Google-Original-Date: Wed, 13 Feb 2019 16:30:21 PST (-0800) Subject: Re: [v4 PATCH 8/8] RISC-V: Assign hwcap as per comman capabilities. In-Reply-To: <20190213084442.GD28278@localhost> CC: atish.patra@wdc.com, johan@kernel.org, robh@kernel.org, aou@eecs.berkeley.edu, jason@lakedaemon.net, alankao@andestech.com, dmitriy@oss-tech.org, schwab@suse.de, daniel.lezcano@linaro.org, linux-kernel@vger.kernel.org, marc.zyngier@arm.com, Paul Walmsley , anup@brainfault.org, linux-riscv@lists.infradead.org, tglx@linutronix.de From: Palmer Dabbelt To: johan@kernel.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Feb 2019 00:44:42 PST (-0800), johan@kernel.org wrote: > On Tue, Feb 12, 2019 at 11:58:10AM -0800, Atish Patra wrote: >> On 2/12/19 3:25 AM, Johan Hovold wrote: >> > 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? >> >> Hmm. If a cpu node doesn't have isa in DT, that means DT is wrong. A >> "continue" here will let user space use other harts just with a warning >> message? >> >> Returning here will not set elf_hwcap which forces the user to fix the >> DT. I am not sure what should be the defined behavior in this case. >> >> Any thoughts ? > > The problem is that the proposed code might still set elf_hwcap -- it > all depends on the order of the hart nodes in dt (i.e. it will only be > left unset if the first node is malformed). > > For that reason, I'd say it's better to either bail out (hard or at > least with elf_hwcap unset) or to continue processing the other nodes. > > The former might break current systems with malformed dt, though. > > And since the harts are expected to have the same ISA, continuing the > processing while warning and ignoring the malformed node might be > acceptable. Handling malformed device trees by providing a warning and an empty HWCAP seems like the right way to go to me. > > Johan