aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/ttm/ttm_bo_driver.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-10-01 05:20:33 -0400
committerIngo Molnar <mingo@elte.hu>2009-10-01 05:20:48 -0400
commit0aa73ba1c4e1ad1d51a29e0df95ccd9f746918b6 (patch)
treef0714ddcd02812b4fbe3b5405df9e4068f5587e2 /include/drm/ttm/ttm_bo_driver.h
parent925936ebf35a95c290e010b784c962164e6728f3 (diff)
parent33974093c024f08caadd2fc71a83bd811ed1831d (diff)
Merge branch 'tracing/urgent' into tracing/core
Merge reason: Pick up latest fixes and update to latest upstream. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/drm/ttm/ttm_bo_driver.h')
-rw-r--r--include/drm/ttm/ttm_bo_driver.h94
1 files changed, 68 insertions, 26 deletions
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index a68829db381a..e8cd6d20aed2 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"
@@ -161,7 +162,7 @@ struct ttm_tt {
161 long last_lomem_page; 162 long last_lomem_page;
162 uint32_t page_flags; 163 uint32_t page_flags;
163 unsigned long num_pages; 164 unsigned long num_pages;
164 struct ttm_bo_device *bdev; 165 struct ttm_bo_global *glob;
165 struct ttm_backend *be; 166 struct ttm_backend *be;
166 struct task_struct *tsk; 167 struct task_struct *tsk;
167 unsigned long start; 168 unsigned long start;
@@ -364,24 +365,73 @@ struct ttm_bo_driver {
364 void (*fault_reserve_notify)(struct ttm_buffer_object *bo); 365 void (*fault_reserve_notify)(struct ttm_buffer_object *bo);
365}; 366};
366 367
367#define TTM_NUM_MEM_TYPES 8 368/**
369 * struct ttm_bo_global_ref - Argument to initialize a struct ttm_bo_global.
370 */
371
372struct ttm_bo_global_ref {
373 struct ttm_global_reference ref;
374 struct ttm_mem_global *mem_glob;
375};
368 376
369#define TTM_BO_PRIV_FLAG_MOVING 0 /* Buffer object is moving and needs
370 idling before CPU mapping */
371#define TTM_BO_PRIV_FLAG_MAX 1
372/** 377/**
373 * struct ttm_bo_device - Buffer object driver device-specific data. 378 * struct ttm_bo_global - Buffer object driver global data.
374 * 379 *
375 * @mem_glob: Pointer to a struct ttm_mem_global object for accounting. 380 * @mem_glob: Pointer to a struct ttm_mem_global object for accounting.
376 * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
377 * @count: Current number of buffer object.
378 * @pages: Current number of pinned pages.
379 * @dummy_read_page: Pointer to a dummy page used for mapping requests 381 * @dummy_read_page: Pointer to a dummy page used for mapping requests
380 * of unpopulated pages. 382 * of unpopulated pages.
381 * @shrink: A shrink callback object used for buffre object swap. 383 * @shrink: A shrink callback object used for buffer object swap.
382 * @ttm_bo_extra_size: Extra size (sizeof(struct ttm_buffer_object) excluded) 384 * @ttm_bo_extra_size: Extra size (sizeof(struct ttm_buffer_object) excluded)
383 * used by a buffer object. This is excluding page arrays and backing pages. 385 * used by a buffer object. This is excluding page arrays and backing pages.
384 * @ttm_bo_size: This is @ttm_bo_extra_size + sizeof(struct ttm_buffer_object). 386 * @ttm_bo_size: This is @ttm_bo_extra_size + sizeof(struct ttm_buffer_object).
387 * @device_list_mutex: Mutex protecting the device list.
388 * This mutex is held while traversing the device list for pm options.
389 * @lru_lock: Spinlock protecting the bo subsystem lru lists.
390 * @device_list: List of buffer object devices.
391 * @swap_lru: Lru list of buffer objects used for swapping.
392 */
393
394struct ttm_bo_global {
395
396 /**
397 * Constant after init.
398 */
399
400 struct kobject kobj;
401 struct ttm_mem_global *mem_glob;
402 struct page *dummy_read_page;
403 struct ttm_mem_shrink shrink;
404 size_t ttm_bo_extra_size;
405 size_t ttm_bo_size;
406 struct mutex device_list_mutex;
407 spinlock_t lru_lock;
408
409 /**
410 * Protected by device_list_mutex.
411 */
412 struct list_head device_list;
413
414 /**
415 * Protected by the lru_lock.
416 */
417 struct list_head swap_lru;
418
419 /**
420 * Internal protection.
421 */
422 atomic_t bo_count;
423};
424
425
426#define TTM_NUM_MEM_TYPES 8
427
428#define TTM_BO_PRIV_FLAG_MOVING 0 /* Buffer object is moving and needs
429 idling before CPU mapping */
430#define TTM_BO_PRIV_FLAG_MAX 1
431/**
432 * struct ttm_bo_device - Buffer object driver device-specific data.
433 *
434 * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
385 * @man: An array of mem_type_managers. 435 * @man: An array of mem_type_managers.
386 * @addr_space_mm: Range manager for the device address space. 436 * @addr_space_mm: Range manager for the device address space.
387 * lru_lock: Spinlock that protects the buffer+device lru lists and 437 * lru_lock: Spinlock that protects the buffer+device lru lists and
@@ -399,32 +449,21 @@ struct ttm_bo_device {
399 /* 449 /*
400 * Constant after bo device init / atomic. 450 * Constant after bo device init / atomic.
401 */ 451 */
402 452 struct list_head device_list;
403 struct ttm_mem_global *mem_glob; 453 struct ttm_bo_global *glob;
404 struct ttm_bo_driver *driver; 454 struct ttm_bo_driver *driver;
405 struct page *dummy_read_page;
406 struct ttm_mem_shrink shrink;
407
408 size_t ttm_bo_extra_size;
409 size_t ttm_bo_size;
410
411 rwlock_t vm_lock; 455 rwlock_t vm_lock;
456 struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
412 /* 457 /*
413 * Protected by the vm lock. 458 * Protected by the vm lock.
414 */ 459 */
415 struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
416 struct rb_root addr_space_rb; 460 struct rb_root addr_space_rb;
417 struct drm_mm addr_space_mm; 461 struct drm_mm addr_space_mm;
418 462
419 /* 463 /*
420 * Might want to change this to one lock per manager. 464 * Protected by the global:lru lock.
421 */
422 spinlock_t lru_lock;
423 /*
424 * Protected by the lru lock.
425 */ 465 */
426 struct list_head ddestroy; 466 struct list_head ddestroy;
427 struct list_head swap_lru;
428 467
429 /* 468 /*
430 * Protected by load / firstopen / lastclose /unload sync. 469 * Protected by load / firstopen / lastclose /unload sync.
@@ -640,6 +679,9 @@ extern int ttm_bo_pci_offset(struct ttm_bo_device *bdev,
640 unsigned long *bus_offset, 679 unsigned long *bus_offset,
641 unsigned long *bus_size); 680 unsigned long *bus_size);
642 681
682extern void ttm_bo_global_release(struct ttm_global_reference *ref);
683extern int ttm_bo_global_init(struct ttm_global_reference *ref);
684
643extern int ttm_bo_device_release(struct ttm_bo_device *bdev); 685extern int ttm_bo_device_release(struct ttm_bo_device *bdev);
644 686
645/** 687/**
@@ -657,7 +699,7 @@ extern int ttm_bo_device_release(struct ttm_bo_device *bdev);
657 * !0: Failure. 699 * !0: Failure.
658 */ 700 */
659extern int ttm_bo_device_init(struct ttm_bo_device *bdev, 701extern int ttm_bo_device_init(struct ttm_bo_device *bdev,
660 struct ttm_mem_global *mem_glob, 702 struct ttm_bo_global *glob,
661 struct ttm_bo_driver *driver, 703 struct ttm_bo_driver *driver,
662 uint64_t file_page_offset, bool need_dma32); 704 uint64_t file_page_offset, bool need_dma32);
663 705