Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/linux drm: Use atomic_load_consume/rel...
details: https://anonhg.NetBSD.org/src/rev/5481929ce982
branches: trunk
changeset: 1028991:5481929ce982
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 12:39:40 2021 +0000
description:
drm: Use atomic_load_consume/relaxed to simplify code.
diffstat:
sys/external/bsd/drm2/linux/linux_dma_fence.c | 25 +++++++++----------------
1 files changed, 9 insertions(+), 16 deletions(-)
diffs (57 lines):
diff -r ca70978b2cae -r 5481929ce982 sys/external/bsd/drm2/linux/linux_dma_fence.c
--- a/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:39:32 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:39:40 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_dma_fence.c,v 1.38 2021/12/19 12:39:25 riastradh Exp $ */
+/* $NetBSD: linux_dma_fence.c,v 1.39 2021/12/19 12:39:40 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.38 2021/12/19 12:39:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.39 2021/12/19 12:39:40 riastradh Exp $");
#include <sys/atomic.h>
#include <sys/condvar.h>
@@ -394,21 +394,16 @@
struct dma_fence *
dma_fence_get_rcu_safe(struct dma_fence *volatile const *fencep)
{
- struct dma_fence *fence, *fence0;
+ struct dma_fence *fence;
retry:
- fence = *fencep;
-
- /* Load fence only once. */
- __insn_barrier();
-
- /* If there's nothing there, give up. */
- if (fence == NULL)
+ /*
+ * Load the fence, ensuring we observe the fully initialized
+ * content.
+ */
+ if ((fence = atomic_load_consume(fencep)) == NULL)
return NULL;
- /* Make sure we don't load stale fence guts. */
- membar_datadep_consumer();
-
/* Try to acquire a reference. If we can't, try again. */
if (!dma_fence_get_rcu(fence))
goto retry;
@@ -417,9 +412,7 @@
* Confirm that it's still the same fence. If not, release it
* and retry.
*/
- fence0 = *fencep;
- __insn_barrier();
- if (fence != fence0) {
+ if (fence != atomic_load_relaxed(fencep)) {
dma_fence_put(fence);
goto retry;
}
Home |
Main Index |
Thread Index |
Old Index