From patchwork Wed Jul 9 09:39:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 33272 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3AF14203F4 for ; Wed, 9 Jul 2014 09:42:00 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id uy5sf39955019obc.5 for ; Wed, 09 Jul 2014 02:41:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=j3nJ1GJF/4Z4sbMNgzg0289wdYxulpeeAJgumprI6Tc=; b=IPzOwJR+Qk5xyyaMTps5iThsFLdtN+sdIIhg78TS5Hiwqn5WRLGlYak2dP5WrM2VxS Pf4gy2/zwdadK1yjGtm+uA5JG/ZeSG3BkJ/l8VKoZXoG11rRe/MaEQomc7w04LbNpF4g 8GUhMh4m4jwad6Nh78ayRP+0P7YXZIpEGXv7VCw77Qs/0mdkoVMucGkjcqIKN8/e9KMi OQ817L0r6Yl+jLnuLUG9Jn66DBRU3Q/eIDmRsVS6/AZTrm0a4gX0MgyUR1gnhqMl3CWA Jhmf9EWRT8Fqttkl7HEee7vC4L19Vl34urO4UrGRpSlcVlTktB9TtPDkYutmVoWSsThl +e1Q== X-Gm-Message-State: ALoCoQkGtWnOMU7ZGn1S2DTZ0GFOW7uj5ZQcFrJ4rtPf3BLVxOcjFmCNJuZ9irwvq3PHUvCMO53t X-Received: by 10.42.25.17 with SMTP id y17mr20477077icb.11.1404898919784; Wed, 09 Jul 2014 02:41:59 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.53 with SMTP id q50ls2593376qgd.2.gmail; Wed, 09 Jul 2014 02:41:59 -0700 (PDT) X-Received: by 10.52.27.208 with SMTP id v16mr32681613vdg.21.1404898919684; Wed, 09 Jul 2014 02:41:59 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id rd1si4234939vcb.39.2014.07.09.02.41.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jul 2014 02:41:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id ik5so6590210vcb.35 for ; Wed, 09 Jul 2014 02:41:59 -0700 (PDT) X-Received: by 10.220.68.140 with SMTP id v12mr38521337vci.13.1404898919592; Wed, 09 Jul 2014 02:41:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp31893vcb; Wed, 9 Jul 2014 02:41:59 -0700 (PDT) X-Received: by 10.66.163.98 with SMTP id yh2mr15027454pab.104.1404898918685; Wed, 09 Jul 2014 02:41:58 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id fb5si45600568pbd.178.2014.07.09.02.41.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jul 2014 02:41:58 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; 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 1X4oMr-0006Yc-8c; Wed, 09 Jul 2014 09:40:49 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X4oMH-0004VK-IX for linux-arm-kernel@lists.infradead.org; Wed, 09 Jul 2014 09:40:14 +0000 Received: by mail-wi0-f169.google.com with SMTP id hi2so2452983wib.2 for ; Wed, 09 Jul 2014 02:39:51 -0700 (PDT) X-Received: by 10.194.184.200 with SMTP id ew8mr13990268wjc.61.1404898791133; Wed, 09 Jul 2014 02:39:51 -0700 (PDT) Received: from mohikan.mushroom.smurfnet.nu (cpc4-cmbg17-2-0-cust71.5-4.cable.virginm.net. [86.14.224.72]) by mx.google.com with ESMTPSA id d4sm17320059wik.20.2014.07.09.02.39.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jul 2014 02:39:50 -0700 (PDT) From: Leif Lindholm To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk Subject: [PATCH 1/2] arm: use generic fixmap.h Date: Wed, 9 Jul 2014 10:39:51 +0100 Message-Id: <1404898792-4201-2-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1404898792-4201-1-git-send-email-leif.lindholm@linaro.org> References: <1404898792-4201-1-git-send-email-leif.lindholm@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140709_024013_941014_5B9DF108 X-CRM114-Status: GOOD ( 14.31 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.169 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.169 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: catalin.marinas@arm.com, will.deacon@arm.com, robh@kernel.org, arnd@arndb.de, msalter@redhat.com 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: leif.lindholm@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Mark Salter 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..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))) +#define __kmap_virt_to_fix(x) (FIX_KMAP_NR_PTES - 1 - __fix_to_virt(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