diff options
Diffstat (limited to 'include/drm/ttm/ttm_bo_api.h')
| -rw-r--r-- | include/drm/ttm/ttm_bo_api.h | 115 |
1 files changed, 65 insertions, 50 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 491146170522..81eb9f45883c 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 | ||
| 45 | struct drm_mm_node; | 45 | struct 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 | */ | ||
| 60 | struct 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,29 +303,30 @@ 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 | */ |
| 290 | extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy, | 308 | extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy, |
| 291 | bool interruptible, bool no_wait); | 309 | bool interruptible, bool no_wait); |
| 292 | /** | 310 | /** |
| 293 | * ttm_buffer_object_validate | 311 | * ttm_bo_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 | */ |
| 308 | extern int ttm_buffer_object_validate(struct ttm_buffer_object *bo, | 326 | extern int ttm_bo_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 | ||
| 334 | extern int | 353 | extern int |
| @@ -343,7 +362,7 @@ ttm_bo_synccpu_write_grab(struct ttm_buffer_object *bo, bool no_wait); | |||
| 343 | extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo); | 362 | extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo); |
| 344 | 363 | ||
| 345 | /** | 364 | /** |
| 346 | * ttm_buffer_object_init | 365 | * ttm_bo_init |
| 347 | * | 366 | * |
| 348 | * @bdev: Pointer to a ttm_bo_device struct. | 367 | * @bdev: Pointer to a ttm_bo_device struct. |
| 349 | * @bo: Pointer to a ttm_buffer_object to be initialized. | 368 | * @bo: Pointer to a ttm_buffer_object to be initialized. |
| @@ -371,20 +390,20 @@ 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 | ||
| 377 | extern int ttm_buffer_object_init(struct ttm_bo_device *bdev, | 396 | extern int ttm_bo_init(struct ttm_bo_device *bdev, |
| 378 | struct ttm_buffer_object *bo, | 397 | struct ttm_buffer_object *bo, |
| 379 | unsigned long size, | 398 | unsigned long size, |
| 380 | enum ttm_bo_type type, | 399 | enum ttm_bo_type type, |
| 381 | uint32_t flags, | 400 | struct ttm_placement *placement, |
| 382 | uint32_t page_alignment, | 401 | uint32_t page_alignment, |
| 383 | unsigned long buffer_start, | 402 | unsigned long buffer_start, |
| 384 | bool interrubtible, | 403 | bool interrubtible, |
| 385 | struct file *persistant_swap_storage, | 404 | struct file *persistant_swap_storage, |
| 386 | size_t acc_size, | 405 | size_t acc_size, |
| 387 | void (*destroy) (struct ttm_buffer_object *)); | 406 | void (*destroy) (struct ttm_buffer_object *)); |
| 388 | /** | 407 | /** |
| 389 | * ttm_bo_synccpu_object_init | 408 | * ttm_bo_synccpu_object_init |
| 390 | * | 409 | * |
| @@ -405,47 +424,43 @@ extern int ttm_buffer_object_init(struct ttm_bo_device *bdev, | |||
| 405 | * GEM user interface. | 424 | * GEM user interface. |
| 406 | * @p_bo: On successful completion *p_bo points to the created object. | 425 | * @p_bo: On successful completion *p_bo points to the created object. |
| 407 | * | 426 | * |
| 408 | * This function allocates a ttm_buffer_object, and then calls | 427 | * This function allocates a ttm_buffer_object, and then calls ttm_bo_init |
| 409 | * ttm_buffer_object_init on that object. | 428 | * on that object. The destroy function is set to kfree(). |
| 410 | * The destroy function is set to kfree(). | ||
| 411 | * Returns | 429 | * Returns |
| 412 | * -ENOMEM: Out of memory. | 430 | * -ENOMEM: Out of memory. |
| 413 | * -EINVAL: Invalid placement flags. | 431 | * -EINVAL: Invalid placement flags. |
| 414 | * -ERESTART: Interrupted by signal while waiting for resources. | 432 | * -ERESTARTSYS: Interrupted by signal while waiting for resources. |
| 415 | */ | 433 | */ |
| 416 | 434 | ||
| 417 | extern int ttm_buffer_object_create(struct ttm_bo_device *bdev, | 435 | extern int ttm_bo_create(struct ttm_bo_device *bdev, |
| 418 | unsigned long size, | 436 | unsigned long size, |
| 419 | enum ttm_bo_type type, | 437 | enum ttm_bo_type type, |
| 420 | uint32_t flags, | 438 | struct ttm_placement *placement, |
| 421 | uint32_t page_alignment, | 439 | uint32_t page_alignment, |
| 422 | unsigned long buffer_start, | 440 | unsigned long buffer_start, |
| 423 | bool interruptible, | 441 | bool interruptible, |
| 424 | struct file *persistant_swap_storage, | 442 | struct file *persistant_swap_storage, |
| 425 | struct ttm_buffer_object **p_bo); | 443 | struct ttm_buffer_object **p_bo); |
| 426 | 444 | ||
| 427 | /** | 445 | /** |
| 428 | * ttm_bo_check_placement | 446 | * ttm_bo_check_placement |
| 429 | * | 447 | * |
| 430 | * @bo: the buffer object. | 448 | * @bo: the buffer object. |
| 431 | * @set_flags: placement flags to set. | 449 | * @placement: placements |
| 432 | * @clr_flags: placement flags to clear. | ||
| 433 | * | 450 | * |
| 434 | * Performs minimal validity checking on an intended change of | 451 | * Performs minimal validity checking on an intended change of |
| 435 | * placement flags. | 452 | * placement flags. |
| 436 | * Returns | 453 | * Returns |
| 437 | * -EINVAL: Intended change is invalid or not allowed. | 454 | * -EINVAL: Intended change is invalid or not allowed. |
| 438 | */ | 455 | */ |
| 439 | |||
| 440 | extern int ttm_bo_check_placement(struct ttm_buffer_object *bo, | 456 | extern int ttm_bo_check_placement(struct ttm_buffer_object *bo, |
| 441 | uint32_t set_flags, uint32_t clr_flags); | 457 | struct ttm_placement *placement); |
| 442 | 458 | ||
| 443 | /** | 459 | /** |
| 444 | * ttm_bo_init_mm | 460 | * ttm_bo_init_mm |
| 445 | * | 461 | * |
| 446 | * @bdev: Pointer to a ttm_bo_device struct. | 462 | * @bdev: Pointer to a ttm_bo_device struct. |
| 447 | * @mem_type: The memory type. | 463 | * @mem_type: The memory type. |
| 448 | * @p_offset: offset for managed area in pages. | ||
| 449 | * @p_size: size managed area in pages. | 464 | * @p_size: size managed area in pages. |
| 450 | * | 465 | * |
| 451 | * Initialize a manager for a given memory type. | 466 | * Initialize a manager for a given memory type. |
| @@ -458,7 +473,7 @@ extern int ttm_bo_check_placement(struct ttm_buffer_object *bo, | |||
| 458 | */ | 473 | */ |
| 459 | 474 | ||
| 460 | extern int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, | 475 | extern int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, |
| 461 | unsigned long p_offset, unsigned long p_size); | 476 | unsigned long p_size); |
| 462 | /** | 477 | /** |
| 463 | * ttm_bo_clean_mm | 478 | * ttm_bo_clean_mm |
| 464 | * | 479 | * |
| @@ -503,7 +518,7 @@ extern int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type); | |||
| 503 | * | 518 | * |
| 504 | * Returns: | 519 | * Returns: |
| 505 | * -EINVAL: Invalid or uninitialized memory type. | 520 | * -EINVAL: Invalid or uninitialized memory type. |
| 506 | * -ERESTART: The call was interrupted by a signal while waiting to | 521 | * -ERESTARTSYS: The call was interrupted by a signal while waiting to |
| 507 | * evict a buffer. | 522 | * evict a buffer. |
| 508 | */ | 523 | */ |
| 509 | 524 | ||
| @@ -606,7 +621,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. | 621 | * be called from the fops::read and fops::write method. |
| 607 | * Returns: | 622 | * Returns: |
| 608 | * See man (2) write, man(2) read. In particular, | 623 | * See man (2) write, man(2) read. In particular, |
| 609 | * the function may return -EINTR if | 624 | * the function may return -ERESTARTSYS if |
| 610 | * interrupted by a signal. | 625 | * interrupted by a signal. |
| 611 | */ | 626 | */ |
| 612 | 627 | ||
