Add the acquire variant of smp_cond_load_relaxed_timewait(). This reuses the relaxed variant, with an additional LOAD->LOAD ordering via smp_acquire__after_ctrl_dep(). Also, the rqspinlock implementation has a locally cached copy of this interface. Fixup the parameters used there. Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Will Deacon <will@xxxxxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: linux-arch@xxxxxxxxxxxxxxx Signed-off-by: Ankur Arora <ankur.a.arora@xxxxxxxxxx> --- arch/arm64/include/asm/rqspinlock.h | 2 +- include/asm-generic/barrier.h | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/rqspinlock.h b/arch/arm64/include/asm/rqspinlock.h index 9ea0a74e5892..f1b6a428013e 100644 --- a/arch/arm64/include/asm/rqspinlock.h +++ b/arch/arm64/include/asm/rqspinlock.h @@ -86,7 +86,7 @@ #endif -#define res_smp_cond_load_acquire(v, c) smp_cond_load_acquire_timewait(v, c, 0, 1) +#define res_smp_cond_load_acquire(v, c) smp_cond_load_acquire_timewait(v, c, 0ULL, 1ULL, 0) #include <asm-generic/rqspinlock.h> diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h index 8299c57d1110..dd7c9ca2dff3 100644 --- a/include/asm-generic/barrier.h +++ b/include/asm-generic/barrier.h @@ -388,6 +388,28 @@ static inline u64 ___smp_cond_spinwait(u64 now, u64 prev, u64 end, (typeof(*ptr))_val; \ }) +/** + * smp_cond_load_acquire_timewait() - (Spin) wait for cond with ACQUIRE ordering + * until a timeout expires. + * + * Arguments: same as smp_cond_load_relaxed_timeout(). + * + * Equivalent to using smp_cond_load_acquire() on the condition variable with + * a timeout. + */ +#ifndef smp_cond_load_acquire_timewait +#define smp_cond_load_acquire_timewait(ptr, cond_expr, \ + time_expr, time_end, \ + slack) ({ \ + __unqual_scalar_typeof(*ptr) _val; \ + _val = smp_cond_load_relaxed_timewait(ptr, cond_expr, \ + time_expr, time_end, \ + slack); \ + /* Depends on the control dependency of the wait above. */ \ + smp_acquire__after_ctrl_dep(); \ + (typeof(*ptr))_val; \ +}) +#endif /* * pmem_wmb() ensures that all stores for which the modification * are written to persistent storage by preceding instructions have -- 2.43.5