50 static int mgag200_ttm_global_init(
struct mga_device *ast)
55 global_ref = &ast->
ttm.mem_global_ref;
58 global_ref->
init = &mgag200_ttm_mem_global_init;
59 global_ref->
release = &mgag200_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 == &mgag200_bo_ttm_destroy)
131 DRM_ERROR(
"Unsupported memory type %u\n", (
unsigned)type);
154 static int mgag200_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 mgag200_ttm_backend_destroy(
struct ttm_tt *
tt)
205 .destroy = &mgag200_ttm_backend_destroy,
218 tt->
func = &mgag200_tt_backend_func;
219 if (
ttm_tt_init(tt, bdev, size, page_flags, dummy_read_page)) {
226 static int mgag200_ttm_tt_populate(
struct ttm_tt *ttm)
231 static void mgag200_ttm_tt_unpopulate(
struct ttm_tt *ttm)
238 .ttm_tt_populate = mgag200_ttm_tt_populate,
239 .ttm_tt_unpopulate = mgag200_ttm_tt_unpopulate,
240 .init_mem_type = mgag200_bo_init_mem_type,
241 .evict_flags = mgag200_bo_evict_flags,
242 .move = mgag200_bo_move,
243 .verify_access = mgag200_bo_verify_access,
244 .io_mem_reserve = &mgag200_ttm_io_mem_reserve,
245 .io_mem_free = &mgag200_ttm_io_mem_free,
254 ret = mgag200_ttm_global_init(mdev);
259 mdev->
ttm.bo_global_ref.ref.object,
263 DRM_ERROR(
"Error initialising bo driver; %d\n", ret);
269 DRM_ERROR(
"Failed ttm VRAM init: %d\n", ret);
319 DRM_ERROR(
"reserve failed %p\n", bo);
348 mgabo->
gem.driver_private =
NULL;
349 mgabo->
bo.bdev = &mdev->
ttm.bdev;
359 NULL, mgag200_bo_ttm_destroy);
367 static inline u64 mgag200_bo_gpu_offset(
struct mgag200_bo *bo)
369 return bo->
bo.offset;
379 *gpu_addr = mgag200_bo_gpu_offset(bo);
383 for (i = 0; i < bo->
placement.num_placement; i++)
391 *gpu_addr = mgag200_bo_gpu_offset(bo);
399 DRM_ERROR(
"unpin bad %p\n", bo);
406 for (i = 0; i < bo->
placement.num_placement ; i++)
419 DRM_ERROR(
"unpin bad %p\n", bo);
426 if (bo->
kmap.virtual)
430 for (i = 0; i < bo->
placement.num_placement ; i++)
435 DRM_ERROR(
"pushing to VRAM failed\n");
443 struct drm_file *file_priv;
450 mdev = file_priv->minor->
dev->dev_private;