Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14070564pxu; Mon, 4 Jan 2021 12:05:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZ49GnF9+3zCeOFiE8179sfdU6xGDnDncWVYbwT5D7UulWTBomj6GeiNou562RxSTfl06K X-Received: by 2002:a50:f9cc:: with SMTP id a12mr71307529edq.335.1609790720081; Mon, 04 Jan 2021 12:05:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609790720; cv=none; d=google.com; s=arc-20160816; b=pNZhzFit44HvuU8PdHxn+Myt/8dHAuVu+jc3aCe+PP+f52Gm9b1RjM6eJgMX5n1H5S vVYJX9QlV/rEm70k7OedcXp96PXUye0zMk6LPx+9CplIpdm8qJweJfzzx0sTU3O3FEfu g7ajhnwQsSefng1iCufnmZX02T0/0scbsNBh0U29l75OSIsZsEvtpHoJAAS8asLfIfnq eA+YxD7sF5pf+SlUb1JmPc3inWyKnLgLmQJ9N3Aqo6S9z26JQnPBmyFDNNG5H4Sciizd z1Fk+/cbVIsrux/PcFxyXwJa7i3lE/b6kQ8gFcQlk1xGO4DQfe1cDmLtFNKOtEG5g0bi zAog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DikURUrmbI6Iiwg+UZdjkh/u0ADgA0u7xA8y3hb7fr8=; b=oeqDF9v/9rIp+L2waTET3z8OydsbhL8aa6PBrJdLxZpjvF99mLCyuOAYD678zVFuFh 6kU7Okoe/Gqj/eRNExkr/JBia3l2SUyZOKDN7ugfHC8ayY1mZOPR7w5aB82Q9wDW3xH1 ppwPvMNclo0rjbGMWgYLUN5BJX/bq6SVQw0VZLcsHmMtvLiu94P3lU8j7c2rzLqTL9X4 EgMHK+g0HUSBwQry9MkIvJrgJ6I0YpJ7vBlS64U9LmUsR3FmXCa+QC7rnd8zp+5zkRlG w5rCn9HjlBnKZbgygASCLFwlsnHoOYRZSxGK0//nxW7HtdWeFtDxVUJKz/x/c5SbkwKX vHTw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu24si32403528edb.378.2021.01.04.12.04.56; Mon, 04 Jan 2021 12:05:20 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728061AbhADUCs (ORCPT + 99 others); Mon, 4 Jan 2021 15:02:48 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:38689 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727672AbhADUCr (ORCPT ); Mon, 4 Jan 2021 15:02:47 -0500 Received: from debian.home (lfbn-gre-1-231-212.w90-112.abo.wanadoo.fr [90.112.190.212]) (Authenticated sender: alex@ghiti.fr) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 721C524000A; Mon, 4 Jan 2021 20:02:02 +0000 (UTC) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Zong Li , Anup Patel , Christoph Hellwig , Ard Biesheuvel , Arnd Bergmann , linux-efi@vger.kernel.org, linux-arch@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti , Palmer Dabbelt Subject: [RFC PATCH 03/12] riscv: Get rid of compile time logic with MAX_EARLY_MAPPING_SIZE Date: Mon, 4 Jan 2021 14:58:31 -0500 Message-Id: <20210104195840.1593-4-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210104195840.1593-1-alex@ghiti.fr> References: <20210104195840.1593-1-alex@ghiti.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Anup Patel Reviewed-by: Palmer Dabbelt --- arch/riscv/mm/init.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 7b87c14f1d24..694efcc3a131 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -296,13 +296,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); pmd_t early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE); static pmd_t *__init get_pmd_virt_early(phys_addr_t pa) @@ -324,11 +318,9 @@ static pmd_t *get_pmd_virt_late(phys_addr_t pa) static phys_addr_t __init alloc_pmd_early(uintptr_t va) { - uintptr_t pmd_num; + BUG_ON((va - kernel_virt_addr) >> PGDIR_SHIFT); - pmd_num = (va - kernel_virt_addr) >> PGDIR_SHIFT; - BUG_ON(pmd_num >= NUM_EARLY_PMDS); - return (uintptr_t)&early_pmd[pmd_num * PTRS_PER_PMD]; + return (uintptr_t)early_pmd; } static phys_addr_t __init alloc_pmd_fixmap(uintptr_t va) -- 2.20.1