Module Name: src
Committed By: riastradh
Date: Sun Dec 19 01:42:02 UTC 2021
Modified Files:
src/sys/external/bsd/drm2/include/linux: wait_bit.h
src/sys/external/bsd/drm2/linux: linux_wait_bit.c
Log Message:
wait_on_bit
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/external/bsd/drm2/include/linux/wait_bit.h
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/linux/linux_wait_bit.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/include/linux/wait_bit.h
diff -u src/sys/external/bsd/drm2/include/linux/wait_bit.h:1.1 src/sys/external/bsd/drm2/include/linux/wait_bit.h:1.2
--- src/sys/external/bsd/drm2/include/linux/wait_bit.h:1.1 Sun Dec 19 01:22:15 2021
+++ src/sys/external/bsd/drm2/include/linux/wait_bit.h Sun Dec 19 01:42:01 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: wait_bit.h,v 1.1 2021/12/19 01:22:15 riastradh Exp $ */
+/* $NetBSD: wait_bit.h,v 1.2 2021/12/19 01:42:01 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,6 +32,7 @@
#ifndef _LINUX_WAIT_BIT_H_
#define _LINUX_WAIT_BIT_H_
+#define wait_on_bit linux_wait_on_bit
#define wait_on_bit_timeout linux_wait_on_bit_timeout
#define wake_up_bit linux_wake_up_bit
@@ -39,6 +40,7 @@ int linux_wait_bit_init(void);
void linux_wait_bit_fini(void);
void wake_up_bit(const volatile unsigned long *, unsigned);
+int wait_on_bit(const volatile unsigned long *, unsigned, int);
int wait_on_bit_timeout(const volatile unsigned long *, unsigned, int,
unsigned long);
Index: src/sys/external/bsd/drm2/linux/linux_wait_bit.c
diff -u src/sys/external/bsd/drm2/linux/linux_wait_bit.c:1.2 src/sys/external/bsd/drm2/linux/linux_wait_bit.c:1.3
--- src/sys/external/bsd/drm2/linux/linux_wait_bit.c:1.2 Sun Dec 19 01:41:54 2021
+++ src/sys/external/bsd/drm2/linux/linux_wait_bit.c Sun Dec 19 01:42:02 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_wait_bit.c,v 1.2 2021/12/19 01:41:54 riastradh Exp $ */
+/* $NetBSD: linux_wait_bit.c,v 1.3 2021/12/19 01:42:02 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_wait_bit.c,v 1.2 2021/12/19 01:41:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_wait_bit.c,v 1.3 2021/12/19 01:42:02 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -115,6 +115,38 @@ wake_up_bit(const volatile unsigned long
}
int
+wait_on_bit(const volatile unsigned long *bitmap, unsigned bit, int flags)
+{
+ struct waitbitentry *wbe;
+ int error, ret;
+
+ if (test_bit(bit, bitmap))
+ return 0;
+
+ wbe = wait_bit_enter(bitmap, bit);
+
+ while (!test_bit(bit, bitmap)) {
+ if (flags & TASK_UNINTERRUPTIBLE) {
+ cv_wait(&wbe->cv, &wbe->lock);
+ } else {
+ error = cv_wait_sig(&wbe->cv, &wbe->lock);
+ if (error == EINTR || error == ERESTART)
+ ret = -ERESTARTSYS;
+ else if (error != 0)
+ ret = -error;
+ if (ret)
+ goto out;
+ }
+ }
+
+ /* Bit is set. Return zero on success. */
+ ret = 0;
+
+out: wait_bit_exit(wbe);
+ return ret;
+}
+
+int
wait_on_bit_timeout(const volatile unsigned long *bitmap, unsigned bit,
int flags, unsigned long timeout)
{