diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /include/drm/ttm/ttm_bo_api.h | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'include/drm/ttm/ttm_bo_api.h')
-rw-r--r-- | include/drm/ttm/ttm_bo_api.h | 83 |
1 files changed, 64 insertions, 19 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 2040e6c4f172..62a0e4c4ceee 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h | |||
@@ -50,10 +50,10 @@ struct drm_mm_node; | |||
50 | * | 50 | * |
51 | * @fpfn: first valid page frame number to put the object | 51 | * @fpfn: first valid page frame number to put the object |
52 | * @lpfn: last valid page frame number to put the object | 52 | * @lpfn: last valid page frame number to put the object |
53 | * @num_placement: number of prefered placements | 53 | * @num_placement: number of preferred placements |
54 | * @placement: prefered placements | 54 | * @placement: preferred placements |
55 | * @num_busy_placement: number of prefered placements when need to evict buffer | 55 | * @num_busy_placement: number of preferred placements when need to evict buffer |
56 | * @busy_placement: prefered placements when need to evict buffer | 56 | * @busy_placement: preferred placements when need to evict buffer |
57 | * | 57 | * |
58 | * Structure indicating the placement you request for an object. | 58 | * Structure indicating the placement you request for an object. |
59 | */ | 59 | */ |
@@ -74,6 +74,8 @@ struct ttm_placement { | |||
74 | * @is_iomem: is this io memory ? | 74 | * @is_iomem: is this io memory ? |
75 | * @size: size in byte | 75 | * @size: size in byte |
76 | * @offset: offset from the base address | 76 | * @offset: offset from the base address |
77 | * @io_reserved_vm: The VM system has a refcount in @io_reserved_count | ||
78 | * @io_reserved_count: Refcounting the numbers of callers to ttm_mem_io_reserve | ||
77 | * | 79 | * |
78 | * Structure indicating the bus placement of an object. | 80 | * Structure indicating the bus placement of an object. |
79 | */ | 81 | */ |
@@ -83,7 +85,8 @@ struct ttm_bus_placement { | |||
83 | unsigned long size; | 85 | unsigned long size; |
84 | unsigned long offset; | 86 | unsigned long offset; |
85 | bool is_iomem; | 87 | bool is_iomem; |
86 | bool io_reserved; | 88 | bool io_reserved_vm; |
89 | uint64_t io_reserved_count; | ||
87 | }; | 90 | }; |
88 | 91 | ||
89 | 92 | ||
@@ -102,7 +105,8 @@ struct ttm_bus_placement { | |||
102 | */ | 105 | */ |
103 | 106 | ||
104 | struct ttm_mem_reg { | 107 | struct ttm_mem_reg { |
105 | struct drm_mm_node *mm_node; | 108 | void *mm_node; |
109 | unsigned long start; | ||
106 | unsigned long size; | 110 | unsigned long size; |
107 | unsigned long num_pages; | 111 | unsigned long num_pages; |
108 | uint32_t page_alignment; | 112 | uint32_t page_alignment; |
@@ -153,11 +157,10 @@ struct ttm_tt; | |||
153 | * keeps one refcount. When this refcount reaches zero, | 157 | * keeps one refcount. When this refcount reaches zero, |
154 | * the object is destroyed. | 158 | * the object is destroyed. |
155 | * @event_queue: Queue for processes waiting on buffer object status change. | 159 | * @event_queue: Queue for processes waiting on buffer object status change. |
156 | * @lock: spinlock protecting mostly synchronization members. | ||
157 | * @mem: structure describing current placement. | 160 | * @mem: structure describing current placement. |
158 | * @persistant_swap_storage: Usually the swap storage is deleted for buffers | 161 | * @persistent_swap_storage: Usually the swap storage is deleted for buffers |
159 | * pinned in physical memory. If this behaviour is not desired, this member | 162 | * pinned in physical memory. If this behaviour is not desired, this member |
160 | * holds a pointer to a persistant shmem object. | 163 | * holds a pointer to a persistent shmem object. |
161 | * @ttm: TTM structure holding system pages. | 164 | * @ttm: TTM structure holding system pages. |
162 | * @evicted: Whether the object was evicted without user-space knowing. | 165 | * @evicted: Whether the object was evicted without user-space knowing. |
163 | * @cpu_writes: For synchronization. Number of cpu writers. | 166 | * @cpu_writes: For synchronization. Number of cpu writers. |
@@ -212,14 +215,13 @@ struct ttm_buffer_object { | |||
212 | struct kref kref; | 215 | struct kref kref; |
213 | struct kref list_kref; | 216 | struct kref list_kref; |
214 | wait_queue_head_t event_queue; | 217 | wait_queue_head_t event_queue; |
215 | spinlock_t lock; | ||
216 | 218 | ||
217 | /** | 219 | /** |
218 | * Members protected by the bo::reserved lock. | 220 | * Members protected by the bo::reserved lock. |
219 | */ | 221 | */ |
220 | 222 | ||
221 | struct ttm_mem_reg mem; | 223 | struct ttm_mem_reg mem; |
222 | struct file *persistant_swap_storage; | 224 | struct file *persistent_swap_storage; |
223 | struct ttm_tt *ttm; | 225 | struct ttm_tt *ttm; |
224 | bool evicted; | 226 | bool evicted; |
225 | 227 | ||
@@ -236,6 +238,7 @@ struct ttm_buffer_object { | |||
236 | struct list_head lru; | 238 | struct list_head lru; |
237 | struct list_head ddestroy; | 239 | struct list_head ddestroy; |
238 | struct list_head swap; | 240 | struct list_head swap; |
241 | struct list_head io_reserve_lru; | ||
239 | uint32_t val_seq; | 242 | uint32_t val_seq; |
240 | bool seq_valid; | 243 | bool seq_valid; |
241 | 244 | ||
@@ -247,10 +250,10 @@ struct ttm_buffer_object { | |||
247 | atomic_t reserved; | 250 | atomic_t reserved; |
248 | 251 | ||
249 | /** | 252 | /** |
250 | * Members protected by the bo::lock | 253 | * Members protected by struct buffer_object_device::fence_lock |
251 | * In addition, setting sync_obj to anything else | 254 | * In addition, setting sync_obj to anything else |
252 | * than NULL requires bo::reserved to be held. This allows for | 255 | * than NULL requires bo::reserved to be held. This allows for |
253 | * checking NULL while reserved but not holding bo::lock. | 256 | * checking NULL while reserved but not holding the mentioned lock. |
254 | */ | 257 | */ |
255 | 258 | ||
256 | void *sync_obj_arg; | 259 | void *sync_obj_arg; |
@@ -363,6 +366,44 @@ extern int ttm_bo_validate(struct ttm_buffer_object *bo, | |||
363 | */ | 366 | */ |
364 | extern void ttm_bo_unref(struct ttm_buffer_object **bo); | 367 | extern void ttm_bo_unref(struct ttm_buffer_object **bo); |
365 | 368 | ||
369 | |||
370 | /** | ||
371 | * ttm_bo_list_ref_sub | ||
372 | * | ||
373 | * @bo: The buffer object. | ||
374 | * @count: The number of references with which to decrease @bo::list_kref; | ||
375 | * @never_free: The refcount should not reach zero with this operation. | ||
376 | * | ||
377 | * Release @count lru list references to this buffer object. | ||
378 | */ | ||
379 | extern void ttm_bo_list_ref_sub(struct ttm_buffer_object *bo, int count, | ||
380 | bool never_free); | ||
381 | |||
382 | /** | ||
383 | * ttm_bo_add_to_lru | ||
384 | * | ||
385 | * @bo: The buffer object. | ||
386 | * | ||
387 | * Add this bo to the relevant mem type lru and, if it's backed by | ||
388 | * system pages (ttms) to the swap list. | ||
389 | * This function must be called with struct ttm_bo_global::lru_lock held, and | ||
390 | * is typically called immediately prior to unreserving a bo. | ||
391 | */ | ||
392 | extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo); | ||
393 | |||
394 | /** | ||
395 | * ttm_bo_del_from_lru | ||
396 | * | ||
397 | * @bo: The buffer object. | ||
398 | * | ||
399 | * Remove this bo from all lru lists used to lookup and reserve an object. | ||
400 | * This function must be called with struct ttm_bo_global::lru_lock held, | ||
401 | * and is usually called just immediately after the bo has been reserved to | ||
402 | * avoid recursive reservation from lru lists. | ||
403 | */ | ||
404 | extern int ttm_bo_del_from_lru(struct ttm_buffer_object *bo); | ||
405 | |||
406 | |||
366 | /** | 407 | /** |
367 | * ttm_bo_lock_delayed_workqueue | 408 | * ttm_bo_lock_delayed_workqueue |
368 | * | 409 | * |
@@ -418,9 +459,9 @@ extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo); | |||
418 | * user buffer object. | 459 | * user buffer object. |
419 | * @interruptible: If needing to sleep to wait for GPU resources, | 460 | * @interruptible: If needing to sleep to wait for GPU resources, |
420 | * sleep interruptible. | 461 | * sleep interruptible. |
421 | * @persistant_swap_storage: Usually the swap storage is deleted for buffers | 462 | * @persistent_swap_storage: Usually the swap storage is deleted for buffers |
422 | * pinned in physical memory. If this behaviour is not desired, this member | 463 | * pinned in physical memory. If this behaviour is not desired, this member |
423 | * holds a pointer to a persistant shmem object. Typically, this would | 464 | * holds a pointer to a persistent shmem object. Typically, this would |
424 | * point to the shmem object backing a GEM object if TTM is used to back a | 465 | * point to the shmem object backing a GEM object if TTM is used to back a |
425 | * GEM user interface. | 466 | * GEM user interface. |
426 | * @acc_size: Accounted size for this object. | 467 | * @acc_size: Accounted size for this object. |
@@ -431,6 +472,10 @@ extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo); | |||
431 | * together with the @destroy function, | 472 | * together with the @destroy function, |
432 | * enables driver-specific objects derived from a ttm_buffer_object. | 473 | * enables driver-specific objects derived from a ttm_buffer_object. |
433 | * On successful return, the object kref and list_kref are set to 1. | 474 | * On successful return, the object kref and list_kref are set to 1. |
475 | * If a failure occurs, the function will call the @destroy function, or | ||
476 | * kfree() if @destroy is NULL. Thus, after a failure, dereferencing @bo is | ||
477 | * illegal and will likely cause memory corruption. | ||
478 | * | ||
434 | * Returns | 479 | * Returns |
435 | * -ENOMEM: Out of memory. | 480 | * -ENOMEM: Out of memory. |
436 | * -EINVAL: Invalid placement flags. | 481 | * -EINVAL: Invalid placement flags. |
@@ -445,7 +490,7 @@ extern int ttm_bo_init(struct ttm_bo_device *bdev, | |||
445 | uint32_t page_alignment, | 490 | uint32_t page_alignment, |
446 | unsigned long buffer_start, | 491 | unsigned long buffer_start, |
447 | bool interrubtible, | 492 | bool interrubtible, |
448 | struct file *persistant_swap_storage, | 493 | struct file *persistent_swap_storage, |
449 | size_t acc_size, | 494 | size_t acc_size, |
450 | void (*destroy) (struct ttm_buffer_object *)); | 495 | void (*destroy) (struct ttm_buffer_object *)); |
451 | /** | 496 | /** |
@@ -461,9 +506,9 @@ extern int ttm_bo_init(struct ttm_bo_device *bdev, | |||
461 | * user buffer object. | 506 | * user buffer object. |
462 | * @interruptible: If needing to sleep while waiting for GPU resources, | 507 | * @interruptible: If needing to sleep while waiting for GPU resources, |
463 | * sleep interruptible. | 508 | * sleep interruptible. |
464 | * @persistant_swap_storage: Usually the swap storage is deleted for buffers | 509 | * @persistent_swap_storage: Usually the swap storage is deleted for buffers |
465 | * pinned in physical memory. If this behaviour is not desired, this member | 510 | * pinned in physical memory. If this behaviour is not desired, this member |
466 | * holds a pointer to a persistant shmem object. Typically, this would | 511 | * holds a pointer to a persistent shmem object. Typically, this would |
467 | * point to the shmem object backing a GEM object if TTM is used to back a | 512 | * point to the shmem object backing a GEM object if TTM is used to back a |
468 | * GEM user interface. | 513 | * GEM user interface. |
469 | * @p_bo: On successful completion *p_bo points to the created object. | 514 | * @p_bo: On successful completion *p_bo points to the created object. |
@@ -483,7 +528,7 @@ extern int ttm_bo_create(struct ttm_bo_device *bdev, | |||
483 | uint32_t page_alignment, | 528 | uint32_t page_alignment, |
484 | unsigned long buffer_start, | 529 | unsigned long buffer_start, |
485 | bool interruptible, | 530 | bool interruptible, |
486 | struct file *persistant_swap_storage, | 531 | struct file *persistent_swap_storage, |
487 | struct ttm_buffer_object **p_bo); | 532 | struct ttm_buffer_object **p_bo); |
488 | 533 | ||
489 | /** | 534 | /** |