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/i915drm i915: Adapt sw_fence.
details: https://anonhg.NetBSD.org/src/rev/5ab9e7e7025d
branches: trunk
changeset: 1028653:5ab9e7e7025d
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 11:36:08 2021 +0000
description:
i915: Adapt sw_fence.
diffstat:
sys/external/bsd/drm2/dist/drm/i915/i915_sw_fence.c | 84 +++++++++++++++++++-
sys/external/bsd/drm2/dist/drm/i915/i915_sw_fence.h | 28 +++++-
sys/external/bsd/drm2/i915drm/files.i915drmkms | 6 +-
sys/external/bsd/drm2/i915drm/i915_module.c | 8 +-
4 files changed, 110 insertions(+), 16 deletions(-)
diffs (truncated from 301 to 300 lines):
diff -r c552fa101aea -r 5ab9e7e7025d sys/external/bsd/drm2/dist/drm/i915/i915_sw_fence.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_sw_fence.c Sun Dec 19 11:36:00 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_sw_fence.c Sun Dec 19 11:36:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_sw_fence.c,v 1.2 2021/12/18 23:45:28 riastradh Exp $ */
+/* $NetBSD: i915_sw_fence.c,v 1.3 2021/12/19 11:36:08 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_sw_fence.c,v 1.2 2021/12/18 23:45:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_sw_fence.c,v 1.3 2021/12/19 11:36:08 riastradh Exp $");
#include <linux/slab.h>
#include <linux/dma-fence.h>
@@ -17,6 +17,10 @@
#include "i915_sw_fence.h"
#include "i915_selftest.h"
+#include <drm/drm_wait_netbsd.h>
+
+#include <linux/nbsd-namespace.h>
+
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
#define I915_SW_FENCE_BUG_ON(expr) BUG_ON(expr)
#else
@@ -25,7 +29,11 @@
#define I915_SW_FENCE_FLAG_ALLOC BIT(3) /* after WQ_FLAG_* for safety */
+#ifdef __NetBSD__ /* XXX */
+spinlock_t i915_sw_fence_lock;
+#else
static DEFINE_SPINLOCK(i915_sw_fence_lock);
+#endif
enum {
DEBUG_FENCE_IDLE = 0,
@@ -132,11 +140,66 @@
return fn(fence, state);
}
-#ifdef CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS
void i915_sw_fence_fini(struct i915_sw_fence *fence)
{
+#ifdef CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS
debug_fence_free(fence);
+#endif
+ spin_lock_destroy(&fence->wait.lock);
+ BUG_ON(!list_empty(&fence->wait.head));
}
+
+#ifdef __NetBSD__
+
+/* XXX whattakludge */
+
+typedef struct i915_sw_fence_queue wait_queue_head_t;
+typedef struct i915_sw_fence_waiter wait_queue_entry_t;
+
+#define TASK_NORMAL 0
+
+struct i915_sw_fence_wq {
+ struct i915_sw_fence *fence;
+ drm_waitqueue_t wq;
+};
+
+static int
+autoremove_wake_function(struct i915_sw_fence_waiter *waiter, unsigned mode,
+ int flags, void *cookie)
+{
+ struct i915_sw_fence_wq *sfw = cookie;
+
+ /* Caller presumably already completed the fence. */
+ DRM_SPIN_WAKEUP_ALL(&sfw->wq, &sfw->fence->wait.lock);
+
+ list_del_init(&waiter->entry);
+
+ return 0;
+}
+
+void
+i915_sw_fence_wait(struct i915_sw_fence *fence)
+{
+ struct i915_sw_fence_waiter waiter;
+ struct i915_sw_fence_wq sfw;
+ int ret;
+
+ INIT_LIST_HEAD(&waiter.entry);
+ waiter.flags = 0;
+ waiter.func = autoremove_wake_function;
+ waiter.private = &sfw;
+
+ sfw.fence = fence;
+ DRM_INIT_WAITQUEUE(&sfw.wq, "i915swf");
+
+ spin_lock(&fence->wait.lock);
+ DRM_SPIN_WAIT_NOINTR_UNTIL(ret, &sfw.wq, &fence->wait.lock,
+ i915_sw_fence_done(fence));
+ spin_unlock(&fence->wait.lock);
+
+ DRM_DESTROY_WAITQUEUE(&sfw.wq);
+}
+
#endif
static void __i915_sw_fence_wake_up_all(struct i915_sw_fence *fence,
@@ -147,7 +210,6 @@
unsigned long flags;
debug_fence_deactivate(fence);
- atomic_set_release(&fence->pending, -1); /* 0 -> -1 [done] */
/*
* To prevent unbounded recursion as we traverse the graph of
@@ -157,6 +219,7 @@
*/
spin_lock_irqsave_nested(&x->lock, flags, 1 + !!continuation);
+ atomic_set_release(&fence->pending, -1); /* 0 -> -1 [done] */
if (continuation) {
list_for_each_entry_safe(pos, next, &x->head, entry) {
if (pos->func == autoremove_wake_function)
@@ -229,7 +292,12 @@
{
BUG_ON(!fn || (unsigned long)fn & ~I915_SW_FENCE_MASK);
+#ifdef __NetBSD__
+ spin_lock_init(&fence->wait.lock);
+ INIT_LIST_HEAD(&fence->wait.head);
+#else
__init_waitqueue_head(&fence->wait, name, key);
+#endif
fence->flags = (unsigned long)fn;
i915_sw_fence_reinit(fence);
@@ -363,7 +431,11 @@
spin_lock_irqsave(&signaler->wait.lock, flags);
if (likely(!i915_sw_fence_done(signaler))) {
+#ifdef __NetBSD__
+ list_add(&wq->entry, &signaler->wait.head);
+#else
__add_wait_queue_entry_tail(&signaler->wait, wq);
+#endif
pending = 1;
} else {
i915_sw_fence_wake(wq, 0, signaler->error, NULL);
@@ -415,10 +487,10 @@
if (!fence)
return;
- pr_notice("Asynchronous wait on fence %s:%s:%llx timed out (hint:%pS)\n",
+ pr_notice("Asynchronous wait on fence %s:%s:%"PRIx64" timed out (hint:%p)\n",
cb->dma->ops->get_driver_name(cb->dma),
cb->dma->ops->get_timeline_name(cb->dma),
- cb->dma->seqno,
+ (uint64_t)cb->dma->seqno,
i915_sw_fence_debug_hint(fence));
i915_sw_fence_set_error_once(fence, -ETIMEDOUT);
diff -r c552fa101aea -r 5ab9e7e7025d sys/external/bsd/drm2/dist/drm/i915/i915_sw_fence.h
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_sw_fence.h Sun Dec 19 11:36:00 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_sw_fence.h Sun Dec 19 11:36:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_sw_fence.h,v 1.5 2021/12/19 11:30:45 riastradh Exp $ */
+/* $NetBSD: i915_sw_fence.h,v 1.6 2021/12/19 11:36:08 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -20,8 +20,18 @@
struct completion;
struct dma_resv;
+struct i915_sw_fence_waiter {
+ struct list_head entry;
+ int flags;
+ int (*func)(struct i915_sw_fence_waiter *, unsigned, int, void *);
+ void *private;
+};
+
struct i915_sw_fence {
- wait_queue_head_t wait;
+ struct i915_sw_fence_queue {
+ spinlock_t lock;
+ struct list_head head;
+ } wait;
unsigned long flags;
atomic_t pending;
int error;
@@ -58,17 +68,19 @@
void i915_sw_fence_reinit(struct i915_sw_fence *fence);
-#ifdef CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS
void i915_sw_fence_fini(struct i915_sw_fence *fence);
-#else
-static inline void i915_sw_fence_fini(struct i915_sw_fence *fence) {}
-#endif
void i915_sw_fence_commit(struct i915_sw_fence *fence);
+#ifdef __NetBSD__
+int i915_sw_fence_await_sw_fence(struct i915_sw_fence *,
+ struct i915_sw_fence *,
+ struct i915_sw_fence_waiter *);
+#else
int i915_sw_fence_await_sw_fence(struct i915_sw_fence *fence,
struct i915_sw_fence *after,
wait_queue_entry_t *wq);
+#endif
int i915_sw_fence_await_sw_fence_gfp(struct i915_sw_fence *fence,
struct i915_sw_fence *after,
gfp_t gfp);
@@ -106,10 +118,14 @@
return atomic_read(&fence->pending) < 0;
}
+#ifdef __NetBSD__
+void i915_sw_fence_wait(struct i915_sw_fence *);
+#else
static inline void i915_sw_fence_wait(struct i915_sw_fence *fence)
{
wait_event(fence->wait, i915_sw_fence_done(fence));
}
+#endif
static inline void
i915_sw_fence_set_error_once(struct i915_sw_fence *fence, int error)
diff -r c552fa101aea -r 5ab9e7e7025d sys/external/bsd/drm2/i915drm/files.i915drmkms
--- a/sys/external/bsd/drm2/i915drm/files.i915drmkms Sun Dec 19 11:36:00 2021 +0000
+++ b/sys/external/bsd/drm2/i915drm/files.i915drmkms Sun Dec 19 11:36:08 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.i915drmkms,v 1.70 2021/12/19 11:33:49 riastradh Exp $
+# $NetBSD: files.i915drmkms,v 1.71 2021/12/19 11:36:08 riastradh Exp $
version 20180827
@@ -31,6 +31,8 @@
makeoptions i915drmkms "CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT=0"
makeoptions i915drmkms "CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_I915_DEBUG_MMIO=1" # XXX
makeoptions i915drmkms "CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_I915_FORCE_PROBE=0"
+makeoptions i915drmkms "CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_I915_SPIN_REQUEST=0"
+makeoptions i915drmkms "CPPFLAGS.i915drmkms"+="-DCONFIG_DRM_I915_SW_FENCE_CHECK_DAG=1" # XXX expensive debug option?
makeoptions i915drmkms "CWARNFLAGS.i915drmkms"+="-Wno-missing-field-initializers"
makeoptions i915drmkms "CWARNFLAGS.i915drmkms"+="-Wno-pointer-arith"
@@ -204,7 +206,7 @@
file external/bsd/drm2/dist/drm/i915/i915_scatterlist.c i915drmkms
file external/bsd/drm2/dist/drm/i915/i915_scheduler.c i915drmkms
file external/bsd/drm2/dist/drm/i915/i915_suspend.c i915drmkms
-#file external/bsd/drm2/dist/drm/i915/i915_sw_fence.c i915drmkms
+file external/bsd/drm2/dist/drm/i915/i915_sw_fence.c i915drmkms
file external/bsd/drm2/dist/drm/i915/i915_sw_fence_work.c i915drmkms
file external/bsd/drm2/dist/drm/i915/i915_switcheroo.c i915drmkms
file external/bsd/drm2/dist/drm/i915/i915_syncmap.c i915drmkms
diff -r c552fa101aea -r 5ab9e7e7025d sys/external/bsd/drm2/i915drm/i915_module.c
--- a/sys/external/bsd/drm2/i915drm/i915_module.c Sun Dec 19 11:36:00 2021 +0000
+++ b/sys/external/bsd/drm2/i915drm/i915_module.c Sun Dec 19 11:36:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_module.c,v 1.14 2021/12/19 11:33:49 riastradh Exp $ */
+/* $NetBSD: i915_module.c,v 1.15 2021/12/19 11:36:08 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_module.c,v 1.14 2021/12/19 11:33:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_module.c,v 1.15 2021/12/19 11:36:08 riastradh Exp $");
#include <sys/types.h>
#include <sys/module.h>
@@ -53,6 +53,8 @@
struct drm_sysctl_def i915_def = DRM_SYSCTL_INIT();
+extern spinlock_t i915_sw_fence_lock;
+
int i915_global_buddy_init(void); /* XXX */
static int
@@ -70,6 +72,7 @@
drm_sysctl_init(&i915_def);
spin_lock_init(&mchdev_lock);
+ spin_lock_init(&i915_sw_fence_lock);
return 0;
}
@@ -91,6 +94,7 @@
i915drmkms_fini(void)
{
+ spin_lock_destroy(&i915_sw_fence_lock);
spin_lock_destroy(&mchdev_lock);
drm_sysctl_fini(&i915_def);
Home |
Main Index |
Thread Index |
Old Index