]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/i915: Make GEM object create and create from data take dev_priv
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Thu, 1 Dec 2016 14:16:37 +0000 (14:16 +0000)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Thu, 1 Dec 2016 18:01:08 +0000 (18:01 +0000)
Makes all GEM object constructors consistent.

v2: Fix compilation in GVT code.

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> (v1)
12 files changed:
drivers/gpu/drm/i915/gvt/cmd_parser.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/i915_guc_submission.c
drivers/gpu/drm/i915/i915_perf.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_fbdev.c
drivers/gpu/drm/i915/intel_guc_loader.c
drivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/intel_overlay.c
drivers/gpu/drm/i915/intel_ringbuffer.c

index d26a092c70e8c8fe2a14df28dd22e4253f739a16..9a4b23c3ee97d5d87556d04bc0c5068fe6454eb1 100644 (file)
@@ -1602,7 +1602,7 @@ static int perform_bb_shadow(struct parser_exec_state *s)
                return -ENOMEM;
 
        entry_obj->obj =
-               i915_gem_object_create(&(s->vgpu->gvt->dev_priv->drm),
+               i915_gem_object_create(s->vgpu->gvt->dev_priv,
                                       roundup(bb_size, PAGE_SIZE));
        if (IS_ERR(entry_obj->obj)) {
                ret = PTR_ERR(entry_obj->obj);
@@ -2665,14 +2665,13 @@ int intel_gvt_scan_and_shadow_workload(struct intel_vgpu_workload *workload)
 
 static int shadow_indirect_ctx(struct intel_shadow_wa_ctx *wa_ctx)
 {
-       struct drm_device *dev = &wa_ctx->workload->vgpu->gvt->dev_priv->drm;
        int ctx_size = wa_ctx->indirect_ctx.size;
        unsigned long guest_gma = wa_ctx->indirect_ctx.guest_gma;
        struct drm_i915_gem_object *obj;
        int ret = 0;
        void *map;
 
-       obj = i915_gem_object_create(dev,
+       obj = i915_gem_object_create(wa_ctx->workload->vgpu->gvt->dev_priv,
                                     roundup(ctx_size + CACHELINE_BYTES,
                                             PAGE_SIZE));
        if (IS_ERR(obj))
index 65d7a7811236609accc192b9f0a2fb310ea3d2c1..8b725d13d24e827508f3281fda291cb100e74a09 100644 (file)
@@ -2985,10 +2985,11 @@ 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);
-struct drm_i915_gem_object *i915_gem_object_create(struct drm_device *dev,
-                                                  u64 size);
-struct drm_i915_gem_object *i915_gem_object_create_from_data(
-               struct drm_device *dev, const void *data, size_t size);
+struct drm_i915_gem_object *
+i915_gem_object_create(struct drm_i915_private *dev_priv, u64 size);
+struct drm_i915_gem_object *
+i915_gem_object_create_from_data(struct drm_i915_private *dev_priv,
+                                const void *data, size_t size);
 void i915_gem_close_object(struct drm_gem_object *gem, struct drm_file *file);
 void i915_gem_free_object(struct drm_gem_object *obj);
 
index ab75d27b74d58a523700b4bcf0f1101038b2ca6a..10c3b505f49a8b8178f5d20c181bebfd2383be88 100644 (file)
@@ -635,7 +635,7 @@ void i915_gem_object_free(struct drm_i915_gem_object *obj)
 
 static int
 i915_gem_create(struct drm_file *file,
-               struct drm_device *dev,
+               struct drm_i915_private *dev_priv,
                uint64_t size,
                uint32_t *handle_p)
 {
@@ -648,7 +648,7 @@ i915_gem_create(struct drm_file *file,
                return -EINVAL;
 
        /* Allocate the new object */
-       obj = i915_gem_object_create(dev, size);
+       obj = i915_gem_object_create(dev_priv, size);
        if (IS_ERR(obj))
                return PTR_ERR(obj);
 
@@ -670,7 +670,7 @@ i915_gem_dumb_create(struct drm_file *file,
        /* have to work out size/pitch and return them */
        args->pitch = ALIGN(args->width * DIV_ROUND_UP(args->bpp, 8), 64);
        args->size = args->pitch * args->height;
-       return i915_gem_create(file, dev,
+       return i915_gem_create(file, to_i915(dev),
                               args->size, &args->handle);
 }
 
@@ -684,11 +684,12 @@ int
 i915_gem_create_ioctl(struct drm_device *dev, void *data,
                      struct drm_file *file)
 {
+       struct drm_i915_private *dev_priv = to_i915(dev);
        struct drm_i915_gem_create *args = data;
 
-       i915_gem_flush_free_objects(to_i915(dev));
+       i915_gem_flush_free_objects(dev_priv);
 
-       return i915_gem_create(file, dev,
+       return i915_gem_create(file, dev_priv,
                               args->size, &args->handle);
 }
 
@@ -3970,9 +3971,8 @@ static const struct drm_i915_gem_object_ops i915_gem_object_ops = {
        (sizeof(x) > sizeof(T) && (x) >> (sizeof(T) * BITS_PER_BYTE))
 
 struct drm_i915_gem_object *
-i915_gem_object_create(struct drm_device *dev, u64 size)
+i915_gem_object_create(struct drm_i915_private *dev_priv, u64 size)
 {
-       struct drm_i915_private *dev_priv = to_i915(dev);
        struct drm_i915_gem_object *obj;
        struct address_space *mapping;
        gfp_t mask;
@@ -3993,7 +3993,7 @@ i915_gem_object_create(struct drm_device *dev, u64 size)
        if (obj == NULL)
                return ERR_PTR(-ENOMEM);
 
-       ret = drm_gem_object_init(dev, &obj->base, size);
+       ret = drm_gem_object_init(&dev_priv->drm, &obj->base, size);
        if (ret)
                goto fail;
 
@@ -4749,7 +4749,7 @@ void i915_gem_track_fb(struct drm_i915_gem_object *old,
 
 /* Allocate a new GEM object and fill it with the supplied data */
 struct drm_i915_gem_object *
-i915_gem_object_create_from_data(struct drm_device *dev,
+i915_gem_object_create_from_data(struct drm_i915_private *dev_priv,
                                 const void *data, size_t size)
 {
        struct drm_i915_gem_object *obj;
@@ -4757,7 +4757,7 @@ i915_gem_object_create_from_data(struct drm_device *dev,
        size_t bytes;
        int ret;
 
-       obj = i915_gem_object_create(dev, round_up(size, PAGE_SIZE));
+       obj = i915_gem_object_create(dev_priv, round_up(size, PAGE_SIZE));
        if (IS_ERR(obj))
                return obj;
 
index a6add0c14045070946dc99266d1e785556694e2c..5241b51dd986729ee5fe756c1e5079da9d632a61 100644 (file)
@@ -169,12 +169,13 @@ void i915_gem_context_free(struct kref *ctx_ref)
 static struct drm_i915_gem_object *
 alloc_context_obj(struct drm_device *dev, u64 size)
 {
+       struct drm_i915_private *dev_priv = to_i915(dev);
        struct drm_i915_gem_object *obj;
        int ret;
 
        lockdep_assert_held(&dev->struct_mutex);
 
-       obj = i915_gem_object_create(dev, size);
+       obj = i915_gem_object_create(dev_priv, size);
        if (IS_ERR(obj))
                return obj;
 
@@ -193,7 +194,7 @@ alloc_context_obj(struct drm_device *dev, u64 size)
         * This is only applicable for Ivy Bridge devices since
         * later platforms don't have L3 control bits in the PTE.
         */
-       if (IS_IVYBRIDGE(to_i915(dev))) {
+       if (IS_IVYBRIDGE(dev_priv)) {
                ret = i915_gem_object_set_cache_level(obj, I915_CACHE_L3_LLC);
                /* Failure shouldn't ever happen this early */
                if (WARN_ON(ret)) {
index 58413803ba3c7be755048f243847d7925e1aa3ee..1003b443112ceba184357dc3d350b6379e80d97b 100644 (file)
@@ -574,7 +574,7 @@ static struct i915_vma *guc_allocate_vma(struct intel_guc *guc, u32 size)
        struct i915_vma *vma;
        int ret;
 
-       obj = i915_gem_object_create(&dev_priv->drm, size);
+       obj = i915_gem_object_create(dev_priv, size);
        if (IS_ERR(obj))
                return ERR_CAST(obj);
 
index 14de9a4eee27af4d78a5842e4c7c897bbb58d58b..5669f0862458acbd9bcd95ffed5e43896a2bfa11 100644 (file)
@@ -773,7 +773,7 @@ static int alloc_oa_buffer(struct drm_i915_private *dev_priv)
        BUILD_BUG_ON_NOT_POWER_OF_2(OA_BUFFER_SIZE);
        BUILD_BUG_ON(OA_BUFFER_SIZE < SZ_128K || OA_BUFFER_SIZE > SZ_16M);
 
-       bo = i915_gem_object_create(&dev_priv->drm, OA_BUFFER_SIZE);
+       bo = i915_gem_object_create(dev_priv, OA_BUFFER_SIZE);
        if (IS_ERR(bo)) {
                DRM_ERROR("Failed to allocate OA buffer\n");
                ret = PTR_ERR(bo);
index aeaf701f0ff5365b1ed46f29adb405eee3373ac4..b91e0abf66bacb6da89630720a93d953172991a4 100644 (file)
@@ -10998,7 +10998,7 @@ intel_framebuffer_create_for_mode(struct drm_device *dev,
        struct drm_i915_gem_object *obj;
        struct drm_mode_fb_cmd2 mode_cmd = { 0 };
 
-       obj = i915_gem_object_create(dev,
+       obj = i915_gem_object_create(to_i915(dev),
                                    intel_framebuffer_size_for_mode(mode, bpp));
        if (IS_ERR(obj))
                return ERR_CAST(obj);
index d7e50db20bb823691bf0ad5626beee3ccae0638e..3c445b92e988b1e4f372cf15cf123dafe035ba80 100644 (file)
@@ -147,7 +147,7 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
        if (size * 2 < ggtt->stolen_usable_size)
                obj = i915_gem_object_create_stolen(dev_priv, size);
        if (obj == NULL)
-               obj = i915_gem_object_create(dev, size);
+               obj = i915_gem_object_create(dev_priv, size);
        if (IS_ERR(obj)) {
                DRM_ERROR("failed to allocate framebuffer\n");
                ret = PTR_ERR(obj);
index a330fa4993842b9460d86528770ddc2f573db533..9926747d160ffd3445e03c0f27eb18f2102bbc62 100644 (file)
@@ -590,6 +590,7 @@ fail:
 
 static void guc_fw_fetch(struct drm_device *dev, struct intel_guc_fw *guc_fw)
 {
+       struct drm_i915_private *dev_priv = to_i915(dev);
        struct pci_dev *pdev = dev->pdev;
        struct drm_i915_gem_object *obj;
        const struct firmware *fw = NULL;
@@ -648,7 +649,7 @@ static void guc_fw_fetch(struct drm_device *dev, struct intel_guc_fw *guc_fw)
 
        /* Header and uCode will be loaded to WOPCM. Size of the two. */
        size = guc_fw->header_size + guc_fw->ucode_size;
-       if (size > guc_wopcm_size(to_i915(dev))) {
+       if (size > guc_wopcm_size(dev_priv)) {
                DRM_NOTE("Firmware is too large to fit in WOPCM\n");
                goto fail;
        }
@@ -676,7 +677,7 @@ static void guc_fw_fetch(struct drm_device *dev, struct intel_guc_fw *guc_fw)
                        guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted);
 
        mutex_lock(&dev->struct_mutex);
-       obj = i915_gem_object_create_from_data(dev, fw->data, fw->size);
+       obj = i915_gem_object_create_from_data(dev_priv, fw->data, fw->size);
        mutex_unlock(&dev->struct_mutex);
        if (IS_ERR_OR_NULL(obj)) {
                err = obj ? PTR_ERR(obj) : -ENOMEM;
index b2c0d509e1912ba277edc9586152f213df36db3b..67aec8f33c1db5b6a300a7589788542f289b84cb 100644 (file)
@@ -1243,7 +1243,7 @@ static int lrc_setup_wa_ctx_obj(struct intel_engine_cs *engine, u32 size)
        struct i915_vma *vma;
        int err;
 
-       obj = i915_gem_object_create(&engine->i915->drm, PAGE_ALIGN(size));
+       obj = i915_gem_object_create(engine->i915, PAGE_ALIGN(size));
        if (IS_ERR(obj))
                return PTR_ERR(obj);
 
@@ -2242,7 +2242,7 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
        /* One extra page as the sharing data between driver and GuC */
        context_size += PAGE_SIZE * LRC_PPHWSP_PN;
 
-       ctx_obj = i915_gem_object_create(&ctx->i915->drm, context_size);
+       ctx_obj = i915_gem_object_create(ctx->i915, context_size);
        if (IS_ERR(ctx_obj)) {
                DRM_DEBUG_DRIVER("Alloc LRC backing obj failed.\n");
                return PTR_ERR(ctx_obj);
index 0a7b83aaa2b45aedd6526701ee2e5dc567399dc6..90da6a707de7646590fcaa1b194915b6d79d4594 100644 (file)
@@ -1393,7 +1393,7 @@ void intel_setup_overlay(struct drm_i915_private *dev_priv)
        if (!OVERLAY_NEEDS_PHYSICAL(dev_priv))
                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);
+               reg_bo = i915_gem_object_create(dev_priv, PAGE_SIZE);
        if (IS_ERR(reg_bo))
                goto out_free;
        overlay->reg_bo = reg_bo;
index e193e52f669d615ef4bf532cd663544321199b81..bc18a4f2643df6c06d7f989cdb6aa1a25ecfc2df 100644 (file)
@@ -1871,7 +1871,7 @@ intel_ring_create_vma(struct drm_i915_private *dev_priv, int size)
 
        obj = i915_gem_object_create_stolen(dev_priv, size);
        if (!obj)
-               obj = i915_gem_object_create(&dev_priv->drm, size);
+               obj = i915_gem_object_create(dev_priv, size);
        if (IS_ERR(obj))
                return ERR_CAST(obj);
 
@@ -2452,7 +2452,7 @@ static void intel_ring_init_semaphores(struct drm_i915_private *dev_priv,
        if (INTEL_GEN(dev_priv) >= 8 && !dev_priv->semaphore) {
                struct i915_vma *vma;
 
-               obj = i915_gem_object_create(&dev_priv->drm, 4096);
+               obj = i915_gem_object_create(dev_priv, 4096);
                if (IS_ERR(obj))
                        goto err;