Commit 0433ffc4 authored by Philippe Gerum's avatar Philippe Gerum
Browse files

arm64/ipipe: clarify mm switch helpers

parent 0e6c19a6
......@@ -112,23 +112,25 @@ extern void (*__ipipe_mach_hrtimer_debug)(unsigned irq);
#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
#define ipipe_mm_switch_protect(flags) \
#define ipipe_mm_switch_protect(__flags) \
do { \
(void)(flags); \
(void)(__flags); \
} while(0)
#define ipipe_mm_switch_unprotect(flags) \
#define ipipe_mm_switch_unprotect(__flags) \
do { \
(void)(flags); \
(void)(__flags); \
} while(0)
#else /* !CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH */
#define ipipe_mm_switch_protect(flags) \
flags = hard_cond_local_irq_save()
#define ipipe_mm_switch_protect(__flags) \
do { \
(__flags) = hard_cond_local_irq_save(); \
} while (0)
#define ipipe_mm_switch_unprotect(flags) \
hard_cond_local_irq_restore(flags)
#define ipipe_mm_switch_unprotect(__flags) \
hard_cond_local_irq_restore(__flags)
#endif /* !CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH */
......
......@@ -466,31 +466,32 @@ void __switch_mm_inner(struct mm_struct *prev, struct mm_struct *next,
{
struct mm_struct ** const active_mm =
raw_cpu_ptr(&ipipe_percpu.active_mm);
int ret;
#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
struct thread_info *const tip = current_thread_info();
unsigned long flags;
prev = *active_mm;
clear_bit(TIF_MMSWITCH_INT, &tip->flags);
barrier();
*active_mm = NULL;
barrier();
for (;;) {
#endif
int rc __maybe_unused = __do_switch_mm(prev, next, tsk, true);
#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
unsigned long flags;
ret = __do_switch_mm(prev, next, tsk, true);
/*
* Reading thread_info flags and setting active_mm
* must be done atomically.
*/
flags = hard_local_irq_save();
if (__test_and_clear_bit(TIF_MMSWITCH_INT, &tip->flags) == 0) {
*active_mm = rc < 0 ? prev : next;
*active_mm = ret < 0 ? prev : next;
hard_local_irq_restore(flags);
return;
}
hard_local_irq_restore(flags);
if (rc < 0)
if (ret < 0)
/*
* We were interrupted by head domain, which
* may have changed the mm context, mm context
......@@ -502,8 +503,9 @@ void __switch_mm_inner(struct mm_struct *prev, struct mm_struct *next,
prev = NULL;
}
#else
*active_mm = rc < 0 ? prev : next;
#endif
ret = __do_switch_mm(prev, next, tsk, true);
*active_mm = ret < 0 ? prev : next;
#endif /* CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH */
}
#ifdef finish_arch_post_lock_switch
......@@ -514,16 +516,15 @@ void deferred_switch_mm(struct mm_struct *next)
struct mm_struct *prev = *active_mm;
#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
struct thread_info *const tip = current_thread_info();
unsigned long flags;
clear_bit(TIF_MMSWITCH_INT, &tip->flags);
barrier();
*active_mm = NULL;
barrier();
for (;;) {
unsigned long __maybe_unused flags;
#endif
__do_switch_mm(prev, next, NULL, false);
#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
/*
* Reading thread_info flags and setting active_mm
* must be done atomically.
......@@ -538,10 +539,11 @@ void deferred_switch_mm(struct mm_struct *next)
prev = NULL;
}
#else
__do_switch_mm(prev, next, NULL, false);
*active_mm = next;
#endif
#endif /* CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH */
}
#endif
#endif /* finish_arch_post_lock_switch */
#endif /* CONFIG_MMU */
#ifndef CONFIG_IPIPE_ARM_KUSER_TSC
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment