From 57de4ba959b290f0b8cf36ecd5e7f1b29d4b8a12 Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Fri, 11 Nov 2011 15:42:57 -0500 Subject: drm/ttm: simplify memory accounting for ttm user v2 Provide helper function to compute the kernel memory size needed for each buffer object. Move all the accounting inside ttm, simplifying driver and avoiding code duplication accross them. v2 fix accounting of ghost object, one would have thought that i would have run into the issue since a longtime but it seems ghost object are rare when you have plenty of vram ;) Signed-off-by: Jerome Glisse Reviewed-by: Thomas Hellstrom --- include/drm/ttm/ttm_bo_api.h | 19 ++++++++++++++++++- include/drm/ttm/ttm_bo_driver.h | 5 ----- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'include/drm/ttm') diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 8d95a42cf21e..974c8f801c39 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -429,9 +429,9 @@ extern void ttm_bo_unlock_delayed_workqueue(struct ttm_bo_device *bdev, * -EBUSY if the buffer is busy and no_wait is true. * -ERESTARTSYS if interrupted by a signal. */ - extern int ttm_bo_synccpu_write_grab(struct ttm_buffer_object *bo, bool no_wait); + /** * ttm_bo_synccpu_write_release: * @@ -441,6 +441,22 @@ ttm_bo_synccpu_write_grab(struct ttm_buffer_object *bo, bool no_wait); */ extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo); +/** + * ttm_bo_acc_size + * + * @bdev: Pointer to a ttm_bo_device struct. + * @bo_size: size of the buffer object in byte. + * @struct_size: size of the structure holding buffer object datas + * + * Returns size to account for a buffer object + */ +size_t ttm_bo_acc_size(struct ttm_bo_device *bdev, + unsigned long bo_size, + unsigned struct_size); +size_t ttm_bo_dma_acc_size(struct ttm_bo_device *bdev, + unsigned long bo_size, + unsigned struct_size); + /** * ttm_bo_init * @@ -488,6 +504,7 @@ extern int ttm_bo_init(struct ttm_bo_device *bdev, struct file *persistent_swap_storage, size_t acc_size, void (*destroy) (struct ttm_buffer_object *)); + /** * ttm_bo_synccpu_object_init * diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index b2a0848a4d02..2be889161b4c 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -469,9 +469,6 @@ struct ttm_bo_global_ref { * @dummy_read_page: Pointer to a dummy page used for mapping requests * of unpopulated pages. * @shrink: A shrink callback object used for buffer object swap. - * @ttm_bo_extra_size: Extra size (sizeof(struct ttm_buffer_object) excluded) - * used by a buffer object. This is excluding page arrays and backing pages. - * @ttm_bo_size: This is @ttm_bo_extra_size + sizeof(struct ttm_buffer_object). * @device_list_mutex: Mutex protecting the device list. * This mutex is held while traversing the device list for pm options. * @lru_lock: Spinlock protecting the bo subsystem lru lists. @@ -489,8 +486,6 @@ struct ttm_bo_global { struct ttm_mem_global *mem_glob; struct page *dummy_read_page; struct ttm_mem_shrink shrink; - size_t ttm_bo_extra_size; - size_t ttm_bo_size; struct mutex device_list_mutex; spinlock_t lru_lock; -- cgit v1.2.3