drm/i915/gem: Peek at the inflight context
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 29 Dec 2020 14:41:14 +0000 (14:41 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 29 Dec 2020 19:28:45 +0000 (19:28 +0000)
If supported by the backend, we can quickly look at the context's
inflight engine rather than search along the active list to confirm.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Andi Shyti <andi.shyti@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201229144114.31686-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gem/i915_gem_context.c
drivers/gpu/drm/i915/gt/intel_context.h
drivers/gpu/drm/i915/gt/intel_context_types.h
drivers/gpu/drm/i915/gt/intel_execlists_submission.c

index c736303..68f5876 100644 (file)
@@ -423,6 +423,9 @@ static struct intel_engine_cs *active_engine(struct intel_context *ce)
        struct intel_engine_cs *engine = NULL;
        struct i915_request *rq;
 
+       if (intel_context_has_inflight(ce))
+               return intel_context_inflight(ce);
+
        if (!ce->timeline)
                return NULL;
 
index 2ce2ec6..d24ab6f 100644 (file)
@@ -191,6 +191,11 @@ static inline bool intel_context_is_closed(const struct intel_context *ce)
        return test_bit(CONTEXT_CLOSED_BIT, &ce->flags);
 }
 
+static inline bool intel_context_has_inflight(const struct intel_context *ce)
+{
+       return test_bit(COPS_HAS_INFLIGHT_BIT, &ce->ops->flags);
+}
+
 static inline bool intel_context_use_semaphores(const struct intel_context *ce)
 {
        return test_bit(CONTEXT_USE_SEMAPHORES, &ce->flags);
index f7a0fb6..430aafb 100644 (file)
@@ -30,6 +30,10 @@ struct intel_context;
 struct intel_ring;
 
 struct intel_context_ops {
+       unsigned long flags;
+#define COPS_HAS_INFLIGHT_BIT 0
+#define COPS_HAS_INFLIGHT BIT(COPS_HAS_INFLIGHT_BIT)
+
        int (*alloc)(struct intel_context *ce);
 
        int (*pre_pin)(struct intel_context *ce, struct i915_gem_ww_ctx *ww, void **vaddr);
index 1fae6c6..f08ba2d 100644 (file)
@@ -2531,6 +2531,8 @@ static int execlists_context_alloc(struct intel_context *ce)
 }
 
 static const struct intel_context_ops execlists_context_ops = {
+       .flags = COPS_HAS_INFLIGHT,
+
        .alloc = execlists_context_alloc,
 
        .pre_pin = execlists_context_pre_pin,
@@ -3441,6 +3443,8 @@ static void virtual_context_exit(struct intel_context *ce)
 }
 
 static const struct intel_context_ops virtual_context_ops = {
+       .flags = COPS_HAS_INFLIGHT,
+
        .alloc = virtual_context_alloc,
 
        .pre_pin = virtual_context_pre_pin,