Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp312867ybg; Wed, 3 Jun 2020 01:15:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxhWo+VY55kP8Ijda6DlJW5z123PHRNw/AQPt0jmijvZDzN6upUDevECrfOlM3RukMknay X-Received: by 2002:a17:906:704c:: with SMTP id r12mr26139294ejj.308.1591172117463; Wed, 03 Jun 2020 01:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591172117; cv=none; d=google.com; s=arc-20160816; b=0RD6suvinYQdSEbcdsuA4StFFmSijxLYdoiTYRA4HMw+84IRDi6Cgb7O7ujCLR+D3g 2RMKSsiMY8DfpDJZiC29TfRdIqJkzcV0LVoQzpjPeXZekpEcbABsVhXPm1La2xqvdMLa UUiE1Uud+yxpI7a5cG4SJpIUtYWb0XrljVpZUQSjOFhvWH7m1N5p3sNPfJCsQvGCYoof lq7hIq9xYS9Zd6L6e+mrc4ynrSTXTgAH3nR3Sy/erUW4y6yjBi5+0qL4SJ2gg23KHBbs F1qJgLTnfhMhKS7Bx/Q3h5iiepfYs5oXTAycCbspkw5CUF+5qvaluKCU3o9PdUxrZN5p k5TA== 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=Qw4kliQN2Xn//pq1ZKzOgjmm3xivZPEnpIxia9E7GKo=; b=z26XfsYsCn73v9dKhwCf+yWl6ERFkCrC2EDdok/xWpBQ/yTDr3ffO5Im0CBJyzUnNN MGnWqs4bR+aGCb2c8swxFeNIx1+9/G4+juNmZnqi52xsGvZ/TELBNExWE5loG5Q8xggE PffJDLyN3sj7wfpLqawnqBrlERcZALGc3eLY/fphLlnBfJO7TNM4eKxGA6wBs0hyYAmL ltdTqF2LtQDeN+mAKnMity5Q8sKNsNDYpgkr07MvH8p38n5G5F6xYXmDqKNjwbTT63hr o1OEs/cVd1sFTkriFnYVzOWWiePWFoxsS0bnIt1U0E/KISAx/vt52kmZevgLL/Edmr1a 7Qug== 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 n4si732287edy.244.2020.06.03.01.14.55; Wed, 03 Jun 2020 01:15:17 -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 S1726383AbgFCIMQ (ORCPT + 99 others); Wed, 3 Jun 2020 04:12:16 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:33809 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726326AbgFCIMN (ORCPT ); Wed, 3 Jun 2020 04:12:13 -0400 X-Originating-IP: 90.112.45.105 Received: from debian.home (lfbn-gre-1-325-105.w90-112.abo.wanadoo.fr [90.112.45.105]) (Authenticated sender: alex@ghiti.fr) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 9EA72C0018; Wed, 3 Jun 2020 08:12:09 +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 v2 1/8] riscv: Get rid of compile time logic with MAX_EARLY_MAPPING_SIZE Date: Wed, 3 Jun 2020 04:10:57 -0400 Message-Id: <20200603081104.14004-2-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200603081104.14004-1-alex@ghiti.fr> References: <20200603081104.14004-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 e63ea5b6b6cf..80fd692b72d5 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