mm: fix exec activate_mm vs TLB shootdown and lazy tlb switching race
[linux/fpc-iii.git] / arch / xtensa / mm / ioremap.c
blobd89c3c5fd962de011c80f41e0e1ebf8cf3a221c6
1 /*
2 * ioremap implementation.
4 * Copyright (C) 2015 Cadence Design Systems Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
11 #include <linux/io.h>
12 #include <linux/vmalloc.h>
13 #include <asm/cacheflush.h>
14 #include <asm/io.h>
15 #include <asm/pgtable.h>
17 static void __iomem *xtensa_ioremap(unsigned long paddr, unsigned long size,
18 pgprot_t prot)
20 unsigned long offset = paddr & ~PAGE_MASK;
21 unsigned long pfn = __phys_to_pfn(paddr);
22 struct vm_struct *area;
23 unsigned long vaddr;
24 int err;
26 paddr &= PAGE_MASK;
28 WARN_ON(pfn_valid(pfn));
30 size = PAGE_ALIGN(offset + size);
32 area = get_vm_area(size, VM_IOREMAP);
33 if (!area)
34 return NULL;
36 vaddr = (unsigned long)area->addr;
37 area->phys_addr = paddr;
39 err = ioremap_page_range(vaddr, vaddr + size, paddr, prot);
41 if (err) {
42 vunmap((void *)vaddr);
43 return NULL;
46 flush_cache_vmap(vaddr, vaddr + size);
47 return (void __iomem *)(offset + vaddr);
50 void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size)
52 return xtensa_ioremap(addr, size, pgprot_noncached(PAGE_KERNEL));
54 EXPORT_SYMBOL(xtensa_ioremap_nocache);
56 void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size)
58 return xtensa_ioremap(addr, size, PAGE_KERNEL);
60 EXPORT_SYMBOL(xtensa_ioremap_cache);
62 void xtensa_iounmap(volatile void __iomem *io_addr)
64 void *addr = (void *)(PAGE_MASK & (unsigned long)io_addr);
66 vunmap(addr);
68 EXPORT_SYMBOL(xtensa_iounmap);