diff options
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 107 |
1 files changed, 51 insertions, 56 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index c1ae528c7b0e..fcf421263fd9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
| @@ -92,11 +92,9 @@ static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref) | |||
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | /** | 94 | /** |
| 95 | * amdgpu_ttm_global_init - Initialize global TTM memory reference | 95 | * amdgpu_ttm_global_init - Initialize global TTM memory reference structures. |
| 96 | * structures. | ||
| 97 | * | 96 | * |
| 98 | * @adev: AMDGPU device for which the global structures need to be | 97 | * @adev: AMDGPU device for which the global structures need to be registered. |
| 99 | * registered. | ||
| 100 | * | 98 | * |
| 101 | * This is called as part of the AMDGPU ttm init from amdgpu_ttm_init() | 99 | * This is called as part of the AMDGPU ttm init from amdgpu_ttm_init() |
| 102 | * during bring up. | 100 | * during bring up. |
| @@ -162,13 +160,12 @@ static int amdgpu_invalidate_caches(struct ttm_bo_device *bdev, uint32_t flags) | |||
| 162 | } | 160 | } |
| 163 | 161 | ||
| 164 | /** | 162 | /** |
| 165 | * amdgpu_init_mem_type - Initialize a memory manager for a specific | 163 | * amdgpu_init_mem_type - Initialize a memory manager for a specific type of |
| 166 | * type of memory request. | 164 | * memory request. |
| 167 | * | 165 | * |
| 168 | * @bdev: The TTM BO device object (contains a reference to | 166 | * @bdev: The TTM BO device object (contains a reference to amdgpu_device) |
| 169 | * amdgpu_device) | 167 | * @type: The type of memory requested |
| 170 | * @type: The type of memory requested | 168 | * @man: The memory type manager for each domain |
| 171 | * @man: | ||
| 172 | * | 169 | * |
| 173 | * This is called by ttm_bo_init_mm() when a buffer object is being | 170 | * This is called by ttm_bo_init_mm() when a buffer object is being |
| 174 | * initialized. | 171 | * initialized. |
| @@ -292,8 +289,8 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | |||
| 292 | /** | 289 | /** |
| 293 | * amdgpu_verify_access - Verify access for a mmap call | 290 | * amdgpu_verify_access - Verify access for a mmap call |
| 294 | * | 291 | * |
| 295 | * @bo: The buffer object to map | 292 | * @bo: The buffer object to map |
| 296 | * @filp: The file pointer from the process performing the mmap | 293 | * @filp: The file pointer from the process performing the mmap |
| 297 | * | 294 | * |
| 298 | * This is called by ttm_bo_mmap() to verify whether a process | 295 | * This is called by ttm_bo_mmap() to verify whether a process |
| 299 | * has the right to mmap a BO to their process space. | 296 | * has the right to mmap a BO to their process space. |
| @@ -318,11 +315,10 @@ static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp) | |||
| 318 | /** | 315 | /** |
| 319 | * amdgpu_move_null - Register memory for a buffer object | 316 | * amdgpu_move_null - Register memory for a buffer object |
| 320 | * | 317 | * |
| 321 | * @bo: The bo to assign the memory to | 318 | * @bo: The bo to assign the memory to |
| 322 | * @new_mem: The memory to be assigned. | 319 | * @new_mem: The memory to be assigned. |
| 323 | * | 320 | * |
| 324 | * Assign the memory from new_mem to the memory of the buffer object | 321 | * Assign the memory from new_mem to the memory of the buffer object bo. |
| 325 | * bo. | ||
| 326 | */ | 322 | */ |
| 327 | static void amdgpu_move_null(struct ttm_buffer_object *bo, | 323 | static void amdgpu_move_null(struct ttm_buffer_object *bo, |
| 328 | struct ttm_mem_reg *new_mem) | 324 | struct ttm_mem_reg *new_mem) |
| @@ -335,8 +331,12 @@ static void amdgpu_move_null(struct ttm_buffer_object *bo, | |||
| 335 | } | 331 | } |
| 336 | 332 | ||
| 337 | /** | 333 | /** |
| 338 | * amdgpu_mm_node_addr - Compute the GPU relative offset of a GTT | 334 | * amdgpu_mm_node_addr - Compute the GPU relative offset of a GTT buffer. |
| 339 | * buffer. | 335 | * |
| 336 | * @bo: The bo to assign the memory to. | ||
| 337 | * @mm_node: Memory manager node for drm allocator. | ||
| 338 | * @mem: The region where the bo resides. | ||
| 339 | * | ||
| 340 | */ | 340 | */ |
| 341 | static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo, | 341 | static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo, |
| 342 | struct drm_mm_node *mm_node, | 342 | struct drm_mm_node *mm_node, |
| @@ -352,10 +352,12 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo, | |||
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | /** | 354 | /** |
| 355 | * amdgpu_find_mm_node - Helper function finds the drm_mm_node | 355 | * amdgpu_find_mm_node - Helper function finds the drm_mm_node corresponding to |
| 356 | * corresponding to @offset. It also modifies | 356 | * @offset. It also modifies the offset to be within the drm_mm_node returned |
| 357 | * the offset to be within the drm_mm_node | 357 | * |
| 358 | * returned | 358 | * @mem: The region where the bo resides. |
| 359 | * @offset: The offset that drm_mm_node is used for finding. | ||
| 360 | * | ||
| 359 | */ | 361 | */ |
| 360 | static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem, | 362 | static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem, |
| 361 | unsigned long *offset) | 363 | unsigned long *offset) |
| @@ -497,8 +499,8 @@ error: | |||
| 497 | /** | 499 | /** |
| 498 | * amdgpu_move_blit - Copy an entire buffer to another buffer | 500 | * amdgpu_move_blit - Copy an entire buffer to another buffer |
| 499 | * | 501 | * |
| 500 | * This is a helper called by amdgpu_bo_move() and | 502 | * This is a helper called by amdgpu_bo_move() and amdgpu_move_vram_ram() to |
| 501 | * amdgpu_move_vram_ram() to help move buffers to and from VRAM. | 503 | * help move buffers to and from VRAM. |
| 502 | */ | 504 | */ |
| 503 | static int amdgpu_move_blit(struct ttm_buffer_object *bo, | 505 | static int amdgpu_move_blit(struct ttm_buffer_object *bo, |
| 504 | bool evict, bool no_wait_gpu, | 506 | bool evict, bool no_wait_gpu, |
| @@ -794,8 +796,8 @@ struct amdgpu_ttm_tt { | |||
| 794 | }; | 796 | }; |
| 795 | 797 | ||
| 796 | /** | 798 | /** |
| 797 | * amdgpu_ttm_tt_get_user_pages - Pin pages of memory pointed to | 799 | * amdgpu_ttm_tt_get_user_pages - Pin pages of memory pointed to by a USERPTR |
| 798 | * by a USERPTR pointer to memory | 800 | * pointer to memory |
| 799 | * | 801 | * |
| 800 | * Called by amdgpu_gem_userptr_ioctl() and amdgpu_cs_parser_bos(). | 802 | * Called by amdgpu_gem_userptr_ioctl() and amdgpu_cs_parser_bos(). |
| 801 | * This provides a wrapper around the get_user_pages() call to provide | 803 | * This provides a wrapper around the get_user_pages() call to provide |
| @@ -818,8 +820,10 @@ int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages) | |||
| 818 | down_read(&mm->mmap_sem); | 820 | down_read(&mm->mmap_sem); |
| 819 | 821 | ||
| 820 | if (gtt->userflags & AMDGPU_GEM_USERPTR_ANONONLY) { | 822 | if (gtt->userflags & AMDGPU_GEM_USERPTR_ANONONLY) { |
| 821 | /* check that we only use anonymous memory | 823 | /* |
| 822 | to prevent problems with writeback */ | 824 | * check that we only use anonymous memory to prevent problems |
| 825 | * with writeback | ||
| 826 | */ | ||
| 823 | unsigned long end = gtt->userptr + ttm->num_pages * PAGE_SIZE; | 827 | unsigned long end = gtt->userptr + ttm->num_pages * PAGE_SIZE; |
| 824 | struct vm_area_struct *vma; | 828 | struct vm_area_struct *vma; |
| 825 | 829 | ||
| @@ -870,10 +874,9 @@ release_pages: | |||
| 870 | } | 874 | } |
| 871 | 875 | ||
| 872 | /** | 876 | /** |
| 873 | * amdgpu_ttm_tt_set_user_pages - Copy pages in, putting old pages | 877 | * amdgpu_ttm_tt_set_user_pages - Copy pages in, putting old pages as necessary. |
| 874 | * as necessary. | ||
| 875 | * | 878 | * |
| 876 | * Called by amdgpu_cs_list_validate(). This creates the page list | 879 | * Called by amdgpu_cs_list_validate(). This creates the page list |
| 877 | * that backs user memory and will ultimately be mapped into the device | 880 | * that backs user memory and will ultimately be mapped into the device |
| 878 | * address space. | 881 | * address space. |
| 879 | */ | 882 | */ |
| @@ -915,8 +918,7 @@ void amdgpu_ttm_tt_mark_user_pages(struct ttm_tt *ttm) | |||
| 915 | } | 918 | } |
| 916 | 919 | ||
| 917 | /** | 920 | /** |
| 918 | * amdgpu_ttm_tt_pin_userptr - prepare the sg table with the | 921 | * amdgpu_ttm_tt_pin_userptr - prepare the sg table with the user pages |
| 919 | * user pages | ||
| 920 | * | 922 | * |
| 921 | * Called by amdgpu_ttm_backend_bind() | 923 | * Called by amdgpu_ttm_backend_bind() |
| 922 | **/ | 924 | **/ |
| @@ -1295,8 +1297,8 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm) | |||
| 1295 | } | 1297 | } |
| 1296 | 1298 | ||
| 1297 | /** | 1299 | /** |
| 1298 | * amdgpu_ttm_tt_set_userptr - Initialize userptr GTT ttm_tt | 1300 | * amdgpu_ttm_tt_set_userptr - Initialize userptr GTT ttm_tt for the current |
| 1299 | * for the current task | 1301 | * task |
| 1300 | * | 1302 | * |
| 1301 | * @ttm: The ttm_tt object to bind this userptr object to | 1303 | * @ttm: The ttm_tt object to bind this userptr object to |
| 1302 | * @addr: The address in the current tasks VM space to use | 1304 | * @addr: The address in the current tasks VM space to use |
| @@ -1346,9 +1348,8 @@ struct mm_struct *amdgpu_ttm_tt_get_usermm(struct ttm_tt *ttm) | |||
| 1346 | } | 1348 | } |
| 1347 | 1349 | ||
| 1348 | /** | 1350 | /** |
| 1349 | * amdgpu_ttm_tt_affect_userptr - Determine if a ttm_tt object lays | 1351 | * amdgpu_ttm_tt_affect_userptr - Determine if a ttm_tt object lays inside an |
| 1350 | * inside an address range for the | 1352 | * address range for the current task. |
| 1351 | * current task. | ||
| 1352 | * | 1353 | * |
| 1353 | */ | 1354 | */ |
| 1354 | bool amdgpu_ttm_tt_affect_userptr(struct ttm_tt *ttm, unsigned long start, | 1355 | bool amdgpu_ttm_tt_affect_userptr(struct ttm_tt *ttm, unsigned long start, |
| @@ -1386,8 +1387,7 @@ bool amdgpu_ttm_tt_affect_userptr(struct ttm_tt *ttm, unsigned long start, | |||
| 1386 | } | 1387 | } |
