Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1393554ybb; Wed, 25 Mar 2020 23:12:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsa1r8yDwyJKi+okqBpxjwi0KWLmqGCipDCwHg/U+HYIahDc0yTME82/NRJ47C2JjOUftv8 X-Received: by 2002:a9d:798a:: with SMTP id h10mr4970800otm.367.1585203139371; Wed, 25 Mar 2020 23:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585203139; cv=none; d=google.com; s=arc-20160816; b=nZY3zcwkRs1cMd4ixKLMkfC2irxEkp2BKzns9/ElSn9zAsTQxpey8PLB2N1rf45f9Z wewX24MPrs2+eJwRQ1dU0Ce0O8vGx9j3+xB5hrf0RS9CRnsLeHbV9BAENbAiuCwGT4b8 IHJEhHm7JlwDS0d7DZgVnupa79mn/Q33Rf2O0DoiJuxiqXOp2w+EdtHTz38eR3QBSiao uMFFgM6MBYcBly+UJh7FO5dWY881ZbPlYoVDnYtkZcz4yezGL2aF7T3sD9XrJtYFIRzB aiPBn0Qf37s2T5bbsTNS5Ns25TNyPTEv8lMtvypzsLoklD091Iz+UTD6ascoVU2BcOyr 76dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=wVoY4lXNG7Gme6In75qZRg7QM7A7s34V74dfLUTDGcs=; b=jPyPW/u+FtGMpo/FWlr0etzMFe+6Gxfc0KORrboiNXs+Aeq1q+17UtkCKMEi2vSTkt vXbGMgfZB82sO5y7Ng/yj3TgXysYjMoYgmoussYIQz9k82iNs9A1qmTpB2cOe7NPgZPv shiewwvpypObcMxqrKjguhmCEgcU6jpn87HpptosxnD8Z8fBxvtTF9qoS3nXtS2d2Jni xc+uDTb1vVn+Y1MWWgVGTDIPX7J3cR+VQASipcsqniiByKw+7tI6K56GlczUNPnLe8yj h9MSTQq/86uWEla2qHDzWnYUS62kmvKBPE5+V7tZNfrNhfr7QZ6YMnjXuVWDFWe+mysV 89mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b="GtxD/Ymy"; 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 v9si619527otn.120.2020.03.25.23.11.50; Wed, 25 Mar 2020 23:12:19 -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=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b="GtxD/Ymy"; 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 S1726322AbgCZGLN (ORCPT + 99 others); Thu, 26 Mar 2020 02:11:13 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:39286 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726259AbgCZGLM (ORCPT ); Thu, 26 Mar 2020 02:11:12 -0400 Received: by mail-wm1-f67.google.com with SMTP id a9so5656499wmj.4 for ; Wed, 25 Mar 2020 23:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wVoY4lXNG7Gme6In75qZRg7QM7A7s34V74dfLUTDGcs=; b=GtxD/Ymy4a3u/qavJ6N3vSmF7WFooVCXwwer/gGsgIPEbvwmYrmqd0jJOeFyK52yIp RYQQ9dWaTIwuPTjfLV5Aa576UprjHLL0LCIF11YkWNScM9z+iMHBYJkKJqBM1xWVoaka Z/t8ltbj3yaMwq6HuMCBhzhpEMcccMnSneBQe0EnsRUPOW556BNfnl0HKyU/I8RP/kwr +/1ONxRdmVeD9Kq8veipry4nQ7tVTGcZdndYVOmXtprTTjQnruexgiFBFI3KSOJ4laCa TTD0ceety+MZBlbTIRbyFEQ/+RkliIqQyGJ2h+LrK03xlt55jWZySMS9CbQevndt12w0 PiPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wVoY4lXNG7Gme6In75qZRg7QM7A7s34V74dfLUTDGcs=; b=tENNAWVG/neGPxbCVgK3Dpole9YqIGL27gBbB4AYk+p1nRldOUPm15qMx7LOKdQyWW GP9uwoscWaPcDCUQR43EKACIJi+OahtfP1zDjljYUe5pRW0lANhjsQK5h8oGBuK57qA/ TzOkBgSZo/8p1c4ggx8CzrS27yGomA9Bzj8cMPsBAPmao34ieaixHopnDsa0MXEQT3Sb 62XZW6zMYXW7+ri0k2x8lWB/11qM91cnI53DWpGojE1etrCub+yEvhh9nKd/zSxqaQsm lK3yczG6QIWnI4kHmaHuD/Uuyl49x7TRnxz6gvKN8plbkvGf0rmrgmnNP7KdX6RPTjlc T9ag== X-Gm-Message-State: ANhLgQ3QuZsvli/oqysSPpg9R1XeqvJtpLrGpZpsKwl6A+bkEPbiKLTr pyPRTzioYJFlaflBnr3SkcEIWodRHEXV07T6/b9n/A== X-Received: by 2002:a1c:6385:: with SMTP id x127mr1306256wmb.141.1585203069267; Wed, 25 Mar 2020 23:11:09 -0700 (PDT) MIME-Version: 1.0 References: <20200322110028.18279-1-alex@ghiti.fr> <20200322110028.18279-2-alex@ghiti.fr> In-Reply-To: <20200322110028.18279-2-alex@ghiti.fr> From: Anup Patel Date: Thu, 26 Mar 2020 11:40:56 +0530 Message-ID: Subject: Re: [RFC PATCH 1/7] riscv: Get rid of compile time logic with MAX_EARLY_MAPPING_SIZE To: Alexandre Ghiti Cc: Paul Walmsley , Palmer Dabbelt , Zong Li , Christoph Hellwig , linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 22, 2020 at 4:31 PM Alexandre Ghiti wrote: > > There is no need to compare at compile time MAX_EARLY_MAPPING_SIZE value > with PGDIR_SIZE since MAX_EARLY_MAPPING_SIZE is set to 128MB which is less > than PGDIR_SIZE that is equal to 1GB: that allows to simplify early_pmd > definition. > > Signed-off-by: Alexandre Ghiti > --- > arch/riscv/mm/init.c | 16 ++++------------ > 1 file changed, 4 insertions(+), 12 deletions(-) > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index 238bd0033c3f..18bbb426848e 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -247,13 +247,7 @@ static void __init create_pte_mapping(pte_t *ptep, > > pmd_t trampoline_pmd[PTRS_PER_PMD] __page_aligned_bss; > pmd_t fixmap_pmd[PTRS_PER_PMD] __page_aligned_bss; > - > -#if MAX_EARLY_MAPPING_SIZE < PGDIR_SIZE > -#define NUM_EARLY_PMDS 1UL > -#else > -#define NUM_EARLY_PMDS (1UL + MAX_EARLY_MAPPING_SIZE / PGDIR_SIZE) > -#endif > -pmd_t early_pmd[PTRS_PER_PMD * NUM_EARLY_PMDS] __initdata __aligned(PAGE_SIZE); > +pmd_t early_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE); > > static pmd_t *__init get_pmd_virt(phys_addr_t pa) > { > @@ -267,14 +261,12 @@ static pmd_t *__init get_pmd_virt(phys_addr_t pa) > > static phys_addr_t __init alloc_pmd(uintptr_t va) > { > - uintptr_t pmd_num; > - > if (mmu_enabled) > return memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE); > > - pmd_num = (va - PAGE_OFFSET) >> PGDIR_SHIFT; > - BUG_ON(pmd_num >= NUM_EARLY_PMDS); > - return (uintptr_t)&early_pmd[pmd_num * PTRS_PER_PMD]; > + BUG_ON((va - PAGE_OFFSET) >> PGDIR_SHIFT); > + > + return (uintptr_t)early_pmd; > } > > static void __init create_pmd_mapping(pmd_t *pmdp, > -- > 2.20.1 > Looks good to me. Reviewed-by: Anup Patel Regards, Anup