Module Name: src
Committed By: riastradh
Date: Mon Aug 27 13:36:53 UTC 2018
Modified Files:
src/sys/external/bsd/drm2/include/linux: fence.h
src/sys/external/bsd/drm2/linux: linux_fence.c
Log Message:
Use atomics to manage fence->flags.
Outside users use this field too, and expect it to be managed with
atomics.
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/drm2/include/linux/fence.h
cvs rdiff -u -r1.1 -r1.2 src/sys/external/bsd/drm2/linux/linux_fence.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/fence.h
diff -u src/sys/external/bsd/drm2/include/linux/fence.h:1.11 src/sys/external/bsd/drm2/include/linux/fence.h:1.12
--- src/sys/external/bsd/drm2/include/linux/fence.h:1.11 Mon Aug 27 13:33:59 2018
+++ src/sys/external/bsd/drm2/include/linux/fence.h Mon Aug 27 13:36:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fence.h,v 1.11 2018/08/27 13:33:59 riastradh Exp $ */
+/* $NetBSD: fence.h,v 1.12 2018/08/27 13:36:53 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -46,7 +46,7 @@ struct fence_cb;
struct fence {
struct kref refcount;
spinlock_t *lock;
- unsigned long flags;
+ volatile unsigned long flags;
unsigned context;
unsigned seqno;
const struct fence_ops *ops;
Index: src/sys/external/bsd/drm2/linux/linux_fence.c
diff -u src/sys/external/bsd/drm2/linux/linux_fence.c:1.1 src/sys/external/bsd/drm2/linux/linux_fence.c:1.2
--- src/sys/external/bsd/drm2/linux/linux_fence.c:1.1 Mon Aug 27 13:33:59 2018
+++ src/sys/external/bsd/drm2/linux/linux_fence.c Mon Aug 27 13:36:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_fence.c,v 1.1 2018/08/27 13:33:59 riastradh Exp $ */
+/* $NetBSD: linux_fence.c,v 1.2 2018/08/27 13:36:53 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,12 +30,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_fence.c,v 1.1 2018/08/27 13:33:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_fence.c,v 1.2 2018/08/27 13:36:53 riastradh Exp $");
#include <sys/atomic.h>
#include <sys/condvar.h>
#include <sys/queue.h>
+#include <linux/atomic.h>
#include <linux/errno.h>
#include <linux/kref.h>
#include <linux/fence.h>
@@ -191,12 +192,14 @@ fence_ensure_signal_enabled(struct fence
if (fence->flags & (1u << FENCE_FLAG_SIGNALED_BIT))
return -ENOENT;
- /* If the enable signalling callback has been called, success. */
- if (fence->flags & (1u << FENCE_FLAG_ENABLE_SIGNAL_BIT))
+ /*
+ * If the enable signaling callback has been called, success.
+ * Otherwise, set the bit indicating it.
+ */
+ if (test_and_set_bit(FENCE_FLAG_ENABLE_SIGNAL_BIT, &fence->flags))
return 0;
/* Otherwise, note that we've called it and call it. */
- fence->flags |= 1u << FENCE_FLAG_ENABLE_SIGNAL_BIT;
if (!(*fence->ops->enable_signaling)(fence)) {
/* If it failed, signal and return -ENOENT. */
fence_signal_locked(fence);
@@ -377,9 +380,8 @@ fence_signal_locked(struct fence *fence)
KASSERT(spin_is_locked(fence->lock));
/* If it's been signalled, fail; otherwise set the signalled bit. */
- if (fence->flags & (1u << FENCE_FLAG_SIGNALED_BIT))
+ if (test_and_set_bit(FENCE_FLAG_SIGNALED_BIT, &fence->flags))
return -EINVAL;
- fence->flags |= 1u << FENCE_FLAG_SIGNALED_BIT;
/* Wake waiters. */
cv_broadcast(&fence->f_cv);