aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2011-11-11 15:42:57 -0500
committerDave Airlie <airlied@redhat.com>2011-12-06 05:40:11 -0500
commit57de4ba959b290f0b8cf36ecd5e7f1b29d4b8a12 (patch)
tree8063f4dfaf1a22bf8cf7a5f0410d4e4929b250ec /include/drm
parent8e7e70522d760c4ccd4cd370ebfa0ba69e006c6e (diff)
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 <jglisse@redhat.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/ttm/ttm_bo_api.h19
-rw-r--r--include/drm/ttm/ttm_bo_driver.h5
2 files changed, 18 insertions, 6 deletions
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,
429 * -EBUSY if the buffer is busy and no_wait is true. 429 * -EBUSY if the buffer is busy and no_wait is true.
430 * -ERESTARTSYS if interrupted by a signal. 430 * -ERESTARTSYS if interrupted by a signal.
431 */ 431 */
432
433extern int 432extern int
434ttm_bo_synccpu_write_grab(struct ttm_buffer_object *bo, bool no_wait); 433ttm_bo_synccpu_write_grab(struct ttm_buffer_object *bo, bool no_wait);
434
435/** 435/**
436 * ttm_bo_synccpu_write_release: 436 * ttm_bo_synccpu_write_release:
437 * 437 *
@@ -442,6 +442,22 @@ ttm_bo_synccpu_write_grab(struct ttm_buffer_object *bo, bool no_wait);
442extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo); 442extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo);
443 443
444/** 444/**
445 * ttm_bo_acc_size
446 *
447 * @bdev: Pointer to a ttm_bo_device struct.
448 * @bo_size: size of the buffer object in byte.
449 * @struct_size: size of the structure holding buffer object datas
450 *
451 * Returns size to account for a buffer object
452 */
453size_t ttm_bo_acc_size(struct ttm_bo_device *bdev,
454 unsigned long bo_size,
455 unsigned struct_size);
456size_t ttm_bo_dma_acc_size(struct ttm_bo_device *bdev,
457 unsigned long bo_size,
458 unsigned struct_size);
459
460/**
445 * ttm_bo_init 461 * ttm_bo_init
446 * 462 *
447 * @bdev: Pointer to a ttm_bo_device struct. 463 * @bdev: Pointer to a ttm_bo_device struct.
@@ -488,6 +504,7 @@ extern int ttm_bo_init(struct ttm_bo_device *bdev,
488 struct file *persistent_swap_storage, 504 struct file *persistent_swap_storage,
489 size_t acc_size, 505 size_t acc_size,
490 void (*destroy) (struct ttm_buffer_object *)); 506 void (*destroy) (struct ttm_buffer_object *));
507
491/** 508/**
492 * ttm_bo_synccpu_object_init 509 * ttm_bo_synccpu_object_init
493 * 510 *
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 {
469 * @dummy_read_page: Pointer to a dummy page used for mapping requests 469 * @dummy_read_page: Pointer to a dummy page used for mapping requests
470 * of unpopulated pages. 470 * of unpopulated pages.
471 * @shrink: A shrink callback object used for buffer object swap. 471 * @shrink: A shrink callback object used for buffer object swap.
472 * @ttm_bo_extra_size: Extra size (sizeof(struct ttm_buffer_object) excluded)
473 * used by a buffer object. This is excluding page arrays and backing pages.
474 * @ttm_bo_size: This is @ttm_bo_extra_size + sizeof(struct ttm_buffer_object).
475 * @device_list_mutex: Mutex protecting the device list. 472 * @device_list_mutex: Mutex protecting the device list.
476 * This mutex is held while traversing the device list for pm options. 473 * This mutex is held while traversing the device list for pm options.
477 * @lru_lock: Spinlock protecting the bo subsystem lru lists. 474 * @lru_lock: Spinlock protecting the bo subsystem lru lists.
@@ -489,8 +486,6 @@ struct ttm_bo_global {
489 struct ttm_mem_global *mem_glob; 486 struct ttm_mem_global *mem_glob;
490 struct page *dummy_read_page; 487 struct page *dummy_read_page;
491 struct ttm_mem_shrink shrink; 488 struct ttm_mem_shrink shrink;
492 size_t ttm_bo_extra_size;
493 size_t ttm_bo_size;
494 struct mutex device_list_mutex; 489 struct mutex device_list_mutex;
495 spinlock_t lru_lock; 490 spinlock_t lru_lock;
496 491