mmu_context.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * arch/arm/include/asm/mmu_context.h
  3. *
  4. * Copyright (C) 1996 Russell King.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Changelog:
  11. * 27-06-1996 RMK Created
  12. */
  13. #ifndef __ASM_ARM_MMU_CONTEXT_H
  14. #define __ASM_ARM_MMU_CONTEXT_H
  15. #include <linux/compiler.h>
  16. #include <linux/sched.h>
  17. #include <asm/cacheflush.h>
  18. #include <asm/cachetype.h>
  19. #include <asm/proc-fns.h>
  20. #include <asm-generic/mm_hooks.h>
  21. void __check_vmalloc_seq(struct mm_struct *mm);
  22. #ifdef CONFIG_CPU_HAS_ASID
  23. void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
  24. #define init_new_context(tsk,mm) ({ atomic64_set(&mm->context.id, 0); 0; })
  25. #else /* !CONFIG_CPU_HAS_ASID */
  26. #ifdef CONFIG_MMU
  27. static inline void check_and_switch_context(struct mm_struct *mm,
  28. struct task_struct *tsk)
  29. {
  30. if (unlikely(mm->context.vmalloc_seq != init_mm.context.vmalloc_seq))
  31. __check_vmalloc_seq(mm);
  32. if (irqs_disabled())
  33. /*
  34. * cpu_switch_mm() needs to flush the VIVT caches. To avoid
  35. * high interrupt latencies, defer the call and continue
  36. * running with the old mm. Since we only support UP systems
  37. * on non-ASID CPUs, the old mm will remain valid until the
  38. * finish_arch_post_lock_switch() call.
  39. */
  40. set_ti_thread_flag(task_thread_info(tsk), TIF_SWITCH_MM);
  41. else
  42. cpu_switch_mm(mm->pgd, mm);
  43. }
  44. #define finish_arch_post_lock_switch \
  45. finish_arch_post_lock_switch
  46. static inline void finish_arch_post_lock_switch(void)
  47. {
  48. if (test_and_clear_thread_flag(TIF_SWITCH_MM)) {
  49. struct mm_struct *mm = current->mm;
  50. cpu_switch_mm(mm->pgd, mm);
  51. }
  52. }
  53. #endif /* CONFIG_MMU */
  54. #define init_new_context(tsk,mm) 0
  55. #endif /* CONFIG_CPU_HAS_ASID */
  56. #define destroy_context(mm) do { } while(0)
  57. #define activate_mm(prev,next) switch_mm(prev, next, NULL)
  58. /*
  59. * This is called when "tsk" is about to enter lazy TLB mode.
  60. *
  61. * mm: describes the currently active mm context
  62. * tsk: task which is entering lazy tlb
  63. * cpu: cpu number which is entering lazy tlb
  64. *
  65. * tsk->mm will be NULL
  66. */
  67. static inline void
  68. enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
  69. {
  70. }
  71. /*
  72. * This is the actual mm switch as far as the scheduler
  73. * is concerned. No registers are touched. We avoid
  74. * calling the CPU specific function when the mm hasn't
  75. * actually changed.
  76. */
  77. static inline void
  78. switch_mm(struct mm_struct *prev, struct mm_struct *next,
  79. struct task_struct *tsk)
  80. {
  81. #ifdef CONFIG_MMU
  82. unsigned int cpu = smp_processor_id();
  83. #ifdef CONFIG_SMP
  84. /* check for possible thread migration */
  85. if (!cpumask_empty(mm_cpumask(next)) &&
  86. !cpumask_test_cpu(cpu, mm_cpumask(next)))
  87. __flush_icache_all();
  88. #endif
  89. if (!cpumask_test_and_set_cpu(cpu, mm_cpumask(next)) || prev != next) {
  90. check_and_switch_context(next, tsk);
  91. if (cache_is_vivt())
  92. cpumask_clear_cpu(cpu, mm_cpumask(prev));
  93. }
  94. #endif
  95. }
  96. #define deactivate_mm(tsk,mm) do { } while (0)
  97. #endif