Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5505205ybi; Tue, 30 Jul 2019 22:21:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxN14fD+Peiw99wiogHZnKEMaEDhrzf50wBYKunxSbeDhym9PF1cDo8u3R8x3ppip12+R1f X-Received: by 2002:a62:3103:: with SMTP id x3mr44534019pfx.107.1564550506494; Tue, 30 Jul 2019 22:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564550506; cv=none; d=google.com; s=arc-20160816; b=DmtIBD9l8jZmwjRfM6yhq/DieNdLItLMir8roewm+948BZ48Uichno9bq8/MAius+M 5u2G20g9GerkLlVAoLXoIsJ8RSpnitl3lli+WOk4+NfQPKoBsp2PBwPsDlo+pzEYnmNm B16RbLK4RWvKtf1kXcIIeyFaI9VzsjDuTRMA70Sb3QCQJddawTQ4+ffjdp8Ptr3m6k9Q TLGJRRfPVabOVeVHCZtMtCm3jRQVrosoJHVDKa9YBJEHoMAuDFwkogsSlL7KO3flnXAd bEaOgcgIH+7j17eHnCDSkLVo2/YCDPVSQmNz1lI9owQeIes+Y+pm1bAaEZujuB6wx1kW KYQQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr:ironport-sdr:dkim-signature; bh=Qc91V627WXBfZC7DDP1F5mIq96z4qVswWLYGaIP73D0=; b=jmBePev9JN+CCF5JErWQhxPvL46Q7IL2DUbB2mdLWeZ0Az5u/6CZwyfv/f1ZyHJHGz OFTci33vceWJTdVaTLqQS9UyW2ff7XjVcFOGp/2Rx0Mxzzluq+j/r+AK8B3HALD+zcGL I8+MtqumsTv7RHIXUj9q1WfPyCY17hSvIVP8MW6T5vU+fnJJXk3JBM8RzGWElGfoDzEA DmcwWexTWude6XFyUUoZM2h8VbeaZw6lv+6RquC+Ykiq8TjatFBW3s3xZ9k1MJrJlBvY +kWHeYsSsAAycm1LCqBmwY34uJ/fWEhxlVujeL7nrRbIJq+lj8FQNO7Ngn8CHi7WFAHn S0CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=P20NFZJ2; 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 n11si218219pgr.460.2019.07.30.22.21.31; Tue, 30 Jul 2019 22:21:46 -0700 (PDT) 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=P20NFZJ2; 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 S1727814AbfGaBYx (ORCPT + 99 others); Tue, 30 Jul 2019 21:24:53 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:64333 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727599AbfGaBYh (ORCPT ); Tue, 30 Jul 2019 21:24:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1564536278; x=1596072278; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+zY9hAEVm58gSXJfAJQWINzIbb639f01AsOcw7UEO4w=; b=P20NFZJ210c1C9AxJy84xAXk+wBJ+GizVnCnoqJjHfNZEO8LkdIiEcU9 5Bt6Umr6fUKATphDY+n1KDTVf4pKEJ7uAxLcqstBY9zAUw8icOsLJfHs1 +wFvDbZ2lWJlb93qGBmB/599yb966W1z/qJLTsYz+DrEIJ+ZpBxs5NBMv 2jlTFXFKcRooL+Nf47nWr5YA1+6o7SKrkRyqACGNL6tej/W4XW6bL6VsQ 9zBNvOSLi/VwXhdE/0iDbK5krS/ZnM32N7LP//m7DDvvD1GNg5xWHzReT ecOMZlR6pcNQCJgqXvAe+Ycj72lysWHCMoxARazS/06JCgEpODlqXM/8H A==; IronPort-SDR: AZF2Jb8S+yDrI7Zn6NLczfH/f7pfS6HyVJD0yI5r+Piki1hwAW4IKlwiiQQEzGewGdRWwHeKcT xcil2DITpxDwprHRJIZ7KZvbpXUUiIvGApicZNeL3w+7gJuf5n/AF8FBdf/V9HFeU9f4X0Ob0F poqHtx4lEU8vpp00TvjSZ4XG+BJM/1M6Ln1v4GTN3kKLw3GpaUvkT+LnaDjrwIs6NS7zdw+f1T xZoaMPmS1gdTlYk0XfpWx5pnJBIVJ9ckriS8X0F36YmCT+Jfj5LgoWiuscVudmNHJwisWfBApc hMs= X-IronPort-AV: E=Sophos;i="5.64,328,1559491200"; d="scan'208";a="115555806" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 31 Jul 2019 09:24:37 +0800 IronPort-SDR: xT7Jc1NgIpfielIcW7hS1x7y3Mrj5r5ZnLLFW45hxfNYqpznJMRSydzoR8G3jwC09HtZi7fZhu xrfbeDedZGG2wi6ccBn26QDUwDefeRc2XBEXKLWLgJohUO2fDPAAOsMw5y20wvdR4yldUL/Z02 gWlJBqauchulighY9/wYgT+tXGJkuj8GW2RdGiHsyVDmGXatDpCbueT4pd5uhGYTyV2G5LQg6W MQV1uQyVTRHp2rM620aA/tmQnxPk9IAAVS/6jRFfHr88RliDfkcJ/ubVfN9Rt6/V7mCDi7PBPg WXvkwlN0dhiYN6b3+cnRN7ui Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 30 Jul 2019 18:22:39 -0700 IronPort-SDR: uH9oqNQNTYwcQqtIEcYCIgNqnHzHdX+JoR4A2KfOPDKCO9p3gl82GD81hDzFPGxl4tp/fVPTJ2 YnsSfZhm6QgC5SBvHzb+Wvd/V+3azwrvMoPopoTAskjCq7zxiE2rv74CRdNmXUecdvHtKJ8Q7+ 7nYBc2iyr3OCJnCq8cgl/GS67q5fAcCiMtgVnufwwu04vBHWzkO5AOsz/MEzB6ekPGa8yuVpoB Oe6g4kRdZ/CdzNJW6kskJZ2vkKiM+pYTqwmOCebZ9LSuqjTANu3GP9ri7jIxiAMo7tlLY2k8sZ T/s= Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip02.wdc.com with ESMTP; 30 Jul 2019 18:24:37 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Albert Ou , Alexios Zavras , Allison Randal , Anup Patel , Daniel Lezcano , devicetree@vger.kernel.org, Enrico Weigelt , Greg Kroah-Hartman , Johan Hovold , linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paul Walmsley , Rob Herring , Thomas Gleixner Subject: [PATCH v2 3/5] RISC-V: Fix unsupported isa string info. Date: Tue, 30 Jul 2019 18:24:16 -0700 Message-Id: <20190731012418.24565-4-atish.patra@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190731012418.24565-1-atish.patra@wdc.com> References: <20190731012418.24565-1-atish.patra@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, kernel prints a info warning if any of the extensions from "mafdcsu" is missing in device tree. This is not entirely correct as Linux can boot with "f or d" extensions if kernel is configured accordingly. Moreover, it will continue to print the info string for future extensions such as hypervisor as well which is misleading. /proc/cpuinfo also doesn't print any other extensions except "mafdcsu". Make sure that info log is only printed only if kernel is configured to have any mandatory extensions but device tree doesn't describe it. All the extensions present in device tree and follow the order described in the RISC-V specification (except 'S') are printed via /proc/cpuinfo always. Signed-off-by: Atish Patra --- arch/riscv/kernel/cpu.c | 47 ++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 7da3c6a93abd..9b1d4550fbe6 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -7,6 +7,7 @@ #include #include #include +#include /* * Returns the hart ID of the given device tree node, or -ENODEV if the node @@ -46,11 +47,14 @@ int riscv_of_processor_hartid(struct device_node *node) #ifdef CONFIG_PROC_FS -static void print_isa(struct seq_file *f, const char *orig_isa) +static void print_isa(struct seq_file *f, const char *orig_isa, + unsigned long cpuid) { - static const char *ext = "mafdcsu"; + static const char *mandatory_ext = "mafdcsu"; const char *isa = orig_isa; const char *e; + char unsupported_isa[26] = {0}; + int index = 0; /* * Linux doesn't support rv32e or rv128i, and we only support booting @@ -70,27 +74,50 @@ static void print_isa(struct seq_file *f, const char *orig_isa) isa += 5; /* - * Check the rest of the ISA string for valid extensions, printing those - * we find. RISC-V ISA strings define an order, so we only print the + * RISC-V ISA strings define an order, so we only print all the * extension bits when they're in order. Hide the supervisor (S) * extension from userspace as it's not accessible from there. + * Throw a warning only if any mandatory extensions are not available + * and kernel is configured to have that mandatory extensions. */ - for (e = ext; *e != '\0'; ++e) { - if (isa[0] == e[0]) { + for (e = mandatory_ext; *e != '\0'; ++e) { + if (isa[0] != e[0]) { +#if defined(CONFIG_ISA_RISCV_C) + if (isa[0] == 'c') + continue; +#endif +#if defined(CONFIG_FP) + if ((isa[0] == 'f') || (isa[0] == 'd')) + continue; +#endif + unsupported_isa[index] = e[0]; + index++; + } + /* Only write if part of isa string */ + if (isa[0] != '\0') { if (isa[0] != 's') seq_write(f, isa, 1); - isa++; } } + if (isa[0] != '\0') { + /* Add remainging isa strings */ + for (e = isa; *e != '\0'; ++e) { +#if !defined(CONFIG_VIRTUALIZATION) + if (e[0] != 'h') +#endif + seq_write(f, e, 1); + } + } seq_puts(f, "\n"); /* * If we were given an unsupported ISA in the device tree then print * a bit of info describing what went wrong. */ - if (isa[0] != '\0') - pr_info("unsupported ISA \"%s\" in device tree\n", orig_isa); + if (unsupported_isa[0]) + pr_info("unsupported ISA extensions \"%s\" in device tree for cpu [%ld]\n", + unsupported_isa, cpuid); } static void print_mmu(struct seq_file *f, const char *mmu_type) @@ -134,7 +161,7 @@ static int c_show(struct seq_file *m, void *v) seq_printf(m, "processor\t: %lu\n", cpu_id); seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id)); if (!of_property_read_string(node, "riscv,isa", &isa)) - print_isa(m, isa); + print_isa(m, isa, cpu_id); if (!of_property_read_string(node, "mmu-type", &mmu)) print_mmu(m, mmu); if (!of_property_read_string(node, "compatible", &compat) -- 2.21.0