Module Name: src Committed By: riastradh Date: Sun Dec 19 12:39:41 UTC 2021
Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Use atomic_load_consume/relaxed to simplify code. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/external/bsd/drm2/linux/linux_dma_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/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.38 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.39 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.38 Sun Dec 19 12:39:25 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:39:40 2021 @@ -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 @@ dma_fence_get_rcu(struct dma_fence *fenc 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 @@ retry: * 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; }