From patchwork Fri Jul 18 14:33:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 4585391 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 712159F37C for ; Fri, 18 Jul 2014 14:35:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73D5520176 for ; Fri, 18 Jul 2014 14:35:33 +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 7E33420166 for ; Fri, 18 Jul 2014 14:35:32 +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 1X89ED-0003c7-31; Fri, 18 Jul 2014 14:33:41 +0000 Received: from mail-wg0-f50.google.com ([74.125.82.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X89E9-0003NC-5U for linux-arm-kernel@lists.infradead.org; Fri, 18 Jul 2014 14:33:38 +0000 Received: by mail-wg0-f50.google.com with SMTP id n12so3575925wgh.33 for ; Fri, 18 Jul 2014 07:33:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=/DwNBEYmB5o0sE20XtfsTu8Dq29PaNkF3LoBckl9pl0=; b=R8ak17GKZODOHoEwmO93Yn/ixV7+MHctAKOdscQitdhOrhzzv9+rGOiP9mhwprac6m 4X9CDsLXxen6qxcFoy5dKsvv8RsFv0LFxEhui2NiJW6atI73d3LvMUPAgA4Z5aOJvKAJ 0zRwVNym22zxeMIZ+IsOImwJIQ/xmr6QZsilHGaU5CtWNJdPoj+tbs7OXebwELgeDvaP ccFkPNpyJlOEz70Yfuy45ur1fkwNNmjawIVXB/gpKcMU/LncESnKkZxrkrpGls/DEtKX LxBBtob9ner/ACOzv+XD3f1qCmO+nWI1Yz4W8x5RpEhJGXT/L7R539nAa4Le+/mYtS44 SEJw== X-Gm-Message-State: ALoCoQlXHvhRy1o4PMfFfEzXmZb05hzczf9bTM11LVTgQc6CZdwCuJ+q7dk/FSmhgsJHnTK8Lh4R X-Received: by 10.180.94.234 with SMTP id df10mr17446763wib.76.1405693992330; Fri, 18 Jul 2014 07:33:12 -0700 (PDT) Received: from bivouac.eciton.net ([2a00:1098:0:86:1000:23:0:2]) by mx.google.com with ESMTPSA id fu7sm7364980wib.2.2014.07.18.07.33.10 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 18 Jul 2014 07:33:11 -0700 (PDT) Date: Fri, 18 Jul 2014 15:33:08 +0100 From: Leif Lindholm To: Mark Salter Subject: Re: [PATCH 1/2] arm: use generic fixmap.h Message-ID: <20140718143308.GA4179@bivouac.eciton.net> References: <1404898792-4201-1-git-send-email-leif.lindholm@linaro.org> <1404898792-4201-2-git-send-email-leif.lindholm@linaro.org> <1404938942.24950.12.camel@deneb.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1404938942.24950.12.camel@deneb.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140718_073337_505000_FCB0612B X-CRM114-Status: GOOD ( 19.47 ) X-Spam-Score: -0.7 (/) Cc: robh@kernel.org, linux@arm.linux.org.uk, arnd@arndb.de, catalin.marinas@arm.com, will.deacon@arm.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, 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 On Wed, Jul 09, 2014 at 04:49:02PM -0400, Mark Salter wrote: > On Wed, 2014-07-09 at 10:39 +0100, Leif Lindholm wrote: > > diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c > > index 45aeaac..3c59cdf 100644 > > --- a/arch/arm/mm/highmem.c > > +++ b/arch/arm/mm/highmem.c > > @@ -20,16 +20,19 @@ > > > > pte_t *fixmap_page_table; > > > > +#define __kmap_fix_to_virt(x) (__fix_to_virt(FIX_KMAP_NR_PTES - 1 - (x))) > > FIX_KMAP_END - (x) ? > > > +#define __kmap_virt_to_fix(x) (FIX_KMAP_NR_PTES - 1 - __fix_to_virt(x)) > > shouldn't this use __virt_to_fix(x)? Err, clearly. Good thing I managed to mess up the end of the interface that actually isn't used anywhere in the kernel(!). Fixed in the below. / Leif From d0a82cd19000139d32232f415bcf46f476c16561 Mon Sep 17 00:00:00 2001 From: Mark Salter Date: Thu, 14 Nov 2013 11:37:32 -0500 Subject: [PATCH 1/2] arm: use generic fixmap.h ARM is different from other architectures in that fixmap pages are indexed with a positive offset from FIXADDR_START. Other architectures index with a negative offset from FIXADDR_TOP. In order to use the generic fixmap.h definitions, this patch redefines FIXADDR_TOP to be inclusive of the useable range. That is, FIXADDR_TOP is the virtual address of the topmost fixed page. The newly defined FIXADDR_END is the first virtual address past the fixed mappings. The patch also introduces local helper macros in highmem.c to reverse the iteration order of fixmap pages. Signed-off-by: Mark Salter [Rebased to 3.16-rc4, reverse kmap fixmap traversal] Signed-off-by: Leif Lindholm --- arch/arm/include/asm/fixmap.h | 45 ++++++++++++++++++++++++++--------------- arch/arm/mm/highmem.c | 13 +++++++----- arch/arm/mm/init.c | 2 +- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/arch/arm/include/asm/fixmap.h b/arch/arm/include/asm/fixmap.h index 74124b0..8992431 100644 --- a/arch/arm/include/asm/fixmap.h +++ b/arch/arm/include/asm/fixmap.h @@ -1,28 +1,41 @@ #ifndef _ASM_FIXMAP_H #define _ASM_FIXMAP_H +#include + #define FIXADDR_START 0xffc00000UL -#define FIXADDR_TOP 0xffe00000UL -#define FIXADDR_SIZE (FIXADDR_TOP - FIXADDR_START) +#define FIXADDR_END 0xffe00000UL +#define FIXADDR_SIZE (FIXADDR_END - FIXADDR_START) +#define FIXADDR_TOP (FIXADDR_END - PAGE_SIZE) #define FIX_KMAP_NR_PTES (FIXADDR_SIZE >> PAGE_SHIFT) -#define __fix_to_virt(x) (FIXADDR_START + ((x) << PAGE_SHIFT)) -#define __virt_to_fix(x) (((x) - FIXADDR_START) >> PAGE_SHIFT) +enum fixed_addresses { + FIX_KMAP_BEGIN, + FIX_KMAP_END = FIX_KMAP_NR_PTES - 1, + __end_of_fixed_addresses +}; + +/* + * Temporary boot-time mappings, used by early_ioremap(), + * before ioremap() is functional. + * + * (P)re-using the last pmd of the FIXADDR region, which is used for + * highmem later on, and statically aligned to 1MB. + * Growing down from FIXADDR_TOP + */ +#define NR_FIX_BTMAPS 32 +#define FIX_BTMAPS_SLOTS (PTRS_PER_PTE / NR_FIX_BTMAPS) +#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) +#define FIX_BTMAP_END FIX_KMAP_BEGIN +#define FIX_BTMAP_BEGIN (FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1) -extern void __this_fixmap_does_not_exist(void); +#define FIXMAP_PAGE_NORMAL (L_PTE_MT_WRITEBACK | L_PTE_YOUNG | L_PTE_PRESENT) +#define FIXMAP_PAGE_IO (L_PTE_MT_DEV_NONSHARED | L_PTE_YOUNG | L_PTE_PRESENT) -static inline unsigned long fix_to_virt(const unsigned int idx) -{ - if (idx >= FIX_KMAP_NR_PTES) - __this_fixmap_does_not_exist(); - return __fix_to_virt(idx); -} +extern void __early_set_fixmap(enum fixed_addresses idx, + phys_addr_t phys, pgprot_t flags); -static inline unsigned int virt_to_fix(const unsigned long vaddr) -{ - BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); - return __virt_to_fix(vaddr); -} +#include #endif diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c index 45aeaac..2e5b773 100644 --- a/arch/arm/mm/highmem.c +++ b/arch/arm/mm/highmem.c @@ -20,16 +20,19 @@ pte_t *fixmap_page_table; +#define __kmap_fix_to_virt(x) (__fix_to_virt(FIX_KMAP_NR_PTES - 1 - (x))) +#define __kmap_virt_to_fix(x) (FIX_KMAP_NR_PTES - 1 - __virt_to_fix(x)) + static inline void set_fixmap_pte(int idx, pte_t pte) { - unsigned long vaddr = __fix_to_virt(idx); + unsigned long vaddr = __kmap_fix_to_virt(idx); set_pte_ext(fixmap_page_table + idx, pte, 0); local_flush_tlb_kernel_page(vaddr); } static inline pte_t get_fixmap_pte(unsigned long vaddr) { - unsigned long idx = __virt_to_fix(vaddr); + unsigned long idx = __kmap_virt_to_fix(vaddr); return *(fixmap_page_table + idx); } @@ -78,7 +81,7 @@ void *kmap_atomic(struct page *page) type = kmap_atomic_idx_push(); idx = type + KM_TYPE_NR * smp_processor_id(); - vaddr = __fix_to_virt(idx); + vaddr = __kmap_fix_to_virt(idx); #ifdef CONFIG_DEBUG_HIGHMEM /* * With debugging enabled, kunmap_atomic forces that entry to 0. @@ -109,7 +112,7 @@ void __kunmap_atomic(void *kvaddr) if (cache_is_vivt()) __cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE); #ifdef CONFIG_DEBUG_HIGHMEM - BUG_ON(vaddr != __fix_to_virt(idx)); + BUG_ON(vaddr != __kmap_fix_to_virt(idx)); set_fixmap_pte(idx, __pte(0)); #else (void) idx; /* to kill a warning */ @@ -132,7 +135,7 @@ void *kmap_atomic_pfn(unsigned long pfn) type = kmap_atomic_idx_push(); idx = type + KM_TYPE_NR * smp_processor_id(); - vaddr = __fix_to_virt(idx); + vaddr = __kmap_fix_to_virt(idx); #ifdef CONFIG_DEBUG_HIGHMEM BUG_ON(!pte_none(*(fixmap_page_table + idx))); #endif diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 659c75d..ad82c05 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -570,7 +570,7 @@ void __init mem_init(void) MLK(DTCM_OFFSET, (unsigned long) dtcm_end), MLK(ITCM_OFFSET, (unsigned long) itcm_end), #endif - MLK(FIXADDR_START, FIXADDR_TOP), + MLK(FIXADDR_START, FIXADDR_END), MLM(VMALLOC_START, VMALLOC_END), MLM(PAGE_OFFSET, (unsigned long)high_memory), #ifdef CONFIG_HIGHMEM