]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
drm/i915: Only track real ppgtt for a context
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 6 Aug 2014 13:04:53 +0000 (15:04 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 13 Aug 2014 12:23:33 +0000 (14:23 +0200)
There's a bit a confusion since we track the global gtt,
the aliasing and real ppgtt in the ctx->vm pointer. And not
all callers really bother to check for the different cases and just
presume that it points to a real ppgtt.

Now looking closely we don't actually need ->vm to always point at an
address space - the only place that cares actually has fixup code
already to decide whether to look at the per-proces or the global
address space.

So switch to just tracking the ppgtt directly and ditch all the
extraneous code.

v2: Fixup the ppgtt debugfs file to not oops on a NULL ctx->ppgtt.
Also drop the early exit - without aliasing ppgtt we want to dump all
the ppgtts of the contexts if we have full ppgtt.

v3: Actually git add the compile fix.

Reviewed-by: Michel Thierry <michel.thierry@intel.com>
Cc: "Thierry, Michel" <michel.thierry@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
OTC-Jira: VIZ-3724
[danvet: Resolve conflicts with execlist patches while applying.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/i915_gem_execbuffer.c
drivers/gpu/drm/i915/i915_gpu_error.c
drivers/gpu/drm/i915/intel_lrc.c

index 1c3a9943a742e63e43ec6c51e8e9923de6d0be56..d42db6bc34e07b1af72c3ccdec2832215bb5e518 100644 (file)
@@ -1821,7 +1821,13 @@ static int per_file_ctx(int id, void *ptr, void *data)
 {
        struct intel_context *ctx = ptr;
        struct seq_file *m = data;
-       struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(ctx);
+       struct i915_hw_ppgtt *ppgtt = ctx->ppgtt;
+
+       if (!ppgtt) {
+               seq_printf(m, "  no ppgtt for context %d\n",
+                          ctx->user_handle);
+               return 0;
+       }
 
        if (i915_gem_context_is_default(ctx))
                seq_puts(m, "  default context:\n");
@@ -1881,8 +1887,7 @@ static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev)
                seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset);
 
                ppgtt->debug_dump(ppgtt, m);
-       } else
-               return;
+       }
 
        list_for_each_entry_reverse(file, &dev->filelist, lhead) {
                struct drm_i915_file_private *file_priv = file->driver_priv;
index 2db22732c7aec507cb5bab3ab220235676e58687..eb99a109c0bc7849c8280e24f19f97d2d16475a5 100644 (file)
@@ -624,7 +624,7 @@ struct intel_context {
        uint8_t remap_slice;
        struct drm_i915_file_private *file_priv;
        struct i915_ctx_hang_stats hang_stats;
-       struct i915_address_space *vm;
+       struct i915_hw_ppgtt *ppgtt;
 
        /* Legacy ring buffer submission */
        struct {
@@ -2556,7 +2556,6 @@ i915_gem_object_ggtt_unbind(struct drm_i915_gem_object *obj)
 void i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj);
 
 /* i915_gem_context.c */
-#define ctx_to_ppgtt(ctx) container_of((ctx)->vm, struct i915_hw_ppgtt, base)
 int __must_check i915_gem_context_init(struct drm_device *dev);
 void i915_gem_context_fini(struct drm_device *dev);
 void i915_gem_context_reset(struct drm_device *dev);
index 7093f5df9ee77adb2b3867b119ff2372fe49cc63..206bf2d6c554da51efe203c96fdbefa7b3a0f17a 100644 (file)
@@ -135,19 +135,13 @@ static int get_context_size(struct drm_device *dev)
 void i915_gem_context_free(struct kref *ctx_ref)
 {
        struct intel_context *ctx = container_of(ctx_ref,
-                                                  typeof(*ctx), ref);
-       struct i915_hw_ppgtt *ppgtt = NULL;
+                                                typeof(*ctx), ref);
 
-       if (i915.enable_execlists) {
-               ppgtt = ctx_to_ppgtt(ctx);
+       if (i915.enable_execlists)
                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);
-       }
 
-       i915_ppgtt_put(ppgtt);
+       i915_ppgtt_put(ctx->ppgtt);
+
        if (ctx->legacy_hw_ctx.rcs_state)
                drm_gem_object_unreference(&ctx->legacy_hw_ctx.rcs_state->base);
        list_del(&ctx->link);
@@ -243,7 +237,6 @@ i915_gem_create_context(struct drm_device *dev,
                        bool create_vm)
 {
        const bool is_global_default_ctx = file_priv == NULL;
-       struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_context *ctx;
        int ret = 0;
 
@@ -277,15 +270,10 @@ i915_gem_create_context(struct drm_device *dev,
                                         PTR_ERR(ppgtt));
                        ret = PTR_ERR(ppgtt);
                        goto err_unpin;
-               } else
-                       ctx->vm = &ppgtt->base;
-       } else if (USES_PPGTT(dev)) {
-               /* For platforms which only have aliasing PPGTT, we fake the
-                * address space and refcounting. */
-               ctx->vm = &dev_priv->mm.aliasing_ppgtt->base;
-               i915_ppgtt_get(dev_priv->mm.aliasing_ppgtt);
-       } else
-               ctx->vm = &dev_priv->gtt.base;
+               }
+
+               ctx->ppgtt = ppgtt;
+       }
 
        return ctx;
 
@@ -543,7 +531,6 @@ static int do_switch(struct intel_engine_cs *ring,
 {
        struct drm_i915_private *dev_priv = ring->dev->dev_private;
        struct intel_context *from = ring->last_context;
-       struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(to);
        u32 hw_flags = 0;
        bool uninitialized = false;
        int ret, i;
@@ -571,8 +558,8 @@ static int do_switch(struct intel_engine_cs *ring,
         */
        from = ring->last_context;
 
-       if (USES_FULL_PPGTT(ring->dev)) {
-               ret = ppgtt->switch_mm(ppgtt, ring, false);
+       if (to->ppgtt) {
+               ret = to->ppgtt->switch_mm(to->ppgtt, ring, false);
                if (ret)
                        goto unpin_out;
        }
index 7e04a4825ed0758148a4c6edfe047bd62179e72d..1a0611bb576b3eb9b78ede149955f36b798360df 100644 (file)
@@ -1315,8 +1315,9 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 
        i915_gem_context_reference(ctx);
 
-       vm = ctx->vm;
-       if (!USES_FULL_PPGTT(dev))
+       if (ctx->ppgtt)
+               vm = &ctx->ppgtt->base;
+       else
                vm = &dev_priv->gtt.base;
 
        eb = eb_create(args);
index eab41f9390f8c3bd1907c7625488c977a910ead3..fc11ac6b0373e37c23a318b366f5d1066ef6c4ce 100644 (file)
@@ -967,6 +967,12 @@ static void i915_gem_record_rings(struct drm_device *dev,
 
                request = i915_gem_find_active_request(ring);
                if (request) {
+                       struct i915_address_space *vm;
+
+                       vm = request->ctx && request->ctx->ppgtt ?
+                               &request->ctx->ppgtt->base :
+                               &dev_priv->gtt.base;
+
                        /* We need to copy these to an anonymous buffer
                         * as the simplest method to avoid being overwritten
                         * by userspace.
@@ -974,9 +980,7 @@ static void i915_gem_record_rings(struct drm_device *dev,
                        error->ring[i].batchbuffer =
                                i915_error_object_create(dev_priv,
                                                         request->batch_obj,
-                                                        request->ctx ?
-                                                        request->ctx->vm :
-                                                        &dev_priv->gtt.base);
+                                                        vm);
 
                        if (HAS_BROKEN_CS_TLB(dev_priv->dev) &&
                            ring->scratch.obj)
index 6f1b64e01a051ecc6d9b290c4ff723e3f7de62a2..6b5f416b5c0dd76f823c60e17e0fd6f94a9c1b7e 100644 (file)
@@ -904,7 +904,7 @@ populate_lr_context(struct intel_context *ctx, struct drm_i915_gem_object *ctx_o
                    struct intel_engine_cs *ring, struct intel_ringbuffer *ringbuf)
 {
        struct drm_i915_gem_object *ring_obj = ringbuf->obj;
-       struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(ctx);
+       struct i915_hw_ppgtt *ppgtt = ctx->ppgtt;
        struct page *page;
        uint32_t *reg_state;
        int ret;