drm/ttm: replace context flags with bools v2
[linux-2.6-microblaze.git] / drivers / gpu / drm / ttm / ttm_bo.c
index 593e558..e2a124b 100644 (file)
@@ -252,24 +252,16 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
                if (ret)
                        goto out_err;
 
-               ret = ttm_bo_move_to_new_tt_mem(bo, ctx, mem);
-               if (ret)
-                       goto out_err;
+               if (mem->mem_type != TTM_PL_SYSTEM) {
+                       ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+                       if (ret)
+                               goto out_err;
+               }
        }
 
-       if (bdev->driver->move_notify)
-               bdev->driver->move_notify(bo, evict, mem);
-
        ret = bdev->driver->move(bo, evict, ctx, mem);
-       if (ret) {
-               if (bdev->driver->move_notify) {
-                       swap(*mem, bo->mem);
-                       bdev->driver->move_notify(bo, false, mem);
-                       swap(*mem, bo->mem);
-               }
-
+       if (ret)
                goto out_err;
-       }
 
        ctx->bytes_moved += bo->num_pages << PAGE_SHIFT;
        return 0;
@@ -292,8 +284,8 @@ out_err:
 
 static void ttm_bo_cleanup_memtype_use(struct ttm_buffer_object *bo)
 {
-       if (bo->bdev->driver->move_notify)
-               bo->bdev->driver->move_notify(bo, false, NULL);
+       if (bo->bdev->driver->delete_mem_notify)
+               bo->bdev->driver->delete_mem_notify(bo);
 
        ttm_bo_tt_destroy(bo);
        ttm_resource_free(bo, &bo->mem);
@@ -620,7 +612,7 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
        /* Don't evict this BO if it's outside of the
         * requested placement range
         */
-       if (place->fpfn >= (bo->mem.start + bo->mem.size) ||
+       if (place->fpfn >= (bo->mem.start + bo->mem.num_pages) ||
            (place->lpfn && place->lpfn <= bo->mem.start))
                return false;
 
@@ -645,7 +637,7 @@ static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
 
        if (bo->base.resv == ctx->resv) {
                dma_resv_assert_held(bo->base.resv);
-               if (ctx->flags & TTM_OPT_FLAG_ALLOW_RES_EVICT)
+               if (ctx->allow_res_evict)
                        ret = true;
                *locked = false;
                if (busy)
@@ -838,7 +830,6 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
  * @bo: BO to find memory for
  * @place: where to search
  * @mem: the memory object to fill in
- * @ctx: operation context
  *
  * Check if placement is compatible and fill in mem structure.
  * Returns -EBUSY if placement won't work or negative error code.
@@ -846,8 +837,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
  */
 static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
                                const struct ttm_place *place,
-                               struct ttm_resource *mem,
-                               struct ttm_operation_ctx *ctx)
+                               struct ttm_resource *mem)
 {
        struct ttm_bo_device *bdev = bo->bdev;
        struct ttm_resource_manager *man;
@@ -892,7 +882,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
                const struct ttm_place *place = &placement->placement[i];
                struct ttm_resource_manager *man;
 
-               ret = ttm_bo_mem_placement(bo, place, mem, ctx);
+               ret = ttm_bo_mem_placement(bo, place, mem);
                if (ret)
                        continue;
 
@@ -918,7 +908,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
        for (i = 0; i < placement->num_busy_placement; ++i) {
                const struct ttm_place *place = &placement->busy_placement[i];
 
-               ret = ttm_bo_mem_placement(bo, place, mem, ctx);
+               ret = ttm_bo_mem_placement(bo, place, mem);
                if (ret)
                        continue;
 
@@ -1202,7 +1192,7 @@ size_t ttm_bo_dma_acc_size(struct ttm_bo_device *bdev,
 
        size += ttm_round_pot(struct_size);
        size += ttm_round_pot(npages * (2*sizeof(void *) + sizeof(dma_addr_t)));
-       size += ttm_round_pot(sizeof(struct ttm_dma_tt));
+       size += ttm_round_pot(sizeof(struct ttm_tt));
        return size;
 }
 EXPORT_SYMBOL(ttm_bo_dma_acc_size);
@@ -1293,6 +1283,8 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
                        pr_debug("Swap list %d was clean\n", i);
        spin_unlock(&glob->lru_lock);
 
+       ttm_pool_fini(&bdev->pool);
+
        if (!ret)
                ttm_bo_global_release();
 
@@ -1317,9 +1309,10 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
 
 int ttm_bo_device_init(struct ttm_bo_device *bdev,
                       struct ttm_bo_driver *driver,
+                      struct device *dev,
                       struct address_space *mapping,
                       struct drm_vma_offset_manager *vma_manager,
-                      bool need_dma32)
+                      bool use_dma_alloc, bool use_dma32)
 {
        struct ttm_bo_global *glob = &ttm_bo_glob;
        int ret;
@@ -1334,12 +1327,12 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
        bdev->driver = driver;
 
        ttm_bo_init_sysman(bdev);
+       ttm_pool_init(&bdev->pool, dev, use_dma_alloc, use_dma32);
 
        bdev->vma_manager = vma_manager;
        INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue);
        INIT_LIST_HEAD(&bdev->ddestroy);
        bdev->dev_mapping = mapping;
-       bdev->need_dma32 = need_dma32;
        mutex_lock(&ttm_global_mutex);
        list_add_tail(&bdev->device_list, &glob->device_list);
        mutex_unlock(&ttm_global_mutex);
@@ -1492,7 +1485,3 @@ void ttm_bo_tt_destroy(struct ttm_buffer_object *bo)
        bo->ttm = NULL;
 }
 
-int ttm_bo_tt_bind(struct ttm_buffer_object *bo, struct ttm_resource *mem)
-{
-       return bo->bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
-}