Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp190614ybs; Sun, 24 May 2020 02:16:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoByoPo0bdoCsyivcVYrNQkd8xN10SFP8zrKzK1KZBvF8ae0p7E2gApvVZFRLoq50Fh2XH X-Received: by 2002:a17:906:ff54:: with SMTP id zo20mr14293682ejb.124.1590311763597; Sun, 24 May 2020 02:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590311763; cv=none; d=google.com; s=arc-20160816; b=nd0DQPjYziT+CfGbjhdzQwAEMuXYYbkj9HaoJpA1DjVum6eIlmmrTeJ0n+hd/zgnDI GRXDwniR89s3cltNG3mJhX04sAReYmJ6II8C3Q8mW/SR+9i9FkT9I9gSEjfHV/JKoSGd 07vR4af4Y+7qRrXG/sVkq0WtUHLyLoa3LD1NZt0BILwctzPSP4RHEHvm90RgJvsmgapP qcjxFj+TaYttZcdnIefl7mbffc7NC+unXgdit9akQ6ekBXcLOV7nPZh/OLeLW1dwl4yh M1ZXS6h1jlKQSfyMYR7z//3EyLAH3EWkiUKaDfvnnhRXyzhc6GKG0BmcAt1hu4rM9xQm o85Q== 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=mkyDO9P0LTsutq9QUvFaEqE+aLWaCRxlzaPGotaA4Kc=; b=iqRvQsC1wCS4TT+wC789PYApRh7U0l1iA9Ojfb9HHWBbJLWpPqtmj1L7px5Q4lI6Gg 39kQns6YbU39ewuex7+GZazDyY2RVt+rPgD08c7Z8QH/z4Dv7/veMq/a0ksWbQUtLNhv 5epSRXyHy96PQ9j1+BnA5gsVrH2Ns9kV5vs3vBNSpx4xSx0MmOdmTjlmxBWkF9goW/5d XBLPnJ5Xisz2fSVZER6O/VgKPO48jKyyzKgkQ68DtiTZr1Yxg8tXZ+rrnusgCxFQ8HIf ZZtW/ImXXQaO/KTcFgQiy6cu5RKApN4+Wy3jauxVFZGSYGIA0/3Zvjlsm0KKGD4sFTEf v7Mg== 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 g25si7009061edy.554.2020.05.24.02.15.41; Sun, 24 May 2020 02:16:03 -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; 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 S1728722AbgEXJLP (ORCPT + 99 others); Sun, 24 May 2020 05:11:15 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:47495 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728252AbgEXJLP (ORCPT ); Sun, 24 May 2020 05:11:15 -0400 X-Originating-IP: 90.112.45.105 Received: from localhost.localdomain (lfbn-gre-1-325-105.w90-112.abo.wanadoo.fr [90.112.45.105]) (Authenticated sender: alex@ghiti.fr) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id E8EF720002; Sun, 24 May 2020 09:11:11 +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 , Palmer Dabbelt Subject: [PATCH 1/8] riscv: Get rid of compile time logic with MAX_EARLY_MAPPING_SIZE Date: Sun, 24 May 2020 05:10:01 -0400 Message-Id: <20200524091008.25587-2-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200524091008.25587-1-alex@ghiti.fr> References: <20200524091008.25587-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 Reviewed-by: Anup Patel Reviewed-by: Palmer Dabbelt --- 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 7074522d40c6..5782cae58ac2 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -256,13 +256,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) { @@ -276,14 +270,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 - kernel_virt_addr) >> PGDIR_SHIFT; - BUG_ON(pmd_num >= NUM_EARLY_PMDS); - return (uintptr_t)&early_pmd[pmd_num * PTRS_PER_PMD]; + BUG_ON((va - kernel_virt_addr) >> PGDIR_SHIFT); + + return (uintptr_t)early_pmd; } static void __init create_pmd_mapping(pmd_t *pmdp, -- 2.20.1