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/dist/drm/i915 i915: Abuse abstractions...
details: https://anonhg.NetBSD.org/src/rev/6e11b2de9044
branches: trunk
changeset: 1028842:6e11b2de9044
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 12:11:14 2021 +0000
description:
i915: Abuse abstractions gruesomely but with less lock screwitude.
diffstat:
sys/external/bsd/drm2/dist/drm/i915/i915_active.c | 43 +++++++++++++---------
1 files changed, 26 insertions(+), 17 deletions(-)
diffs (104 lines):
diff -r a18d60274863 -r 6e11b2de9044 sys/external/bsd/drm2/dist/drm/i915/i915_active.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_active.c Sun Dec 19 12:11:05 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_active.c Sun Dec 19 12:11:14 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_active.c,v 1.7 2021/12/19 11:59:04 riastradh Exp $ */
+/* $NetBSD: i915_active.c,v 1.8 2021/12/19 12:11:14 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_active.c,v 1.7 2021/12/19 11:59:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_active.c,v 1.8 2021/12/19 12:11:14 riastradh Exp $");
#include <linux/debugobjects.h>
@@ -285,6 +285,7 @@
prealloc = kmem_cache_alloc(global.slab_cache, GFP_KERNEL);
if (!prealloc)
return NULL;
+ memset(prealloc, 0, sizeof(*prealloc));
spin_lock_irq(&ref->tree_lock);
GEM_BUG_ON(i915_active_is_idle(ref));
@@ -724,6 +725,7 @@
goto unwind;
}
+ memset(node, 0, sizeof(*node));
RCU_INIT_POINTER(node->base.fence, NULL);
node->base.cb.func = node_retire;
node->timeline = idx;
@@ -852,16 +854,20 @@
/* serialise with reuse_idle_barrier */
smp_store_mb(*ll_to_fence_slot(node), &rq->fence);
#ifdef __NetBSD__
- spin_unlock(&rq->lock);
+ /* XXX ugh bletch */
struct i915_active_fence *active =
container_of(node, struct i915_active_fence, llist);
/* XXX something bad went wrong in making this code */
KASSERT(active->cb.func == node_retire ||
active->cb.func == excl_retire ||
active->cb.func == i915_active_noop);
- (void)dma_fence_add_callback(active->fence, &active->cb,
- active->cb.func);
- spin_lock(&rq->lock);
+ KASSERTMSG(active->fence == &rq->fence,
+ "active=%p fence=%p; rq=%p fence=%p",
+ active, active->fence, rq, &rq->fence);
+ KASSERTMSG(!active->cb.fcb_onqueue, "active=%p", active);
+ active->cb.fcb_onqueue = true;
+ TAILQ_INSERT_TAIL(&rq->fence.f_callbacks, &active->cb,
+ fcb_entry);
#else
list_add_tail((struct list_head *)node, &rq->fence.cb_list);
#endif
@@ -917,30 +923,33 @@
prev = xchg(__active_fence_slot(active), fence);
if (prev) {
GEM_BUG_ON(prev == fence);
+ spin_lock_nested(prev->lock, SINGLE_DEPTH_NESTING);
#ifdef __NetBSD__
+ /* XXX ugh bletch */
KASSERT(active->cb.func == node_retire ||
active->cb.func == excl_retire ||
active->cb.func == i915_active_noop);
- (void)dma_fence_remove_callback(prev, &active->cb);
+ if (active->cb.fcb_onqueue) {
+ TAILQ_REMOVE(&prev->f_callbacks, &active->cb,
+ fcb_entry);
+ active->cb.fcb_onqueue = false;
+ }
#else
- spin_lock_nested(prev->lock, SINGLE_DEPTH_NESTING);
__list_del_entry(&active->cb.node);
+#endif
spin_unlock(prev->lock); /* serialise with prev->cb_list */
-#endif
}
GEM_BUG_ON(rcu_access_pointer(active->fence) != fence);
-#ifndef __NetBSD__
+#ifdef __NetBSD__
+ /* XXX ugh bletch */
+ KASSERT(!active->cb.fcb_onqueue);
+ active->cb.fcb_onqueue = true;
+ TAILQ_INSERT_TAIL(&fence->f_callbacks, &active->cb, fcb_entry);
+#else
list_add_tail(&active->cb.node, &fence->cb_list);
#endif
spin_unlock_irqrestore(fence->lock, flags);
-#ifdef __NetBSD__
- KASSERT(active->cb.func == node_retire ||
- active->cb.func == excl_retire ||
- active->cb.func == i915_active_noop);
- dma_fence_add_callback(fence, &active->cb, active->cb.func);
-#endif
-
return prev;
}
Home |
Main Index |
Thread Index |
Old Index