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/include/linux i915: intel_engine_pm.c ...
details: https://anonhg.NetBSD.org/src/rev/c05cbc39e5e5
branches: trunk
changeset: 1028725:c05cbc39e5e5
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 11:52:07 2021 +0000
description:
i915: intel_engine_pm.c and i915_active.c
...with a little less heinous abuse of C, and an attempt to
disentangle the tentacular abstraction violations rampant in these
components
diffstat:
sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_pm.c | 11 +-
sys/external/bsd/drm2/dist/drm/i915/i915_active.c | 159 ++++++++++----
sys/external/bsd/drm2/dist/drm/i915/i915_active_types.h | 6 +-
sys/external/bsd/drm2/i915drm/files.i915drmkms | 6 +-
sys/external/bsd/drm2/include/linux/llist.h | 16 +-
sys/external/bsd/drm2/include/linux/refcount.h | 20 +-
sys/external/bsd/drm2/include/linux/spinlock.h | 30 ++-
7 files changed, 169 insertions(+), 79 deletions(-)
diffs (truncated from 537 to 300 lines):
diff -r 0c2d4fd860fa -r c05cbc39e5e5 sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_pm.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_pm.c Sun Dec 19 11:51:59 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gt/intel_engine_pm.c Sun Dec 19 11:52:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intel_engine_pm.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $ */
+/* $NetBSD: intel_engine_pm.c,v 1.3 2021/12/19 11:52:07 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_engine_pm.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_engine_pm.c,v 1.3 2021/12/19 11:52:07 riastradh Exp $");
#include "i915_drv.h"
@@ -229,11 +229,10 @@
struct llist_node *node, *next;
llist_for_each_safe(node, next, llist_del_all(&engine->barrier_tasks)) {
- struct dma_fence_cb *cb =
- container_of((struct list_head *)node,
- typeof(*cb), node);
+ struct i915_active_fence *fence =
+ container_of(node, struct i915_active_fence, llist);
- cb->func(ERR_PTR(-EAGAIN), cb);
+ fence->cb.func(ERR_PTR(-EAGAIN), &fence->cb);
}
}
diff -r 0c2d4fd860fa -r c05cbc39e5e5 sys/external/bsd/drm2/dist/drm/i915/i915_active.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_active.c Sun Dec 19 11:51:59 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_active.c Sun Dec 19 11:52:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i915_active.c,v 1.3 2021/12/19 01:44:57 riastradh Exp $ */
+/* $NetBSD: i915_active.c,v 1.4 2021/12/19 11:52:07 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
@@ -7,7 +7,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_active.c,v 1.3 2021/12/19 01:44:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_active.c,v 1.4 2021/12/19 11:52:07 riastradh Exp $");
#include <linux/debugobjects.h>
@@ -19,6 +19,8 @@
#include "i915_active.h"
#include "i915_globals.h"
+#include <linux/nbsd-namespace.h>
+
/*
* Active refs memory management
*
@@ -36,6 +38,7 @@
struct i915_active *ref;
struct rb_node node;
u64 timeline;
+ struct intel_engine_cs *engine;
};
static inline struct active_node *
@@ -54,13 +57,13 @@
static inline struct llist_node *barrier_to_ll(struct active_node *node)
{
GEM_BUG_ON(!is_barrier(&node->base));
- return (struct llist_node *)&node->base.cb.node;
+ return &node->base.llist;
}
static inline struct intel_engine_cs *
__barrier_to_engine(struct active_node *node)
{
- return (struct intel_engine_cs *)READ_ONCE(node->base.cb.node.prev);
+ return READ_ONCE(node->engine);
}
static inline struct intel_engine_cs *
@@ -72,8 +75,7 @@
static inline struct active_node *barrier_from_ll(struct llist_node *x)
{
- return container_of((struct list_head *)x,
- struct active_node, base.cb.node);
+ return container_of(x, struct active_node, base.llist);
}
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) && IS_ENABLED(CONFIG_DEBUG_OBJECTS)
@@ -129,6 +131,42 @@
#endif
+#ifdef __NetBSD__
+
+static int
+compare_nodes(void *cookie, const void *va, const void *vb)
+{
+ const struct active_node *a = va;
+ const struct active_node *b = vb;
+
+ if (a->timeline < b->timeline)
+ return -1;
+ if (a->timeline > b->timeline)
+ return +1;
+ return 0;
+}
+
+static int
+compare_node_key(void *cookie, const void *vn, const void *vk)
+{
+ const struct active_node *a = vn;
+ const uint64_t *k = vk;
+
+ if (a->timeline < *k)
+ return -1;
+ if (a->timeline > *k)
+ return +1;
+ return 0;
+}
+
+static const rb_tree_ops_t active_rb_ops = {
+ .rbto_compare_nodes = compare_nodes,
+ .rbto_compare_key = compare_node_key,
+ .rbto_node_offset = offsetof(struct active_node, node),
+};
+
+#endif
+
static void
__active_retire(struct i915_active *ref)
{
@@ -146,9 +184,15 @@
debug_active_deactivate(ref);
root = ref->tree;
+#ifdef __NetBSD__
+ rb_tree_init(&ref->tree.rbr_tree, &active_rb_ops);
+#else
ref->tree = RB_ROOT;
+#endif
ref->cache = NULL;
+ DRM_SPIN_WAKEUP_ALL(&ref->tree_wq, &ref->tree_lock);
+
spin_unlock_irqrestore(&ref->tree_lock, flags);
/* After the final retire, the entire struct may be freed */
@@ -156,7 +200,6 @@
ref->retire(ref);
/* ... except if you wait on it, you must manage your own references! */
- wake_up_var(ref);
rbtree_postorder_for_each_entry_safe(it, n, &root, node) {
GEM_BUG_ON(i915_active_fence_isset(&it->base));
@@ -249,7 +292,7 @@
#ifdef __NetBSD__
__USE(parent);
__USE(p);
- node = rb_tree_find_node(&vma->active.rbr_tree, &idx);
+ node = rb_tree_find_node(&ref->tree.rbr_tree, &idx);
if (node) {
KASSERT(node->timeline == idx);
goto out;
@@ -279,8 +322,8 @@
node->timeline = idx;
#ifdef __NetBSD__
- struct i915_vma_active *collision __diagused;
- collision = rb_tree_insert_node(&vma->active.rbr_tree, node);
+ struct active_node *collision __diagused;
+ collision = rb_tree_insert_node(&ref->tree.rbr_tree, node);
KASSERT(collision == node);
#else
rb_link_node(&node->node, parent, p);
@@ -295,40 +338,6 @@
return &node->base;
}
-#ifdef __NetBSD__
-static int
-compare_active(void *cookie, const void *va, const void *vb)
-{
- const struct i915_active *a = va;
- const struct i915_active *b = vb;
-
- if (a->timeline < b->timeline)
- return -1;
- if (a->timeline > b->timeline)
- return +1;
- return 0;
-}
-
-static int
-compare_active_key(void *cookie, const void *vn, const void *vk)
-{
- const struct i915_active *a = vn;
- const uint64_t *k = vk;
-
- if (a->timeline < *k)
- return -1;
- if (a->timeline > *k)
- return +1;
- return 0;
-}
-
-static const rb_tree_ops_t active_rb_ops = {
- .rbto_compare_nodes = compare_active,
- .rbto_compare_key = compare_active_key,
- .rbto_node_offset = offsetof(struct i915_active, node),
-};
-#endif
-
void __i915_active_init(struct i915_active *ref,
int (*active)(struct i915_active *ref),
void (*retire)(struct i915_active *ref),
@@ -346,8 +355,9 @@
ref->flags |= I915_ACTIVE_RETIRE_SLEEPS;
spin_lock_init(&ref->tree_lock);
+ DRM_INIT_WAITQUEUE(&ref->tree_wq, "i915act");
#ifdef __NetBSD__
- rb_tree_init(&vma->active.rbr_tree, &active_rb_ops);
+ rb_tree_init(&ref->tree.rbr_tree, &active_rb_ops);
#else
ref->tree = RB_ROOT;
#endif
@@ -533,8 +543,12 @@
if (err)
return err;
- if (wait_var_event_interruptible(ref, i915_active_is_idle(ref)))
- return -EINTR;
+ spin_lock(&ref->tree_lock);
+ DRM_SPIN_WAIT_UNTIL(err, &ref->tree_wq, &ref->tree_lock,
+ i915_active_is_idle(ref));
+ spin_unlock(&ref->tree_lock);
+ if (err)
+ return err;
flush_work(&ref->work);
return 0;
@@ -599,6 +613,21 @@
goto match;
}
+#ifdef __NetBSD__
+ {
+ struct active_node *node =
+ rb_tree_find_node_leq(&ref->tree.rbr_tree, &idx);
+ if (node) {
+ if (node->timeline == idx && is_idle_barrier(node, idx)) {
+ p = &node->node;
+ goto match;
+ }
+ prev = &node->node;
+ } else {
+ prev = NULL;
+ }
+ }
+#else
prev = NULL;
p = ref->tree.rb_node;
while (p) {
@@ -614,6 +643,7 @@
else
p = p->rb_left;
}
+#endif
/*
* No quick match, but we did find the leftmost rb_node for the
@@ -621,7 +651,7 @@
* any idle-barriers on this timeline that we missed, or just use
* the first pending barrier.
*/
- for (p = prev; p; p = rb_next(p)) {
+ for (p = prev; p; p = rb_next2(&ref->tree, p)) {
struct active_node *node =
rb_entry(p, struct active_node, node);
struct intel_engine_cs *engine;
@@ -712,7 +742,7 @@
* for our tracking of the pending barrier.
*/
RCU_INIT_POINTER(node->base.fence, ERR_PTR(-EAGAIN));
- node->base.cb.node.prev = (void *)engine;
+ node->engine = engine;
atomic_inc(&ref->count);
}
GEM_BUG_ON(rcu_access_pointer(node->base.fence) != ERR_PTR(-EAGAIN));
@@ -764,6 +794,13 @@
spin_lock_irqsave_nested(&ref->tree_lock, flags,
SINGLE_DEPTH_NESTING);
Home |
Main Index |
Thread Index |
Old Index