drm/ttm: flip the switch, and convert to dma_fence
[deliverable/linux.git] / drivers / gpu / drm / ttm / ttm_bo_util.c
index 495aebf0f9c332f3396cca5369c08dd6b7f1472b..824af90cbe315c16caa543ef8f2d6ae26f90a374 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/module.h>
+#include <linux/reservation.h>
 
 void ttm_bo_free_old_node(struct ttm_buffer_object *bo)
 {
@@ -444,8 +445,6 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
                                      struct ttm_buffer_object **new_obj)
 {
        struct ttm_buffer_object *fbo;
-       struct ttm_bo_device *bdev = bo->bdev;
-       struct ttm_bo_driver *driver = bdev->driver;
        int ret;
 
        fbo = kmalloc(sizeof(*fbo), GFP_KERNEL);
@@ -466,10 +465,6 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
        drm_vma_node_reset(&fbo->vma_node);
        atomic_set(&fbo->cpu_writers, 0);
 
-       if (bo->sync_obj)
-               fbo->sync_obj = driver->sync_obj_ref(bo->sync_obj);
-       else
-               fbo->sync_obj = NULL;
        kref_init(&fbo->list_kref);
        kref_init(&fbo->kref);
        fbo->destroy = &ttm_transfered_destroy;
@@ -642,28 +637,20 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map)
 EXPORT_SYMBOL(ttm_bo_kunmap);
 
 int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
-                             void *sync_obj,
+                             struct fence *fence,
                              bool evict,
                              bool no_wait_gpu,
                              struct ttm_mem_reg *new_mem)
 {
        struct ttm_bo_device *bdev = bo->bdev;
-       struct ttm_bo_driver *driver = bdev->driver;
        struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type];
        struct ttm_mem_reg *old_mem = &bo->mem;
        int ret;
        struct ttm_buffer_object *ghost_obj;
-       void *tmp_obj = NULL;
 
-       if (bo->sync_obj) {
-               tmp_obj = bo->sync_obj;
-               bo->sync_obj = NULL;
-       }
-       bo->sync_obj = driver->sync_obj_ref(sync_obj);
+       reservation_object_add_excl_fence(bo->resv, fence);
        if (evict) {
                ret = ttm_bo_wait(bo, false, false, false);
-               if (tmp_obj)
-                       driver->sync_obj_unref(&tmp_obj);
                if (ret)
                        return ret;
 
@@ -684,13 +671,13 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
                 */
 
                set_bit(TTM_BO_PRIV_FLAG_MOVING, &bo->priv_flags);
-               if (tmp_obj)
-                       driver->sync_obj_unref(&tmp_obj);
 
                ret = ttm_buffer_object_transfer(bo, &ghost_obj);
                if (ret)
                        return ret;
 
+               reservation_object_add_excl_fence(ghost_obj->resv, fence);
+
                /**
                 * If we're not moving to fixed memory, the TTM object
                 * needs to stay alive. Otherwhise hang it on the ghost
This page took 0.037595 seconds and 5 git commands to generate.