From patchwork Fri Feb 22 19:41:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 10826881 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFD82180E for ; Fri, 22 Feb 2019 19:42:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBDEA328DB for ; Fri, 22 Feb 2019 19:42:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B966332CB4; Fri, 22 Feb 2019 19:42:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 585CC3294F for ; Fri, 22 Feb 2019 19:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Nn5Bz0aXryPwwz+VDY1dgiOnhNRlEmuld5j2wwPETQc=; b=G/KfzLa9hoq9zeyPithJfLqtZp o5YzL0Q94uKao+Mj2yn+8Kj9Z0U0P50x6z1fK1OIHnFObukOLVgfwrD4V01c6EtJ+a68iXa2S/xX/ hfsTca7kf6BlrNX2EiDNFGnyI2HcsN2/8ORvN24vy57Yixm/dOCdMvIjmCCHCw3mv4hQpD4Zjj9Ch l6TSJOPXrgybeR6+O1tbgF08onvyFJtL0NuYl0fO6Gt+T8QaIVjMLzP8LZc5oRGLLlxjRxjWGOId+ QtEoa5lrmUouTsX8HUWphFovJmQchWnyuEgjdJfETp0BeittLbHf3YZeZh/Q4ZsUEkDIGRgbVC+83 mRdl+jvw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gxGiL-0007Rv-T6; Fri, 22 Feb 2019 19:42:29 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gxGiG-0007Kt-Fg for linux-riscv@lists.infradead.org; Fri, 22 Feb 2019 19:42:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1550864544; x=1582400544; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=LuHhF9t57ihPno63oc42DW7mqejQI1UJBdnLjc5u4ww=; b=rwFaOayNBU8eDHLTN+X0RKU6FkUzaimDhsuNYJcvV0DMjG9Qvc/J17w2 nQxLNORwlmvQoBKxAZvezi6o8/p+XlyJo8ujfiUG0FnXtJwgsvmr4Ph07 4oDLrTMLjynBVexjFQ8NWx33KkBd8C6EF+B45xpewLuUWGRyvy7C2nMYe nQE1nzI6TeHO9Iz5phd8ZE/X+RFF9rk9FSyMD0BrzuKdFR3rm0rHQk/pp zs2myGkOUW0mNhEi1ML4ZqWKN5y+NIJiEUHG3VUPoUn5h5b+JpTAjnTYG BW6DHBqOtijCfpPRxXvMcjRkU0bUzWpNp5+jByjP760Ko8zUMXBI3Yd+t A==; X-IronPort-AV: E=Sophos;i="5.58,400,1544457600"; d="scan'208";a="101966792" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 Feb 2019 03:42:04 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 22 Feb 2019 11:20:04 -0800 Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Feb 2019 11:41:46 -0800 From: Atish Patra To: linux-riscv@lists.infradead.org Subject: [v6 PATCH 6/6] RISC-V: Assign hwcap as per comman capabilities. Date: Fri, 22 Feb 2019 11:41:40 -0800 Message-Id: <1550864500-13652-7-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550864500-13652-1-git-send-email-atish.patra@wdc.com> References: <1550864500-13652-1-git-send-email-atish.patra@wdc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190222_114224_699796_46B75140 X-CRM114-Status: GOOD ( 11.28 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Alan Kao , Dmitriy Cherkasov , Anup Patel , Palmer Dabbelt , Johan Hovold , linux-kernel@vger.kernel.org, Atish Patra , Paul Walmsley , Andreas Schwab , Thomas Gleixner MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Anup Patel Reviewed-by: Johan Hovold --- 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. */