summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Harrison <John.C.Harrison@Intel.com>2015-10-26 12:22:22 +0000
committerJohn Harrison <John.C.Harrison@Intel.com>2016-05-06 14:12:46 +0100
commit4ecd753df36e64aa078cb2e846954fee2a7650ed (patch)
tree5be7b1a320fbcdde2ad5015c3d05000f88857d57
parent031d89719ae15ab42a7a1182fbac8f6721d8f455 (diff)
drm/i915: Cache last IRQ seqno to reduce IRQ overhead
The notify function can be called many times without the seqno changing. A large number of duplicates are to prevent races due to the requirement of not enabling interrupts until requested. However, when interrupts are enabled the IRQ handle can be called multiple times without the ring's seqno value changing. This patch reduces the overhead of these extra calls by caching the last processed seqno value and early exiting if it has not changed. v3: New patch for series. v5: Added comment about last_irq_seqno usage due to code review feedback (Tvrtko Ursulin). v6: Minor update to resolve a race condition with the wait_request optimisation. v7: Updated to newer nightly - lots of ring -> engine renaming plus an interface change to get_seqno(). For: VIZ-5190 Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c26
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.h1
2 files changed, 23 insertions, 4 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 596c46929fee..a0d67f80e679 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1383,6 +1383,7 @@ out:
* request has not actually been fully processed yet.
*/
spin_lock_irq(&req->engine->fence_lock);
+ req->engine->last_irq_seqno = 0;
i915_gem_request_notify(req->engine, true);
spin_unlock_irq(&req->engine->fence_lock);
}
@@ -2584,9 +2585,12 @@ i915_gem_init_seqno(struct drm_device *dev, u32 seqno)
i915_gem_retire_requests(dev);
/* Finally reset hw state */
- for_each_engine(engine, dev_priv)
+ for_each_engine(engine, dev_priv) {
intel_ring_init_seqno(engine, seqno);
+ engine->last_irq_seqno = 0;
+ }
+
return 0;
}
@@ -2920,13 +2924,24 @@ void i915_gem_request_notify(struct intel_engine_cs *engine, bool fence_locked)
return;
}
- if (!fence_locked)
- spin_lock_irqsave(&engine->fence_lock, flags);
-
+ /*
+ * Check for a new seqno. If it hasn't actually changed then early
+ * exit without even grabbing the spinlock. Note that this is safe
+ * because any corruption of last_irq_seqno merely results in doing
+ * the full processing when there is potentially no work to be done.
+ * It can never lead to not processing work that does need to happen.
+ */
if (engine->irq_seqno_barrier)
engine->irq_seqno_barrier(engine);
seqno = engine->get_seqno(engine);
trace_i915_gem_request_notify(engine, seqno);
+ if (seqno == engine->last_irq_seqno)
+ return;
+
+ if (!fence_locked)
+ spin_lock_irqsave(&engine->fence_lock, flags);
+
+ engine->last_irq_seqno = seqno;
list_for_each_entry_safe(req, req_next, &engine->fence_signal_list, signal_link) {
if (!req->cancelled) {
@@ -3242,7 +3257,10 @@ static void i915_gem_reset_engine_cleanup(struct drm_i915_private *dev_priv,
* Tidy up anything left over. This includes a call to
* i915_gem_request_notify() which will make sure that any requests
* that were on the signal pending list get also cleaned up.
+ * NB: The seqno cache must be cleared otherwise the notify call will
+ * simply return immediately.
*/
+ engine->last_irq_seqno = 0;
i915_gem_retire_requests_ring(engine);
/* Having flushed all requests from all queues, we know that all
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 160e71e89925..c75c5e1eb7ca 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -359,6 +359,7 @@ struct intel_engine_cs {
spinlock_t fence_lock;
struct list_head fence_signal_list;
struct list_head fence_unsignal_list;
+ uint32_t last_irq_seqno;
};
static inline bool