Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1763427pxk; Sat, 19 Sep 2020 01:19:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4hQRMLjmVhLQH6fEWSGsyGvhLrlCrHeMUUqSgtEtb64hzIF7Qi8B/x3slYgT6XkIcl4dO X-Received: by 2002:aa7:d3da:: with SMTP id o26mr41261186edr.169.1600503576262; Sat, 19 Sep 2020 01:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600503576; cv=none; d=google.com; s=arc-20160816; b=TS2c/302viw+MF5WFLsmSO/t8dQw6J3G8yNxOpWxmM++HrsW5Jc9+2mPDuTsjTKgLB tkrDJySF0fn0Kiho9qWZjfEulqwRJe45N0BOXJvPQENE8VOGaHPDfv3S3Pq308esQ9ek FCWyPiYFkmwzghfSit11FjwwshYt9plWeGQIKCUIGFyE6rzLXVk650PWli8rfYtc78vT PU2iw7jPdkGtj8jb6O/Mm7iTDBPfxIbFb5QuTKSHNtwHUVohLH7g4hvBidtCly9lKrKn i3cPOz45hT8yIRQIvC32obtU0zZMfAxFtAPl54Dg6FprBh+R4zPxnHgvJGNzFrVPkScF wsbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qozaYWzYQkzZJ4PYPy55Zf+OUXy+vRjRSwhu+3b3lDM=; b=oRjc87uSspnO8hryGGxlHNt0yEfChFJW41EfbIbER1kB5lgKi+ufga2382is27rdy7 ICjro07+jh+sSNtoEVO/LKifZQnYDRFDe+/wo1uFxkPrxxKNJrsqwEdpAFAzBjjT41ou /b+iAm/7utIDUUkOggjc0sy4k5OyPRf2VMPppL2YXJNOMT9X9rfhQu68QKBzUUaJ8bYE Za61dn/7oVkLs9VoUfZl1iq6X68N6b9FVAQ+CizykFj9MIoW85Csm0immOigZR+q6eYy e3BnLmKsgH9P2hj0c3jwfqxW8WGbScRr512YsYBTqQ+dKnOS3KFzGty7DRm5ePvJKAnD DvJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oq1HgnGL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m3si3870296ejk.485.2020.09.19.01.19.11; Sat, 19 Sep 2020 01:19:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oq1HgnGL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726168AbgISIRN (ORCPT + 99 others); Sat, 19 Sep 2020 04:17:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:48730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbgISIRN (ORCPT ); Sat, 19 Sep 2020 04:17:13 -0400 Received: from kernel.org (unknown [87.71.73.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B2BD921481; Sat, 19 Sep 2020 08:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600503433; bh=T3vHD+t2wwh+JRDOjD6PywHEwj3QURdLWr2DXDdJ9Eg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oq1HgnGLpd/kJhUyal09FR8c6/MJma3nfq0mW9Sav1TAbwGIap2bn5F+ldxCKBWSH TgdlCVi+a7xtDsYOjH18OgegqpQCN7OObO/ttl6jzq6yGIwxT2PBTt2s0N8GH0v5zD TsDy9a6iTV3m8lbvthtBa4MM0gMNYi1AnleUGgH4= Date: Sat, 19 Sep 2020 11:17:06 +0300 From: Mike Rapoport To: Atish Patra Cc: linux-kernel@vger.kernel.org, Albert Ou , Anup Patel , linux-riscv@lists.infradead.org, Palmer Dabbelt , Paul Walmsley , Zong Li Subject: Re: [PATCH v2] RISC-V: Remove any memblock representing unusable memory area Message-ID: <20200919081706.GP2142832@kernel.org> References: <20200917234055.2321977-1-atish.patra@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200917234055.2321977-1-atish.patra@wdc.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 17, 2020 at 04:40:55PM -0700, Atish Patra wrote: > RISC-V limits the physical memory size by -PAGE_OFFSET. Any memory beyond > that size from DRAM start is unusable. Just remove any memblock pointing > to those memory region without worrying about computing the maximum size. > > Signed-off-by: Atish Patra With one nit below Reviewed-by: Mike Rapoport > --- > Changes from v1->v2: > Used memblock_enforce_memory_limit instead of memblock_remove without > computing the maximum memory size. > --- > arch/riscv/mm/init.c | 15 +++++---------- > 1 file changed, 5 insertions(+), 10 deletions(-) > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index 787c75f751a5..ed6e83871112 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -146,8 +146,6 @@ static phys_addr_t dtb_early_pa __initdata; > void __init setup_bootmem(void) > { > struct memblock_region *reg; > - phys_addr_t mem_size = 0; > - phys_addr_t total_mem = 0; > phys_addr_t mem_start, end = 0; > phys_addr_t vmlinux_end = __pa_symbol(&_end); > phys_addr_t vmlinux_start = __pa_symbol(&_start); > @@ -155,21 +153,18 @@ void __init setup_bootmem(void) > /* Find the memory region containing the kernel */ > for_each_memblock(memory, reg) { > end = reg->base + reg->size; > - if (!total_mem) > + if (!mem_start) > mem_start = reg->base; > if (reg->base <= vmlinux_start && vmlinux_end <= end) > BUG_ON(reg->size == 0); > - total_mem = total_mem + reg->size; > } > > /* > - * Remove memblock from the end of usable area to the > - * end of region > + * The maximum physical memory supported is -PAGE_OFFSET. Maybe The maximal supported physical memory size is -PAGE_OFFSET > + * Make sure that any memory beyond mem_start + (-PAGE_OFFSET) is removed > + * as it is unusable by kernel. > */ > - mem_size = min(total_mem, (phys_addr_t)-PAGE_OFFSET); > - if (mem_start + mem_size < end) > - memblock_remove(mem_start + mem_size, > - end - mem_start - mem_size); > + memblock_enforce_memory_limit(mem_start - PAGE_OFFSET); > > /* Reserve from the start of the kernel to the end of the kernel */ > memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start); > -- > 2.25.1 > -- Sincerely yours, Mike.