@@ -754,6 +754,21 @@ int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
return radeon_bo_get_surface_reg(bo);
}
+
+void radeon_bo_invalidate(struct radeon_bo *rbo)
+{
+ radeon_bo_check_tiling(rbo, 0, 1);
+ radeon_vm_bo_invalidate(rbo->rdev, rbo);
+}
+
+void radeon_bo_memory_usage(struct radeon_bo *rbo,
+ uint32_t old_mem_type,
+ uint32_t new_mem_type)
+{
+ radeon_update_memory_usage(rbo, old_mem_type, -1);
+ radeon_update_memory_usage(rbo, new_mem_type, 1);
+}
+
void radeon_bo_move_notify(struct ttm_buffer_object *bo,
bool evict,
struct ttm_resource *new_mem)
@@ -763,16 +778,11 @@ void radeon_bo_move_notify(struct ttm_buffer_object *bo,
if (!radeon_ttm_bo_is_radeon_bo(bo))
return;
- rbo = container_of(bo, struct radeon_bo, tbo);
- radeon_bo_check_tiling(rbo, 0, 1);
- radeon_vm_bo_invalidate(rbo->rdev, rbo);
-
- /* update statistics */
- if (!new_mem)
+ /* the new_mem path is handled via the move callback now */
+ if (new_mem)
return;
-
- radeon_update_memory_usage(rbo, bo->mem.mem_type, -1);
- radeon_update_memory_usage(rbo, new_mem->mem_type, 1);
+ rbo = container_of(bo, struct radeon_bo, tbo);
+ radeon_bo_invalidate(rbo);
}
int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
@@ -160,6 +160,10 @@ extern void radeon_bo_get_tiling_flags(struct radeon_bo *bo,
u32 *tiling_flags, u32 *pitch);
extern int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
bool force_drop);
+void radeon_bo_memory_usage(struct radeon_bo *rbo,
+ uint32_t old_mem_type,
+ uint32_t new_mem_type);
+void radeon_bo_invalidate(struct radeon_bo *rbo);
extern void radeon_bo_move_notify(struct ttm_buffer_object *bo,
bool evict,
struct ttm_resource *new_mem);
@@ -316,12 +316,16 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
struct ttm_resource *old_mem = &bo->mem;
int r;
+ rbo = container_of(bo, struct radeon_bo, tbo);
+
+ radeon_bo_invalidate(rbo);
+ radeon_bo_memory_usage(rbo, bo->mem.mem_type, new_mem->mem_type);
+
r = ttm_bo_wait_ctx(bo, ctx);
if (r)
return r;
/* Can't move a pinned BO */
- rbo = container_of(bo, struct radeon_bo, tbo);
if (WARN_ON_ONCE(rbo->tbo.pin_count > 0))
return -EINVAL;
@@ -361,6 +365,8 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
memcpy:
r = ttm_bo_move_memcpy(bo, ctx, new_mem);
if (r) {
+ radeon_bo_invalidate(rbo);
+ radeon_bo_memory_usage(rbo, new_mem->mem_type, old_mem->mem_type);
return r;
}
}