123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- #ifndef _ASM_ARC_MMU_CONTEXT_H
- #define _ASM_ARC_MMU_CONTEXT_H
- #include <asm/arcregs.h>
- #include <asm/tlb.h>
- #include <linux/sched/mm.h>
- #include <asm-generic/mm_hooks.h>
- #define MM_CTXT_ASID_MASK 0x000000ff
- #define MM_CTXT_CYCLE_MASK (~MM_CTXT_ASID_MASK)
- #define MM_CTXT_FIRST_CYCLE (MM_CTXT_ASID_MASK + 1)
- #define MM_CTXT_NO_ASID 0UL
- #define asid_mm(mm, cpu) mm->context.asid[cpu]
- #define hw_pid(mm, cpu) (asid_mm(mm, cpu) & MM_CTXT_ASID_MASK)
- DECLARE_PER_CPU(unsigned int, asid_cache);
- #define asid_cpu(cpu) per_cpu(asid_cache, cpu)
- static inline void get_new_mmu_context(struct mm_struct *mm)
- {
- const unsigned int cpu = smp_processor_id();
- unsigned long flags;
- local_irq_save(flags);
-
- if (!((asid_mm(mm, cpu) ^ asid_cpu(cpu)) & MM_CTXT_CYCLE_MASK))
- goto set_hw;
-
- if (unlikely(!(++asid_cpu(cpu) & MM_CTXT_ASID_MASK))) {
- local_flush_tlb_all();
-
- if (!asid_cpu(cpu))
- asid_cpu(cpu) = MM_CTXT_FIRST_CYCLE;
- }
-
- asid_mm(mm, cpu) = asid_cpu(cpu);
- set_hw:
- write_aux_reg(ARC_REG_PID, hw_pid(mm, cpu) | MMU_ENABLE);
- local_irq_restore(flags);
- }
- static inline int
- init_new_context(struct task_struct *tsk, struct mm_struct *mm)
- {
- int i;
- for_each_possible_cpu(i)
- asid_mm(mm, i) = MM_CTXT_NO_ASID;
- return 0;
- }
- static inline void destroy_context(struct mm_struct *mm)
- {
- unsigned long flags;
-
- local_irq_save(flags);
- asid_mm(mm, smp_processor_id()) = MM_CTXT_NO_ASID;
- local_irq_restore(flags);
- }
- static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
- struct task_struct *tsk)
- {
- const int cpu = smp_processor_id();
-
- cpumask_set_cpu(cpu, mm_cpumask(next));
- #ifndef CONFIG_SMP
-
- write_aux_reg(ARC_REG_SCRATCH_DATA0, next->pgd);
- #endif
- get_new_mmu_context(next);
- }
- #define activate_mm(prev, next) switch_mm(prev, next, NULL)
- #define deactivate_mm(tsk, mm) do { } while (0)
- #define enter_lazy_tlb(mm, tsk)
- #endif
|