50 static int ast_ttm_global_init(
struct ast_private *ast)
55 global_ref = &ast->
ttm.mem_global_ref;
58 global_ref->
init = &ast_ttm_mem_global_init;
59 global_ref->
release = &ast_ttm_mem_global_release;
62 DRM_ERROR(
"Failed setting up TTM memory accounting "
67 ast->
ttm.bo_global_ref.mem_glob =
68 ast->
ttm.mem_global_ref.object;
69 global_ref = &ast->
ttm.bo_global_ref.ref;
76 DRM_ERROR(
"Failed setting up TTM BO subsystem.\n");
86 if (ast->
ttm.mem_global_ref.release ==
NULL)
91 ast->
ttm.mem_global_ref.release =
NULL;
107 if (bo->
destroy == &ast_bo_ttm_destroy)
131 DRM_ERROR(
"Unsupported memory type %u\n", (
unsigned)type);
154 static int ast_ttm_io_mem_reserve(
struct ttm_bo_device *bdev,
164 mem->
bus.is_iomem =
false;
174 mem->
bus.is_iomem =
true;
188 bool evict,
bool interruptible,
189 bool no_wait_reserve,
bool no_wait_gpu,
198 static void ast_ttm_backend_destroy(
struct ttm_tt *
tt)
205 .destroy = &ast_ttm_backend_destroy,
218 tt->
func = &ast_tt_backend_func;
219 if (
ttm_tt_init(tt, bdev, size, page_flags, dummy_read_page)) {
226 static int ast_ttm_tt_populate(
struct ttm_tt *ttm)
231 static void ast_ttm_tt_unpopulate(
struct ttm_tt *ttm)
238 .ttm_tt_populate = ast_ttm_tt_populate,
239 .ttm_tt_unpopulate = ast_ttm_tt_unpopulate,
240 .init_mem_type = ast_bo_init_mem_type,
241 .evict_flags = ast_bo_evict_flags,
243 .verify_access = ast_bo_verify_access,
244 .io_mem_reserve = &ast_ttm_io_mem_reserve,
245 .io_mem_free = &ast_ttm_io_mem_free,
254 ret = ast_ttm_global_init(ast);
259 ast->
ttm.bo_global_ref.ref.object,
263 DRM_ERROR(
"Error initialising bo driver; %d\n", ret);
270 DRM_ERROR(
"Failed ttm VRAM init: %d\n", ret);
320 DRM_ERROR(
"reserve failed %p\n", bo);
349 astbo->
gem.driver_private =
NULL;
350 astbo->
bo.bdev = &ast->
ttm.bdev;
360 NULL, ast_bo_ttm_destroy);
368 static inline u64 ast_bo_gpu_offset(
struct ast_bo *bo)
370 return bo->
bo.offset;
380 *gpu_addr = ast_bo_gpu_offset(bo);
384 for (i = 0; i < bo->
placement.num_placement; i++)
392 *gpu_addr = ast_bo_gpu_offset(bo);
400 DRM_ERROR(
"unpin bad %p\n", bo);
407 for (i = 0; i < bo->
placement.num_placement ; i++)
420 DRM_ERROR(
"unpin bad %p\n", bo);
427 if (bo->
kmap.virtual)
431 for (i = 0; i < bo->
placement.num_placement ; i++)
436 DRM_ERROR(
"pushing to VRAM failed\n");
444 struct drm_file *file_priv;
451 ast = file_priv->minor->
dev->dev_private;