50 static int cirrus_ttm_global_init(
struct cirrus_device *cirrus)
55 global_ref = &cirrus->
ttm.mem_global_ref;
58 global_ref->
init = &cirrus_ttm_mem_global_init;
59 global_ref->
release = &cirrus_ttm_mem_global_release;
62 DRM_ERROR(
"Failed setting up TTM memory accounting "
67 cirrus->
ttm.bo_global_ref.mem_glob =
68 cirrus->
ttm.mem_global_ref.object;
69 global_ref = &cirrus->
ttm.bo_global_ref.ref;
76 DRM_ERROR(
"Failed setting up TTM BO subsystem.\n");
86 if (cirrus->
ttm.mem_global_ref.release ==
NULL)
91 cirrus->
ttm.mem_global_ref.release =
NULL;
107 if (bo->
destroy == &cirrus_bo_ttm_destroy)
131 DRM_ERROR(
"Unsupported memory type %u\n", (
unsigned)type);
154 static int cirrus_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 cirrus_ttm_backend_destroy(
struct ttm_tt *
tt)
205 .destroy = &cirrus_ttm_backend_destroy,
218 tt->
func = &cirrus_tt_backend_func;
219 if (
ttm_tt_init(tt, bdev, size, page_flags, dummy_read_page)) {
226 static int cirrus_ttm_tt_populate(
struct ttm_tt *ttm)
231 static void cirrus_ttm_tt_unpopulate(
struct ttm_tt *ttm)
238 .ttm_tt_populate = cirrus_ttm_tt_populate,
239 .ttm_tt_unpopulate = cirrus_ttm_tt_unpopulate,
240 .init_mem_type = cirrus_bo_init_mem_type,
241 .evict_flags = cirrus_bo_evict_flags,
242 .move = cirrus_bo_move,
243 .verify_access = cirrus_bo_verify_access,
244 .io_mem_reserve = &cirrus_ttm_io_mem_reserve,
245 .io_mem_free = &cirrus_ttm_io_mem_free,
254 ret = cirrus_ttm_global_init(cirrus);
259 cirrus->
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);
325 DRM_ERROR(
"reserve failed %p\n", bo);
354 cirrusbo->
gem.driver_private =
NULL;
355 cirrusbo->
bo.bdev = &cirrus->
ttm.bdev;
365 NULL, cirrus_bo_ttm_destroy);
369 *pcirrusbo = cirrusbo;
373 static inline u64 cirrus_bo_gpu_offset(
struct cirrus_bo *bo)
375 return bo->
bo.offset;
385 *gpu_addr = cirrus_bo_gpu_offset(bo);
389 for (i = 0; i < bo->
placement.num_placement; i++)
397 *gpu_addr = cirrus_bo_gpu_offset(bo);
405 DRM_ERROR(
"unpin bad %p\n", bo);
412 for (i = 0; i < bo->
placement.num_placement ; i++)
425 DRM_ERROR(
"unpin bad %p\n", bo);
432 if (bo->
kmap.virtual)
436 for (i = 0; i < bo->
placement.num_placement ; i++)
441 DRM_ERROR(
"pushing to VRAM failed\n");
449 struct drm_file *file_priv;
456 cirrus = file_priv->minor->
dev->dev_private;