Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5041054imu; Tue, 15 Jan 2019 10:07:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN7IN5mftGamrhET9t9ViAMUO4os9G3BVSTFDN16YH1HrNe1tiWR4bIibR+Kl4mvopmvIcM0 X-Received: by 2002:aa7:80d7:: with SMTP id a23mr5229699pfn.86.1547575672869; Tue, 15 Jan 2019 10:07:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547575672; cv=none; d=google.com; s=arc-20160816; b=oFtVdzavhXFLLZz6ZXggvxBtoK3rKhfHhj8/CRNlizq+lVaCDF+0JgliivBFVfhHXO QAqjfsuTSvKY7ncGFS9ELlZo6ez2FDR1UWqDp7p+H83TVztfzLHHlGb2bEuO1L+DQtY3 nzATe4csHCWlIIjlbCuca/wjJrN7+WulvpAQFUOm5PLNPIoWaMJPyakWOQJG+KC2vbbj EXsbgzfN2dw0kRFGSi7WlC3w9WhMTgyFGvTYMp0LXYJFOcqynK6nL2rVOVLLq2fY0Mee kKrI2GIMNsl91bPuZ7+FOAnERDCbd4iecFC3LZ07+3m4bjDdp7y9ihgsiENn010EZGdC M1mA== 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=Bs9ahMtpRGHw9gEJAKE7tGeHnnlpDtM946YCPVveanI=; b=unW855CaYJ1VCGYD6RbQFcVeHrKxND3jAQ63Ex82aiHHtUWrPDRj1FqYC8eD8huH+E P1BPDt5w5PdjyOZAL6HP6R8vH+mLZmFI8DxK5ksv4NUK61hz0aOwX9rfC83S8j/9zhpm /Kb9cMwCudmlWw2SOQQhC0HR6rc3cN/M0ZB9UVXMcjcsgZFUB5RSLx/Pu0IQvGPud+7K q0mvqvXSatl2aiG5sfzF+nsqb+qNYYCdvvHUy3cvEal6jU2y2pD+HhO/sYZhX1bvEnah 4amhu96hHlWqJE2L9kV1x6dRWa+jGho5MmUpE8U03lAdMyIlna3UsSLkSIvWILyIZ5dC YBkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=kL0VTn13; 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 85si3933791pfc.145.2019.01.15.10.07.35; Tue, 15 Jan 2019 10:07:52 -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=@infradead.org header.s=bombadil.20170209 header.b=kL0VTn13; 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 S1730955AbfAOPgP (ORCPT + 99 others); Tue, 15 Jan 2019 10:36:15 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:41248 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728652AbfAOPgP (ORCPT ); Tue, 15 Jan 2019 10:36:15 -0500 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=Bs9ahMtpRGHw9gEJAKE7tGeHnnlpDtM946YCPVveanI=; b=kL0VTn13Tn/2/UFCR0SUF6UO0 tQAzM7U3dg7xEVj/dOPJH3DyYsj1vEg0cqf8z+HLSCr9uQ8am9lHvUx0iQUuJ6iBj5h+f38sOcDJj 60vACHwfG2ovQBusuPSkdoJA/tPQM4J1n1PgQiAwnfo8VMuE/yAzLJqPBJyBNFhrmpAxTWEoJldkQ S7LckID5XVKVq/wHEkAvu0YR+ikrBpO/0YKefd0QKGvKJjNGGxb6T7Kb4IJYq6iW3R/IbzouygIrf cNVD2PBGVeXq7puW/YiGOC2vVnoxFHbUSRqR9Rv3dVEnR/VubnuENKdzfPHuu6C2S8YczaGooSZ4g M6Bwu+vSA==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjQlB-0003Zr-UR; Tue, 15 Jan 2019 15:36:13 +0000 Date: Tue, 15 Jan 2019 07:36:13 -0800 From: Christoph Hellwig To: guoren@kernel.org Cc: palmer@sifive.com, aou@eecs.berkeley.edu, linux-arch@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Guo Ren , Mao Han Subject: Re: [PATCH] riscv: fixup max_low_pfn with PFN_DOWN. Message-ID: <20190115153613.GC26443@infradead.org> References: <1547280987-7630-1-git-send-email-guoren@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1547280987-7630-1-git-send-email-guoren@kernel.org> User-Agent: Mutt/1.9.2 (2017-12-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 On Sat, Jan 12, 2019 at 04:16:27PM +0800, guoren@kernel.org wrote: > From: Guo Ren > > max_low_pfn should be pfn_size not byte_size. > > Signed-off-by: Guo Ren > Signed-off-by: Mao Han > Cc: Palmer Dabbelt > Cc: Albert Ou > --- > arch/riscv/kernel/setup.c | 2 +- > arch/riscv/mm/init.c | 3 ++- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c > index fc8006a..5463e67 100644 > --- a/arch/riscv/kernel/setup.c > +++ b/arch/riscv/kernel/setup.c > @@ -174,7 +174,7 @@ static void __init setup_bootmem(void) > BUG_ON(mem_size == 0); > > set_max_mapnr(PFN_DOWN(mem_size)); > - max_low_pfn = memblock_end_of_DRAM(); > + max_low_pfn = PFN_DOWN(memblock_end_of_DRAM()); I know it is used just above, but can we please just switch this code to use >> PAGE_SHIFT instead of PFN_DOWN, which just horribly obsfucates what is going on? > > #ifdef CONFIG_BLK_DEV_INITRD > setup_initrd(); > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index 1d9bfaf..658ebf6 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -28,7 +28,8 @@ static void __init zone_sizes_init(void) > unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; > > #ifdef CONFIG_ZONE_DMA32 > - max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, max_low_pfn)); > + max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, > + (unsigned long) PFN_PHYS(max_low_pfn))); > #endif Same comment as above here, plus I think we should just use memblock_end_of_DRAM directly, e.g. something like: static const phys_addr_t max_dma32_addr = 4UL * SZ_1G; max_zone_pfns[ZONE_DMA32] = min(memblock_end_of_DRAM(), max_dma32_addr) >> PAGE_SHIFT;