diff options
| author | Paul Mundt <lethal@linux-sh.org> | 2011-01-12 00:37:42 -0500 |
|---|---|---|
| committer | Paul Mundt <lethal@linux-sh.org> | 2011-01-12 00:37:42 -0500 |
| commit | 83eb95b852902f952ba594447a796ad8146b9462 (patch) | |
| tree | 33c199aeeae58b69ad8d6d2a33c2d96ba2b98ddf /include/drm/ttm/ttm_bo_driver.h | |
| parent | efb3e34b6176d30c4fe8635fa8e1beb6280cc2cd (diff) | |
| parent | 9bbe7b984096ac45586da2adf26c14069ecb79b2 (diff) | |
Merge branch 'sh/sdio' into sh-latest
Diffstat (limited to 'include/drm/ttm/ttm_bo_driver.h')
| -rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 152 |
1 files changed, 103 insertions, 49 deletions
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 8e0c848326b6..1da8af6ac884 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
| @@ -179,30 +179,6 @@ struct ttm_tt { | |||
| 179 | #define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */ | 179 | #define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */ |
| 180 | #define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */ | 180 | #define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */ |
| 181 | 181 | ||
| 182 | /** | ||
| 183 | * struct ttm_mem_type_manager | ||
| 184 | * | ||
| 185 | * @has_type: The memory type has been initialized. | ||
| 186 | * @use_type: The memory type is enabled. | ||
| 187 | * @flags: TTM_MEMTYPE_XX flags identifying the traits of the memory | ||
| 188 | * managed by this memory type. | ||
| 189 | * @gpu_offset: If used, the GPU offset of the first managed page of | ||
| 190 | * fixed memory or the first managed location in an aperture. | ||
| 191 | * @size: Size of the managed region. | ||
| 192 | * @available_caching: A mask of available caching types, TTM_PL_FLAG_XX, | ||
| 193 | * as defined in ttm_placement_common.h | ||
| 194 | * @default_caching: The default caching policy used for a buffer object | ||
| 195 | * placed in this memory type if the user doesn't provide one. | ||
| 196 | * @manager: The range manager used for this memory type. FIXME: If the aperture | ||
| 197 | * has a page size different from the underlying system, the granularity | ||
| 198 | * of this manager should take care of this. But the range allocating code | ||
| 199 | * in ttm_bo.c needs to be modified for this. | ||
| 200 | * @lru: The lru list for this memory type. | ||
| 201 | * | ||
| 202 | * This structure is used to identify and manage memory types for a device. | ||
| 203 | * It's set up by the ttm_bo_driver::init_mem_type method. | ||
| 204 | */ | ||
| 205 | |||
| 206 | struct ttm_mem_type_manager; | 182 | struct ttm_mem_type_manager; |
| 207 | 183 | ||
| 208 | struct ttm_mem_type_manager_func { | 184 | struct ttm_mem_type_manager_func { |
| @@ -287,6 +263,36 @@ struct ttm_mem_type_manager_func { | |||
| 287 | void (*debug)(struct ttm_mem_type_manager *man, const char *prefix); | 263 | void (*debug)(struct ttm_mem_type_manager *man, const char *prefix); |
| 288 | }; | 264 | }; |
| 289 | 265 | ||
| 266 | /** | ||
| 267 | * struct ttm_mem_type_manager | ||
| 268 | * | ||
| 269 | * @has_type: The memory type has been initialized. | ||
| 270 | * @use_type: The memory type is enabled. | ||
| 271 | * @flags: TTM_MEMTYPE_XX flags identifying the traits of the memory | ||
| 272 | * managed by this memory type. | ||
| 273 | * @gpu_offset: If used, the GPU offset of the first managed page of | ||
| 274 | * fixed memory or the first managed location in an aperture. | ||
| 275 | * @size: Size of the managed region. | ||
| 276 | * @available_caching: A mask of available caching types, TTM_PL_FLAG_XX, | ||
| 277 | * as defined in ttm_placement_common.h | ||
| 278 | * @default_caching: The default caching policy used for a buffer object | ||
| 279 | * placed in this memory type if the user doesn't provide one. | ||
| 280 | * @func: structure pointer implementing the range manager. See above | ||
| 281 | * @priv: Driver private closure for @func. | ||
| 282 | * @io_reserve_mutex: Mutex optionally protecting shared io_reserve structures | ||
| 283 | * @use_io_reserve_lru: Use an lru list to try to unreserve io_mem_regions | ||
| 284 | * reserved by the TTM vm system. | ||
| 285 | * @io_reserve_lru: Optional lru list for unreserving io mem regions. | ||
| 286 | * @io_reserve_fastpath: Only use bdev::driver::io_mem_reserve to obtain | ||
| 287 | * static information. bdev::driver::io_mem_free is never used. | ||
| 288 | * @lru: The lru list for this memory type. | ||
| 289 | * | ||
| 290 | * This structure is used to identify and manage memory types for a device. | ||
| 291 | * It's set up by the ttm_bo_driver::init_mem_type method. | ||
| 292 | */ | ||
| 293 | |||
| 294 | |||
| 295 | |||
| 290 | struct ttm_mem_type_manager { | 296 | struct ttm_mem_type_manager { |
| 291 | struct ttm_bo_device *bdev; | 297 | struct ttm_bo_device *bdev; |
| 292 | 298 | ||
| @@ -303,6 +309,15 @@ struct ttm_mem_type_manager { | |||
| 303 | uint32_t default_caching; | 309 | uint32_t default_caching; |
| 304 | const struct ttm_mem_type_manager_func *func; | 310 | const struct ttm_mem_type_manager_func *func; |
| 305 | void *priv; | 311 | void *priv; |
| 312 | struct mutex io_reserve_mutex; | ||
| 313 | bool use_io_reserve_lru; | ||
| 314 | bool io_reserve_fastpath; | ||
| 315 | |||
| 316 | /* | ||
| 317 | * Protected by @io_reserve_mutex: | ||
| 318 | */ | ||
| 319 | |||
| 320 | struct list_head io_reserve_lru; | ||
| 306 | 321 | ||
| 307 | /* | 322 | /* |
| 308 | * Protected by the global->lru_lock. | 323 | * Protected by the global->lru_lock. |
| @@ -510,9 +525,12 @@ struct ttm_bo_global { | |||
| 510 | * | 525 | * |
| 511 | * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver. | 526 | * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver. |
| 512 | * @man: An array of mem_type_managers. | 527 | * @man: An array of mem_type_managers. |
| 528 | * @fence_lock: Protects the synchronizing members on *all* bos belonging | ||
| 529 | * to this device. | ||
| 513 | * @addr_space_mm: Range manager for the device address space. | 530 | * @addr_space_mm: Range manager for the device address space. |
| 514 | * lru_lock: Spinlock that protects the buffer+device lru lists and | 531 | * lru_lock: Spinlock that protects the buffer+device lru lists and |
| 515 | * ddestroy lists. | 532 | * ddestroy lists. |
| 533 | * @val_seq: Current validation sequence. | ||
| 516 | * @nice_mode: Try nicely to wait for buffer idle when cleaning a manager. | 534 | * @nice_mode: Try nicely to wait for buffer idle when cleaning a manager. |
| 517 | * If a GPU lockup has been detected, this is forced to 0. | 535 | * If a GPU lockup has been detected, this is forced to 0. |
| 518 | * @dev_mapping: A pointer to the struct address_space representing the | 536 | * @dev_mapping: A pointer to the struct address_space representing the |
| @@ -531,6 +549,7 @@ struct ttm_bo_device { | |||
| 531 | struct ttm_bo_driver *driver; | 549 | struct ttm_bo_driver *driver; |
| 532 | rwlock_t vm_lock; | 550 | rwlock_t vm_lock; |
| 533 | struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES]; | 551 | struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES]; |
| 552 | spinlock_t fence_lock; | ||
| 534 | /* | 553 | /* |
| 535 | * Protected by the vm lock. | 554 | * Protected by the vm lock. |
| 536 | */ | 555 | */ |
| @@ -541,6 +560,7 @@ struct ttm_bo_device { | |||
| 541 | * Protected by the global:lru lock. | 560 | * Protected by the global:lru lock. |
| 542 | */ | 561 | */ |
| 543 | struct list_head ddestroy; | 562 | struct list_head ddestroy; |
| 563 | uint32_t val_seq; | ||
| 544 | 564 | ||
| 545 | /* | 565 | /* |
| 546 | * Protected by load / firstopen / lastclose /unload sync. | 566 | * Protected by load / firstopen / lastclose /unload sync. |
| @@ -753,31 +773,6 @@ extern void ttm_bo_mem_put_locked(struct ttm_buffer_object *bo, | |||
| 753 | 773 | ||
| 754 | extern int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait); | 774 | extern int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait); |
| 755 | 775 | ||
| 756 | /** | ||
| 757 | * ttm_bo_pci_offset - Get the PCI offset for the buffer object memory. | ||
| 758 | * | ||
| 759 | * @bo Pointer to a struct ttm_buffer_object. | ||
| 760 | * @bus_base On return the base of the PCI region | ||
| 761 | * @bus_offset On return the byte offset into the PCI region | ||
| 762 | * @bus_size On return the byte size of the buffer object or zero if | ||
| 763 | * the buffer object memory is not accessible through a PCI region. | ||
| 764 | * | ||
| 765 | * Returns: | ||
| 766 | * -EINVAL if the buffer object is currently not mappable. | ||
| 767 | * 0 otherwise. | ||
| 768 | */ | ||
| 769 | |||
| 770 | extern int ttm_bo_pci_offset(struct ttm_bo_device *bdev, | ||
| 771 | struct ttm_mem_reg *mem, | ||
| 772 | unsigned long *bus_base, | ||
| 773 | unsigned long *bus_offset, | ||
| 774 | unsigned long *bus_size); | ||
| 775 | |||
| 776 | extern int ttm_mem_io_reserve(struct ttm_bo_device *bdev, | ||
| 777 | struct ttm_mem_reg *mem); | ||
| 778 | extern void ttm_mem_io_free(struct ttm_bo_device *bdev, | ||
| 779 | struct ttm_mem_reg *mem); | ||
| 780 | |||
| 781 | extern void ttm_bo_global_release(struct drm_global_reference *ref); | 776 | extern void ttm_bo_global_release(struct drm_global_reference *ref); |
| 782 | extern int ttm_bo_global_init(struct drm_global_reference *ref); | 777 | extern int ttm_bo_global_init(struct drm_global_reference *ref); |
| 783 | 778 | ||
| @@ -810,6 +805,22 @@ extern int ttm_bo_device_init(struct ttm_bo_device *bdev, | |||
| 810 | extern void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo); | 805 | extern void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo); |
| 811 | 806 | ||
| 812 | /** | 807 | /** |
| 808 | * ttm_bo_unmap_virtual | ||
| 809 | * | ||
| 810 | * @bo: tear down the virtual mappings for this BO | ||
| 811 | * | ||
| 812 | * The caller must take ttm_mem_io_lock before calling this function. | ||
| 813 | */ | ||
| 814 | extern void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo); | ||
| 815 | |||
| 816 | extern int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo); | ||
| 817 | extern void ttm_mem_io_free_vm(struct ttm_buffer_object *bo); | ||
| 818 | extern int ttm_mem_io_lock(struct ttm_mem_type_manager *man, | ||
| 819 | bool interruptible); | ||
| 820 | extern void ttm_mem_io_unlock(struct ttm_mem_type_manager *man); | ||
| 821 | |||
| 822 | |||
| 823 | /** | ||
| 813 | * ttm_bo_reserve: | 824 | * ttm_bo_reserve: |
| 814 | * | 825 | * |
| 815 | * @bo: A pointer to a struct ttm_buffer_object. | 826 | * @bo: A pointer to a struct ttm_buffer_object. |
| @@ -859,11 +870,44 @@ extern void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo); | |||
| 859 | * try again. (only if use_sequence == 1). | 870 | * try again. (only if use_sequence == 1). |
| 860 | * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by | 871 | * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by |
| 861 | * a signal. Release all buffer reservations and return to user-space. | 872 | * a signal. Release all buffer reservations and return to user-space. |
| 873 | * -EBUSY: The function needed to sleep, but @no_wait was true | ||
| 874 | * -EDEADLK: Bo already reserved using @sequence. This error code will only | ||
| 875 | * be returned if @use_sequence is set to true. | ||
| 862 | */ | 876 | */ |
| 863 | extern int ttm_bo_reserve(struct ttm_buffer_object *bo, | 877 | extern int ttm_bo_reserve(struct ttm_buffer_object *bo, |
| 864 | bool interruptible, | 878 | bool interruptible, |
| 865 | bool no_wait, bool use_sequence, uint32_t sequence); | 879 | bool no_wait, bool use_sequence, uint32_t sequence); |
| 866 | 880 | ||
| 881 | |||
| 882 | /** | ||
| 883 | * ttm_bo_reserve_locked: | ||
| 884 | * | ||
| 885 | * @bo: A pointer to a struct ttm_buffer_object. | ||
| 886 | * @interruptible: Sleep interruptible if waiting. | ||
| 887 | * @no_wait: Don't sleep while trying to reserve, rather return -EBUSY. | ||
| 888 | * @use_sequence: If @bo is already reserved, Only sleep waiting for | ||
| 889 | * it to become unreserved if @sequence < (@bo)->sequence. | ||
| 890 | * | ||
| 891 | * Must be called with struct ttm_bo_global::lru_lock held, | ||
| 892 | * and will not remove reserved buffers from the lru lists. | ||
| 893 | * The function may release the LRU spinlock if it needs to sleep. | ||
| 894 | * Otherwise identical to ttm_bo_reserve. | ||
| 895 | * | ||
| 896 | * Returns: | ||
| 897 | * -EAGAIN: The reservation may cause a deadlock. | ||
| 898 | * Release all buffer reservations, wait for @bo to become unreserved and | ||
| 899 | * try again. (only if use_sequence == 1). | ||
| 900 | * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by | ||
| 901 | * a signal. Release all buffer reservations and return to user-space. | ||
| 902 | * -EBUSY: The function needed to sleep, but @no_wait was true | ||
| 903 | * -EDEADLK: Bo already reserved using @sequence. This error code will only | ||
| 904 | * be returned if @use_sequence is set to true. | ||
| 905 | */ | ||
| 906 | extern int ttm_bo_reserve_locked(struct ttm_buffer_object *bo, | ||
| 907 | bool interruptible, | ||
| 908 | bool no_wait, bool use_sequence, | ||
| 909 | uint32_t sequence); | ||
| 910 | |||
| 867 | /** | 911 | /** |
| 868 | * ttm_bo_unreserve | 912 | * ttm_bo_unreserve |
| 869 | * | 913 | * |
| @@ -874,6 +918,16 @@ extern int ttm_bo_reserve(struct ttm_buffer_object *bo, | |||
| 874 | extern void ttm_bo_unreserve(struct ttm_buffer_object *bo); | 918 | extern void ttm_bo_unreserve(struct ttm_buffer_object *bo); |
| 875 | 919 | ||
| 876 | /** | 920 | /** |
| 921 | * ttm_bo_unreserve_locked | ||
| 922 | * | ||
| 923 | * @bo: A pointer to a struct ttm_buffer_object. | ||
| 924 | * | ||
| 925 | * Unreserve a previous reservation of @bo. | ||
| 926 | * Needs to be called with struct ttm_bo_global::lru_lock held. | ||
| 927 | */ | ||
| 928 | extern void ttm_bo_unreserve_locked(struct ttm_buffer_object *bo); | ||
| 929 | |||
| 930 | /** | ||
| 877 | * ttm_bo_wait_unreserved | 931 | * ttm_bo_wait_unreserved |
| 878 | * | 932 | * |
| 879 | * @bo: A pointer to a struct ttm_buffer_object. | 933 | * @bo: A pointer to a struct ttm_buffer_object. |
