Lines Matching refs:gbo
23 static void drm_gem_vram_cleanup(struct drm_gem_vram_object *gbo) in drm_gem_vram_cleanup() argument
29 drm_gem_object_release(&gbo->bo.base); in drm_gem_vram_cleanup()
32 static void drm_gem_vram_destroy(struct drm_gem_vram_object *gbo) in drm_gem_vram_destroy() argument
34 drm_gem_vram_cleanup(gbo); in drm_gem_vram_destroy()
35 kfree(gbo); in drm_gem_vram_destroy()
40 struct drm_gem_vram_object *gbo = drm_gem_vram_of_bo(bo); in ttm_buffer_object_destroy() local
42 drm_gem_vram_destroy(gbo); in ttm_buffer_object_destroy()
45 static void drm_gem_vram_placement(struct drm_gem_vram_object *gbo, in drm_gem_vram_placement() argument
51 gbo->placement.placement = gbo->placements; in drm_gem_vram_placement()
52 gbo->placement.busy_placement = gbo->placements; in drm_gem_vram_placement()
55 gbo->placements[c++].flags = TTM_PL_FLAG_WC | in drm_gem_vram_placement()
60 gbo->placements[c++].flags = TTM_PL_MASK_CACHING | in drm_gem_vram_placement()
64 gbo->placements[c++].flags = TTM_PL_MASK_CACHING | in drm_gem_vram_placement()
67 gbo->placement.num_placement = c; in drm_gem_vram_placement()
68 gbo->placement.num_busy_placement = c; in drm_gem_vram_placement()
71 gbo->placements[i].fpfn = 0; in drm_gem_vram_placement()
72 gbo->placements[i].lpfn = 0; in drm_gem_vram_placement()
78 struct drm_gem_vram_object *gbo, in drm_gem_vram_init() argument
85 if (!gbo->bo.base.funcs) in drm_gem_vram_init()
86 gbo->bo.base.funcs = &drm_gem_vram_object_funcs; in drm_gem_vram_init()
88 ret = drm_gem_object_init(dev, &gbo->bo.base, size); in drm_gem_vram_init()
92 acc_size = ttm_bo_dma_acc_size(bdev, size, sizeof(*gbo)); in drm_gem_vram_init()
94 gbo->bo.bdev = bdev; in drm_gem_vram_init()
95 drm_gem_vram_placement(gbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); in drm_gem_vram_init()
97 ret = ttm_bo_init(bdev, &gbo->bo, size, ttm_bo_type_device, in drm_gem_vram_init()
98 &gbo->placement, pg_align, interruptible, acc_size, in drm_gem_vram_init()
106 drm_gem_object_release(&gbo->bo.base); in drm_gem_vram_init()
128 struct drm_gem_vram_object *gbo; in drm_gem_vram_create() local
131 gbo = kzalloc(sizeof(*gbo), GFP_KERNEL); in drm_gem_vram_create()
132 if (!gbo) in drm_gem_vram_create()
135 ret = drm_gem_vram_init(dev, bdev, gbo, size, pg_align, interruptible); in drm_gem_vram_create()
139 return gbo; in drm_gem_vram_create()
142 kfree(gbo); in drm_gem_vram_create()
153 void drm_gem_vram_put(struct drm_gem_vram_object *gbo) in drm_gem_vram_put() argument
155 ttm_bo_put(&gbo->bo); in drm_gem_vram_put()
169 u64 drm_gem_vram_mmap_offset(struct drm_gem_vram_object *gbo) in drm_gem_vram_mmap_offset() argument
171 return drm_vma_node_offset_addr(&gbo->bo.base.vma_node); in drm_gem_vram_mmap_offset()
187 s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo) in drm_gem_vram_offset() argument
189 if (WARN_ON_ONCE(!gbo->pin_count)) in drm_gem_vram_offset()
191 return gbo->bo.offset; in drm_gem_vram_offset()
210 int drm_gem_vram_pin(struct drm_gem_vram_object *gbo, unsigned long pl_flag) in drm_gem_vram_pin() argument
215 ret = ttm_bo_reserve(&gbo->bo, true, false, NULL); in drm_gem_vram_pin()
219 if (gbo->pin_count) in drm_gem_vram_pin()
223 drm_gem_vram_placement(gbo, pl_flag); in drm_gem_vram_pin()
225 for (i = 0; i < gbo->placement.num_placement; ++i) in drm_gem_vram_pin()
226 gbo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT; in drm_gem_vram_pin()
228 ret = ttm_bo_validate(&gbo->bo, &gbo->placement, &ctx); in drm_gem_vram_pin()
233 ++gbo->pin_count; in drm_gem_vram_pin()
234 ttm_bo_unreserve(&gbo->bo); in drm_gem_vram_pin()
239 ttm_bo_unreserve(&gbo->bo); in drm_gem_vram_pin()
252 int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo) in drm_gem_vram_unpin() argument
257 ret = ttm_bo_reserve(&gbo->bo, true, false, NULL); in drm_gem_vram_unpin()
261 if (WARN_ON_ONCE(!gbo->pin_count)) in drm_gem_vram_unpin()
264 --gbo->pin_count; in drm_gem_vram_unpin()
265 if (gbo->pin_count) in drm_gem_vram_unpin()
268 for (i = 0; i < gbo->placement.num_placement ; ++i) in drm_gem_vram_unpin()
269 gbo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT; in drm_gem_vram_unpin()
271 ret = ttm_bo_validate(&gbo->bo, &gbo->placement, &ctx); in drm_gem_vram_unpin()
276 ttm_bo_unreserve(&gbo->bo); in drm_gem_vram_unpin()
281 ttm_bo_unreserve(&gbo->bo); in drm_gem_vram_unpin()
303 void *drm_gem_vram_kmap(struct drm_gem_vram_object *gbo, bool map, in drm_gem_vram_kmap() argument
307 struct ttm_bo_kmap_obj *kmap = &gbo->kmap; in drm_gem_vram_kmap()
312 ret = ttm_bo_kmap(&gbo->bo, 0, gbo->bo.num_pages, kmap); in drm_gem_vram_kmap()
331 void drm_gem_vram_kunmap(struct drm_gem_vram_object *gbo) in drm_gem_vram_kunmap() argument
333 struct ttm_bo_kmap_obj *kmap = &gbo->kmap; in drm_gem_vram_kunmap()
371 struct drm_gem_vram_object *gbo; in drm_gem_vram_fill_create_dumb() local
382 gbo = drm_gem_vram_create(dev, bdev, size, pg_align, interruptible); in drm_gem_vram_fill_create_dumb()
383 if (IS_ERR(gbo)) in drm_gem_vram_fill_create_dumb()
384 return PTR_ERR(gbo); in drm_gem_vram_fill_create_dumb()
386 ret = drm_gem_handle_create(file, &gbo->bo.base, &handle); in drm_gem_vram_fill_create_dumb()
390 drm_gem_object_put_unlocked(&gbo->bo.base); in drm_gem_vram_fill_create_dumb()
399 drm_gem_object_put_unlocked(&gbo->bo.base); in drm_gem_vram_fill_create_dumb()
422 struct drm_gem_vram_object *gbo; in drm_gem_vram_bo_driver_evict_flags() local
428 gbo = drm_gem_vram_of_bo(bo); in drm_gem_vram_bo_driver_evict_flags()
429 drm_gem_vram_placement(gbo, TTM_PL_FLAG_SYSTEM); in drm_gem_vram_bo_driver_evict_flags()
430 *pl = gbo->placement; in drm_gem_vram_bo_driver_evict_flags()
447 struct drm_gem_vram_object *gbo = drm_gem_vram_of_bo(bo); in drm_gem_vram_bo_driver_verify_access() local
449 return drm_vma_node_verify_access(&gbo->bo.base.vma_node, in drm_gem_vram_bo_driver_verify_access()
478 struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem); in drm_gem_vram_object_free() local
480 drm_gem_vram_put(gbo); in drm_gem_vram_object_free()
531 struct drm_gem_vram_object *gbo; in drm_gem_vram_driver_dumb_mmap_offset() local
537 gbo = drm_gem_vram_of_gem(gem); in drm_gem_vram_driver_dumb_mmap_offset()
538 *offset = drm_gem_vram_mmap_offset(gbo); in drm_gem_vram_driver_dumb_mmap_offset()
561 struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem); in drm_gem_vram_object_pin() local
571 return drm_gem_vram_pin(gbo, 0); in drm_gem_vram_object_pin()
581 struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem); in drm_gem_vram_object_unpin() local
583 drm_gem_vram_unpin(gbo); in drm_gem_vram_object_unpin()
597 struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem); in drm_gem_vram_object_vmap() local
601 ret = drm_gem_vram_pin(gbo, 0); in drm_gem_vram_object_vmap()
604 base = drm_gem_vram_kmap(gbo, true, NULL); in drm_gem_vram_object_vmap()
606 drm_gem_vram_unpin(gbo); in drm_gem_vram_object_vmap()
621 struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem); in drm_gem_vram_object_vunmap() local
623 drm_gem_vram_kunmap(gbo); in drm_gem_vram_object_vunmap()
624 drm_gem_vram_unpin(gbo); in drm_gem_vram_object_vunmap()