[PATCH 4/4] drm/i915: Make the stale cached active node available for any timeline

Chris Wilson chris at chris-wilson.co.uk
Thu Jul 9 09:15:43 UTC 2020


Rather than require the next timeline after idling to match the MRU
before idling, reset the index on the node and allow it to match the
first request. However, this requires cmpxchg(u64) and so is not trivial
on 32b, so for compatability we just fallback to keeping the cached node
pointing to the MRU timline.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_active.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
index 437c60920d5b..38f4f45e7a04 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -151,6 +151,11 @@ __active_retire(struct i915_active *ref)
 		rb_link_node(&ref->cache->node, NULL, &ref->tree.rb_node);
 		rb_insert_color(&ref->cache->node, &ref->tree);
 		GEM_BUG_ON(ref->tree.rb_node != &ref->cache->node);
+
+#ifdef CONFIG_64BIT
+		/* Make the cached node available for reuse with any timeline */
+		ref->cache->timeline = 0; /* needs cmpxchg(u64) */
+#endif
 	}
 
 	spin_unlock_irqrestore(&ref->tree_lock, flags);
@@ -230,10 +235,17 @@ static struct active_node *__active_lookup(struct i915_active *ref, u64 idx)
 	struct active_node *node;
 	struct rb_node *p;
 
+	GEM_BUG_ON(idx == 0);
+
 	node = READ_ONCE(ref->cache);
 	if (node && node->timeline == idx)
 		return node;
 
+#ifdef CONFIG_64BIT
+	if (node && !cmpxchg(&node->timeline, 0, idx))
+		return node;
+#endif
+
 	spin_lock_irq(&ref->tree_lock);
 	GEM_BUG_ON(i915_active_is_idle(ref));
 	p = ref->tree.rb_node;
-- 
2.20.1



More information about the Intel-gfx-trybot mailing list