blob: 91b99abe7a95c114be0d3b628fb8b8d09f781c74 [file] [log] [blame]
Nicolas Pitred73cd422008-09-15 16:44:55 -04001#ifndef _ASM_HIGHMEM_H
2#define _ASM_HIGHMEM_H
3
4#include <asm/kmap_types.h>
5
6#define PKMAP_BASE (PAGE_OFFSET - PMD_SIZE)
7#define LAST_PKMAP PTRS_PER_PTE
8#define LAST_PKMAP_MASK (LAST_PKMAP - 1)
9#define PKMAP_NR(virt) (((virt) - PKMAP_BASE) >> PAGE_SHIFT)
10#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
11
12#define kmap_prot PAGE_KERNEL
13
Nicolas Pitre7e5a69e2010-03-29 21:46:02 +010014#define flush_cache_kmaps() \
15 do { \
16 if (cache_is_vivt()) \
17 flush_cache_all(); \
18 } while (0)
Nicolas Pitred73cd422008-09-15 16:44:55 -040019
20extern pte_t *pkmap_page_table;
21
22extern void *kmap_high(struct page *page);
Nicolas Pitred73cd422008-09-15 16:44:55 -040023extern void kunmap_high(struct page *page);
24
Nicolas Pitre7e5a69e2010-03-29 21:46:02 +010025/*
Nicolas Pitreaaa50042011-01-25 21:35:38 +010026 * The reason for kmap_high_get() is to ensure that the currently kmap'd
27 * page usage count does not decrease to zero while we're using its
28 * existing virtual mapping in an atomic context. With a VIVT cache this
29 * is essential to do, but with a VIPT cache this is only an optimization
30 * so not to pay the price of establishing a second mapping if an existing
31 * one can be used. However, on platforms without hardware TLB maintenance
32 * broadcast, we simply cannot use ARCH_NEEDS_KMAP_HIGH_GET at all since
33 * the locking involved must also disable IRQs which is incompatible with
34 * the IPI mechanism used by global TLB operations.
35 */
36#define ARCH_NEEDS_KMAP_HIGH_GET
37#if defined(CONFIG_SMP) && defined(CONFIG_CPU_TLB_V6)
38#undef ARCH_NEEDS_KMAP_HIGH_GET
39#if defined(CONFIG_HIGHMEM) && defined(CONFIG_CPU_CACHE_VIVT)
40#error "The sum of features in your kernel config cannot be supported together"
41#endif
42#endif
43
Catalin Marinas93dc6882013-03-26 23:35:04 +010044/*
45 * Needed to be able to broadcast the TLB invalidation for kmap.
46 */
47#ifdef CONFIG_ARM_ERRATA_798181
48#undef ARCH_NEEDS_KMAP_HIGH_GET
49#endif
50
Nicolas Pitreaaa50042011-01-25 21:35:38 +010051#ifdef ARCH_NEEDS_KMAP_HIGH_GET
52extern void *kmap_high_get(struct page *page);
53#else
54static inline void *kmap_high_get(struct page *page)
55{
56 return NULL;
57}
58#endif
59
60/*
Nicolas Pitre7e5a69e2010-03-29 21:46:02 +010061 * The following functions are already defined by <linux/highmem.h>
62 * when CONFIG_HIGHMEM is not set.
63 */
64#ifdef CONFIG_HIGHMEM
Nicolas Pitred73cd422008-09-15 16:44:55 -040065extern void *kmap(struct page *page);
66extern void kunmap(struct page *page);
Cong Wanga24401b2011-11-26 10:53:39 +080067extern void *kmap_atomic(struct page *page);
Peter Zijlstra3e4d3af2010-10-26 14:21:51 -070068extern void __kunmap_atomic(void *kvaddr);
69extern void *kmap_atomic_pfn(unsigned long pfn);
Nicolas Pitred73cd422008-09-15 16:44:55 -040070extern struct page *kmap_atomic_to_page(const void *ptr);
Nicolas Pitre7e5a69e2010-03-29 21:46:02 +010071#endif
Nicolas Pitred73cd422008-09-15 16:44:55 -040072
73#endif