18c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_MEMBARRIER_H
28c2ecf20Sopenharmony_ci#define _ASM_POWERPC_MEMBARRIER_H
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_cistatic inline void membarrier_arch_switch_mm(struct mm_struct *prev,
58c2ecf20Sopenharmony_ci					     struct mm_struct *next,
68c2ecf20Sopenharmony_ci					     struct task_struct *tsk)
78c2ecf20Sopenharmony_ci{
88c2ecf20Sopenharmony_ci	/*
98c2ecf20Sopenharmony_ci	 * Only need the full barrier when switching between processes.
108c2ecf20Sopenharmony_ci	 * Barrier when switching from kernel to userspace is not
118c2ecf20Sopenharmony_ci	 * required here, given that it is implied by mmdrop(). Barrier
128c2ecf20Sopenharmony_ci	 * when switching from userspace to kernel is not needed after
138c2ecf20Sopenharmony_ci	 * store to rq->curr.
148c2ecf20Sopenharmony_ci	 */
158c2ecf20Sopenharmony_ci	if (likely(!(atomic_read(&next->membarrier_state) &
168c2ecf20Sopenharmony_ci		     (MEMBARRIER_STATE_PRIVATE_EXPEDITED |
178c2ecf20Sopenharmony_ci		      MEMBARRIER_STATE_GLOBAL_EXPEDITED)) || !prev))
188c2ecf20Sopenharmony_ci		return;
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci	/*
218c2ecf20Sopenharmony_ci	 * The membarrier system call requires a full memory barrier
228c2ecf20Sopenharmony_ci	 * after storing to rq->curr, before going back to user-space.
238c2ecf20Sopenharmony_ci	 */
248c2ecf20Sopenharmony_ci	smp_mb();
258c2ecf20Sopenharmony_ci}
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_MEMBARRIER_H */
28