]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
drm/i915/bdw: Initialization for Logical Ring Contexts
authorOscar Mateo <oscar.mateo@intel.com>
Thu, 24 Jul 2014 16:04:12 +0000 (17:04 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 11 Aug 2014 14:04:11 +0000 (16:04 +0200)
For the moment this is just a placeholder, but it shows one of the
main differences between the good ol' HW contexts and the shiny
new Logical Ring Contexts: LR contexts allocate  and free their
own backing objects. Another difference is that the allocation is
deferred (as the create function name suggests), but that does not
happen in this patch yet, because for the moment we are only dealing
with the default context.

Early in the series we had our own gen8_gem_context_init/fini
functions, but the truth is they now look almost the same as the
legacy hw context init/fini functions. We can always split them
later if this ceases to be the case.

Also, we do not fall back to legacy ringbuffers when logical ring
context initialization fails (not very likely to happen and, even
if it does, hw contexts would probably fail as well).

v2: Daniel says "explain, do not showcase".

Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>
[danvet: s/BUG_ON/WARN_ON/.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/intel_lrc.h

index 3b99390e467aa3bfabcfb99438d66981ec2509c0..3552a351ccf7fd7f4abdcabbaec17117b684c4d3 100644 (file)
@@ -182,7 +182,10 @@ void i915_gem_context_free(struct kref *ctx_ref)
                                                   typeof(*ctx), ref);
        struct i915_hw_ppgtt *ppgtt = NULL;
 
-       if (ctx->legacy_hw_ctx.rcs_state) {
+       if (i915.enable_execlists) {
+               ppgtt = ctx_to_ppgtt(ctx);
+               intel_lr_context_free(ctx);
+       } else if (ctx->legacy_hw_ctx.rcs_state) {
                /* We refcount even the aliasing PPGTT to keep the code symmetric */
                if (USES_PPGTT(ctx->legacy_hw_ctx.rcs_state->base.dev))
                        ppgtt = ctx_to_ppgtt(ctx);
@@ -417,7 +420,11 @@ int i915_gem_context_init(struct drm_device *dev)
        if (WARN_ON(dev_priv->ring[RCS].default_context))
                return 0;
 
-       if (HAS_HW_CONTEXTS(dev)) {
+       if (i915.enable_execlists) {
+               /* NB: intentionally left blank. We will allocate our own
+                * backing objects as we need them, thank you very much */
+               dev_priv->hw_context_size = 0;
+       } else if (HAS_HW_CONTEXTS(dev)) {
                dev_priv->hw_context_size = round_up(get_context_size(dev), 4096);
                if (dev_priv->hw_context_size > (1<<20)) {
                        DRM_DEBUG_DRIVER("Disabling HW Contexts; invalid size %d\n",
@@ -433,11 +440,20 @@ int i915_gem_context_init(struct drm_device *dev)
                return PTR_ERR(ctx);
        }
 
-       /* NB: RCS will hold a ref for all rings */
-       for (i = 0; i < I915_NUM_RINGS; i++)
-               dev_priv->ring[i].default_context = ctx;
+       for (i = 0; i < I915_NUM_RINGS; i++) {
+               struct intel_engine_cs *ring = &dev_priv->ring[i];
+
+               /* NB: RCS will hold a ref for all rings */
+               ring->default_context = ctx;
+
+               /* FIXME: we really only want to do this for initialized rings */
+               if (i915.enable_execlists)
+                       intel_lr_context_deferred_create(ctx, ring);
+       }
 
-       DRM_DEBUG_DRIVER("%s context support initialized\n", dev_priv->hw_context_size ? "HW" : "fake");
+       DRM_DEBUG_DRIVER("%s context support initialized\n",
+                       i915.enable_execlists ? "LR" :
+                       dev_priv->hw_context_size ? "HW" : "fake");
        return 0;
 }
 
@@ -779,6 +795,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
        struct intel_context *ctx;
        int ret;
 
+       /* FIXME: allow user-created LR contexts as well */
        if (!hw_context_enabled(dev))
                return -ENODEV;
 
index 44721292eb770032216093f83a371167d6ddcc97..2d82d52d18bb94fc8d6dd3e7ea182c0a367a057f 100644 (file)
@@ -53,3 +53,18 @@ int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists
 
        return 0;
 }
+
+void intel_lr_context_free(struct intel_context *ctx)
+{
+       /* TODO */
+}
+
+int intel_lr_context_deferred_create(struct intel_context *ctx,
+                                    struct intel_engine_cs *ring)
+{
+       WARN_ON(ctx->legacy_hw_ctx.rcs_state != NULL);
+
+       /* TODO */
+
+       return 0;
+}
index 75ee9c3cb7dc067c5f7c82e8f71d52f3aa68794c..3b93572431e3ed58ab839f325f8270d6c8b92cf5 100644 (file)
 #ifndef _INTEL_LRC_H_
 #define _INTEL_LRC_H_
 
+/* Logical Ring Contexts */
+void intel_lr_context_free(struct intel_context *ctx);
+int intel_lr_context_deferred_create(struct intel_context *ctx,
+                                    struct intel_engine_cs *ring);
+
 /* Execlists */
 int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists);