drm/ttm: Don't print error message if eviction was interrupted
[linux-2.6-microblaze.git] / drivers / gpu / drm / ttm / ttm_bo.c
index 326a3d1..459f1b4 100644 (file)
@@ -120,8 +120,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
        bool old_use_tt, new_use_tt;
        int ret;
 
-       old_use_tt = bo->resource &&
-               ttm_manager_type(bdev, bo->resource->mem_type)->use_tt;
+       old_use_tt = !bo->resource || ttm_manager_type(bdev, bo->resource->mem_type)->use_tt;
        new_use_tt = ttm_manager_type(bdev, mem->mem_type)->use_tt;
 
        ttm_bo_unmap_virtual(bo);
@@ -465,7 +464,8 @@ bounce:
        if (ret == -EMULTIHOP) {
                ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop);
                if (ret) {
-                       pr_err("Buffer eviction failed\n");
+                       if (ret != -ERESTARTSYS && ret != -EINTR)
+                               pr_err("Buffer eviction failed\n");
                        ttm_resource_free(bo, &evict_mem);
                        goto out;
                }
@@ -894,14 +894,18 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
        if (!placement->num_placement && !placement->num_busy_placement)
                return ttm_bo_pipeline_gutting(bo);
 
-       /*
-        * Check whether we need to move buffer.
-        */
-       if (!bo->resource || !ttm_resource_compat(bo->resource, placement)) {
-               ret = ttm_bo_move_buffer(bo, placement, ctx);
-               if (ret)
-                       return ret;
-       }
+       /* Check whether we need to move buffer. */
+       if (bo->resource && ttm_resource_compat(bo->resource, placement))
+               return 0;
+
+       /* Moving of pinned BOs is forbidden */
+       if (bo->pin_count)
+               return -EINVAL;
+
+       ret = ttm_bo_move_buffer(bo, placement, ctx);
+       if (ret)
+               return ret;
+
        /*
         * We might need to add a TTM.
         */
@@ -953,7 +957,6 @@ int ttm_bo_init_reserved(struct ttm_device *bdev, struct ttm_buffer_object *bo,
                         struct sg_table *sg, struct dma_resv *resv,
                         void (*destroy) (struct ttm_buffer_object *))
 {
-       static const struct ttm_place sys_mem = { .mem_type = TTM_PL_SYSTEM };
        int ret;
 
        kref_init(&bo->kref);
@@ -970,12 +973,6 @@ int ttm_bo_init_reserved(struct ttm_device *bdev, struct ttm_buffer_object *bo,
                bo->base.resv = &bo->base._resv;
        atomic_inc(&ttm_glob.bo_count);
 
-       ret = ttm_resource_alloc(bo, &sys_mem, &bo->resource);
-       if (unlikely(ret)) {
-               ttm_bo_put(bo);
-               return ret;
-       }
-
        /*
         * For ttm_bo_type_device buffers, allocate
         * address space from the device.