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 Move grody i915 dma-fence hacks ...



details:   https://anonhg.NetBSD.org/src/rev/3f8629ecf700
branches:  trunk
changeset: 1028443:3f8629ecf700
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:03:57 2021 +0000

description:
Move grody i915 dma-fence hacks into dma-fence proper.

diffstat:

 sys/external/bsd/drm2/dist/drm/i915/gt/intel_breadcrumbs.c |  12 ++-
 sys/external/bsd/drm2/include/linux/dma-fence.h            |  13 +++-
 sys/external/bsd/drm2/linux/linux_dma_fence.c              |  48 +++++++++++++-
 3 files changed, 67 insertions(+), 6 deletions(-)

diffs (175 lines):

diff -r a04c11cc47ee -r 3f8629ecf700 sys/external/bsd/drm2/dist/drm/i915/gt/intel_breadcrumbs.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gt/intel_breadcrumbs.c        Sun Dec 19 11:03:49 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gt/intel_breadcrumbs.c        Sun Dec 19 11:03:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intel_breadcrumbs.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $  */
+/*     $NetBSD: intel_breadcrumbs.c,v 1.3 2021/12/19 11:03:57 riastradh Exp $  */
 
 /*
  * Copyright © 2015 Intel Corporation
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_breadcrumbs.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_breadcrumbs.c,v 1.3 2021/12/19 11:03:57 riastradh Exp $");
 
 #include <linux/kthread.h>
 #include <trace/events/dma_fence.h>
@@ -108,6 +108,8 @@
        return true;
 }
 
+#ifndef __NetBSD__
+
 static bool
 __dma_fence_signal(struct dma_fence *fence)
 {
@@ -136,6 +138,8 @@
        }
 }
 
+#endif
+
 static void add_retire(struct intel_breadcrumbs *b, struct intel_timeline *tl)
 {
        struct intel_engine_cs *engine =
@@ -208,6 +212,9 @@
        list_for_each_safe(pos, next, &signal) {
                struct i915_request *rq =
                        list_entry(pos, typeof(*rq), signal_link);
+#ifdef __NetBSD__
+               __dma_fence_signal_wake(&rq->fence, timestamp);
+#else
                struct list_head cb_list;
 
                spin_lock(&rq->lock);
@@ -215,6 +222,7 @@
                __dma_fence_signal__timestamp(&rq->fence, timestamp);
                __dma_fence_signal__notify(&rq->fence, &cb_list);
                spin_unlock(&rq->lock);
+#endif
 
                i915_request_put(rq);
        }
diff -r a04c11cc47ee -r 3f8629ecf700 sys/external/bsd/drm2/include/linux/dma-fence.h
--- a/sys/external/bsd/drm2/include/linux/dma-fence.h   Sun Dec 19 11:03:49 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/dma-fence.h   Sun Dec 19 11:03:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dma-fence.h,v 1.11 2021/12/19 10:58:04 riastradh Exp $ */
+/*     $NetBSD: dma-fence.h,v 1.12 2021/12/19 11:03:57 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -39,6 +39,7 @@
 
 #include <linux/err.h>
 #include <linux/kref.h>
+#include <linux/ktime.h>
 #include <linux/rcupdate.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
@@ -53,6 +54,7 @@
        unsigned                        seqno;
        const struct dma_fence_ops      *ops;
        int                             error;
+       ktime_t                         timestamp;
 
        TAILQ_HEAD(, dma_fence_cb)      f_callbacks;
        kcondvar_t                      f_cv;
@@ -61,7 +63,8 @@
 
 #define        DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT        0
 #define        DMA_FENCE_FLAG_SIGNALED_BIT             1
-#define        DMA_FENCE_FLAG_USER_BITS                2
+#define        DMA_FENCE_FLAG_TIMESTAMP_BIT            2
+#define        DMA_FENCE_FLAG_USER_BITS                3
 
 struct dma_fence_ops {
        const char      *(*get_driver_name)(struct dma_fence *);
@@ -80,6 +83,8 @@
        bool                            fcb_onqueue;
 };
 
+#define        __dma_fence_signal              linux___dma_fence_signal
+#define        __dma_fence_signal_wake         linux___dma_fence_signal_wake
 #define        dma_fence_add_callback          linux_dma_fence_add_callback
 #define        dma_fence_context_alloc         linux_dma_fence_context_alloc
 #define        dma_fence_default_wait          linux_dma_fence_default_wait
@@ -143,6 +148,10 @@
            uint32_t *);
 long   dma_fence_wait_timeout(struct dma_fence *, bool, long);
 
+/* i915 hacks */
+bool   __dma_fence_signal(struct dma_fence *);
+void   __dma_fence_signal_wake(struct dma_fence *, ktime_t);
+
 static inline void __printflike(2, 3)
 DMA_FENCE_TRACE(struct dma_fence *f, const char *fmt, ...)
 {
diff -r a04c11cc47ee -r 3f8629ecf700 sys/external/bsd/drm2/linux/linux_dma_fence.c
--- a/sys/external/bsd/drm2/linux/linux_dma_fence.c     Sun Dec 19 11:03:49 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_dma_fence.c     Sun Dec 19 11:03:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_dma_fence.c,v 1.11 2021/12/19 10:58:04 riastradh Exp $   */
+/*     $NetBSD: linux_dma_fence.c,v 1.12 2021/12/19 11:03:57 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.11 2021/12/19 10:58:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.12 2021/12/19 11:03:57 riastradh Exp $");
 
 #include <sys/atomic.h>
 #include <sys/condvar.h>
@@ -877,3 +877,47 @@
         */
        return (timeout < MAX_SCHEDULE_TIMEOUT ? MIN(deadline - now, 1) : 1);
 }
+
+/*
+ * __dma_fence_signal(fence)
+ *
+ *     Set fence's signalled bit, without waking waiters yet.  Return
+ *     true if it was newly set, false if it was already set.
+ */
+bool
+__dma_fence_signal(struct dma_fence *fence)
+{
+
+       if (test_and_set_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
+               return false;
+
+       return true;
+}
+
+/*
+ * __dma_fence_signal_wake(fence)
+ *
+ *     Wake fence's waiters.  Caller must have previously called
+ *     __dma_fence_signal and it must have previously returned true.
+ */
+void
+__dma_fence_signal_wake(struct dma_fence *fence, ktime_t timestamp)
+{
+       struct dma_fence_cb *fcb, *next;
+
+       spin_lock(fence->lock);
+
+       KASSERT(fence->flags & DMA_FENCE_FLAG_SIGNALED_BIT);
+
+       /* Wake waiters.  */
+       cv_broadcast(&fence->f_cv);
+
+       /* Remove and call the callbacks.  */
+       TAILQ_FOREACH_SAFE(fcb, &fence->f_callbacks, fcb_entry, next) {
+               TAILQ_REMOVE(&fence->f_callbacks, fcb, fcb_entry);
+               fcb->fcb_onqueue = false;
+               (*fcb->func)(fence, fcb);
+       }
+
+       spin_unlock(fence->lock);
+}



Home | Main Index | Thread Index | Old Index