Module Name: src
Committed By: riastradh
Date: Sun Dec 19 11:03:57 UTC 2021
Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/gt: intel_breadcrumbs.c
src/sys/external/bsd/drm2/include/linux: dma-fence.h
src/sys/external/bsd/drm2/linux: linux_dma_fence.c
Log Message:
Move grody i915 dma-fence hacks into dma-fence proper.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_breadcrumbs.c
cvs rdiff -u -r1.11 -r1.12 \
src/sys/external/bsd/drm2/include/linux/dma-fence.h
cvs rdiff -u -r1.11 -r1.12 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/dist/drm/i915/gt/intel_breadcrumbs.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_breadcrumbs.c:1.2 src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_breadcrumbs.c:1.3
--- src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_breadcrumbs.c:1.2 Sat Dec 18 23:45:30 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/gt/intel_breadcrumbs.c Sun Dec 19 11:03:57 2021
@@ -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 @@ check_signal_order(struct intel_context
return true;
}
+#ifndef __NetBSD__
+
static bool
__dma_fence_signal(struct dma_fence *fence)
{
@@ -136,6 +138,8 @@ __dma_fence_signal__notify(struct dma_fe
}
}
+#endif
+
static void add_retire(struct intel_breadcrumbs *b, struct intel_timeline *tl)
{
struct intel_engine_cs *engine =
@@ -208,6 +212,9 @@ static void signal_irq_work(struct irq_w
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 @@ static void signal_irq_work(struct irq_w
__dma_fence_signal__timestamp(&rq->fence, timestamp);
__dma_fence_signal__notify(&rq->fence, &cb_list);
spin_unlock(&rq->lock);
+#endif
i915_request_put(rq);
}
Index: src/sys/external/bsd/drm2/include/linux/dma-fence.h
diff -u src/sys/external/bsd/drm2/include/linux/dma-fence.h:1.11 src/sys/external/bsd/drm2/include/linux/dma-fence.h:1.12
--- src/sys/external/bsd/drm2/include/linux/dma-fence.h:1.11 Sun Dec 19 10:58:04 2021
+++ src/sys/external/bsd/drm2/include/linux/dma-fence.h Sun Dec 19 11:03:57 2021
@@ -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 @@ struct dma_fence {
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 @@ struct dma_fence {
#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 @@ struct dma_fence_cb {
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 @@ long dma_fence_wait_any_timeout(struct d
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, ...)
{
Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c
diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.11 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.12
--- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.11 Sun Dec 19 10:58:04 2021
+++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 11:03:57 2021
@@ -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 @@ out:
*/
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);
+}