From c116837aad9abc5f2fea7c32a4f9431bedfbfba1 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 23 Aug 2022 16:00:51 +0200 Subject: [PATCH] infra: new smp versions of brick locking inteded: compatible to kernel upstream, but additional smp_.?mb() as necessary --- kernel/brick_wait.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/kernel/brick_wait.h b/kernel/brick_wait.h index d1a3086b..d21e7a9a 100644 --- a/kernel/brick_wait.h +++ b/kernel/brick_wait.h @@ -24,6 +24,36 @@ #ifndef BRICK_WAIT_H #define BRICK_WAIT_H +/* New smp operations for brick waiting. + */ +#define brick_wait_smp(wq, condition, timeout) \ +({ \ + long __tmout = (timeout); \ + \ + might_sleep(); \ + smp_rmb(); \ + \ + while (!(condition)) { \ + __tmout = wait_event_interruptible_timeout( \ + wq, \ + ({ \ + smp_rmb(); \ + (condition); \ + }), \ + __tmout); \ + if (__tmout <= 1) \ + break; \ + } \ + __tmout; \ +}) + +#define brick_wake_smp(wq) \ +({ \ + smp_wmb(); \ + wake_up_interruptible_all(wq); \ +}) + + /* Historic adaptor. * To disappear somewhen. */