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_relaxed for...



details:   https://anonhg.NetBSD.org/src/rev/15d0dcf941dd
branches:  trunk
changeset: 1028961:15d0dcf941dd
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 12:35:21 2021 +0000

description:
drm: Use atomic_load_relaxed for fence->flags when not locked.

Shouldn't make a semantic difference on any machines we run on, but
will make sanitizers happier and emphasize to readers that the result
may not be reliable at these points.

diffstat:

 sys/external/bsd/drm2/linux/linux_dma_fence.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (48 lines):

diff -r ffe9abbb2a95 -r 15d0dcf941dd sys/external/bsd/drm2/linux/linux_dma_fence.c
--- a/sys/external/bsd/drm2/linux/linux_dma_fence.c     Sun Dec 19 12:35:13 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_dma_fence.c     Sun Dec 19 12:35:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_dma_fence.c,v 1.33 2021/12/19 12:34:58 riastradh Exp $   */
+/*     $NetBSD: linux_dma_fence.c,v 1.34 2021/12/19 12:35:21 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.33 2021/12/19 12:34:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.34 2021/12/19 12:35:21 riastradh Exp $");
 
 #include <sys/atomic.h>
 #include <sys/condvar.h>
@@ -443,7 +443,8 @@
        KASSERT(dma_fence_referenced_p(fence));
 
        /* Optimistically try to skip the lock if it's already signalled.  */
-       if (fence->flags & (1u << DMA_FENCE_FLAG_SIGNALED_BIT)) {
+       if (atomic_load_relaxed(&fence->flags) &
+           (1u << DMA_FENCE_FLAG_SIGNALED_BIT)) {
                ret = -ENOENT;
                goto out0;
        }
@@ -585,7 +586,8 @@
 
        KASSERTMSG(fence->f_magic != FENCE_MAGIC_BAD, "fence %p", fence);
        KASSERTMSG(fence->f_magic == FENCE_MAGIC_GOOD, "fence %p", fence);
-       KASSERT(!(fence->flags & (1u << DMA_FENCE_FLAG_SIGNALED_BIT)));
+       KASSERT((atomic_load_relaxed(&fence->flags) &
+               (1u << DMA_FENCE_FLAG_SIGNALED_BIT)) == 0);
        KASSERTMSG(error >= -ELAST, "%d", error);
        KASSERTMSG(error < 0, "%d", error);
 
@@ -938,7 +940,8 @@
        KASSERTMSG(timeout <= MAX_SCHEDULE_TIMEOUT, "timeout %ld", timeout);
 
        /* Optimistically try to skip the lock if it's already signalled.  */
-       if (fence->flags & (1u << DMA_FENCE_FLAG_SIGNALED_BIT))
+       if (atomic_load_relaxed(&fence->flags) &
+           (1u << DMA_FENCE_FLAG_SIGNALED_BIT))
                return MAX(1, timeout);
 
        /* Acquire the lock.  */



Home | Main Index | Thread Index | Old Index