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 Teach dma_fence_any_wait_timeout...



details:   https://anonhg.NetBSD.org/src/rev/92e026614f2d
branches:  trunk
changeset: 1028404:92e026614f2d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 10:58:04 2021 +0000

description:
Teach dma_fence_any_wait_timeout to return index of signalled fence.

diffstat:

 sys/external/bsd/drm2/include/linux/dma-fence.h |   5 +++--
 sys/external/bsd/drm2/linux/linux_dma_fence.c   |  23 +++++++++++++++++------
 2 files changed, 20 insertions(+), 8 deletions(-)

diffs (95 lines):

diff -r 6193bd6b74b3 -r 92e026614f2d sys/external/bsd/drm2/include/linux/dma-fence.h
--- a/sys/external/bsd/drm2/include/linux/dma-fence.h   Sun Dec 19 10:57:56 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/dma-fence.h   Sun Dec 19 10:58:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dma-fence.h,v 1.10 2021/12/19 10:50:03 riastradh Exp $ */
+/*     $NetBSD: dma-fence.h,v 1.11 2021/12/19 10:58:04 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -139,7 +139,8 @@
 int    dma_fence_signal_locked(struct dma_fence *);
 long   dma_fence_default_wait(struct dma_fence *, bool, long);
 long   dma_fence_wait(struct dma_fence *, bool);
-long   dma_fence_wait_any_timeout(struct dma_fence **, uint32_t, bool, long);
+long   dma_fence_wait_any_timeout(struct dma_fence **, uint32_t, bool, long,
+           uint32_t *);
 long   dma_fence_wait_timeout(struct dma_fence *, bool, long);
 
 static inline void __printflike(2, 3)
diff -r 6193bd6b74b3 -r 92e026614f2d sys/external/bsd/drm2/linux/linux_dma_fence.c
--- a/sys/external/bsd/drm2/linux/linux_dma_fence.c     Sun Dec 19 10:57:56 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_dma_fence.c     Sun Dec 19 10:58:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_dma_fence.c,v 1.10 2021/12/19 10:50:03 riastradh Exp $   */
+/*     $NetBSD: linux_dma_fence.c,v 1.11 2021/12/19 10:58:04 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.10 2021/12/19 10:50:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.11 2021/12/19 10:58:04 riastradh Exp $");
 
 #include <sys/atomic.h>
 #include <sys/condvar.h>
@@ -589,6 +589,8 @@
                kmutex_t        lock;
                kcondvar_t      cv;
                bool            done;
+               uint32_t        *ip;
+               struct wait_any *cb;
        }               *common;
 };
 
@@ -601,19 +603,22 @@
 
        mutex_enter(&cb->common->lock);
        cb->common->done = true;
+       if (cb->common->ip)
+               *cb->common->ip = cb - cb->common->cb;
        cv_broadcast(&cb->common->cv);
        mutex_exit(&cb->common->lock);
 }
 
 /*
- * dma_fence_wait_any_timeout(fence, nfences, intr, timeout)
+ * dma_fence_wait_any_timeout(fence, nfences, intr, timeout, ip)
  *
  *     Wait for any of fences[0], fences[1], fences[2], ...,
- *     fences[nfences-1] to be signaled.
+ *     fences[nfences-1] to be signaled.  If ip is nonnull, set *ip to
+ *     the index of the first one.
  */
 long
 dma_fence_wait_any_timeout(struct dma_fence **fences, uint32_t nfences,
-    bool intr, long timeout)
+    bool intr, long timeout, uint32_t *ip)
 {
        struct wait_any1 common;
        struct wait_any *cb;
@@ -632,6 +637,8 @@
        mutex_init(&common.lock, MUTEX_DEFAULT, IPL_VM);
        cv_init(&common.cv, "fence");
        common.done = false;
+       common.ip = ip;
+       common.cb = cb;
 
        /* Add a callback to each of the fences, or stop here if we can't.  */
        for (i = 0; i < nfences; i++) {
@@ -649,8 +656,12 @@
         * notified by one of the callbacks when they have.
         */
        for (j = 0; j < nfences; j++) {
-               if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fences[j]->flags))
+               if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fences[j]->flags)) {
+                       if (ip)
+                               *ip = j;
+                       ret = 0;
                        goto out1;
+               }
        }
 
        /*



Home | Main Index | Thread Index | Old Index