]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
d73cd428 NP |
2 | #ifndef _ASM_HIGHMEM_H |
3 | #define _ASM_HIGHMEM_H | |
4 | ||
5 | #include <asm/kmap_types.h> | |
6 | ||
7 | #define PKMAP_BASE (PAGE_OFFSET - PMD_SIZE) | |
8 | #define LAST_PKMAP PTRS_PER_PTE | |
9 | #define LAST_PKMAP_MASK (LAST_PKMAP - 1) | |
10 | #define PKMAP_NR(virt) (((virt) - PKMAP_BASE) >> PAGE_SHIFT) | |
11 | #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) | |
12 | ||
13 | #define kmap_prot PAGE_KERNEL | |
14 | ||
7e5a69e8 NP |
15 | #define flush_cache_kmaps() \ |
16 | do { \ | |
17 | if (cache_is_vivt()) \ | |
18 | flush_cache_all(); \ | |
19 | } while (0) | |
d73cd428 NP |
20 | |
21 | extern pte_t *pkmap_page_table; | |
a05e54c1 | 22 | extern pte_t *fixmap_page_table; |
d73cd428 | 23 | |
aaa50048 NP |
24 | extern void *kmap_high(struct page *page); |
25 | extern void kunmap_high(struct page *page); | |
26 | ||
27 | /* | |
28 | * The reason for kmap_high_get() is to ensure that the currently kmap'd | |
29 | * page usage count does not decrease to zero while we're using its | |
30 | * existing virtual mapping in an atomic context. With a VIVT cache this | |
31 | * is essential to do, but with a VIPT cache this is only an optimization | |
32 | * so not to pay the price of establishing a second mapping if an existing | |
33 | * one can be used. However, on platforms without hardware TLB maintenance | |
34 | * broadcast, we simply cannot use ARCH_NEEDS_KMAP_HIGH_GET at all since | |
35 | * the locking involved must also disable IRQs which is incompatible with | |
36 | * the IPI mechanism used by global TLB operations. | |
37 | */ | |
43377453 | 38 | #define ARCH_NEEDS_KMAP_HIGH_GET |
aaa50048 NP |
39 | #if defined(CONFIG_SMP) && defined(CONFIG_CPU_TLB_V6) |
40 | #undef ARCH_NEEDS_KMAP_HIGH_GET | |
41 | #if defined(CONFIG_HIGHMEM) && defined(CONFIG_CPU_CACHE_VIVT) | |
42 | #error "The sum of features in your kernel config cannot be supported together" | |
43 | #endif | |
44 | #endif | |
43377453 | 45 | |
93dc6887 CM |
46 | /* |
47 | * Needed to be able to broadcast the TLB invalidation for kmap. | |
48 | */ | |
49 | #ifdef CONFIG_ARM_ERRATA_798181 | |
50 | #undef ARCH_NEEDS_KMAP_HIGH_GET | |
51 | #endif | |
52 | ||
aaa50048 | 53 | #ifdef ARCH_NEEDS_KMAP_HIGH_GET |
43377453 | 54 | extern void *kmap_high_get(struct page *page); |
aaa50048 NP |
55 | #else |
56 | static inline void *kmap_high_get(struct page *page) | |
57 | { | |
58 | return NULL; | |
59 | } | |
60 | #endif | |
d73cd428 | 61 | |
7e5a69e8 NP |
62 | /* |
63 | * The following functions are already defined by <linux/highmem.h> | |
64 | * when CONFIG_HIGHMEM is not set. | |
65 | */ | |
66 | #ifdef CONFIG_HIGHMEM | |
d73cd428 NP |
67 | extern void *kmap(struct page *page); |
68 | extern void kunmap(struct page *page); | |
a24401bc | 69 | extern void *kmap_atomic(struct page *page); |
3e4d3af5 PZ |
70 | extern void __kunmap_atomic(void *kvaddr); |
71 | extern void *kmap_atomic_pfn(unsigned long pfn); | |
7e5a69e8 | 72 | #endif |
d73cd428 NP |
73 | |
74 | #endif |