diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-09-24 16:22:33 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-09-24 16:22:33 -0400 |
commit | baea7b946f00a291b166ccae7fcfed6c01530cc6 (patch) | |
tree | 4aa275fbdbec9c7b9b4629e8bee2bbecd3c6a6af /include/drm/ttm | |
parent | ae19ffbadc1b2100285a5b5b3d0a4e0a11390904 (diff) | |
parent | 94e0fb086fc5663c38bbc0fe86d698be8314f82f (diff) |
Merge branch 'origin' into for-linus
Conflicts:
MAINTAINERS
Diffstat (limited to 'include/drm/ttm')
-rw-r--r-- | include/drm/ttm/ttm_bo_api.h | 13 | ||||
-rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 94 | ||||
-rw-r--r-- | include/drm/ttm/ttm_memory.h | 43 | ||||
-rw-r--r-- | include/drm/ttm/ttm_module.h | 2 |
4 files changed, 101 insertions, 51 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index cd22ab4b495c..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; |
@@ -245,14 +246,15 @@ struct ttm_buffer_object { | |||
245 | * premapped region. | 246 | * premapped region. |
246 | */ | 247 | */ |
247 | 248 | ||
249 | #define TTM_BO_MAP_IOMEM_MASK 0x80 | ||
248 | struct ttm_bo_kmap_obj { | 250 | struct ttm_bo_kmap_obj { |
249 | void *virtual; | 251 | void *virtual; |
250 | struct page *page; | 252 | struct page *page; |
251 | enum { | 253 | enum { |
252 | ttm_bo_map_iomap, | 254 | ttm_bo_map_iomap = 1 | TTM_BO_MAP_IOMEM_MASK, |
253 | ttm_bo_map_vmap, | 255 | ttm_bo_map_vmap = 2, |
254 | ttm_bo_map_kmap, | 256 | ttm_bo_map_kmap = 3, |
255 | ttm_bo_map_premapped, | 257 | ttm_bo_map_premapped = 4 | TTM_BO_MAP_IOMEM_MASK, |
256 | } bo_kmap_type; | 258 | } bo_kmap_type; |
257 | }; | 259 | }; |
258 | 260 | ||
@@ -522,8 +524,7 @@ extern int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type); | |||
522 | static inline void *ttm_kmap_obj_virtual(struct ttm_bo_kmap_obj *map, | 524 | static inline void *ttm_kmap_obj_virtual(struct ttm_bo_kmap_obj *map, |
523 | bool *is_iomem) | 525 | bool *is_iomem) |
524 | { | 526 | { |
525 | *is_iomem = (map->bo_kmap_type == ttm_bo_map_iomap || | 527 | *is_iomem = !!(map->bo_kmap_type & TTM_BO_MAP_IOMEM_MASK); |
526 | map->bo_kmap_type == ttm_bo_map_premapped); | ||
527 | return map->virtual; | 528 | return map->virtual; |
528 | } | 529 | } |
529 | 530 | ||
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 | |||
372 | struct 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 | |||
394 | struct 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 | ||
682 | extern void ttm_bo_global_release(struct ttm_global_reference *ref); | ||
683 | extern int ttm_bo_global_init(struct ttm_global_reference *ref); | ||
684 | |||
643 | extern int ttm_bo_device_release(struct ttm_bo_device *bdev); | 685 | extern 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 | */ |
659 | extern int ttm_bo_device_init(struct ttm_bo_device *bdev, | 701 | extern 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 | ||
diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h index d8b8f042c4f1..6983a7cf4da4 100644 --- a/include/drm/ttm/ttm_memory.h +++ b/include/drm/ttm/ttm_memory.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/spinlock.h> | 32 | #include <linux/spinlock.h> |
33 | #include <linux/wait.h> | 33 | #include <linux/wait.h> |
34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
35 | #include <linux/kobject.h> | ||
35 | 36 | ||
36 | /** | 37 | /** |
37 | * struct ttm_mem_shrink - callback to shrink TTM memory usage. | 38 | * struct ttm_mem_shrink - callback to shrink TTM memory usage. |
@@ -60,34 +61,33 @@ struct ttm_mem_shrink { | |||
60 | * @queue: Wait queue for processes suspended waiting for memory. | 61 | * @queue: Wait queue for processes suspended waiting for memory. |
61 | * @lock: Lock to protect the @shrink - and the memory accounting members, | 62 | * @lock: Lock to protect the @shrink - and the memory accounting members, |
62 | * that is, essentially the whole structure with some exceptions. | 63 | * that is, essentially the whole structure with some exceptions. |
63 | * @emer_memory: Lowmem memory limit available for root. | 64 | * @zones: Array of pointers to accounting zones. |
64 | * @max_memory: Lowmem memory limit available for non-root. | 65 | * @num_zones: Number of populated entries in the @zones array. |
65 | * @swap_limit: Lowmem memory limit where the shrink workqueue kicks in. | 66 | * @zone_kernel: Pointer to the kernel zone. |
66 | * @used_memory: Currently used lowmem memory. | 67 | * @zone_highmem: Pointer to the highmem zone if there is one. |
67 | * @used_total_memory: Currently used total (lowmem + highmem) memory. | 68 | * @zone_dma32: Pointer to the dma32 zone if there is one. |
68 | * @total_memory_swap_limit: Total memory limit where the shrink workqueue | ||
69 | * kicks in. | ||
70 | * @max_total_memory: Total memory available to non-root processes. | ||
71 | * @emer_total_memory: Total memory available to root processes. | ||
72 | * | 69 | * |
73 | * Note that this structure is not per device. It should be global for all | 70 | * Note that this structure is not per device. It should be global for all |
74 | * graphics devices. | 71 | * graphics devices. |
75 | */ | 72 | */ |
76 | 73 | ||
74 | #define TTM_MEM_MAX_ZONES 2 | ||
75 | struct ttm_mem_zone; | ||
77 | struct ttm_mem_global { | 76 | struct ttm_mem_global { |
77 | struct kobject kobj; | ||
78 | struct ttm_mem_shrink *shrink; | 78 | struct ttm_mem_shrink *shrink; |
79 | struct workqueue_struct *swap_queue; | 79 | struct workqueue_struct *swap_queue; |
80 | struct work_struct work; | 80 | struct work_struct work; |
81 | wait_queue_head_t queue; | 81 | wait_queue_head_t queue; |
82 | spinlock_t lock; | 82 | spinlock_t lock; |
83 | uint64_t emer_memory; | 83 | struct ttm_mem_zone *zones[TTM_MEM_MAX_ZONES]; |
84 | uint64_t max_memory; | 84 | unsigned int num_zones; |
85 | uint64_t swap_limit; | 85 | struct ttm_mem_zone *zone_kernel; |
86 | uint64_t used_memory; | 86 | #ifdef CONFIG_HIGHMEM |
87 | uint64_t used_total_memory; | 87 | struct ttm_mem_zone *zone_highmem; |
88 | uint64_t total_memory_swap_limit; | 88 | #else |
89 | uint64_t max_total_memory; | 89 | struct ttm_mem_zone *zone_dma32; |
90 | uint64_t emer_total_memory; | 90 | #endif |
91 | }; | 91 | }; |
92 | 92 | ||
93 | /** | 93 | /** |
@@ -146,8 +146,13 @@ static inline void ttm_mem_unregister_shrink(struct ttm_mem_global *glob, | |||
146 | extern int ttm_mem_global_init(struct ttm_mem_global *glob); | 146 | extern int ttm_mem_global_init(struct ttm_mem_global *glob); |
147 | extern void ttm_mem_global_release(struct ttm_mem_global *glob); | 147 | extern void ttm_mem_global_release(struct ttm_mem_global *glob); |
148 | extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, | 148 | extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, |
149 | bool no_wait, bool interruptible, bool himem); | 149 | bool no_wait, bool interruptible); |
150 | extern void ttm_mem_global_free(struct ttm_mem_global *glob, | 150 | extern void ttm_mem_global_free(struct ttm_mem_global *glob, |
151 | uint64_t amount, bool himem); | 151 | uint64_t amount); |
152 | extern int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, | ||
153 | struct page *page, | ||
154 | bool no_wait, bool interruptible); | ||
155 | extern void ttm_mem_global_free_page(struct ttm_mem_global *glob, | ||
156 | struct page *page); | ||
152 | extern size_t ttm_round_pot(size_t size); | 157 | extern size_t ttm_round_pot(size_t size); |
153 | #endif | 158 | #endif |
diff --git a/include/drm/ttm/ttm_module.h b/include/drm/ttm/ttm_module.h index d1d433834e4f..cf416aee19af 100644 --- a/include/drm/ttm/ttm_module.h +++ b/include/drm/ttm/ttm_module.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #define _TTM_MODULE_H_ | 32 | #define _TTM_MODULE_H_ |
33 | 33 | ||
34 | #include <linux/kernel.h> | 34 | #include <linux/kernel.h> |
35 | struct kobject; | ||
35 | 36 | ||
36 | #define TTM_PFX "[TTM] " | 37 | #define TTM_PFX "[TTM] " |
37 | 38 | ||
@@ -54,5 +55,6 @@ extern void ttm_global_init(void); | |||
54 | extern void ttm_global_release(void); | 55 | extern void ttm_global_release(void); |
55 | extern int ttm_global_item_ref(struct ttm_global_reference *ref); | 56 | extern int ttm_global_item_ref(struct ttm_global_reference *ref); |
56 | extern void ttm_global_item_unref(struct ttm_global_reference *ref); | 57 | extern void ttm_global_item_unref(struct ttm_global_reference *ref); |
58 | extern struct kobject *ttm_get_kobj(void); | ||
57 | 59 | ||
58 | #endif /* _TTM_MODULE_H_ */ | 60 | #endif /* _TTM_MODULE_H_ */ |