drm/i915: Track file_priv, not ctx in the ppgtt structure
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 6 Aug 2014 13:04:47 +0000 (15:04 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 13 Aug 2014 12:23:28 +0000 (14:23 +0200)
Hardware contexts reference a ppgtt, not the other way round. And the
only user of this (in debugfs) actually only cares about which file
the ppgtt is associated with. So give it what it wants.

While at it give the ppgtt create function a proper name&place.

Reviewed-by: Michel Thierry <michel.thierry@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_gem_gtt.h

index 3b7decbeeed3c548d27e762c30b6e0d4fc62e6a1..1c3a9943a742e63e43ec6c51e8e9923de6d0be56 100644 (file)
@@ -333,7 +333,7 @@ static int per_file_stats(int id, void *ptr, void *data)
                        }
 
                        ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base);
-                       if (ppgtt->ctx && ppgtt->ctx->file_priv != stats->file_priv)
+                       if (ppgtt->file_priv != stats->file_priv)
                                continue;
 
                        if (obj->ring) /* XXX per-vma statistic */
index dc43d0263a01e625e80893b3584c56ae247c7bdf..90665872734d9bdf40fc464c8cd37579e0acef51 100644 (file)
@@ -184,26 +184,6 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)
        return obj;
 }
 
-static struct i915_hw_ppgtt *
-create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx)
-{
-       struct i915_hw_ppgtt *ppgtt;
-       int ret;
-
-       ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
-       if (!ppgtt)
-               return ERR_PTR(-ENOMEM);
-
-       ret = i915_ppgtt_init(dev, ppgtt);
-       if (ret) {
-               kfree(ppgtt);
-               return ERR_PTR(ret);
-       }
-
-       ppgtt->ctx = ctx;
-       return ppgtt;
-}
-
 static struct intel_context *
 __create_hw_context(struct drm_device *dev,
                    struct drm_i915_file_private *file_priv)
@@ -290,7 +270,7 @@ i915_gem_create_context(struct drm_device *dev,
        }
 
        if (create_vm) {
-               struct i915_hw_ppgtt *ppgtt = create_vm_for_ctx(dev, ctx);
+               struct i915_hw_ppgtt *ppgtt = i915_ppgtt_create(dev, file_priv);
 
                if (IS_ERR_OR_NULL(ppgtt)) {
                        DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n",
index 6ffa12b72538fbf5238655af21fdc9abd13c7c45..a5715faba65fa34d556ea510d6640e78f863f062 100644 (file)
@@ -1211,6 +1211,27 @@ int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)
        return ret;
 }
 
+struct i915_hw_ppgtt *
+i915_ppgtt_create(struct drm_device *dev, struct drm_i915_file_private *fpriv)
+{
+       struct i915_hw_ppgtt *ppgtt;
+       int ret;
+
+       ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
+       if (!ppgtt)
+               return ERR_PTR(-ENOMEM);
+
+       ret = i915_ppgtt_init(dev, ppgtt);
+       if (ret) {
+               kfree(ppgtt);
+               return ERR_PTR(ret);
+       }
+
+       ppgtt->file_priv = fpriv;
+
+       return ppgtt;
+}
+
 void  i915_ppgtt_release(struct kref *kref)
 {
        struct i915_hw_ppgtt *ppgtt =
index c6beb528f955c775106f8abf0a4add4beaab0117..90ff45246b62d782b2c132c4ed42341e80c2e329 100644 (file)
@@ -34,6 +34,8 @@
 #ifndef __I915_GEM_GTT_H__
 #define __I915_GEM_GTT_H__
 
+struct drm_i915_file_private;
+
 typedef uint32_t gen6_gtt_pte_t;
 typedef uint64_t gen8_gtt_pte_t;
 typedef gen8_gtt_pte_t gen8_ppgtt_pde_t;
@@ -258,7 +260,7 @@ struct i915_hw_ppgtt {
                dma_addr_t *gen8_pt_dma_addr[4];
        };
 
-       struct intel_context *ctx;
+       struct drm_i915_file_private *file_priv;
 
        int (*enable)(struct i915_hw_ppgtt *ppgtt);
        int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
@@ -275,6 +277,8 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, unsigned long start,
 
 int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt);
 void i915_ppgtt_release(struct kref *kref);
+struct i915_hw_ppgtt *i915_ppgtt_create(struct drm_device *dev,
+                                       struct drm_i915_file_private *fpriv);
 static inline void i915_ppgtt_get(struct i915_hw_ppgtt *ppgtt)
 {
        if (ppgtt)