Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2627187ybb; Sun, 22 Mar 2020 04:03:20 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvocmjgJv62/rSHinS/govCLdpjjATg7eqw8qH8MZtH0IKYnZD6YCMSo73rEm9rzbE/svxB X-Received: by 2002:aca:db41:: with SMTP id s62mr12893290oig.87.1584875000386; Sun, 22 Mar 2020 04:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584875000; cv=none; d=google.com; s=arc-20160816; b=mMjJi8UjBlRnhmebLHEMp7ic21iDzRh9Y1v2acZOICyV8gDIxPv5rlliK0bxNrfPB2 zzNbrI2YlOGO3z65pYr++Rk3XFt0s400H5aH+rb4Zy+Ro9/UaBGByyd7JzGjOgAaKhS2 BXB8yo3y0M1AiBrG7BkxbyIldVcBMg83lQNihehdknsAJ3uLPY90iDsR+SXtLGBte52D h4fjUxXZtYfWpWexu+ZD+9AdRapDZZneo4KB+fQmXxUuFeP1YExHt6/HjlBoDftRdJyM aPkE2GIrTcpzlHEXA1eQGwi+kF7ry2dF4PgZD1Zvw/ujPVbRwjM+BIiMrgI3rRPKsdaM ZuSg== 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; bh=HHW8UhyZhsJSXCFfN9u1FEowySO2B1+JFh9Q66ilZkY=; b=XOde3Hi8dA/Nh7CfEG0fRr35LfGWqkQvLYkAVnmWHbgVhIUbAh1Wz8Bfl7BOtTq5Lv OaFw+DhtvlQ1LduAY+oruBxJPda3zJtX5AcQlYAeFs7ihNYj7EzV3M3SKBEJWRcfs+FJ +7vzv/zG8P38tL/8wspk0mody1JPm1CGd8f+cKriBByhKl8RatucQnhZMJ569P3xB1Qi vQGIr6/JoNLc0KlkA72uHYqyXIIdCKR29BAc8hbfEULWPuHn+Tr5ZzC+k9vG2uefm1EY 24LNKf1ew3lF/y2YE1mWaBUtD0ffPG7rNKM2mNUSifmArHBRDkWYfJxMNnH38l6aW4Cn OkGA== ARC-Authentication-Results: i=1; mx.google.com; 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 q124si5973382oig.228.2020.03.22.04.03.07; Sun, 22 Mar 2020 04:03:20 -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; 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 S1727023AbgCVLBl (ORCPT + 99 others); Sun, 22 Mar 2020 07:01:41 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:43157 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726936AbgCVLBl (ORCPT ); Sun, 22 Mar 2020 07:01:41 -0400 Received: from localhost.localdomain (lfbn-lyo-1-453-25.w2-7.abo.wanadoo.fr [2.7.45.25]) (Authenticated sender: alex@ghiti.fr) by relay10.mail.gandi.net (Postfix) with ESMTPSA id ED460240003; Sun, 22 Mar 2020 11:01:35 +0000 (UTC) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Zong Li , Anup Patel , Christoph Hellwig , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [RFC PATCH 1/7] riscv: Get rid of compile time logic with MAX_EARLY_MAPPING_SIZE Date: Sun, 22 Mar 2020 07:00:22 -0400 Message-Id: <20200322110028.18279-2-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322110028.18279-1-alex@ghiti.fr> References: <20200322110028.18279-1-alex@ghiti.fr> 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 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