From 1bbbe083a104f6eed9d29698a1ba29bd8947ac04 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 1 May 2020 10:28:21 +0000 Subject: [PATCH] Implement mutex_lock_killable() in the LinuxKPI. Submitted by: ashafer_badland.io (Austin Shafer) MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/compat/linuxkpi/common/include/linux/mutex.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/mutex.h b/sys/compat/linuxkpi/common/include/linux/mutex.h index c5b67bad7c45..6c8fb2e3d000 100644 --- a/sys/compat/linuxkpi/common/include/linux/mutex.h +++ b/sys/compat/linuxkpi/common/include/linux/mutex.h @@ -66,6 +66,18 @@ typedef struct mutex { linux_mutex_lock_interruptible(_m); \ }) +/* + * Reuse the interruptable method since the SX + * lock handles both signals and interrupts: + */ +#define mutex_lock_killable(_m) ({ \ + MUTEX_SKIP() ? 0 : \ + linux_mutex_lock_interruptible(_m); \ +}) + +#define mutex_lock_killable_nested(_m, _sub) \ + mutex_lock_killable(_m) + #define mutex_unlock(_m) do { \ if (MUTEX_SKIP()) \ break; \