From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fGABn-0006NN-0z for barebox@lists.infradead.org; Tue, 08 May 2018 21:30:31 +0000 Received: by mail-pl0-x243.google.com with SMTP id v24-v6so2976358plo.3 for ; Tue, 08 May 2018 14:30:20 -0700 (PDT) From: Andrey Smirnov Date: Tue, 8 May 2018 14:29:40 -0700 Message-Id: <20180508212951.6446-18-andrew.smirnov@gmail.com> In-Reply-To: <20180508212951.6446-1-andrew.smirnov@gmail.com> References: <20180508212951.6446-1-andrew.smirnov@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 17/28] ARM: mmu: Define and use PTRS_PER_PTE To: barebox@lists.infradead.org Cc: Andrey Smirnov Signed-off-by: Andrey Smirnov --- arch/arm/cpu/mmu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c index b4cc474d8..d70516f9c 100644 --- a/arch/arm/cpu/mmu.c +++ b/arch/arm/cpu/mmu.c @@ -34,6 +34,7 @@ #include "mmu.h" #define PMD_SECT_DEF_CACHED (PMD_SECT_WB | PMD_SECT_DEF_UNCACHED) +#define PTRS_PER_PTE (PGDIR_SIZE / PAGE_SIZE) static uint32_t *ttb; @@ -91,14 +92,15 @@ static u32 *arm_create_pte(unsigned long virt) u32 *table; int i; - table = memalign(0x400, 0x400); + table = memalign(PTRS_PER_PTE * sizeof(u32), + PTRS_PER_PTE * sizeof(u32)); if (!ttb) arm_mmu_not_initialized_error(); ttb[pgd_index(virt)] = (unsigned long)table | PMD_TYPE_TABLE; - for (i = 0; i < 256; i++) { + for (i = 0; i < PTRS_PER_PTE; i++) { table[i] = virt | PTE_TYPE_SMALL | pte_flags_uncached; virt += PAGE_SIZE; } @@ -242,7 +244,7 @@ static int arm_mmu_remap_sdram(struct memory_bank *bank) for (i = ttb_start; i < ttb_end; i++) { ttb[i] = (unsigned long)(&ptes[pte]) | PMD_TYPE_TABLE | (0 << 4); - pte += 256; + pte += PTRS_PER_PTE; } dma_flush_range((unsigned long)ttb, (unsigned long)ttb + 0x4000); -- 2.17.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox