From patchwork Sat Jul 14 02:03:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 1197321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 816F0DFFFD for ; Sat, 14 Jul 2012 02:11:00 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Sprkc-0006LT-ES; Sat, 14 Jul 2012 02:06:30 +0000 Received: from mail-ob0-f177.google.com ([209.85.214.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Sprih-0006FL-SG for linux-arm-kernel@lists.infradead.org; Sat, 14 Jul 2012 02:04:35 +0000 Received: by obbta17 with SMTP id ta17so5800682obb.36 for ; Fri, 13 Jul 2012 19:04:30 -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:x-mailer:in-reply-to:references; bh=va8aQX6s327sieMiYzsOaMjkBHlRLVdVmLcJSMNIYQs=; b=u9fXw6n9nHL50nIxj2IsLxskCarjVoirWB0HTkixBukEQyracD2LU7MnlNohFDZRXU B8KP8Qx4VHWUhMdRUeTjlTdEJDJwxh1ehdZBgml68fbFfZUqQanTSa7LGG37xNf2UJj0 ozLt69zH3jwITpRpHbFIkQQku4fEKiZRW08Lz/euo9ooDRgZSYL2XgCToV43gCZFg5uS FLkAQUu8JPKzhSvxJYAKH5vLeCTeTBa4SZ35mYLxh3S2y+2pOUA8kpt5mqCaaIEF+JvM PXoz+EdCJTaFOK+UZTwYIXdTOimJzCN7MmZF49q8FbfUVEoqjmvQJZ8IDSzz0GPv9FYI l8UQ== Received: by 10.60.24.4 with SMTP id q4mr4539188oef.50.1342231470419; Fri, 13 Jul 2012 19:04:30 -0700 (PDT) Received: from rob-laptop.grandecom.net (65-36-72-55.dyn.grandenetworks.net. [65.36.72.55]) by mx.google.com with ESMTPS id i2sm7899752obn.19.2012.07.13.19.04.27 (version=SSLv3 cipher=OTHER); Fri, 13 Jul 2012 19:04:28 -0700 (PDT) From: Rob Herring To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 01/15] ARM: Add fixed PCI i/o mapping Date: Fri, 13 Jul 2012 21:03:57 -0500 Message-Id: <1342231451-28861-2-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1342231451-28861-1-git-send-email-robherring2@gmail.com> References: <1342231451-28861-1-git-send-email-robherring2@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (robherring2[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (robherring2[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Andrew Lunn , Stephen Warren , Jason Cooper , Arnd Bergmann , Nicolas Pitre , thierry.reding@avionic-design.de, Rob Herring , bhelgaas@google.com, Nicolas Pitre , Colin Cross , Olof Johansson , Russell King X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Rob Herring This adds a fixed virtual mapping for PCI i/o addresses. The mapping is located at the last 2MB of vmalloc region (0xfee00000-0xff000000). 2MB is used to align with PMD size, but IO_SPACE_LIMIT is 1MB. The space is reserved just before .map_io and can be mapped at any time later with pci_ioremap_io. This has changed completely from the 1st implementation which only supported creating the static mapping at .map_io. Signed-off-by: Rob Herring Cc: Russell King Cc: Nicolas Pitre Acked-by: Nicolas Pitre --- Documentation/arm/memory.txt | 3 +++ arch/arm/include/asm/io.h | 8 ++++++++ arch/arm/include/asm/mach/map.h | 7 +++++++ arch/arm/include/asm/mach/pci.h | 15 +++++++++++++++ arch/arm/kernel/bios32.c | 1 + arch/arm/mm/ioremap.c | 14 ++++++++++++++ arch/arm/mm/mmu.c | 25 +++++++++++++++++-------- 7 files changed, 65 insertions(+), 8 deletions(-) diff --git a/Documentation/arm/memory.txt b/Documentation/arm/memory.txt index 208a2d4..83e9b18 100644 --- a/Documentation/arm/memory.txt +++ b/Documentation/arm/memory.txt @@ -51,6 +51,9 @@ ffc00000 ffefffff DMA memory mapping region. Memory returned ff000000 ffbfffff Reserved for future expansion of DMA mapping region. +fef00000 feffffff Mapping of PCI I/O space. This is a static + mapping within the vmalloc space. + VMALLOC_START VMALLOC_END-1 vmalloc() / ioremap() space. Memory returned by vmalloc/ioremap will be dynamically placed in this region. diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h index 815c669..8f4db67 100644 --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h @@ -113,11 +113,19 @@ static inline void __iomem *__typesafe_io(unsigned long addr) #define __iowmb() do { } while (0) #endif +/* PCI fixed i/o mapping */ +#define PCI_IO_VIRT_BASE 0xfee00000 + +extern int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr); + /* * Now, pick up the machine-defined IO definitions */ #ifdef CONFIG_NEED_MACH_IO_H #include +#elif defined(CONFIG_PCI) +#define IO_SPACE_LIMIT ((resource_size_t)0xfffff) +#define __io(a) __typesafe_io(PCI_IO_VIRT_BASE + ((a) & IO_SPACE_LIMIT)) #else #define __io(a) __typesafe_io((a) & IO_SPACE_LIMIT) #endif diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h index a6efcdd..808c517 100644 --- a/arch/arm/include/asm/mach/map.h +++ b/arch/arm/include/asm/mach/map.h @@ -9,6 +9,9 @@ * * Page table mapping constructs and function prototypes */ +#ifndef __ASM_MACH_MAP_H +#define __ASM_MACH_MAP_H + #include struct map_desc { @@ -34,6 +37,7 @@ struct map_desc { #ifdef CONFIG_MMU extern void iotable_init(struct map_desc *, int); +extern void vm_reserve_area_early(unsigned long addr, unsigned long size); struct mem_type; extern const struct mem_type *get_mem_type(unsigned int type); @@ -44,4 +48,7 @@ extern int ioremap_page(unsigned long virt, unsigned long phys, const struct mem_type *mtype); #else #define iotable_init(map,num) do { } while (0) +#define vm_reserve_area_early(a,s) do { } while (0) +#endif + #endif diff --git a/arch/arm/include/asm/mach/pci.h b/arch/arm/include/asm/mach/pci.h index 26c511f..51630c0 100644 --- a/arch/arm/include/asm/mach/pci.h +++ b/arch/arm/include/asm/mach/pci.h @@ -11,6 +11,8 @@ #ifndef __ASM_MACH_PCI_H #define __ASM_MACH_PCI_H +#include + struct pci_sys_data; struct pci_ops; struct pci_bus; @@ -55,6 +57,19 @@ struct pci_sys_data { void pci_common_init(struct hw_pci *); /* + * Setup fixed I/O mapping. + */ +#if defined(CONFIG_PCI) && !defined(CONFIG_NEED_MACH_IO_H) +/* Called from devicemaps_init before .map_io */ +static inline void pci_reserve_io(void) +{ + vm_reserve_area_early(PCI_IO_VIRT_BASE, SZ_2M); +} +#else +static inline void pci_reserve_io(void) {} +#endif + +/* * PCI controllers */ extern struct pci_ops iop3xx_ops; diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index 2555250..311e1cc 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -13,6 +13,7 @@ #include #include +#include #include static int debug_pci; diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c index 4f55f50..8727802 100644 --- a/arch/arm/mm/ioremap.c +++ b/arch/arm/mm/ioremap.c @@ -36,6 +36,7 @@ #include #include +#include #include "mm.h" int ioremap_page(unsigned long virt, unsigned long phys, @@ -383,3 +384,16 @@ void __arm_iounmap(volatile void __iomem *io_addr) arch_iounmap(io_addr); } EXPORT_SYMBOL(__arm_iounmap); + +#ifdef CONFIG_PCI +int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr) +{ + BUG_ON(offset + SZ_64K > IO_SPACE_LIMIT); + + return ioremap_page_range(PCI_IO_VIRT_BASE + offset, + PCI_IO_VIRT_BASE + offset + SZ_64K, + phys_addr, + __pgprot(get_mem_type(MT_DEVICE)->prot_pte)); +} +EXPORT_SYMBOL_GPL(pci_ioremap_io); +#endif diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index cf4528d..c5ca07b 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -31,6 +31,7 @@ #include #include +#include #include "mm.h" @@ -791,6 +792,18 @@ void __init iotable_init(struct map_desc *io_desc, int nr) } } +void __init vm_reserve_area_early(unsigned long addr, unsigned long size) +{ + struct vm_struct *vm; + + vm = early_alloc_aligned(sizeof(*vm), __alignof__(*vm)); + vm->addr = (void *)addr; + vm->size = size; + vm->flags = VM_IOREMAP | VM_ARM_STATIC_MAPPING; + vm->caller = vm_reserve_area_early; + vm_area_add_early(vm++); +} + #ifndef CONFIG_ARM_LPAE /* @@ -808,14 +821,7 @@ void __init iotable_init(struct map_desc *io_desc, int nr) static void __init pmd_empty_section_gap(unsigned long addr) { - struct vm_struct *vm; - - vm = early_alloc_aligned(sizeof(*vm), __alignof__(*vm)); - vm->addr = (void *)addr; - vm->size = SECTION_SIZE; - vm->flags = VM_IOREMAP | VM_ARM_STATIC_MAPPING; - vm->caller = pmd_empty_section_gap; - vm_area_add_early(vm); + vm_reserve_area_early(addr, SECTION_SIZE); } static void __init fill_pmd_gaps(void) @@ -1140,6 +1146,9 @@ static void __init devicemaps_init(struct machine_desc *mdesc) create_mapping(&map); } + /* Reserve fixed i/o space in VMALLOC region */ + pci_reserve_io(); + /* * Ask the machine support to map in the statically mapped devices. */