diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-07-24 15:08:53 -0400 |
---|---|---|
committer | Dave Airlie <airlied@gmail.com> | 2013-07-25 06:47:07 -0400 |
commit | 72525b3f333de54fa0c42ef87f27861e41478f1e (patch) | |
tree | 33f5a2435f0b15396702aa0a0ee36e8b73b5a897 /include/drm | |
parent | 0de23977cfeb5b357ec884ba15417ae118ff9e9b (diff) |
drm/ttm: convert to unified vma offset manager
Use the new vma-manager infrastructure. This doesn't change any
implementation details as the vma-offset-manager is nearly copied 1-to-1
from TTM.
The vm_lock is moved into the offset manager so we can drop it from TTM.
During lookup, we use the vma locking helpers to take a reference to the
found object.
In all other scenarios, locking stays the same as before. We always
guarantee that drm_vma_offset_remove() is called only during destruction.
Hence, helpers like drm_vma_node_offset_addr() are always safe as long as
the node has a valid offset.
This also drops the addr_space_offset member as it is a copy of vm_start
in vma_node objects. Use the accessor functions instead.
v4:
- remove vm_lock
- use drm_vma_offset_lock_lookup() to protect lookup (instead of vm_lock)
Cc: Dave Airlie <airlied@redhat.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: Martin Peres <martin.peres@labri.fr>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@gmail.com>
Diffstat (limited to 'include/drm')
-rw-r--r-- | include/drm/ttm/ttm_bo_api.h | 15 | ||||
-rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 10 |
2 files changed, 8 insertions, 17 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 8a6aa56ece52..751eaffbf0d5 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h | |||
@@ -32,12 +32,12 @@ | |||
32 | #define _TTM_BO_API_H_ | 32 | #define _TTM_BO_API_H_ |
33 | 33 | ||
34 | #include <drm/drm_hashtab.h> | 34 | #include <drm/drm_hashtab.h> |
35 | #include <drm/drm_vma_manager.h> | ||
35 | #include <linux/kref.h> | 36 | #include <linux/kref.h> |
36 | #include <linux/list.h> | 37 | #include <linux/list.h> |
37 | #include <linux/wait.h> | 38 | #include <linux/wait.h> |
38 | #include <linux/mutex.h> | 39 | #include <linux/mutex.h> |
39 | #include <linux/mm.h> | 40 | #include <linux/mm.h> |
40 | #include <linux/rbtree.h> | ||
41 | #include <linux/bitmap.h> | 41 | #include <linux/bitmap.h> |
42 | #include <linux/reservation.h> | 42 | #include <linux/reservation.h> |
43 | 43 | ||
@@ -145,7 +145,6 @@ struct ttm_tt; | |||
145 | * @type: The bo type. | 145 | * @type: The bo type. |
146 | * @destroy: Destruction function. If NULL, kfree is used. | 146 | * @destroy: Destruction function. If NULL, kfree is used. |
147 | * @num_pages: Actual number of pages. | 147 | * @num_pages: Actual number of pages. |
148 | * @addr_space_offset: Address space offset. | ||
149 | * @acc_size: Accounted size for this object. | 148 | * @acc_size: Accounted size for this object. |
150 | * @kref: Reference count of this buffer object. When this refcount reaches | 149 | * @kref: Reference count of this buffer object. When this refcount reaches |
151 | * zero, the object is put on the delayed delete list. | 150 | * zero, the object is put on the delayed delete list. |
@@ -166,8 +165,7 @@ struct ttm_tt; | |||
166 | * @swap: List head for swap LRU list. | 165 | * @swap: List head for swap LRU list. |
167 | * @sync_obj: Pointer to a synchronization object. | 166 | * @sync_obj: Pointer to a synchronization object. |
168 | * @priv_flags: Flags describing buffer object internal state. | 167 | * @priv_flags: Flags describing buffer object internal state. |
169 | * @vm_rb: Rb node for the vm rb tree. | 168 | * @vma_node: Address space manager node. |
170 | * @vm_node: Address space manager node. | ||
171 | * @offset: The current GPU offset, which can have different meanings | 169 | * @offset: The current GPU offset, which can have different meanings |
172 | * depending on the memory type. For SYSTEM type memory, it should be 0. | 170 | * depending on the memory type. For SYSTEM type memory, it should be 0. |
173 | * @cur_placement: Hint of current placement. | 171 | * @cur_placement: Hint of current placement. |
@@ -194,7 +192,6 @@ struct ttm_buffer_object { | |||
194 | enum ttm_bo_type type; | 192 | enum ttm_bo_type type; |
195 | void (*destroy) (struct ttm_buffer_object *); | 193 | void (*destroy) (struct ttm_buffer_object *); |
196 | unsigned long num_pages; | 194 | unsigned long num_pages; |
197 | uint64_t addr_space_offset; | ||
198 | size_t acc_size; | 195 | size_t acc_size; |
199 | 196 | ||
200 | /** | 197 | /** |
@@ -238,13 +235,7 @@ struct ttm_buffer_object { | |||
238 | void *sync_obj; | 235 | void *sync_obj; |
239 | unsigned long priv_flags; | 236 | unsigned long priv_flags; |
240 | 237 | ||
241 | /** | 238 | struct drm_vma_offset_node vma_node; |
242 | * Members protected by the bdev::vm_lock | ||
243 | */ | ||
244 | |||
245 | struct rb_node vm_rb; | ||
246 | struct drm_mm_node *vm_node; | ||
247 | |||
248 | 239 | ||
249 | /** | 240 | /** |
250 | * Special members that are protected by the reserve lock | 241 | * Special members that are protected by the reserve lock |
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 984fc2d571a1..8639c85d61c4 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <ttm/ttm_placement.h> | 36 | #include <ttm/ttm_placement.h> |
37 | #include <drm/drm_mm.h> | 37 | #include <drm/drm_mm.h> |
38 | #include <drm/drm_global.h> | 38 | #include <drm/drm_global.h> |
39 | #include <drm/drm_vma_manager.h> | ||
39 | #include <linux/workqueue.h> | 40 | #include <linux/workqueue.h> |
40 | #include <linux/fs.h> | 41 | #include <linux/fs.h> |
41 | #include <linux/spinlock.h> | 42 | #include <linux/spinlock.h> |
@@ -519,7 +520,7 @@ struct ttm_bo_global { | |||
519 | * @man: An array of mem_type_managers. | 520 | * @man: An array of mem_type_managers. |
520 | * @fence_lock: Protects the synchronizing members on *all* bos belonging | 521 | * @fence_lock: Protects the synchronizing members on *all* bos belonging |
521 | * to this device. | 522 | * to this device. |
522 | * @addr_space_mm: Range manager for the device address space. | 523 | * @vma_manager: Address space manager |
523 | * lru_lock: Spinlock that protects the buffer+device lru lists and | 524 | * lru_lock: Spinlock that protects the buffer+device lru lists and |
524 | * ddestroy lists. | 525 | * ddestroy lists. |
525 | * @val_seq: Current validation sequence. | 526 | * @val_seq: Current validation sequence. |
@@ -537,14 +538,13 @@ struct ttm_bo_device { | |||
537 | struct list_head device_list; | 538 | struct list_head device_list; |
538 | struct ttm_bo_global *glob; | 539 | struct ttm_bo_global *glob; |
539 | struct ttm_bo_driver *driver; | 540 | struct ttm_bo_driver *driver; |
540 | rwlock_t vm_lock; | ||
541 | struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES]; | 541 | struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES]; |
542 | spinlock_t fence_lock; | 542 | spinlock_t fence_lock; |
543 | |||
543 | /* | 544 | /* |
544 | * Protected by the vm lock. | 545 | * Protected by internal locks. |
545 | */ | 546 | */ |
546 | struct rb_root addr_space_rb; | 547 | struct drm_vma_offset_manager vma_manager; |
547 | struct drm_mm addr_space_mm; | ||
548 | 548 | ||
549 | /* | 549 | /* |
550 | * Protected by the global:lru lock. | 550 | * Protected by the global:lru lock. |