From patchwork Tue May 6 22:58:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 4124641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CEB4FBFF02 for ; Tue, 6 May 2014 23:01:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E712520274 for ; Tue, 6 May 2014 23:01:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F310C20256 for ; Tue, 6 May 2014 23:01:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WhoK7-0000c3-6m; Tue, 06 May 2014 22:58:55 +0000 Received: from mail-oa0-x22f.google.com ([2607:f8b0:4003:c02::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WhoJs-0000Y4-TM for linux-arm-kernel@lists.infradead.org; Tue, 06 May 2014 22:58:41 +0000 Received: by mail-oa0-f47.google.com with SMTP id i7so219735oag.6 for ; Tue, 06 May 2014 15:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Ku/tsOVXazKxP2zuPRNazMIm6UkJpoSUlJ3rs2jZSQ=; b=d2sJltX12Gh5pXrPrCAXvr/gCJXVXdH5V9f8ISJGCp2bcvqb6ULiN5VrUPJaqzP4Hv YVhc5ksg+vRg+paM3xHnQruq2a8ROa7CGRHfdbaWL5DoWmLShP9Q/9DWnwRZupkByAGe wXxyfMUqhLqmZGozXde5wSgObzO4kOHli9VB1+9DPPCCvjAaJIjr3xUM5y5BxHo34moH onLqVYm99rkiJW+Zkk1pbM3b0UOa8jwHNnmPecOixvxbxhz3yitP1gEBqvh7fcy8Dvcf a8MV21Xl1EyDj9mZdQy3kx8mGUPk3gAiBIHWojdleOWPt9cwR4G0prqxw4+ZOKiU/DXA ThDg== X-Received: by 10.182.33.99 with SMTP id q3mr41021791obi.33.1399417099738; Tue, 06 May 2014 15:58:19 -0700 (PDT) Received: from localhost.localdomain (72-48-77-163.dyn.grandenetworks.net. [72.48.77.163]) by mx.google.com with ESMTPSA id dh8sm58001745oeb.10.2014.05.06.15.58.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 May 2014 15:58:19 -0700 (PDT) From: Rob Herring To: Russell King , linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] ARM: fixmap early permanent mapping support Date: Tue, 6 May 2014 17:58:07 -0500 Message-Id: <1399417087-24772-4-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1399417087-24772-1-git-send-email-robherring2@gmail.com> References: <1399417087-24772-1-git-send-email-robherring2@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140506_155841_002208_CDE49EE3 X-CRM114-Status: GOOD ( 18.84 ) X-Spam-Score: 0.1 (/) Cc: Catalin Marinas , Mark Salter , Leif Lindholm , Rob Herring X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rob Herring This adds early permanent mapping support to fixmap early mappings. Unlike early_ioremap mappings, permanent mappings are kept after paging_init. Each permament mapping must be explicitly added. Initially, the only permanent mapping is for early console. The early pmd and ptes are still destroyed and recreated since the attributes may change as the memory types are initialized. Cc: Mark Salter Cc: Russell King Signed-off-by: Rob Herring --- arch/arm/Kconfig | 3 +++ arch/arm/include/asm/fixmap.h | 7 +++++++ arch/arm/include/asm/mach/map.h | 1 + arch/arm/mm/early_ioremap.c | 22 ++++++++++++++++++++++ arch/arm/mm/mmu.c | 6 +++--- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index b33c68b..f15a096 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -188,6 +188,9 @@ config ARCH_HAS_CPUFREQ config ARCH_HAS_BANDGAP bool +config FIX_EARLYCON_MEM + def_bool EARLY_IOREMAP + config GENERIC_HWEIGHT bool default y diff --git a/arch/arm/include/asm/fixmap.h b/arch/arm/include/asm/fixmap.h index e36020c..3324599 100644 --- a/arch/arm/include/asm/fixmap.h +++ b/arch/arm/include/asm/fixmap.h @@ -1,6 +1,9 @@ #ifndef _ASM_FIXMAP_H #define _ASM_FIXMAP_H +#include +#include + /* * Nothing too fancy for now. * @@ -18,6 +21,8 @@ #define FIXADDR_TOP (FIXADDR_END - PAGE_SIZE) enum fixed_addresses { + FIX_EARLYCON_MEM_BASE, + __end_of_permanent_fixed_addresses, FIX_KMAP_BEGIN, FIX_KMAP_END = (FIXADDR_TOP - FIXADDR_START) >> PAGE_SHIFT, __end_of_fixed_addresses @@ -44,6 +49,8 @@ enum fixed_addresses { extern void __early_set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags); +#define __set_fixmap __early_set_fixmap + #include #endif diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h index f98c7f3..cc5ed24 100644 --- a/arch/arm/include/asm/mach/map.h +++ b/arch/arm/include/asm/mach/map.h @@ -39,6 +39,7 @@ enum { }; #ifdef CONFIG_MMU +extern void create_mapping(struct map_desc *); extern void iotable_init(struct map_desc *, int); extern void vm_reserve_area_early(unsigned long addr, unsigned long size, void *caller); diff --git a/arch/arm/mm/early_ioremap.c b/arch/arm/mm/early_ioremap.c index 0258a20..cf143115 100644 --- a/arch/arm/mm/early_ioremap.c +++ b/arch/arm/mm/early_ioremap.c @@ -86,5 +86,27 @@ void __init __early_set_fixmap(enum fixed_addresses idx, void __init early_ioremap_shutdown(void) { + int i; + pmd_clear(early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN))); + + /* Create new entries for permanent mappings */ + for (i = 0; i < __end_of_permanent_fixed_addresses; i++) { + pte_t *pte; + struct map_desc map; + + map.virtual = fix_to_virt(i); + pte = early_ioremap_pte(map.virtual); + + /* Only i/o device mappings are supported ATM */ + if (pte_none(*pte) || + (pte_val(*pte) & L_PTE_MT_MASK) != L_PTE_MT_DEV_SHARED) + continue; + + map.pfn = pte_pfn(*pte); + map.type = MT_DEVICE; + map.length = PAGE_SIZE; + + create_mapping(&map); + } } diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 9576f87..b2187f1 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -829,7 +829,7 @@ static void __init create_36bit_mapping(struct map_desc *md, * offsets, and we take full advantage of sections and * supersections. */ -static void __init create_mapping(struct map_desc *md) +void __init create_mapping(struct map_desc *md) { unsigned long addr, length, end; phys_addr_t phys; @@ -844,7 +844,7 @@ static void __init create_mapping(struct map_desc *md) } if ((md->type == MT_DEVICE || md->type == MT_ROM) && - md->virtual >= PAGE_OFFSET && + md->virtual >= PAGE_OFFSET && md->virtual < 0xffe00000 && (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) { printk(KERN_WARNING "BUG: mapping for 0x%08llx" " at 0x%08lx out of vmalloc space\n", @@ -1271,7 +1271,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc) early_trap_init(vectors); - for (addr = VMALLOC_START; addr; addr += PMD_SIZE) + for (addr = VMALLOC_START; addr < 0xffe00000; addr += PMD_SIZE) pmd_clear(pmd_off_k(addr)); /*