Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5820305ybp; Tue, 8 Oct 2019 08:47:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjJxTtCD9BPfRTSqiBGuXkI5LXdcjYAJO4G4Ka3v82fHmpiugHUe6zMzUyhmEBIpkp+sQX X-Received: by 2002:a17:906:34d0:: with SMTP id h16mr29972992ejb.190.1570549623545; Tue, 08 Oct 2019 08:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570549623; cv=none; d=google.com; s=arc-20160816; b=BqtDAFwAk/4JOgE2cfNapVTgxk0GJfkEmC+KRDNbNMvuMp78laSnNHA66Ycdg9CJnU I68kydfF/peyHQYWR1CIGaU6/Ua0HTxZigTOzgjZgDLstjtPJMd4OylefxILjtLGEXHg q/SD2uJNfMNtnzHDwNNpvzuTcGq2swZmi5zZuB3EY1AdZb7p5pHp91VRUPR3LSqovCbl d/NcBmYOMK7lyVEu9AvpkyYxtv9onmWfTuyhbTlM4mSio22x1La14IvuitfFLFRAU2xS imLzxfugPqtc2iRXuTaIAxuBRvnakNjPKzTvGj+OP7tlzqqPxIhx1gnvT/AnnRsMQs6B 9tEQ== 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:dkim-signature; bh=Rm4/9rv6HX2r0nJlpOILNCRrJ7/GYeb4OrtBUUbPm84=; b=VAC9UqZ6D/D8+Etm9SZCUJQqTKdbxwbCerftaWDlPIiUtMwBfEcFU2okp1QIgvBOdX RnCEIHQvIe2ZLPsLEM+vxiWS0gMNpLQw8UIYkjhCjmqvO9giHJFBXfN2p47ajSeCTPST 2v94cwD1r4RgoNPXr0TqfNpnhyj1vZFFdKVDMS/uJGJ1xrMdqy4+Ycv4OI3ws6iWfG8I CEBPY2gqApuguedYVBpi2EJUsTIf2B5eBLxn1CDA7GZOeeM7P1y8OW76GJTUwNanlQTW t5BDTewEF+4CxjV+GGnQZlk1ymBsIzDLzjuPcEYufZ+Ii0xk3jbH72ZZ0YxMGjwQeGZw HmCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XoZbfyRr; 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 q1si11042465edj.354.2019.10.08.08.46.40; Tue, 08 Oct 2019 08:47:03 -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=@infradead.org header.s=bombadil.20170209 header.b=XoZbfyRr; 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 S1727711AbfJHPoJ (ORCPT + 99 others); Tue, 8 Oct 2019 11:44:09 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48748 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbfJHPoJ (ORCPT ); Tue, 8 Oct 2019 11:44:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Rm4/9rv6HX2r0nJlpOILNCRrJ7/GYeb4OrtBUUbPm84=; b=XoZbfyRrk2Yb9Xh/JWriMo57w 0MlWAM/84VG3DoYgBjM9o1GsAaajHkBisrShC21UZ/dgEzxExcZPpibG1/Gyotgp+84IJqBCxg+Ty nvgJr2coRkCNnyOesaeqKQzY86vATs2BI4MQraBpeK3X1BEI2MIxEnjhx9BBpXcuKMVqNbjpSUFI7 FvjQvHeK9GVKw+cOMIsXDiBEzDhvmWZKXYpSl6rEKyE9RIC7zr9clShR9I2VpzK2k84Zp9WDvkcRN 3SgHOINsTr/DceK00Y9xFGANdeUewSp/oOU/2C1RGF1gSadDYXxufXLsdp5iIZsvG3nDqiVin6TsG XTxymkvww==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iHrei-0001rR-O5; Tue, 08 Oct 2019 15:44:08 +0000 Date: Tue, 8 Oct 2019 08:44:08 -0700 From: Christoph Hellwig To: Atish Patra Cc: linux-kernel@vger.kernel.org, Albert Ou , Richard Fontana , Greg Kroah-Hartman , Palmer Dabbelt , Johan Hovold , Alexandre Ghiti , Thomas Gleixner , Paul Walmsley , Anup Patel , Andrew Morton , linux-riscv@lists.infradead.org Subject: Re: [v1 PATCH 2/2] RISC-V: Consolidate isa correctness check Message-ID: <20191008154408.GC20318@infradead.org> References: <20191004012000.2661-1-atish.patra@wdc.com> <20191004012000.2661-3-atish.patra@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191004012000.2661-3-atish.patra@wdc.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +int riscv_read_check_isa(struct device_node *node, const char **isa) > +{ > + u32 hart; > + > + if (of_property_read_u32(node, "reg", &hart)) { > + pr_warn("Found CPU without hart ID\n"); > + return -ENODEV; > + } > + > + if (of_property_read_string(node, "riscv,isa", isa)) { > + pr_warn("CPU with hartid=%d has no \"riscv,isa\" property\n", > + hart); > + return -ENODEV; > + } > + > + /* > + * Linux doesn't support rv32e or rv128i, and we only support booting > + * kernels on harts with the same ISA that the kernel is compiled for. > + */ > +#if defined(CONFIG_32BIT) > + if (strncmp(*isa, "rv32i", 5) != 0) > + return -ENODEV; > +#elif defined(CONFIG_64BIT) > + if (strncmp(*isa, "rv64i", 5) != 0) > + return -ENODEV; > +#endif Using IS_ENABLED here would clean the checks up a bit. > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c > index b1ade9a49347..eaad5aa07403 100644 > --- a/arch/riscv/kernel/cpufeature.c > +++ b/arch/riscv/kernel/cpufeature.c > @@ -38,10 +38,8 @@ void riscv_fill_hwcap(void) > if (riscv_of_processor_hartid(node) < 0) > continue; > > - if (of_property_read_string(node, "riscv,isa", &isa)) { > - pr_warn("Unable to find \"riscv,isa\" devicetree entry\n"); > + if (riscv_read_check_isa(node, &isa) < 0) > continue; Do we really get rid of warnings if we didn't find anything proper?