drm/i915: Rename drm_gem_object_unreference in preparation for lockless free
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 20 Jul 2016 12:31:53 +0000 (13:31 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 20 Jul 2016 12:40:12 +0000 (13:40 +0100)
Ultimately wraps kref_put(), so adopt its nomenclature for consistency
with other subsystems.

s/drm_gem_object_unreference/i915_gem_object_put/

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1469005202-9659-6-git-send-email-chris@chris-wilson.co.uk
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1469017917-15134-5-git-send-email-chris@chris-wilson.co.uk
18 files changed:
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_batch_pool.c
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/i915_gem_evict.c
drivers/gpu/drm/i915/i915_gem_execbuffer.c
drivers/gpu/drm/i915/i915_gem_render_state.c
drivers/gpu/drm/i915/i915_gem_shrinker.c
drivers/gpu/drm/i915/i915_gem_stolen.c
drivers/gpu/drm/i915/i915_gem_tiling.c
drivers/gpu/drm/i915/i915_gem_userptr.c
drivers/gpu/drm/i915/i915_guc_submission.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 163d28e8e92c11122b2f427f08febb6de8ddc969..ffc97c5f9d2e518f9a144590dc57faccdb8a3ae7 100644 (file)
@@ -2317,6 +2317,16 @@ i915_gem_object_get(struct drm_i915_gem_object *obj)
 __deprecated
 extern void drm_gem_object_reference(struct drm_gem_object *);
 
+__attribute__((nonnull))
+static inline void
+i915_gem_object_put(struct drm_i915_gem_object *obj)
+{
+       drm_gem_object_unreference(&obj->base);
+}
+
+__deprecated
+extern void drm_gem_object_unreference(struct drm_gem_object *);
+
 static inline bool
 i915_gem_object_has_struct_page(const struct drm_i915_gem_object *obj)
 {
index f886c0bb24ca62b06dfd3653aece9b7ed7e6670d..f23670fbc8a9eb67bb830a246645175ec78ca68e 100644 (file)
@@ -295,7 +295,7 @@ drop_pages(struct drm_i915_gem_object *obj)
                        break;
 
        ret = i915_gem_object_put_pages(obj);
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 
        return ret;
 }
@@ -887,7 +887,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
                                        args->offset, args->data_ptr);
 
 out:
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 unlock:
        mutex_unlock(&dev->struct_mutex);
        return ret;
@@ -1320,7 +1320,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
        }
 
 out:
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 unlock:
        mutex_unlock(&dev->struct_mutex);
 put_rpm:
@@ -1522,7 +1522,7 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
                intel_fb_obj_invalidate(obj, write_origin(obj, write_domain));
 
 unref:
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 unlock:
        mutex_unlock(&dev->struct_mutex);
        return ret;
@@ -1556,7 +1556,7 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
        if (obj->pin_display)
                i915_gem_object_flush_cpu_write_domain(obj);
 
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 unlock:
        mutex_unlock(&dev->struct_mutex);
        return ret;
@@ -1987,7 +1987,7 @@ i915_gem_mmap_gtt(struct drm_file *file,
        *offset = drm_vma_node_offset_addr(&obj->base.vma_node);
 
 out:
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 unlock:
        mutex_unlock(&dev->struct_mutex);
        return ret;
@@ -2411,7 +2411,7 @@ i915_gem_object_retire__read(struct drm_i915_gem_object *obj, int ring)
        }
 
        i915_gem_request_assign(&obj->last_fenced_req, NULL);
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 }
 
 static bool i915_context_is_banned(const struct i915_gem_context *ctx)
@@ -2814,7 +2814,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
                goto out;
        }
 
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 
        for (i = 0; i < I915_NUM_ENGINES; i++) {
                if (obj->last_read_req[i] == NULL)
@@ -2835,7 +2835,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
        return ret;
 
 out:
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
        mutex_unlock(&dev->struct_mutex);
        return ret;
 }
@@ -3665,7 +3665,7 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
 
        ret = i915_gem_object_set_cache_level(obj, level);
 
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 unlock:
        mutex_unlock(&dev->struct_mutex);
 rpm_put:
@@ -4057,7 +4057,7 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
        }
 
 unref:
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 unlock:
        mutex_unlock(&dev->struct_mutex);
        return ret;
@@ -4121,7 +4121,7 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
        args->retained = obj->madv != __I915_MADV_PURGED;
 
 out:
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 unlock:
        mutex_unlock(&dev->struct_mutex);
        return ret;
@@ -4952,6 +4952,6 @@ i915_gem_object_create_from_data(struct drm_device *dev,
        return obj;
 
 fail:
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
        return ERR_PTR(ret);
 }
index 3752d5daa4b2171cc9f3f45f312e7985407ae381..3507b2753fd3d6fd335209022e2a6cd0bb67c88c 100644 (file)
@@ -75,7 +75,7 @@ void i915_gem_batch_pool_fini(struct i915_gem_batch_pool *pool)
                                                 batch_pool_link);
 
                        list_del(&obj->batch_pool_link);
-                       drm_gem_object_unreference(&obj->base);
+                       i915_gem_object_put(obj);
                }
        }
 }
@@ -121,7 +121,7 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,
                /* While we're looping, do some clean up */
                if (tmp->madv == __I915_MADV_PURGED) {
                        list_del(&tmp->batch_pool_link);
-                       drm_gem_object_unreference(&tmp->base);
+                       i915_gem_object_put(tmp);
                        continue;
                }
 
index 71517918853af653c6be7201c102045a0ce68b02..2600939fc2ee3f335c7746c4fc85daa64b05ce76 100644 (file)
@@ -176,7 +176,7 @@ void i915_gem_context_free(struct kref *ctx_ref)
                if (ce->ringbuf)
                        intel_ringbuffer_free(ce->ringbuf);
 
-               drm_gem_object_unreference(&ce->state->base);
+               i915_gem_object_put(ce->state);
        }
 
        list_del(&ctx->link);
@@ -216,7 +216,7 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)
                ret = i915_gem_object_set_cache_level(obj, I915_CACHE_L3_LLC);
                /* Failure shouldn't ever happen this early */
                if (WARN_ON(ret)) {
-                       drm_gem_object_unreference(&obj->base);
+                       i915_gem_object_put(obj);
                        return ERR_PTR(ret);
                }
        }
index 56103948ee167e2885678f5587917ea448c3b619..81f7b4383d5ed16cdbb993ca5a527fbae5409f22 100644 (file)
@@ -191,17 +191,18 @@ found:
 
        /* Unbinding will emit any required flushes */
        while (!list_empty(&eviction_list)) {
-               struct drm_gem_object *obj;
+               struct drm_i915_gem_object *obj;
+
                vma = list_first_entry(&eviction_list,
                                       struct i915_vma,
                                       exec_list);
 
-               obj =  &vma->obj->base;
+               obj =  vma->obj;
                list_del_init(&vma->exec_list);
                if (ret == 0)
                        ret = i915_vma_unbind(vma);
 
-               drm_gem_object_unreference(obj);
+               i915_gem_object_put(obj);
        }
 
        return ret;
index 28bcc99a0cc19664df4131c79f46bd5e4513de54..6482ec24ff3b8122547f304ba3118bf4abb869e2 100644 (file)
@@ -176,7 +176,7 @@ err:
                                       struct drm_i915_gem_object,
                                       obj_exec_link);
                list_del_init(&obj->obj_exec_link);
-               drm_gem_object_unreference(&obj->base);
+               i915_gem_object_put(obj);
        }
        /*
         * Objects already transfered to the vmas list will be unreferenced by
@@ -264,7 +264,7 @@ static void eb_destroy(struct eb_vmas *eb)
                                       exec_list);
                list_del_init(&vma->exec_list);
                i915_gem_execbuffer_unreserve_vma(vma);
-               drm_gem_object_unreference(&vma->obj->base);
+               i915_gem_object_put(vma->obj);
        }
        kfree(eb);
 }
@@ -873,7 +873,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
                vma = list_first_entry(&eb->vmas, struct i915_vma, exec_list);
                list_del_init(&vma->exec_list);
                i915_gem_execbuffer_unreserve_vma(vma);
-               drm_gem_object_unreference(&vma->obj->base);
+               i915_gem_object_put(vma->obj);
        }
 
        mutex_unlock(&dev->struct_mutex);
index f75bbd67a13a2805768cb5ffb9735a3df49b8957..b2be4676a5cfe6ad3803c8cf4d6f3603c32a66e2 100644 (file)
@@ -70,7 +70,7 @@ static int render_state_init(struct render_state *so,
        return 0;
 
 free_gem:
-       drm_gem_object_unreference(&so->obj->base);
+       i915_gem_object_put(so->obj);
        return ret;
 }
 
@@ -195,7 +195,7 @@ err_out:
 void i915_gem_render_state_fini(struct render_state *so)
 {
        i915_gem_object_ggtt_unpin(so->obj);
-       drm_gem_object_unreference(&so->obj->base);
+       i915_gem_object_put(so->obj);
 }
 
 int i915_gem_render_state_prepare(struct intel_engine_cs *engine,
index 3aa76d3608ea08e9a9352649f0c958e843dd2233..afaa2597e35e17cfd4ad1a705050b9fafae32a3b 100644 (file)
@@ -201,7 +201,7 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,
                        if (i915_gem_object_put_pages(obj) == 0)
                                count += obj->base.size >> PAGE_SHIFT;
 
-                       drm_gem_object_unreference(&obj->base);
+                       i915_gem_object_put(obj);
                }
                list_splice(&still_in_list, phase->list);
        }
index 66be299a1486f4f656ba4e3970249a0e5e909aeb..310756c3072397a1c0c318c1c3769be0a63fa5bb 100644 (file)
@@ -716,6 +716,6 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
        return obj;
 
 err:
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
        return NULL;
 }
index 46e80f30afcdf204967752622331f6b06e41166d..2d9d190bd6efa07eee2feec9a71328d221443bb0 100644 (file)
@@ -268,7 +268,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
        }
 
 err:
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
        mutex_unlock(&dev->struct_mutex);
 
        intel_runtime_pm_put(dev_priv);
@@ -328,7 +328,7 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
        if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_10_17)
                args->swizzle_mode = I915_BIT_6_SWIZZLE_9_10;
 
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
        mutex_unlock(&dev->struct_mutex);
 
        return 0;
index c41bf74f926e62d43d441344cc141408d8e634af..cd4af22b8c59ce93731fb10b36e62c6278198ed4 100644 (file)
@@ -119,7 +119,7 @@ static void cancel_userptr(struct work_struct *work)
                dev_priv->mm.interruptible = was_interruptible;
        }
 
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
        mutex_unlock(&dev->struct_mutex);
 }
 
@@ -577,7 +577,7 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
        }
 
        obj->userptr.workers--;
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
        mutex_unlock(&dev->struct_mutex);
 
        release_pages(pvec, pinned, 0);
index 1cc5de129e769670396b255a64b781c0a5b8184d..01c1c16718111058411f9499c385dc340a062b47 100644 (file)
@@ -633,13 +633,13 @@ gem_allocate_guc_obj(struct drm_i915_private *dev_priv, u32 size)
                return NULL;
 
        if (i915_gem_object_get_pages(obj)) {
-               drm_gem_object_unreference(&obj->base);
+               i915_gem_object_put(obj);
                return NULL;
        }
 
        if (i915_gem_obj_ggtt_pin(obj, PAGE_SIZE,
                        PIN_OFFSET_BIAS | GUC_WOPCM_TOP)) {
-               drm_gem_object_unreference(&obj->base);
+               i915_gem_object_put(obj);
                return NULL;
        }
 
@@ -661,7 +661,7 @@ static void gem_release_guc_obj(struct drm_i915_gem_object *obj)
        if (i915_gem_obj_is_pinned(obj))
                i915_gem_object_ggtt_unpin(obj);
 
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 }
 
 static void
index 84904a2d3fcd8f67d0ddc67c73eff95aa7e7bae5..a18a79c5db1cae40a07d70cb3e268740a5c6ba34 100644 (file)
@@ -2488,7 +2488,7 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,
        return true;
 
 out_unref_obj:
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
        mutex_unlock(&dev->struct_mutex);
        return false;
 }
@@ -10953,7 +10953,7 @@ static void intel_unpin_work_fn(struct work_struct *__work)
 
        mutex_lock(&dev->struct_mutex);
        intel_unpin_fb_obj(work->old_fb, primary->state->rotation);
-       drm_gem_object_unreference(&work->pending_flip_obj->base);
+       i915_gem_object_put(work->pending_flip_obj);
        mutex_unlock(&dev->struct_mutex);
 
        i915_gem_request_put(work->flip_queued_req);
@@ -14851,7 +14851,7 @@ static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb)
        drm_framebuffer_cleanup(fb);
        mutex_lock(&dev->struct_mutex);
        WARN_ON(!intel_fb->obj->framebuffer_references--);
-       drm_gem_object_unreference(&intel_fb->obj->base);
+       i915_gem_object_put(intel_fb->obj);
        mutex_unlock(&dev->struct_mutex);
        kfree(intel_fb);
 }
index 23129dcfba9d6b5345fef07b1c0fc2f21a92fc2f..b1074a2b28606f13a7b90147c1acec7c81c440b9 100644 (file)
@@ -159,7 +159,7 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
 
        fb = __intel_framebuffer_create(dev, &mode_cmd, obj);
        if (IS_ERR(fb)) {
-               drm_gem_object_unreference(&obj->base);
+               i915_gem_object_put(obj);
                ret = PTR_ERR(fb);
                goto out;
        }
index 605c69658d2c1c55b2408b0bc36dd6c41d26d667..a6a8fba7acd02bf8d033bb01e29493d4c195a774 100644 (file)
@@ -662,7 +662,7 @@ fail:
        mutex_lock(&dev->struct_mutex);
        obj = guc_fw->guc_fw_obj;
        if (obj)
-               drm_gem_object_unreference(&obj->base);
+               i915_gem_object_put(obj);
        guc_fw->guc_fw_obj = NULL;
        mutex_unlock(&dev->struct_mutex);
 
@@ -743,7 +743,7 @@ void intel_guc_fini(struct drm_device *dev)
        i915_guc_submission_fini(dev_priv);
 
        if (guc_fw->guc_fw_obj)
-               drm_gem_object_unreference(&guc_fw->guc_fw_obj->base);
+               i915_gem_object_put(guc_fw->guc_fw_obj);
        guc_fw->guc_fw_obj = NULL;
        mutex_unlock(&dev->struct_mutex);
 
index 6282fca6229c522f959a829d8af05487928165a8..439aeab807b10a65172f5ff6f943bf730542d64b 100644 (file)
@@ -1367,7 +1367,7 @@ static int lrc_setup_wa_ctx_obj(struct intel_engine_cs *engine, u32 size)
        if (ret) {
                DRM_DEBUG_DRIVER("pin LRC WA ctx backing obj failed: %d\n",
                                 ret);
-               drm_gem_object_unreference(&engine->wa_ctx.obj->base);
+               i915_gem_object_put(engine->wa_ctx.obj);
                return ret;
        }
 
@@ -1378,7 +1378,7 @@ static void lrc_destroy_wa_ctx_obj(struct intel_engine_cs *engine)
 {
        if (engine->wa_ctx.obj) {
                i915_gem_object_ggtt_unpin(engine->wa_ctx.obj);
-               drm_gem_object_unreference(&engine->wa_ctx.obj->base);
+               i915_gem_object_put(engine->wa_ctx.obj);
                engine->wa_ctx.obj = NULL;
        }
 }
@@ -2382,7 +2382,7 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
 error_ringbuf:
        intel_ringbuffer_free(ringbuf);
 error_deref_obj:
-       drm_gem_object_unreference(&ctx_obj->base);
+       i915_gem_object_put(ctx_obj);
        ce->ringbuf = NULL;
        ce->state = NULL;
        return ret;
index 5ca797b01ccb122a52f80d58d218d6bf0c68d884..30d2f5db7d871a5c462fef6e486aaf369f84bff9 100644 (file)
@@ -308,7 +308,7 @@ static void intel_overlay_release_old_vid_tail(struct intel_overlay *overlay)
        struct drm_i915_gem_object *obj = overlay->old_vid_bo;
 
        i915_gem_object_ggtt_unpin(obj);
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
 
        overlay->old_vid_bo = NULL;
 }
@@ -322,7 +322,7 @@ static void intel_overlay_off_tail(struct intel_overlay *overlay)
                return;
 
        i915_gem_object_ggtt_unpin(obj);
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
        overlay->vid_bo = NULL;
 
        overlay->crtc->overlay = NULL;
@@ -1219,7 +1219,7 @@ int intel_overlay_put_image_ioctl(struct drm_device *dev, void *data,
 out_unlock:
        mutex_unlock(&dev->struct_mutex);
        drm_modeset_unlock_all(dev);
-       drm_gem_object_unreference_unlocked(&new_bo->base);
+       i915_gem_object_put(new_bo);
 out_free:
        kfree(params);
 
@@ -1443,7 +1443,7 @@ out_unpin_bo:
        if (!OVERLAY_NEEDS_PHYSICAL(dev_priv))
                i915_gem_object_ggtt_unpin(reg_bo);
 out_free_bo:
-       drm_gem_object_unreference(&reg_bo->base);
+       i915_gem_object_put(reg_bo);
 out_free:
        mutex_unlock(&dev_priv->drm.struct_mutex);
        kfree(overlay);
index 3a7135d0003388441c062bf17a3493e04bf5541f..9c0a0b47628a35829cc0d692af57869edcfd431b 100644 (file)
@@ -641,7 +641,7 @@ void intel_fini_pipe_control(struct intel_engine_cs *engine)
                return;
 
        i915_gem_object_ggtt_unpin(engine->scratch.obj);
-       drm_gem_object_unreference(&engine->scratch.obj->base);
+       i915_gem_object_put(engine->scratch.obj);
        engine->scratch.obj = NULL;
 }
 
@@ -672,7 +672,7 @@ int intel_init_pipe_control(struct intel_engine_cs *engine, int size)
        return 0;
 
 err_unref:
-       drm_gem_object_unreference(&engine->scratch.obj->base);
+       i915_gem_object_put(engine->scratch.obj);
 err:
        return ret;
 }
@@ -1312,7 +1312,7 @@ static void render_ring_cleanup(struct intel_engine_cs *engine)
 
        if (dev_priv->semaphore_obj) {
                i915_gem_object_ggtt_unpin(dev_priv->semaphore_obj);
-               drm_gem_object_unreference(&dev_priv->semaphore_obj->base);
+               i915_gem_object_put(dev_priv->semaphore_obj);
                dev_priv->semaphore_obj = NULL;
        }
 
@@ -1898,7 +1898,7 @@ static void cleanup_status_page(struct intel_engine_cs *engine)
 
        kunmap(sg_page(obj->pages->sgl));
        i915_gem_object_ggtt_unpin(obj);
-       drm_gem_object_unreference(&obj->base);
+       i915_gem_object_put(obj);
        engine->status_page.obj = NULL;
 }
 
@@ -1936,7 +1936,7 @@ static int init_status_page(struct intel_engine_cs *engine)
                ret = i915_gem_obj_ggtt_pin(obj, 4096, flags);
                if (ret) {
 err_unref:
-                       drm_gem_object_unreference(&obj->base);
+                       i915_gem_object_put(obj);
                        return ret;
                }
 
@@ -2039,7 +2039,7 @@ err_unpin:
 
 static void intel_destroy_ringbuffer_obj(struct intel_ringbuffer *ringbuf)
 {
-       drm_gem_object_unreference(&ringbuf->obj->base);
+       i915_gem_object_put(ringbuf->obj);
        ringbuf->obj = NULL;
 }
 
@@ -2691,7 +2691,7 @@ static void intel_ring_init_semaphores(struct drm_i915_private *dev_priv,
                        i915_gem_object_set_cache_level(obj, I915_CACHE_LLC);
                        ret = i915_gem_obj_ggtt_pin(obj, 0, PIN_NONBLOCK);
                        if (ret != 0) {
-                               drm_gem_object_unreference(&obj->base);
+                               i915_gem_object_put(obj);
                                DRM_ERROR("Failed to pin semaphore bo. Disabling semaphores\n");
                                i915.semaphores = 0;
                        } else {