Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4235517imj; Tue, 12 Feb 2019 12:10:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IYKsZfyB3sKSbPuSmVjmnF/jvnpX6YYnArf2HccFwJEsNOfaN/uGadVmYa5cYZmxGkoVrjw X-Received: by 2002:a62:53c5:: with SMTP id h188mr5549847pfb.190.1550002247144; Tue, 12 Feb 2019 12:10:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550002247; cv=none; d=google.com; s=arc-20160816; b=kbvdOTts3Y7qucFsvq23b2CG7EfM0ly/WEV+7S13K1ja5XGwwxi7M+qHm7N4dfbRic siOV6qVdUphqQxGabAVH4Mwoiiu98U1Xu1gJdLYLWF8sgNn0YQPoN1lSh6euQoHpEv4k g52ufesmacSFG3u6H5h8ig2tkiqty1xCTnw/eFxmApgyltKsWqRCsxOhS4cT0hbpPCIW Dxw/3C+xBsl4AMwUgT2XzJdK1XkLBQ327M1fU4JSb/e9Qn7+qJaPaDrxUaEefaZrSyRp WXAKfDtzBeDK2V6bSwAJ1L0oNU7qbeLEyhL5yMrY/N62uZgDa1Gl/Px50HTkk/q6GyZt JFnA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=XHKhWE8uxpmevb3ofaYVpBySBDtySewA6Fjr4r0CZ2s=; b=MOq5qFHHxXgnHFDlxEEIWG118R3vtxB9RbmZcg9FrFM1GxFNJpBrTokvYi92U7ROaz tSUQSMP9K8oM0CvN8WfPTb5iIS7KJlmtJBR5vtEwCHfw29Iv/fJPDfRxwedldwi38yVV KIWEC5yUSqrSjWfXjmgvNuTC7a/a/an4hWZ/VK7K5foMTxlbjPgdqxwJoaKNb83f0Rdl ZnspEGAFG/b2MxrL5+WpQr85qtJ1F6r0Yfv9yalYfF+6RELSKh2sO02o3sO0bWP3swTh oLF3Y8enWx2pkrlRpVSOJNq5VQPAPVD/zOAPm3knEy/BfAzXKpnJLM1SiH0FvMk7hViu K0Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=KNHi+B+A; 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 d10si10367684pgh.591.2019.02.12.12.10.31; Tue, 12 Feb 2019 12:10:47 -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=KNHi+B+A; 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 S1729159AbfBLT6N (ORCPT + 99 others); Tue, 12 Feb 2019 14:58:13 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:35500 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbfBLT6N (ORCPT ); Tue, 12 Feb 2019 14:58:13 -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=1550001519; x=1581537519; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=hwqIbYi5G3kRqkmsvPNoG9+WwfcisAP7zx393j6fDlk=; b=KNHi+B+ATvUYOXh/loAWWYHBV4KXUtLb2twxbX9YrQjcHd/LZJFgwvV0 sXSodRcY/lv3AmxPZYFOpFzl/HGkIa1hdhkmkJOCgLwM9lYfNfSrxsQC5 mqzdEBqgbsO+nVVvZ2khJl3l7Nbef1tzpo7zJwbyq/qzaeYmZJgIvRtPC Jii2IrnDylUTdA2QlCVWLOEJj+vmEf6gpK4KExJ+GrqzvwoonD8clQqdm 54Vckomiquxk6oxLRb/yajoAGkJMkF5WgMmGW9bP/hbiaVeQBgf130XDB JNP6ROiHe6+xHcEZsJI5Vc4xPOo5eLqUByUwtx9Of23OZJhPqfyneDiyF A==; X-IronPort-AV: E=Sophos;i="5.58,362,1544457600"; d="scan'208";a="199247381" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Feb 2019 03:58:38 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 12 Feb 2019 11:36:47 -0800 Received: from c02v91rdhtd5.sdcorp.global.sandisk.com (HELO [10.111.69.190]) ([10.111.69.190]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Feb 2019 11:58:13 -0800 Subject: Re: [v4 PATCH 8/8] RISC-V: Assign hwcap as per comman capabilities. To: Johan Hovold Cc: "linux-riscv@lists.infradead.org" , Alan Kao , Albert Ou , Andreas Schwab , Anup Patel , Daniel Lezcano , Dmitriy Cherkasov , Jason Cooper , "linux-kernel@vger.kernel.org" , Marc Zyngier , Palmer Dabbelt , Paul Walmsley , Rob Herring , Thomas Gleixner References: <1549969812-22502-1-git-send-email-atish.patra@wdc.com> <1549969812-22502-9-git-send-email-atish.patra@wdc.com> <20190212112534.GB28278@localhost> From: Atish Patra Message-ID: <61766631-42f4-ec25-3b5c-ae892da44ccb@wdc.com> Date: Tue, 12 Feb 2019 11:58:10 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190212112534.GB28278@localhost> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ? > Note that you currently leak the device node when returning. > Ahh yes. I will fix it if we continue to return in the error case. Regards, Atish > Johan >