aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2009-12-10 00:47:57 -0500
committerDave Airlie <airlied@redhat.com>2009-12-10 00:48:04 -0500
commit115a5c2ba0aac55e1bac390f271c818c3cbfa1fb (patch)
treebf3029a9a68e4d3dbe82553f8a88dc25072c7dc2 /include
parent0b5e8db639de032bd4febbb0a5b1cd2c19bac26d (diff)
parentfb53f8621a3fab88776ae2450a1f3afc7920231b (diff)
Merge remote branch 'korg/drm-radeon-next' of into drm-linus
This merges some TTM overhauls to allow us to do better object placement for certain radeon GPUs that need scanout+cursor within range of each other, along with an API change to not return ERESTART to userspace, but to use ERESTARTSYS properly internally and have it convert to EINTR and catch that correctly. Also lots of radeon fixes across the board.
Diffstat (limited to 'include')
-rw-r--r--include/drm/drm_mm.h35
-rw-r--r--include/drm/ttm/ttm_bo_api.h56
-rw-r--r--include/drm/ttm/ttm_bo_driver.h28
3 files changed, 81 insertions, 38 deletions
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
index 62329f9a42cb..4c10be39a43b 100644
--- a/include/drm/drm_mm.h
+++ b/include/drm/drm_mm.h
@@ -66,6 +66,13 @@ extern struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *node,
66 unsigned long size, 66 unsigned long size,
67 unsigned alignment, 67 unsigned alignment,
68 int atomic); 68 int atomic);
69extern struct drm_mm_node *drm_mm_get_block_range_generic(
70 struct drm_mm_node *node,
71 unsigned long size,
72 unsigned alignment,
73 unsigned long start,
74 unsigned long end,
75 int atomic);
69static inline struct drm_mm_node *drm_mm_get_block(struct drm_mm_node *parent, 76static inline struct drm_mm_node *drm_mm_get_block(struct drm_mm_node *parent,
70 unsigned long size, 77 unsigned long size,
71 unsigned alignment) 78 unsigned alignment)
@@ -78,11 +85,38 @@ static inline struct drm_mm_node *drm_mm_get_block_atomic(struct drm_mm_node *pa
78{ 85{
79 return drm_mm_get_block_generic(parent, size, alignment, 1); 86 return drm_mm_get_block_generic(parent, size, alignment, 1);
80} 87}
88static inline struct drm_mm_node *drm_mm_get_block_range(
89 struct drm_mm_node *parent,
90 unsigned long size,
91 unsigned alignment,
92 unsigned long start,
93 unsigned long end)
94{
95 return drm_mm_get_block_range_generic(parent, size, alignment,
96 start, end, 0);
97}
98static inline struct drm_mm_node *drm_mm_get_block_atomic_range(
99 struct drm_mm_node *parent,
100 unsigned long size,
101 unsigned alignment,
102 unsigned long start,
103 unsigned long end)
104{
105 return drm_mm_get_block_range_generic(parent, size, alignment,
106 start, end, 1);
107}
81extern void drm_mm_put_block(struct drm_mm_node *cur); 108extern void drm_mm_put_block(struct drm_mm_node *cur);
82extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm, 109extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm,
83 unsigned long size, 110 unsigned long size,
84 unsigned alignment, 111 unsigned alignment,
85 int best_match); 112 int best_match);
113extern struct drm_mm_node *drm_mm_search_free_in_range(
114 const struct drm_mm *mm,
115 unsigned long size,
116 unsigned alignment,
117 unsigned long start,
118 unsigned long end,
119 int best_match);
86extern int drm_mm_init(struct drm_mm *mm, unsigned long start, 120extern int drm_mm_init(struct drm_mm *mm, unsigned long start,
87 unsigned long size); 121 unsigned long size);
88extern void drm_mm_takedown(struct drm_mm *mm); 122extern void drm_mm_takedown(struct drm_mm *mm);
@@ -99,6 +133,7 @@ static inline struct drm_mm *drm_get_mm(struct drm_mm_node *block)
99 return block->mm; 133 return block->mm;
100} 134}
101 135
136extern void drm_mm_debug_table(struct drm_mm *mm, const char *prefix);
102#ifdef CONFIG_DEBUG_FS 137#ifdef CONFIG_DEBUG_FS
103int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm); 138int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm);
104#endif 139#endif
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 491146170522..4fd498523ce3 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -44,6 +44,29 @@ struct ttm_bo_device;
44 44
45struct drm_mm_node; 45struct drm_mm_node;
46 46
47
48/**
49 * struct ttm_placement
50 *
51 * @fpfn: first 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
54 * @placement: prefered placements
55 * @num_busy_placement: number of prefered placements when need to evict buffer
56 * @busy_placement: prefered placements when need to evict buffer
57 *
58 * Structure indicating the placement you request for an object.
59 */
60struct ttm_placement {
61 unsigned fpfn;
62 unsigned lpfn;
63 unsigned num_placement;
64 const uint32_t *placement;
65 unsigned num_busy_placement;
66 const uint32_t *busy_placement;
67};
68
69
47/** 70/**
48 * struct ttm_mem_reg 71 * struct ttm_mem_reg
49 * 72 *
@@ -109,10 +132,6 @@ struct ttm_tt;
109 * the object is destroyed. 132 * the object is destroyed.
110 * @event_queue: Queue for processes waiting on buffer object status change. 133 * @event_queue: Queue for processes waiting on buffer object status change.
111 * @lock: spinlock protecting mostly synchronization members. 134 * @lock: spinlock protecting mostly synchronization members.
112 * @proposed_placement: Proposed placement for the buffer. Changed only by the
113 * creator prior to validation as opposed to bo->mem.proposed_flags which is
114 * changed by the implementation prior to a buffer move if it wants to outsmart
115 * the buffer creator / user. This latter happens, for example, at eviction.
116 * @mem: structure describing current placement. 135 * @mem: structure describing current placement.
117 * @persistant_swap_storage: Usually the swap storage is deleted for buffers 136 * @persistant_swap_storage: Usually the swap storage is deleted for buffers
118 * pinned in physical memory. If this behaviour is not desired, this member 137 * pinned in physical memory. If this behaviour is not desired, this member
@@ -177,7 +196,6 @@ struct ttm_buffer_object {
177 * Members protected by the bo::reserved lock. 196 * Members protected by the bo::reserved lock.
178 */ 197 */
179 198
180 uint32_t proposed_placement;
181 struct ttm_mem_reg mem; 199 struct ttm_mem_reg mem;
182 struct file *persistant_swap_storage; 200 struct file *persistant_swap_storage;
183 struct ttm_tt *ttm; 201 struct ttm_tt *ttm;
@@ -285,7 +303,7 @@ ttm_bo_reference(struct ttm_buffer_object *bo)
285 * Note: It might be necessary to block validations before the 303 * Note: It might be necessary to block validations before the
286 * wait by reserving the buffer. 304 * wait by reserving the buffer.
287 * Returns -EBUSY if no_wait is true and the buffer is busy. 305 * Returns -EBUSY if no_wait is true and the buffer is busy.
288 * Returns -ERESTART if interrupted by a signal. 306 * Returns -ERESTARTSYS if interrupted by a signal.
289 */ 307 */
290extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy, 308extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,
291 bool interruptible, bool no_wait); 309 bool interruptible, bool no_wait);
@@ -293,21 +311,22 @@ extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,
293 * ttm_buffer_object_validate 311 * ttm_buffer_object_validate
294 * 312 *
295 * @bo: The buffer object. 313 * @bo: The buffer object.
296 * @proposed_placement: Proposed_placement for the buffer object. 314 * @placement: Proposed placement for the buffer object.
297 * @interruptible: Sleep interruptible if sleeping. 315 * @interruptible: Sleep interruptible if sleeping.
298 * @no_wait: Return immediately if the buffer is busy. 316 * @no_wait: Return immediately if the buffer is busy.
299 * 317 *
300 * Changes placement and caching policy of the buffer object 318 * Changes placement and caching policy of the buffer object
301 * according to bo::proposed_flags. 319 * according proposed placement.
302 * Returns 320 * Returns
303 * -EINVAL on invalid proposed_flags. 321 * -EINVAL on invalid proposed placement.
304 * -ENOMEM on out-of-memory condition. 322 * -ENOMEM on out-of-memory condition.
305 * -EBUSY if no_wait is true and buffer busy. 323 * -EBUSY if no_wait is true and buffer busy.
306 * -ERESTART if interrupted by a signal. 324 * -ERESTARTSYS if interrupted by a signal.
307 */ 325 */
308extern int ttm_buffer_object_validate(struct ttm_buffer_object *bo, 326extern int ttm_buffer_object_validate(struct ttm_buffer_object *bo,
309 uint32_t proposed_placement, 327 struct ttm_placement *placement,
310 bool interruptible, bool no_wait); 328 bool interruptible, bool no_wait);
329
311/** 330/**
312 * ttm_bo_unref 331 * ttm_bo_unref
313 * 332 *
@@ -328,7 +347,7 @@ extern void ttm_bo_unref(struct ttm_buffer_object **bo);
328 * waiting for buffer idle. This lock is recursive. 347 * waiting for buffer idle. This lock is recursive.
329 * Returns 348 * Returns
330 * -EBUSY if the buffer is busy and no_wait is true. 349 * -EBUSY if the buffer is busy and no_wait is true.
331 * -ERESTART if interrupted by a signal. 350 * -ERESTARTSYS if interrupted by a signal.
332 */ 351 */
333 352
334extern int 353extern int
@@ -371,7 +390,7 @@ extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo);
371 * Returns 390 * Returns
372 * -ENOMEM: Out of memory. 391 * -ENOMEM: Out of memory.
373 * -EINVAL: Invalid placement flags. 392 * -EINVAL: Invalid placement flags.
374 * -ERESTART: Interrupted by signal while sleeping waiting for resources. 393 * -ERESTARTSYS: Interrupted by signal while sleeping waiting for resources.
375 */ 394 */
376 395
377extern int ttm_buffer_object_init(struct ttm_bo_device *bdev, 396extern int ttm_buffer_object_init(struct ttm_bo_device *bdev,
@@ -411,7 +430,7 @@ extern int ttm_buffer_object_init(struct ttm_bo_device *bdev,
411 * Returns 430 * Returns
412 * -ENOMEM: Out of memory. 431 * -ENOMEM: Out of memory.
413 * -EINVAL: Invalid placement flags. 432 * -EINVAL: Invalid placement flags.
414 * -ERESTART: Interrupted by signal while waiting for resources. 433 * -ERESTARTSYS: Interrupted by signal while waiting for resources.
415 */ 434 */
416 435
417extern int ttm_buffer_object_create(struct ttm_bo_device *bdev, 436extern int ttm_buffer_object_create(struct ttm_bo_device *bdev,
@@ -445,7 +464,6 @@ extern int ttm_bo_check_placement(struct ttm_buffer_object *bo,
445 * 464 *
446 * @bdev: Pointer to a ttm_bo_device struct. 465 * @bdev: Pointer to a ttm_bo_device struct.
447 * @mem_type: The memory type. 466 * @mem_type: The memory type.
448 * @p_offset: offset for managed area in pages.
449 * @p_size: size managed area in pages. 467 * @p_size: size managed area in pages.
450 * 468 *
451 * Initialize a manager for a given memory type. 469 * Initialize a manager for a given memory type.
@@ -458,7 +476,7 @@ extern int ttm_bo_check_placement(struct ttm_buffer_object *bo,
458 */ 476 */
459 477
460extern int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, 478extern int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
461 unsigned long p_offset, unsigned long p_size); 479 unsigned long p_size);
462/** 480/**
463 * ttm_bo_clean_mm 481 * ttm_bo_clean_mm
464 * 482 *
@@ -503,7 +521,7 @@ extern int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type);
503 * 521 *
504 * Returns: 522 * Returns:
505 * -EINVAL: Invalid or uninitialized memory type. 523 * -EINVAL: Invalid or uninitialized memory type.
506 * -ERESTART: The call was interrupted by a signal while waiting to 524 * -ERESTARTSYS: The call was interrupted by a signal while waiting to
507 * evict a buffer. 525 * evict a buffer.
508 */ 526 */
509 527
@@ -606,7 +624,7 @@ extern int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
606 * be called from the fops::read and fops::write method. 624 * be called from the fops::read and fops::write method.
607 * Returns: 625 * Returns:
608 * See man (2) write, man(2) read. In particular, 626 * See man (2) write, man(2) read. In particular,
609 * the function may return -EINTR if 627 * the function may return -ERESTARTSYS if
610 * interrupted by a signal. 628 * interrupted by a signal.
611 */ 629 */
612 630
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 7a39ab9aa1d1..ff7664e0c3cd 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -242,12 +242,6 @@ struct ttm_mem_type_manager {
242/** 242/**
243 * struct ttm_bo_driver 243 * struct ttm_bo_driver
244 * 244 *
245 * @mem_type_prio: Priority array of memory types to place a buffer object in
246 * if it fits without evicting buffers from any of these memory types.
247 * @mem_busy_prio: Priority array of memory types to place a buffer object in
248 * if it needs to evict buffers to make room.
249 * @num_mem_type_prio: Number of elements in the @mem_type_prio array.
250 * @num_mem_busy_prio: Number of elements in the @num_mem_busy_prio array.
251 * @create_ttm_backend_entry: Callback to create a struct ttm_backend. 245 * @create_ttm_backend_entry: Callback to create a struct ttm_backend.
252 * @invalidate_caches: Callback to invalidate read caches when a buffer object 246 * @invalidate_caches: Callback to invalidate read caches when a buffer object
253 * has been evicted. 247 * has been evicted.
@@ -265,11 +259,6 @@ struct ttm_mem_type_manager {
265 */ 259 */
266 260
267struct ttm_bo_driver { 261struct ttm_bo_driver {
268 const uint32_t *mem_type_prio;
269 const uint32_t *mem_busy_prio;
270 uint32_t num_mem_type_prio;
271 uint32_t num_mem_busy_prio;
272
273 /** 262 /**
274 * struct ttm_bo_driver member create_ttm_backend_entry 263 * struct ttm_bo_driver member create_ttm_backend_entry
275 * 264 *
@@ -306,7 +295,8 @@ struct ttm_bo_driver {
306 * finished, they'll end up in bo->mem.flags 295 * finished, they'll end up in bo->mem.flags
307 */ 296 */
308 297
309 uint32_t(*evict_flags) (struct ttm_buffer_object *bo); 298 void(*evict_flags) (struct ttm_buffer_object *bo,
299 struct ttm_placement *placement);
310 /** 300 /**
311 * struct ttm_bo_driver member move: 301 * struct ttm_bo_driver member move:
312 * 302 *
@@ -648,12 +638,12 @@ extern bool ttm_mem_reg_is_pci(struct ttm_bo_device *bdev,
648 * -EBUSY: No space available (only if no_wait == 1). 638 * -EBUSY: No space available (only if no_wait == 1).
649 * -ENOMEM: Could not allocate memory for the buffer object, either due to 639 * -ENOMEM: Could not allocate memory for the buffer object, either due to
650 * fragmentation or concurrent allocators. 640 * fragmentation or concurrent allocators.
651 * -ERESTART: An interruptible sleep was interrupted by a signal. 641 * -ERESTARTSYS: An interruptible sleep was interrupted by a signal.
652 */ 642 */
653extern int ttm_bo_mem_space(struct ttm_buffer_object *bo, 643extern int ttm_bo_mem_space(struct ttm_buffer_object *bo,
654 uint32_t proposed_placement, 644 struct ttm_placement *placement,
655 struct ttm_mem_reg *mem, 645 struct ttm_mem_reg *mem,
656 bool interruptible, bool no_wait); 646 bool interruptible, bool no_wait);
657/** 647/**
658 * ttm_bo_wait_for_cpu 648 * ttm_bo_wait_for_cpu
659 * 649 *
@@ -663,7 +653,7 @@ extern int ttm_bo_mem_space(struct ttm_buffer_object *bo,
663 * Wait until a buffer object is no longer sync'ed for CPU access. 653 * Wait until a buffer object is no longer sync'ed for CPU access.
664 * Returns: 654 * Returns:
665 * -EBUSY: Buffer object was sync'ed for CPU access. (only if no_wait == 1). 655 * -EBUSY: Buffer object was sync'ed for CPU access. (only if no_wait == 1).
666 * -ERESTART: An interruptible sleep was interrupted by a signal. 656 * -ERESTARTSYS: An interruptible sleep was interrupted by a signal.
667 */ 657 */
668 658
669extern int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait); 659extern int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait);
@@ -767,7 +757,7 @@ extern void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo);
767 * -EAGAIN: The reservation may cause a deadlock. 757 * -EAGAIN: The reservation may cause a deadlock.
768 * Release all buffer reservations, wait for @bo to become unreserved and 758 * Release all buffer reservations, wait for @bo to become unreserved and
769 * try again. (only if use_sequence == 1). 759 * try again. (only if use_sequence == 1).
770 * -ERESTART: A wait for the buffer to become unreserved was interrupted by 760 * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
771 * a signal. Release all buffer reservations and return to user-space. 761 * a signal. Release all buffer reservations and return to user-space.
772 */ 762 */
773extern int ttm_bo_reserve(struct ttm_buffer_object *bo, 763extern int ttm_bo_reserve(struct ttm_buffer_object *bo,
@@ -808,7 +798,7 @@ extern int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo,
808 * 798 *
809 * Returns: 799 * Returns:
810 * -EBUSY: If no_wait == 1 and the buffer is already reserved. 800 * -EBUSY: If no_wait == 1 and the buffer is already reserved.
811 * -ERESTART: If interruptible == 1 and the process received a signal 801 * -ERESTARTSYS: If interruptible == 1 and the process received a signal
812 * while sleeping. 802 * while sleeping.
813 */ 803 */
814extern int ttm_bo_block_reservation(struct ttm_buffer_object *bo, 804extern int ttm_bo_block_reservation(struct ttm_buffer_object *bo,