]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/i915: Make GEM object alloc/free and stolen created take dev_priv
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Thu, 1 Dec 2016 14:16:36 +0000 (14:16 +0000)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Thu, 1 Dec 2016 18:00:15 +0000 (18:00 +0000)
Where it is more appropriate and also to be consistent with
the direction of the driver.

v2: Leave out object alloc/free inlining. (Joonas Lahtinen)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
12 files changed:
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_dmabuf.c
drivers/gpu/drm/i915/i915_gem_internal.c
drivers/gpu/drm/i915/i915_gem_stolen.c
drivers/gpu/drm/i915/i915_gem_userptr.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_engine_cs.c
drivers/gpu/drm/i915/intel_fbdev.c
drivers/gpu/drm/i915/intel_overlay.c
drivers/gpu/drm/i915/intel_pm.c
drivers/gpu/drm/i915/intel_ringbuffer.c

index 34f2b0da6a8110eba8cf50fe91ea3a17a084056b..65d7a7811236609accc192b9f0a2fb310ea3d2c1 100644 (file)
@@ -2981,7 +2981,7 @@ void i915_gem_load_init_fences(struct drm_i915_private *dev_priv);
 int i915_gem_freeze(struct drm_i915_private *dev_priv);
 int i915_gem_freeze_late(struct drm_i915_private *dev_priv);
 
-void *i915_gem_object_alloc(struct drm_device *dev);
+void *i915_gem_object_alloc(struct drm_i915_private *dev_priv);
 void i915_gem_object_free(struct drm_i915_gem_object *obj);
 void i915_gem_object_init(struct drm_i915_gem_object *obj,
                         const struct drm_i915_gem_object_ops *ops);
@@ -3366,9 +3366,9 @@ void i915_gem_stolen_remove_node(struct drm_i915_private *dev_priv,
 int i915_gem_init_stolen(struct drm_i915_private *dev_priv);
 void i915_gem_cleanup_stolen(struct drm_device *dev);
 struct drm_i915_gem_object *
-i915_gem_object_create_stolen(struct drm_device *dev, u32 size);
+i915_gem_object_create_stolen(struct drm_i915_private *dev_priv, u32 size);
 struct drm_i915_gem_object *
-i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
+i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv,
                                               u32 stolen_offset,
                                               u32 gtt_offset,
                                               u32 size);
index 8ebefb6f6cf21033986368b05b7ed703fdc98134..ab75d27b74d58a523700b4bcf0f1101038b2ca6a 100644 (file)
@@ -622,9 +622,8 @@ out:
        return ret;
 }
 
-void *i915_gem_object_alloc(struct drm_device *dev)
+void *i915_gem_object_alloc(struct drm_i915_private *dev_priv)
 {
-       struct drm_i915_private *dev_priv = to_i915(dev);
        return kmem_cache_zalloc(dev_priv->objects, GFP_KERNEL);
 }
 
@@ -3990,7 +3989,7 @@ i915_gem_object_create(struct drm_device *dev, u64 size)
        if (overflows_type(size, obj->base.size))
                return ERR_PTR(-E2BIG);
 
-       obj = i915_gem_object_alloc(dev);
+       obj = i915_gem_object_alloc(dev_priv);
        if (obj == NULL)
                return ERR_PTR(-ENOMEM);
 
index 5e38299b5df65387876843c7b83fe9327641af8c..d037adcda6f20b71566b6af36dd59eee7df94971 100644 (file)
@@ -278,7 +278,7 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev,
 
        get_dma_buf(dma_buf);
 
-       obj = i915_gem_object_alloc(dev);
+       obj = i915_gem_object_alloc(to_i915(dev));
        if (obj == NULL) {
                ret = -ENOMEM;
                goto fail_detach;
index 4b3ff3e5b911167557880228d5da44bb3d2616bf..08d26306d40eddf23665fca9989d53e6329079b5 100644 (file)
@@ -155,7 +155,7 @@ i915_gem_object_create_internal(struct drm_i915_private *i915,
 {
        struct drm_i915_gem_object *obj;
 
-       obj = i915_gem_object_alloc(&i915->drm);
+       obj = i915_gem_object_alloc(i915);
        if (!obj)
                return ERR_PTR(-ENOMEM);
 
index ebaa941c83afd7843a56287f2b857d8f8fd3a9fa..b3bac2557665b37fae6c941b75a72f2ee7d330dc 100644 (file)
@@ -579,22 +579,21 @@ static const struct drm_i915_gem_object_ops i915_gem_object_stolen_ops = {
 };
 
 static struct drm_i915_gem_object *
-_i915_gem_object_create_stolen(struct drm_device *dev,
+_i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
                               struct drm_mm_node *stolen)
 {
        struct drm_i915_gem_object *obj;
 
-       obj = i915_gem_object_alloc(dev);
+       obj = i915_gem_object_alloc(dev_priv);
        if (obj == NULL)
                return NULL;
 
-       drm_gem_private_object_init(dev, &obj->base, stolen->size);
+       drm_gem_private_object_init(&dev_priv->drm, &obj->base, stolen->size);
        i915_gem_object_init(obj, &i915_gem_object_stolen_ops);
 
        obj->stolen = stolen;
        obj->base.read_domains = I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT;
-       obj->cache_level = HAS_LLC(to_i915(dev)) ?
-                          I915_CACHE_LLC : I915_CACHE_NONE;
+       obj->cache_level = HAS_LLC(dev_priv) ? I915_CACHE_LLC : I915_CACHE_NONE;
 
        if (i915_gem_object_pin_pages(obj))
                goto cleanup;
@@ -607,9 +606,8 @@ cleanup:
 }
 
 struct drm_i915_gem_object *
-i915_gem_object_create_stolen(struct drm_device *dev, u32 size)
+i915_gem_object_create_stolen(struct drm_i915_private *dev_priv, u32 size)
 {
-       struct drm_i915_private *dev_priv = to_i915(dev);
        struct drm_i915_gem_object *obj;
        struct drm_mm_node *stolen;
        int ret;
@@ -630,7 +628,7 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size)
                return NULL;
        }
 
-       obj = _i915_gem_object_create_stolen(dev, stolen);
+       obj = _i915_gem_object_create_stolen(dev_priv, stolen);
        if (obj)
                return obj;
 
@@ -640,12 +638,11 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size)
 }
 
 struct drm_i915_gem_object *
-i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
+i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv,
                                               u32 stolen_offset,
                                               u32 gtt_offset,
                                               u32 size)
 {
-       struct drm_i915_private *dev_priv = to_i915(dev);
        struct i915_ggtt *ggtt = &dev_priv->ggtt;
        struct drm_i915_gem_object *obj;
        struct drm_mm_node *stolen;
@@ -655,7 +652,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
        if (!drm_mm_initialized(&dev_priv->mm.stolen))
                return NULL;
 
-       lockdep_assert_held(&dev->struct_mutex);
+       lockdep_assert_held(&dev_priv->drm.struct_mutex);
 
        DRM_DEBUG_KMS("creating preallocated stolen object: stolen_offset=%x, gtt_offset=%x, size=%x\n",
                        stolen_offset, gtt_offset, size);
@@ -680,7 +677,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
                return NULL;
        }
 
-       obj = _i915_gem_object_create_stolen(dev, stolen);
+       obj = _i915_gem_object_create_stolen(dev_priv, stolen);
        if (obj == NULL) {
                DRM_DEBUG_KMS("failed to allocate stolen object\n");
                i915_gem_stolen_remove_node(dev_priv, stolen);
index 107ddf51065e50be5c810180084f035f06c0dfcd..48963a20992fcf2b069129a31459ba0ef13db2da 100644 (file)
@@ -784,7 +784,7 @@ i915_gem_userptr_ioctl(struct drm_device *dev, void *data, struct drm_file *file
                return -ENODEV;
        }
 
-       obj = i915_gem_object_alloc(dev);
+       obj = i915_gem_object_alloc(dev_priv);
        if (obj == NULL)
                return -ENOMEM;
 
index 97846367146200f10133facb95ac3dfbe5f7d692..aeaf701f0ff5365b1ed46f29adb405eee3373ac4 100644 (file)
@@ -2689,7 +2689,7 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,
 
        mutex_lock(&dev->struct_mutex);
 
-       obj = i915_gem_object_create_stolen_for_preallocated(dev,
+       obj = i915_gem_object_create_stolen_for_preallocated(dev_priv,
                                                             base_aligned,
                                                             base_aligned,
                                                             size_aligned);
index 3da4d466e3329722edd2807d9499a9fad63500ef..348fae620811c5f6174d3d0a211582301693e29a 100644 (file)
@@ -257,7 +257,7 @@ int intel_engine_create_scratch(struct intel_engine_cs *engine, int size)
 
        WARN_ON(engine->scratch);
 
-       obj = i915_gem_object_create_stolen(&engine->i915->drm, size);
+       obj = i915_gem_object_create_stolen(engine->i915, size);
        if (!obj)
                obj = i915_gem_object_create_internal(engine->i915, size);
        if (IS_ERR(obj)) {
index fc958d5ed0dc81c0a279a29389fafcc6d2a12f06..d7e50db20bb823691bf0ad5626beee3ccae0638e 100644 (file)
@@ -145,7 +145,7 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
         * important and we should probably use that space with FBC or other
         * features. */
        if (size * 2 < ggtt->stolen_usable_size)
-               obj = i915_gem_object_create_stolen(dev, size);
+               obj = i915_gem_object_create_stolen(dev_priv, size);
        if (obj == NULL)
                obj = i915_gem_object_create(dev, size);
        if (IS_ERR(obj)) {
index fd0e4dac7cc16f35ff658466bc107a7296407354..0a7b83aaa2b45aedd6526701ee2e5dc567399dc6 100644 (file)
@@ -1391,8 +1391,7 @@ void intel_setup_overlay(struct drm_i915_private *dev_priv)
 
        reg_bo = NULL;
        if (!OVERLAY_NEEDS_PHYSICAL(dev_priv))
-               reg_bo = i915_gem_object_create_stolen(&dev_priv->drm,
-                                                      PAGE_SIZE);
+               reg_bo = i915_gem_object_create_stolen(dev_priv, PAGE_SIZE);
        if (reg_bo == NULL)
                reg_bo = i915_gem_object_create(&dev_priv->drm, PAGE_SIZE);
        if (IS_ERR(reg_bo))
index bfd2c289ce49e96f94f0ee2017fb378fe4c47679..70108aa2309c5b088f61d33f390a6675d6d62e86 100644 (file)
@@ -5805,7 +5805,7 @@ static void valleyview_setup_pctx(struct drm_i915_private *dev_priv)
                int pcbr_offset;
 
                pcbr_offset = (pcbr & (~4095)) - dev_priv->mm.stolen_base;
-               pctx = i915_gem_object_create_stolen_for_preallocated(&dev_priv->drm,
+               pctx = i915_gem_object_create_stolen_for_preallocated(dev_priv,
                                                                      pcbr_offset,
                                                                      I915_GTT_OFFSET_NONE,
                                                                      pctx_size);
@@ -5822,7 +5822,7 @@ static void valleyview_setup_pctx(struct drm_i915_private *dev_priv)
         * overlap with other ranges, such as the frame buffer, protected
         * memory, or any other relevant ranges.
         */
-       pctx = i915_gem_object_create_stolen(&dev_priv->drm, pctx_size);
+       pctx = i915_gem_object_create_stolen(dev_priv, pctx_size);
        if (!pctx) {
                DRM_DEBUG("not enough stolen space for PCTX, disabling\n");
                goto out;
index aeb637dc1fdf490caeb87f7f1938357916082ab8..e193e52f669d615ef4bf532cd663544321199b81 100644 (file)
@@ -1869,7 +1869,7 @@ intel_ring_create_vma(struct drm_i915_private *dev_priv, int size)
        struct drm_i915_gem_object *obj;
        struct i915_vma *vma;
 
-       obj = i915_gem_object_create_stolen(&dev_priv->drm, size);
+       obj = i915_gem_object_create_stolen(dev_priv, size);
        if (!obj)
                obj = i915_gem_object_create(&dev_priv->drm, size);
        if (IS_ERR(obj))