aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorZhi Wang <zhi.a.wang@intel.com>2016-06-16 08:07:03 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2016-06-17 15:36:19 -0400
commit3c7ba6359d70f780de3141c8ab81ac37ad624f05 (patch)
tree24c8e8e22ee96284d00982cf131f261f80014b9f /drivers/gpu/drm
parentc01fc5322956eb03fd4d1fe2251f037ace890172 (diff)
drm/i915: Introduce execlist context status change notification
This patch introduces an approach to track the execlist context status change. GVT-g uses GVT context as the "shadow context". The content inside GVT context will be copied back to guest after the context is idle. And GVT-g has to know the status of the execlist context. This function is configurable when creating a new GEM context. Currently, Only GVT-g will create the "status-change-notification" enabled GEM context. v10: - Fix the identation. (Joonas) v8: - Remove the boolean flag in struct i915_gem_context. (Joonas) v7: - Remove per-engine ctx status notifiers. Use one status notifier for all engines. (Joonas) - Add prefix "INTEL_" for related definitions. (Joonas) - Refine the comments in execlists_context_status_change(). (Joonas) v6: - When !CONFIG_DRM_I915_GVT, make GVT code as dead code then compiler could automatically eliminate them for us. (Chris) - Always initialize the notifier header, so it could be switched on/off at runtime. (Chris) v5: - Only compile this feature when CONFIG_DRM_I915_GVT is enabled.(Tvrtko) Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> (v8) Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Signed-off-by: Zhi Wang <zhi.a.wang@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1466078825-6662-8-git-send-email-zhi.a.wang@intel.com Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h1
-rw-r--r--drivers/gpu/drm/i915/i915_gem_context.c1
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c22
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.h5
4 files changed, 29 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 369fe888c921..85b92b285670 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -882,6 +882,7 @@ struct i915_gem_context {
882 } engine[I915_NUM_ENGINES]; 882 } engine[I915_NUM_ENGINES];
883 u32 ring_size; 883 u32 ring_size;
884 u32 desc_template; 884 u32 desc_template;
885 struct atomic_notifier_head status_notifier;
885 886
886 struct list_head link; 887 struct list_head link;
887 888
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index bd1360259ac5..d9e30e111067 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -298,6 +298,7 @@ __create_hw_context(struct drm_device *dev,
298 ctx->ring_size = 4 * PAGE_SIZE; 298 ctx->ring_size = 4 * PAGE_SIZE;
299 ctx->desc_template = GEN8_CTX_ADDRESSING_MODE(dev_priv) << 299 ctx->desc_template = GEN8_CTX_ADDRESSING_MODE(dev_priv) <<
300 GEN8_CTX_ADDRESSING_MODE_SHIFT; 300 GEN8_CTX_ADDRESSING_MODE_SHIFT;
301 ATOMIC_INIT_NOTIFIER_HEAD(&ctx->status_notifier);
301 302
302 return ctx; 303 return ctx;
303 304
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 2116f865a8d6..67d19bd5a481 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -404,6 +404,20 @@ static void execlists_submit_requests(struct drm_i915_gem_request *rq0,
404 spin_unlock_irq(&dev_priv->uncore.lock); 404 spin_unlock_irq(&dev_priv->uncore.lock);
405} 405}
406 406
407static inline void execlists_context_status_change(
408 struct drm_i915_gem_request *rq,
409 unsigned long status)
410{
411 /*
412 * Only used when GVT-g is enabled now. When GVT-g is disabled,
413 * The compiler should eliminate this function as dead-code.
414 */
415 if (!IS_ENABLED(CONFIG_DRM_I915_GVT))
416 return;
417
418 atomic_notifier_call_chain(&rq->ctx->status_notifier, status, rq);
419}
420
407static void execlists_context_unqueue(struct intel_engine_cs *engine) 421static void execlists_context_unqueue(struct intel_engine_cs *engine)
408{ 422{
409 struct drm_i915_gem_request *req0 = NULL, *req1 = NULL; 423 struct drm_i915_gem_request *req0 = NULL, *req1 = NULL;
@@ -439,6 +453,12 @@ static void execlists_context_unqueue(struct intel_engine_cs *engine)
439 if (unlikely(!req0)) 453 if (unlikely(!req0))
440 return; 454 return;
441 455
456 execlists_context_status_change(req0, INTEL_CONTEXT_SCHEDULE_IN);
457
458 if (req1)
459 execlists_context_status_change(req1,
460 INTEL_CONTEXT_SCHEDULE_IN);
461
442 if (req0->elsp_submitted & engine->idle_lite_restore_wa) { 462 if (req0->elsp_submitted & engine->idle_lite_restore_wa) {
443 /* 463 /*
444 * WaIdleLiteRestore: make sure we never cause a lite restore 464 * WaIdleLiteRestore: make sure we never cause a lite restore
@@ -477,6 +497,8 @@ execlists_check_remove_request(struct intel_engine_cs *engine, u32 ctx_id)
477 if (--head_req->elsp_submitted > 0) 497 if (--head_req->elsp_submitted > 0)
478 return 0; 498 return 0;
479 499
500 execlists_context_status_change(head_req, INTEL_CONTEXT_SCHEDULE_OUT);
501
480 list_del(&head_req->execlist_link); 502 list_del(&head_req->execlist_link);
481 i915_gem_request_unreference(head_req); 503 i915_gem_request_unreference(head_req);
482 504
diff --git a/drivers/gpu/drm/i915/intel_lrc.h b/drivers/gpu/drm/i915/intel_lrc.h
index a8db42a9c50f..2b8255c19dcc 100644
--- a/drivers/gpu/drm/i915/intel_lrc.h
+++ b/drivers/gpu/drm/i915/intel_lrc.h
@@ -57,6 +57,11 @@
57#define GEN8_CSB_READ_PTR(csb_status) \ 57#define GEN8_CSB_READ_PTR(csb_status) \
58 (((csb_status) & GEN8_CSB_READ_PTR_MASK) >> 8) 58 (((csb_status) & GEN8_CSB_READ_PTR_MASK) >> 8)
59 59
60enum {
61 INTEL_CONTEXT_SCHEDULE_IN = 0,
62 INTEL_CONTEXT_SCHEDULE_OUT,
63};
64
60/* Logical Rings */ 65/* Logical Rings */
61int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request); 66int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request);
62int intel_logical_ring_reserve_space(struct drm_i915_gem_request *request); 67int intel_logical_ring_reserve_space(struct drm_i915_gem_request *request);