Skip to content

Commit 629ed3f

Browse files
committed
xtensa/mm/highmem: Switch to generic kmap atomic
No reason having the same code in every architecture Signed-off-by: Thomas Gleixner <[email protected]> Cc: Chris Zankel <[email protected]> Cc: Max Filippov <[email protected]> Cc: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 3293efa commit 629ed3f

File tree

4 files changed

+18
-45
lines changed

4 files changed

+18
-45
lines changed

arch/xtensa/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ endchoice
666666
config HIGHMEM
667667
bool "High Memory Support"
668668
depends on MMU
669+
select KMAP_LOCAL
669670
help
670671
Linux can use the full amount of RAM in the system by
671672
default. However, the default MMUv2 setup only maps the

arch/xtensa/include/asm/fixmap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifdef CONFIG_HIGHMEM
1717
#include <linux/threads.h>
1818
#include <linux/pgtable.h>
19-
#include <asm/kmap_types.h>
19+
#include <asm/kmap_size.h>
2020
#endif
2121

2222
/*
@@ -39,7 +39,7 @@ enum fixed_addresses {
3939
/* reserved pte's for temporary kernel mappings */
4040
FIX_KMAP_BEGIN,
4141
FIX_KMAP_END = FIX_KMAP_BEGIN +
42-
(KM_TYPE_NR * NR_CPUS * DCACHE_N_COLORS) - 1,
42+
(KM_MAX_IDX * NR_CPUS * DCACHE_N_COLORS) - 1,
4343
#endif
4444
__end_of_fixed_addresses
4545
};

arch/xtensa/include/asm/highmem.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
#include <linux/pgtable.h>
1717
#include <asm/cacheflush.h>
1818
#include <asm/fixmap.h>
19-
#include <asm/kmap_types.h>
2019

21-
#define PKMAP_BASE ((FIXADDR_START - \
20+
#define PKMAP_BASE ((FIXADDR_START - \
2221
(LAST_PKMAP + 1) * PAGE_SIZE) & PMD_MASK)
2322
#define LAST_PKMAP (PTRS_PER_PTE * DCACHE_N_COLORS)
2423
#define LAST_PKMAP_MASK (LAST_PKMAP - 1)
@@ -68,6 +67,15 @@ static inline void flush_cache_kmaps(void)
6867
flush_cache_all();
6968
}
7069

70+
enum fixed_addresses kmap_local_map_idx(int type, unsigned long pfn);
71+
#define arch_kmap_local_map_idx kmap_local_map_idx
72+
73+
enum fixed_addresses kmap_local_unmap_idx(int type, unsigned long addr);
74+
#define arch_kmap_local_unmap_idx kmap_local_unmap_idx
75+
76+
#define arch_kmap_local_post_unmap(vaddr) \
77+
local_flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE)
78+
7179
void kmap_init(void);
7280

7381
#endif

arch/xtensa/mm/highmem.c

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include <linux/highmem.h>
1313
#include <asm/tlbflush.h>
1414

15-
static pte_t *kmap_pte;
16-
1715
#if DCACHE_WAY_SIZE > PAGE_SIZE
1816
unsigned int last_pkmap_nr_arr[DCACHE_N_COLORS];
1917
wait_queue_head_t pkmap_map_wait_arr[DCACHE_N_COLORS];
@@ -33,59 +31,25 @@ static inline void kmap_waitqueues_init(void)
3331

3432
static inline enum fixed_addresses kmap_idx(int type, unsigned long color)
3533
{
36-
return (type + KM_TYPE_NR * smp_processor_id()) * DCACHE_N_COLORS +
34+
return (type + KM_MAX_IDX * smp_processor_id()) * DCACHE_N_COLORS +
3735
color;
3836
}
3937

40-
void *kmap_atomic_high_prot(struct page *page, pgprot_t prot)
38+
enum fixed_addresses kmap_local_map_idx(int type, unsigned long pfn)
4139
{
42-
enum fixed_addresses idx;
43-
unsigned long vaddr;
44-
45-
idx = kmap_idx(kmap_atomic_idx_push(),
46-
DCACHE_ALIAS(page_to_phys(page)));
47-
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
48-
#ifdef CONFIG_DEBUG_HIGHMEM
49-
BUG_ON(!pte_none(*(kmap_pte + idx)));
50-
#endif
51-
set_pte(kmap_pte + idx, mk_pte(page, prot));
52-
53-
return (void *)vaddr;
40+
return kmap_idx(type, DCACHE_ALIAS(pfn << PAGE_SHIFT));
5441
}
55-
EXPORT_SYMBOL(kmap_atomic_high_prot);
5642

57-
void kunmap_atomic_high(void *kvaddr)
43+
enum fixed_addresses kmap_local_unmap_idx(int type, unsigned long addr)
5844
{
59-
if (kvaddr >= (void *)FIXADDR_START &&
60-
kvaddr < (void *)FIXADDR_TOP) {
61-
int idx = kmap_idx(kmap_atomic_idx(),
62-
DCACHE_ALIAS((unsigned long)kvaddr));
63-
64-
/*
65-
* Force other mappings to Oops if they'll try to access this
66-
* pte without first remap it. Keeping stale mappings around
67-
* is a bad idea also, in case the page changes cacheability
68-
* attributes or becomes a protected page in a hypervisor.
69-
*/
70-
pte_clear(&init_mm, kvaddr, kmap_pte + idx);
71-
local_flush_tlb_kernel_range((unsigned long)kvaddr,
72-
(unsigned long)kvaddr + PAGE_SIZE);
73-
74-
kmap_atomic_idx_pop();
75-
}
45+
return kmap_idx(type, DCACHE_ALIAS(addr));
7646
}
77-
EXPORT_SYMBOL(kunmap_atomic_high);
7847

7948
void __init kmap_init(void)
8049
{
81-
unsigned long kmap_vstart;
82-
8350
/* Check if this memory layout is broken because PKMAP overlaps
8451
* page table.
8552
*/
8653
BUILD_BUG_ON(PKMAP_BASE < TLBTEMP_BASE_1 + TLBTEMP_SIZE);
87-
/* cache the first kmap pte */
88-
kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
89-
kmap_pte = virt_to_kpte(kmap_vstart);
9054
kmap_waitqueues_init();
9155
}

0 commit comments

Comments
 (0)