License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / arch / parisc / include / asm / mmu_context.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2#ifndef __PARISC_MMU_CONTEXT_H
3#define __PARISC_MMU_CONTEXT_H
4
5#include <linux/mm.h>
e8edc6e0 6#include <linux/sched.h>
60063497 7#include <linux/atomic.h>
1da177e4
LT
8#include <asm/pgalloc.h>
9#include <asm/pgtable.h>
d6dd61c8 10#include <asm-generic/mm_hooks.h>
1da177e4
LT
11
12static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13{
14}
15
16/* on PA-RISC, we actually have enough contexts to justify an allocator
17 * for them. prumpf */
18
19extern unsigned long alloc_sid(void);
20extern void free_sid(unsigned long);
21
22static inline int
23init_new_context(struct task_struct *tsk, struct mm_struct *mm)
24{
25 BUG_ON(atomic_read(&mm->mm_users) != 1);
26
27 mm->context = alloc_sid();
28 return 0;
29}
30
31static inline void
32destroy_context(struct mm_struct *mm)
33{
34 free_sid(mm->context);
35 mm->context = 0;
36}
37
70da2d96 38static inline unsigned long __space_to_prot(mm_context_t context)
1da177e4 39{
1da177e4 40#if SPACEID_SHIFT == 0
a60715f5 41 return context << 1;
1da177e4 42#else
a60715f5 43 return context >> (SPACEID_SHIFT - 1);
1da177e4
LT
44#endif
45}
46
a60715f5
KM
47static inline void load_context(mm_context_t context)
48{
49 mtsp(context, 3);
50 mtctl(__space_to_prot(context), 8);
51}
52
649aa242
HD
53static inline void switch_mm_irqs_off(struct mm_struct *prev,
54 struct mm_struct *next, struct task_struct *tsk)
1da177e4 55{
1da177e4
LT
56 if (prev != next) {
57 mtctl(__pa(next->pgd), 25);
58 load_context(next->context);
59 }
60}
61
649aa242
HD
62static inline void switch_mm(struct mm_struct *prev,
63 struct mm_struct *next, struct task_struct *tsk)
64{
65 unsigned long flags;
66
d2883fa1
JDA
67 if (prev == next)
68 return;
69
649aa242
HD
70 local_irq_save(flags);
71 switch_mm_irqs_off(prev, next, tsk);
72 local_irq_restore(flags);
73}
74#define switch_mm_irqs_off switch_mm_irqs_off
75
1da177e4
LT
76#define deactivate_mm(tsk,mm) do { } while (0)
77
78static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
79{
80 /*
81 * Activate_mm is our one chance to allocate a space id
82 * for a new mm created in the exec path. There's also
83 * some lazy tlb stuff, which is currently dead code, but
84 * we only allocate a space id if one hasn't been allocated
85 * already, so we should be OK.
86 */
87
88 BUG_ON(next == &init_mm); /* Should never happen */
89
90 if (next->context == 0)
91 next->context = alloc_sid();
92
93 switch_mm(prev,next,current);
94}
95#endif