162306a36Sopenharmony_ci#ifndef _ASM_POWERPC_MEMBARRIER_H
262306a36Sopenharmony_ci#define _ASM_POWERPC_MEMBARRIER_H
362306a36Sopenharmony_ci
462306a36Sopenharmony_cistatic inline void membarrier_arch_switch_mm(struct mm_struct *prev,
562306a36Sopenharmony_ci					     struct mm_struct *next,
662306a36Sopenharmony_ci					     struct task_struct *tsk)
762306a36Sopenharmony_ci{
862306a36Sopenharmony_ci	/*
962306a36Sopenharmony_ci	 * Only need the full barrier when switching between processes.
1062306a36Sopenharmony_ci	 * Barrier when switching from kernel to userspace is not
1162306a36Sopenharmony_ci	 * required here, given that it is implied by mmdrop(). Barrier
1262306a36Sopenharmony_ci	 * when switching from userspace to kernel is not needed after
1362306a36Sopenharmony_ci	 * store to rq->curr.
1462306a36Sopenharmony_ci	 */
1562306a36Sopenharmony_ci	if (IS_ENABLED(CONFIG_SMP) &&
1662306a36Sopenharmony_ci	    likely(!(atomic_read(&next->membarrier_state) &
1762306a36Sopenharmony_ci		     (MEMBARRIER_STATE_PRIVATE_EXPEDITED |
1862306a36Sopenharmony_ci		      MEMBARRIER_STATE_GLOBAL_EXPEDITED)) || !prev))
1962306a36Sopenharmony_ci		return;
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci	/*
2262306a36Sopenharmony_ci	 * The membarrier system call requires a full memory barrier
2362306a36Sopenharmony_ci	 * after storing to rq->curr, before going back to user-space.
2462306a36Sopenharmony_ci	 */
2562306a36Sopenharmony_ci	smp_mb();
2662306a36Sopenharmony_ci}
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#endif /* _ASM_POWERPC_MEMBARRIER_H */
29