aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2009-08-18 10:51:56 -0400
committerDave Airlie <airlied@linux.ie>2009-08-19 02:10:34 -0400
commita987fcaa805fcb24ba885c2e29fd4fdb6816f08f (patch)
tree561b6dd8e002e2eb1a75132b1edbd303782dc2fb /include
parent5fd9cbad3a4ae82c83c55b9c621d156c326724ef (diff)
ttm: Make parts of a struct ttm_bo_device global.
Common resources, like memory accounting and swap lists should be global and not per device. Introduce a struct ttm_bo_global to accomodate this, and register it with sysfs. Add a small sysfs interface to return the number of active buffer objects. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'include')
-rw-r--r--include/drm/ttm/ttm_bo_api.h1
-rw-r--r--include/drm/ttm/ttm_bo_driver.h94
2 files changed, 69 insertions, 26 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 99dc521aa1a9..491146170522 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -155,6 +155,7 @@ struct ttm_buffer_object {
155 * Members constant at init. 155 * Members constant at init.
156 */ 156 */
157 157
158 struct ttm_bo_global *glob;
158 struct ttm_bo_device *bdev; 159 struct ttm_bo_device *bdev;
159 unsigned long buffer_start; 160 unsigned long buffer_start;
160 enum ttm_bo_type type; 161 enum ttm_bo_type type;
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 62ed733c52a2..9dc32f70b9a2 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -32,6 +32,7 @@
32 32
33#include "ttm/ttm_bo_api.h" 33#include "ttm/ttm_bo_api.h"
34#include "ttm/ttm_memory.h" 34#include "ttm/ttm_memory.h"
35#include "ttm/ttm_module.h"
35#include "drm_mm.h" 36#include "drm_mm.h"
36#include "linux/workqueue.h" 37#include "linux/workqueue.h"
37#include "linux/fs.h" 38#include "linux/fs.h"
@@ -160,7 +161,7 @@ struct ttm_tt {
160 long last_lomem_page; 161 long last_lomem_page;
161 uint32_t page_flags; 162 uint32_t page_flags;
162 unsigned long num_pages; 163 unsigned long num_pages;
163 struct ttm_bo_device *bdev; 164 struct ttm_bo_global *glob;
164 struct ttm_backend *be; 165 struct ttm_backend *be;
165 struct task_struct *tsk; 166 struct task_struct *tsk;
166 unsigned long start; 167 unsigned long start;
@@ -355,24 +356,73 @@ struct ttm_bo_driver {
355 void *(*sync_obj_ref) (void *sync_obj); 356 void *(*sync_obj_ref) (void *sync_obj);
356}; 357};
357 358
358#define TTM_NUM_MEM_TYPES 8 359/**
360 * struct ttm_bo_global_ref - Argument to initialize a struct ttm_bo_global.
361 */
362
363struct ttm_bo_global_ref {
364 struct ttm_global_reference ref;
365 struct ttm_mem_global *mem_glob;
366};
359 367
360#define TTM_BO_PRIV_FLAG_MOVING 0 /* Buffer object is moving and needs
361 idling before CPU mapping */
362#define TTM_BO_PRIV_FLAG_MAX 1
363/** 368/**
364 * struct ttm_bo_device - Buffer object driver device-specific data. 369 * struct ttm_bo_global - Buffer object driver global data.
365 * 370 *
366 * @mem_glob: Pointer to a struct ttm_mem_global object for accounting. 371 * @mem_glob: Pointer to a struct ttm_mem_global object for accounting.
367 * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
368 * @count: Current number of buffer object.
369 * @pages: Current number of pinned pages.
370 * @dummy_read_page: Pointer to a dummy page used for mapping requests 372 * @dummy_read_page: Pointer to a dummy page used for mapping requests
371 * of unpopulated pages. 373 * of unpopulated pages.
372 * @shrink: A shrink callback object used for buffre object swap. 374 * @shrink: A shrink callback object used for buffer object swap.
373 * @ttm_bo_extra_size: Extra size (sizeof(struct ttm_buffer_object) excluded) 375 * @ttm_bo_extra_size: Extra size (sizeof(struct ttm_buffer_object) excluded)
374 * used by a buffer object. This is excluding page arrays and backing pages. 376 * used by a buffer object. This is excluding page arrays and backing pages.
375 * @ttm_bo_size: This is @ttm_bo_extra_size + sizeof(struct ttm_buffer_object). 377 * @ttm_bo_size: This is @ttm_bo_extra_size + sizeof(struct ttm_buffer_object).
378 * @device_list_mutex: Mutex protecting the device list.
379 * This mutex is held while traversing the device list for pm options.
380 * @lru_lock: Spinlock protecting the bo subsystem lru lists.
381 * @device_list: List of buffer object devices.
382 * @swap_lru: Lru list of buffer objects used for swapping.
383 */
384
385struct ttm_bo_global {
386
387 /**
388 * Constant after init.
389 */
390
391 struct kobject kobj;
392 struct ttm_mem_global *mem_glob;
393 struct page *dummy_read_page;
394 struct ttm_mem_shrink shrink;
395 size_t ttm_bo_extra_size;
396 size_t ttm_bo_size;
397 struct mutex device_list_mutex;
398 spinlock_t lru_lock;
399
400 /**
401 * Protected by device_list_mutex.
402 */
403 struct list_head device_list;
404
405 /**
406 * Protected by the lru_lock.
407 */
408 struct list_head swap_lru;
409
410 /**
411 * Internal protection.
412 */
413 atomic_t bo_count;
414};
415
416
417#define TTM_NUM_MEM_TYPES 8
418
419#define TTM_BO_PRIV_FLAG_MOVING 0 /* Buffer object is moving and needs
420 idling before CPU mapping */
421#define TTM_BO_PRIV_FLAG_MAX 1
422/**
423 * struct ttm_bo_device - Buffer object driver device-specific data.
424 *
425 * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
376 * @man: An array of mem_type_managers. 426 * @man: An array of mem_type_managers.
377 * @addr_space_mm: Range manager for the device address space. 427 * @addr_space_mm: Range manager for the device address space.
378 * lru_lock: Spinlock that protects the buffer+device lru lists and 428 * lru_lock: Spinlock that protects the buffer+device lru lists and
@@ -390,32 +440,21 @@ struct ttm_bo_device {
390 /* 440 /*
391 * Constant after bo device init / atomic. 441 * Constant after bo device init / atomic.
392 */ 442 */
393 443 struct list_head device_list;
394 struct ttm_mem_global *mem_glob; 444 struct ttm_bo_global *glob;
395 struct ttm_bo_driver *driver; 445 struct ttm_bo_driver *driver;
396 struct page *dummy_read_page;
397 struct ttm_mem_shrink shrink;
398
399 size_t ttm_bo_extra_size;
400 size_t ttm_bo_size;
401
402 rwlock_t vm_lock; 446 rwlock_t vm_lock;
447 struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
403 /* 448 /*
404 * Protected by the vm lock. 449 * Protected by the vm lock.
405 */ 450 */
406 struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
407 struct rb_root addr_space_rb; 451 struct rb_root addr_space_rb;
408 struct drm_mm addr_space_mm; 452 struct drm_mm addr_space_mm;
409 453
410 /* 454 /*
411 * Might want to change this to one lock per manager. 455 * Protected by the global:lru lock.
412 */
413 spinlock_t lru_lock;
414 /*
415 * Protected by the lru lock.
416 */ 456 */
417 struct list_head ddestroy; 457 struct list_head ddestroy;
418 struct list_head swap_lru;
419 458
420 /* 459 /*
421 * Protected by load / firstopen / lastclose /unload sync. 460 * Protected by load / firstopen / lastclose /unload sync.
@@ -629,6 +668,9 @@ extern int ttm_bo_pci_offset(struct ttm_bo_device *bdev,
629 unsigned long *bus_offset, 668 unsigned long *bus_offset,
630 unsigned long *bus_size); 669 unsigned long *bus_size);
631 670
671extern void ttm_bo_global_release(struct ttm_global_reference *ref);
672extern int ttm_bo_global_init(struct ttm_global_reference *ref);
673
632extern int ttm_bo_device_release(struct ttm_bo_device *bdev); 674extern int ttm_bo_device_release(struct ttm_bo_device *bdev);
633 675
634/** 676/**
@@ -646,7 +688,7 @@ extern int ttm_bo_device_release(struct ttm_bo_device *bdev);
646 * !0: Failure. 688 * !0: Failure.
647 */ 689 */
648extern int ttm_bo_device_init(struct ttm_bo_device *bdev, 690extern int ttm_bo_device_init(struct ttm_bo_device *bdev,
649 struct ttm_mem_global *mem_glob, 691 struct ttm_bo_global *glob,
650 struct ttm_bo_driver *driver, 692 struct ttm_bo_driver *driver,
651 uint64_t file_page_offset); 693 uint64_t file_page_offset);
652 694