blob: eb4e4207cd3caed204fecdaeb71956eaa1e0b074 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Nicolas Pitred73cd422008-09-15 16:44:55 -04002#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
Nicolas Pitre7e5a69e2010-03-29 21:46:02 +010015#define flush_cache_kmaps() \
16 do { \
17 if (cache_is_vivt()) \
18 flush_cache_all(); \
19 } while (0)
Nicolas Pitred73cd422008-09-15 16:44:55 -040020
21extern pte_t *pkmap_page_table;
22
23extern void *kmap_high(struct page *page);
Nicolas Pitred73cd422008-09-15 16:44:55 -040024extern void kunmap_high(struct page *page);
25
Nicolas Pitre7e5a69e2010-03-29 21:46:02 +010026/*
Nicolas Pitreaaa50042011-01-25 21:35:38 +010027 * The reason for kmap_high_get() is to ensure that the currently kmap'd
28 * page usage count does not decrease to zero while we're using its
29 * existing virtual mapping in an atomic context. With a VIVT cache this
30 * is essential to do, but with a VIPT cache this is only an optimization
31 * so not to pay the price of establishing a second mapping if an existing
32 * one can be used. However, on platforms without hardware TLB maintenance
33 * broadcast, we simply cannot use ARCH_NEEDS_KMAP_HIGH_GET at all since
34 * the locking involved must also disable IRQs which is incompatible with
35 * the IPI mechanism used by global TLB operations.
36 */
37#define ARCH_NEEDS_KMAP_HIGH_GET
38#if defined(CONFIG_SMP) && defined(CONFIG_CPU_TLB_V6)
39#undef ARCH_NEEDS_KMAP_HIGH_GET
40#if defined(CONFIG_HIGHMEM) && defined(CONFIG_CPU_CACHE_VIVT)
41#error "The sum of features in your kernel config cannot be supported together"
42#endif
43#endif
44
Catalin Marinas93dc6882013-03-26 23:35:04 +010045/*
46 * Needed to be able to broadcast the TLB invalidation for kmap.
47 */
48#ifdef CONFIG_ARM_ERRATA_798181
49#undef ARCH_NEEDS_KMAP_HIGH_GET
50#endif
51
Nicolas Pitreaaa50042011-01-25 21:35:38 +010052#ifdef ARCH_NEEDS_KMAP_HIGH_GET
53extern void *kmap_high_get(struct page *page);
54#else
55static inline void *kmap_high_get(struct page *page)
56{
57 return NULL;
58}
59#endif
60
61/*
Nicolas Pitre7e5a69e2010-03-29 21:46:02 +010062 * The following functions are already defined by <linux/highmem.h>
63 * when CONFIG_HIGHMEM is not set.
64 */
65#ifdef CONFIG_HIGHMEM
Nicolas Pitred73cd422008-09-15 16:44:55 -040066extern void *kmap(struct page *page);
67extern void kunmap(struct page *page);
Cong Wanga24401b2011-11-26 10:53:39 +080068extern void *kmap_atomic(struct page *page);
Peter Zijlstra3e4d3af2010-10-26 14:21:51 -070069extern void __kunmap_atomic(void *kvaddr);
70extern void *kmap_atomic_pfn(unsigned long pfn);
Nicolas Pitre7e5a69e2010-03-29 21:46:02 +010071#endif
Nicolas Pitred73cd422008-09-15 16:44:55 -040072
73#endif