drm/amdgpu: revert "drm/amdgpu: use AMDGPU_GEM_CREATE_VRAM_CLEARED for VM PD/PTs"
Subsystems (3)
PATCH 1/4 drm/amdgpu: revert "drm/amdgpu: use AMDGPU_GEM_CREATE_VRAM_CLEARED for VM PD/PTs"
Using the standard clear turned out to be to inflexible.
First of all it is executed on the system queue, together with buffer moves instead on the per VM queue.
And second we need to fill in the page tables with more than just zero.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 116 ++++++++++++++++++++++++++------- 1 file changed, 92 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +92 -24
@@ -257,6 +257,74 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)return ready; } +/** +* amdgpu_vm_clear_bo - initially clear the PDs/PTs +* +* @adev: amdgpu_device pointer +* @bo: BO to clear +* @level: level this BO is at +* +* Root PD needs to be reserved when calling this. +*/ +static int amdgpu_vm_clear_bo (struct amdgpu_device *adev, +struct amdgpu_vm *vm, +struct amdgpu_bo *bo, +unsigned level) +{ +struct ttm_operation_ctx ctx = { true, false }; +struct dma_fence *fence =NULL ; +uint64_t addr, init_value; +struct amdgpu_ring *ring; +struct amdgpu_job *job; +unsigned entries; +int r; + +if (vm->pte_support_ats) { + init_value =AMDGPU_PTE_DEFAULT_ATC ; +if (level !=AMDGPU_VM_PTB ) + init_value |=AMDGPU_PDE_PTE ; + }else { + init_value =0 ; + } + + ring = container_of(vm->entity.sched, struct amdgpu_ring, sched); + + r =reservation_object_reserve_shared (bo->tbo.resv); +if (r) +return r; + + r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx); +if (r) + goto error; + + addr =amdgpu_bo_gpu_offset (bo); + entries =amdgpu_bo_size (bo) /8 ; + + r =amdgpu_job_alloc_with_ib (adev,64 , &job); +if (r) + goto error; + +amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , + entries,0 , init_value); +amdgpu_ring_pad_ib (ring, &job->ibs[0 ]); + +WARN_ON (job->ibs[0 ].length_dw >64 ); + r =amdgpu_job_submit (job, ring, &vm->entity, +AMDGPU_FENCE_OWNER_UNDEFINED , &fence); +if (r) + goto error_free; + +amdgpu_bo_fence (bo, fence, true); +dma_fence_put (fence); +return 0 ; + +error_free: +amdgpu_job_free (job); + +error: +return r; +} +/** * amdgpu_vm_alloc_levels - allocate the PD/PT levels *
@@ -275,9 +343,8 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, {unsigned shift =amdgpu_vm_level_shift (adev, level);unsigned pt_idx, from, to; -int r;u64 flags; -uint64_t init_value =0 ; +int r;if (!parent->entries) {unsigned num_entries =amdgpu_vm_num_entries (adev, level);
@@ -300,21 +367,13 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, saddr = saddr & ((1 << shift) -1 ); eaddr = eaddr & ((1 << shift) -1 ); - flags =AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | -AMDGPU_GEM_CREATE_VRAM_CLEARED ; + flags =AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ;if (vm->use_cpu_for_update) flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ;else flags |= (AMDGPU_GEM_CREATE_NO_CPU_ACCESS |AMDGPU_GEM_CREATE_SHADOW ); -if (vm->pte_support_ats) { - init_value =AMDGPU_PTE_DEFAULT_ATC ; -if (level !=AMDGPU_VM_PTB ) - init_value |=AMDGPU_PDE_PTE ; - - } -/* walk over the address space and allocate the page tables */ for (pt_idx = from; pt_idx <= to; ++pt_idx) {struct reservation_object *resv = vm->root.base.bo->tbo.resv;
@@ -325,12 +384,17 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, r =amdgpu_bo_create (adev,amdgpu_vm_bo_size (adev, level),AMDGPU_GPU_PAGE_SIZE , true, -AMDGPU_GEM_DOMAIN_VRAM , - flags, -NULL , resv, init_value, &pt); +AMDGPU_GEM_DOMAIN_VRAM , flags, +NULL , resv,0 , &pt);if (r)return r; + r =amdgpu_vm_clear_bo (adev, vm, pt, level); +if (r) { +amdgpu_bo_unref (&pt); +return r; + } +if (vm->use_cpu_for_update) { r =amdgpu_bo_kmap (pt,NULL );if (r) {
@@ -2241,11 +2305,11 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, {const unsigned align =min (AMDGPU_VM_PTB_ALIGN_SIZE ,AMDGPU_VM_PTE_COUNT (adev) *8 ); -uint64_t init_pde_value =0 , flags;unsigned ring_instance;struct amdgpu_ring *ring;struct drm_sched_rq *rq;unsigned long size; +uint64_t flags;int r, i; vm->va =RB_ROOT_CACHED ;
@@ -2274,23 +2338,19 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &AMDGPU_VM_USE_CPU_FOR_COMPUTE ); -if (adev->asic_type ==CHIP_RAVEN ) { +if (adev->asic_type ==CHIP_RAVEN ) vm->pte_support_ats = true; - init_pde_value =AMDGPU_PTE_DEFAULT_ATC - |AMDGPU_PDE_PTE ; - - } - }else + }else { vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &AMDGPU_VM_USE_CPU_FOR_GFX ); + }DRM_DEBUG_DRIVER ("VM update mode is %s\n" , vm->use_cpu_for_update ?"CPU" :"SDMA" );WARN_ONCE ((vm->use_cpu_for_update & !amdgpu_vm_is_large_bar (adev)),"CPU update of VM recommended only for large BAR system\n" ); vm->last_update =NULL ; - flags =AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | -AMDGPU_GEM_CREATE_VRAM_CLEARED ; + flags =AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ;if (vm->use_cpu_for_update) flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ;else
@@ -2299,7 +2359,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, size =amdgpu_vm_bo_size (adev, adev->vm_manager.root_level); r =amdgpu_bo_create (adev, size, align, true,AMDGPU_GEM_DOMAIN_VRAM , - flags,NULL ,NULL , init_pde_value, + flags,NULL ,NULL ,0 , &vm->root.base.bo);if (r) goto error_free_sched_entity;
@@ -2308,6 +2368,11 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,if (r) goto error_free_root; + r =amdgpu_vm_clear_bo (adev, vm, vm->root.base.bo, + adev->vm_manager.root_level); +if (r) + goto error_unreserve; + vm->root.base.vm = vm;list_add_tail (&vm->root.base.bo_list, &vm->root.base.bo->va);list_add_tail (&vm->root.base.vm_status, &vm->evicted);
@@ -2331,6 +2396,9 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,return 0 ; +error_unreserve: +amdgpu_bo_unreserve (vm->root.base.bo); + error_free_root:amdgpu_bo_unref (&vm->root.base.bo->shadow);amdgpu_bo_unref (&vm->root.base.bo);
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180126100442.1856-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/4 drm/amdgpu: revert "Add a parameter to amdgpu_bo_create()"
This reverts commit 2046d46db9166bddc84778f0b3477f6d1e9068ea.
Not needed any more.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 13 ++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++--- 14 files changed, 21 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -2
@@ -216,8 +216,7 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size,return -ENOMEM ; r =amdgpu_bo_create (adev, size,PAGE_SIZE , true,AMDGPU_GEM_DOMAIN_GTT , -AMDGPU_GEM_CREATE_CPU_GTT_USWC ,NULL ,NULL ,0 , - &(*mem)->bo); +AMDGPU_GEM_CREATE_CPU_GTT_USWC ,NULL ,NULL , &(*mem)->bo);if (r) {dev_err (adev->dev,"failed to allocate BO for amdkfd (%d)\n" , r);
drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +2 -2
@@ -81,7 +81,7 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size, n =AMDGPU_BENCHMARK_ITERATIONS ; r =amdgpu_bo_create (adev, size,PAGE_SIZE , true, sdomain,0 ,NULL , -NULL ,0 , &sobj); +NULL , &sobj);if (r) { goto out_cleanup; }
@@ -94,7 +94,7 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size, goto out_cleanup; } r =amdgpu_bo_create (adev, size,PAGE_SIZE , true, ddomain,0 ,NULL , -NULL ,0 , &dobj); +NULL , &dobj);if (r) { goto out_cleanup; }
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +1 -1
@@ -109,7 +109,7 @@ static int amdgpu_cgs_alloc_gpu_mem(struct cgs_device *cgs_device, *handle =0 ; ret =amdgpu_bo_create (adev, size, align, true, domain, flags, -NULL ,NULL ,0 , &obj); +NULL ,NULL , &obj);if (ret) {DRM_ERROR ("(%d) bo create failed\n" , ret);return ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
@@ -120,7 +120,7 @@ int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)PAGE_SIZE , true,AMDGPU_GEM_DOMAIN_VRAM ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS , - NULL, NULL, 0, &adev->gart.robj); + NULL, NULL, &adev->gart.robj);if (r) {return r; }
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -1
@@ -60,7 +60,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, retry: r =amdgpu_bo_create (adev, size, alignment, kernel, initial_domain, - flags,NULL , resv,0 , &bo); + flags,NULL , resv, &bo);if (r) {if (r != -ERESTARTSYS ) {if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ) {
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +4 -9
@@ -190,7 +190,7 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev, r =amdgpu_bo_create (adev, size, align, true, domain,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS , -NULL ,NULL ,0 , bo_ptr); +NULL ,NULL , bo_ptr);if (r) {dev_err (adev->dev,"(%d) failed to allocate kernel bo\n" , r);
@@ -336,7 +336,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bool kernel, u32 domain, u64 flags, struct sg_table *sg, struct reservation_object *resv, - uint64_t init_value, struct amdgpu_bo **bo_ptr) { struct ttm_operation_ctx ctx = {
@@ -443,7 +442,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) {struct dma_fence *fence; - r =amdgpu_fill_buffer (bo, init_value, bo->tbo.resv, &fence); + r =amdgpu_fill_buffer (bo,0 , bo->tbo.resv, &fence);if (unlikely (r)) goto fail_unreserve;
@@ -484,7 +483,7 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,AMDGPU_GEM_DOMAIN_GTT ,AMDGPU_GEM_CREATE_CPU_GTT_USWC |AMDGPU_GEM_CREATE_SHADOW , -NULL , bo->tbo.resv,0 , +NULL , bo->tbo.resv, &bo->shadow);if (!r) { bo->shadow->parent =amdgpu_bo_ref (bo);
@@ -496,22 +495,18 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,return r; } -/* init_value will only take effect when flags contains -* AMDGPU_GEM_CREATE_VRAM_CLEARED. -*/ int amdgpu_bo_create (struct amdgpu_device *adev,unsigned long size,int byte_align,bool kernel,u32 domain,u64 flags,struct sg_table *sg,struct reservation_object *resv, -uint64_t init_value,struct amdgpu_bo **bo_ptr) {uint64_t parent_flags = flags & ~AMDGPU_GEM_CREATE_SHADOW ;int r; r =amdgpu_bo_do_create (adev, size, byte_align, kernel, domain, - parent_flags, sg, resv, init_value, bo_ptr); + parent_flags, sg, resv, bo_ptr);if (r)return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +0 -1
@@ -206,7 +206,6 @@ int amdgpu_bo_create(struct amdgpu_device *adev, bool kernel, u32 domain, u64 flags, struct sg_table *sg, struct reservation_object *resv, - uint64_t init_value, struct amdgpu_bo **bo_ptr); int amdgpu_bo_create_reserved(struct amdgpu_device *adev, unsigned long size, int align,
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +1 -1
@@ -104,7 +104,7 @@ amdgpu_gem_prime_import_sg_table(struct drm_device *dev,ww_mutex_lock (&resv->lock,NULL ); ret =amdgpu_bo_create (adev, attach->dmabuf->size,PAGE_SIZE , false, -AMDGPU_GEM_DOMAIN_GTT ,0 , sg, resv,0 , &bo); +AMDGPU_GEM_DOMAIN_GTT ,0 , sg, resv, &bo);ww_mutex_unlock (&resv->lock);if (ret)return ERR_PTR (ret);
drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c +1 -1
@@ -64,7 +64,7 @@ int amdgpu_sa_bo_manager_init(struct amdgpu_device *adev,INIT_LIST_HEAD (&sa_manager->flist[i]); r =amdgpu_bo_create (adev, size, align, true, domain, -0 ,NULL ,NULL ,0 , &sa_manager->bo); +0 ,NULL ,NULL , &sa_manager->bo);if (r) {dev_err (adev->dev,"(%d) failed to allocate bo for manager\n" , r);return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +2 -2
@@ -61,7 +61,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) r =amdgpu_bo_create (adev, size,PAGE_SIZE , true,AMDGPU_GEM_DOMAIN_VRAM ,0 , -NULL ,NULL ,0 , &vram_obj); +NULL ,NULL , &vram_obj);if (r) {DRM_ERROR ("Failed to create VRAM object\n" ); goto out_cleanup;
@@ -82,7 +82,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) r =amdgpu_bo_create (adev, size,PAGE_SIZE , true,AMDGPU_GEM_DOMAIN_GTT ,0 ,NULL , -NULL ,0 , gtt_obj + i); +NULL , gtt_obj + i);if (r) {DRM_ERROR ("Failed to create GTT object %d\n" , i); goto out_lclean;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
@@ -1312,7 +1312,7 @@ static int amdgpu_ttm_fw_reserve_vram_init(struct amdgpu_device *adev) r =amdgpu_bo_create (adev, adev->fw_vram_usage.size,PAGE_SIZE , true,AMDGPU_GEM_DOMAIN_VRAM ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | -AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ,NULL ,NULL ,0 , +AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ,NULL ,NULL , &adev->fw_vram_usage.reserved_bo);if (r) goto error_create;
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +2 -2
@@ -1059,7 +1059,7 @@ int amdgpu_uvd_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,AMDGPU_GEM_DOMAIN_VRAM ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS , - NULL, NULL, 0, &bo); + NULL, NULL, &bo);if (r)return r;
@@ -1109,7 +1109,7 @@ int amdgpu_uvd_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,AMDGPU_GEM_DOMAIN_VRAM ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS , - NULL, NULL, 0, &bo); + NULL, NULL, &bo);if (r)return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +2 -2
@@ -359,7 +359,7 @@ static int amdgpu_vcn_dec_get_create_msg(struct amdgpu_ring *ring, uint32_t handAMDGPU_GEM_DOMAIN_VRAM ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS , - NULL, NULL, 0, &bo); + NULL, NULL, &bo);if (r)return r;
@@ -411,7 +411,7 @@ static int amdgpu_vcn_dec_get_destroy_msg(struct amdgpu_ring *ring, uint32_t hanAMDGPU_GEM_DOMAIN_VRAM ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS , - NULL, NULL, 0, &bo); + NULL, NULL, &bo);if (r)return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -3
@@ -385,7 +385,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,amdgpu_vm_bo_size (adev, level),AMDGPU_GPU_PAGE_SIZE , true,AMDGPU_GEM_DOMAIN_VRAM , flags, - NULL, resv, 0, &pt); + NULL, resv, &pt);if (r)return r;
@@ -2359,8 +2359,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, size =amdgpu_vm_bo_size (adev, adev->vm_manager.root_level); r =amdgpu_bo_create (adev, size, align, true,AMDGPU_GEM_DOMAIN_VRAM , - flags,NULL ,NULL ,0 , - &vm->root.base.bo); + flags,NULL ,NULL , &vm->root.base.bo);if (r) goto error_free_sched_entity;
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amdgpu: revert "Add support for filling a buffer with 64 bit value"
In reply to a message not in the archiveThis reverts commit 7bdc53f925af085ffa0580f10489f82b36cc2f1c and commit 330df03b3abf944f8f5180f2abc61367749984c0.
Neither are needed any more.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 ------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 17 +++++------------ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++--- drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 3 --- drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 3 --- drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 4 ---- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 3 --- drivers/gpu/drm/amd/amdgpu/si_dma.c | 3 --- 9 files changed, 8 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -7
@@ -319,13 +319,6 @@ struct amdgpu_vm_pte_funcs {void (*write_pte)(struct amdgpu_ib *ib,uint64_t pe,uint64_t value,unsigned count,uint32_t incr); - -/* maximum nums of PTEs/PDEs in a single operation */ -uint32_t set_max_nums_pte_pde; - -/* number of dw to reserve per operation */ -unsigned set_pte_pde_num_dw; -/* for linear pte/pde updates without addr mapping */ void (*set_pte_pde)(struct amdgpu_ib *ib, uint64_t pe,
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -12
@@ -1681,13 +1681,12 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset, }int amdgpu_fill_buffer (struct amdgpu_bo *bo, -uint64_t src_data, +uint32_t src_data,struct reservation_object *resv,struct dma_fence **fence) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev); -uint32_t max_bytes =8 * - adev->vm_manager.vm_pte_funcs->set_max_nums_pte_pde; +uint32_t max_bytes = adev->mman.buffer_funcs->fill_max_bytes;struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring;struct drm_mm_node *mm_node;
@@ -1718,9 +1717,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, num_pages -= mm_node->size; ++mm_node; } - -/* num of dwords for each SDMA_OP_PTEPDE cmd */ - num_dw = num_loops * adev->vm_manager.vm_pte_funcs->set_pte_pde_num_dw; + num_dw = num_loops * adev->mman.buffer_funcs->fill_num_dw;/* for IB padding */ num_dw +=64 ;
@@ -1745,16 +1742,12 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,uint32_t byte_count = mm_node->size <<PAGE_SHIFT ;uint64_t dst_addr; -WARN_ONCE (byte_count &0x7 ,"size should be a multiple of 8" ); - dst_addr =amdgpu_mm_node_addr (&bo->tbo, mm_node, &bo->tbo.mem);while (byte_count) {uint32_t cur_size_in_bytes =min (byte_count, max_bytes); -amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], - dst_addr,0 , - cur_size_in_bytes >>3 ,0 , - src_data); +amdgpu_emit_fill_buffer (adev, &job->ibs[0 ], src_data, + dst_addr, cur_size_in_bytes); dst_addr += cur_size_in_bytes; byte_count -= cur_size_in_bytes;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -1
@@ -86,7 +86,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,struct reservation_object *resv, struct dma_fence **f);int amdgpu_fill_buffer (struct amdgpu_bo *bo, -uint64_t src_data, +uint32_t src_data,struct reservation_object *resv,struct dma_fence **fence);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -3
@@ -1247,11 +1247,10 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, }else {/* set page commands needed */ - ndw += ncmds * adev->vm_manager.vm_pte_funcs->set_pte_pde_num_dw; + ndw += ncmds *10 ;/* extra commands for begin/end fragments */ - ndw +=2 * adev->vm_manager.vm_pte_funcs->set_pte_pde_num_dw - * adev->vm_manager.fragment_size; + ndw +=2 *10 * adev->vm_manager.fragment_size; params.func = amdgpu_vm_do_set_ptes; }
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +0 -3
@@ -1382,9 +1382,6 @@ static const struct amdgpu_vm_pte_funcs cik_sdma_vm_pte_funcs = { .copy_pte = cik_sdma_vm_copy_pte, .write_pte = cik_sdma_vm_write_pte, - - .set_max_nums_pte_pde = 0x1fffff >> 3, - .set_pte_pde_num_dw = 10, .set_pte_pde = cik_sdma_vm_set_pte_pde, };
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +0 -3
@@ -1306,9 +1306,6 @@ static const struct amdgpu_vm_pte_funcs sdma_v2_4_vm_pte_funcs = { .copy_pte = sdma_v2_4_vm_copy_pte, .write_pte = sdma_v2_4_vm_write_pte, - - .set_max_nums_pte_pde = 0x1fffff >> 3, - .set_pte_pde_num_dw = 10, .set_pte_pde = sdma_v2_4_vm_set_pte_pde, };
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +0 -4
@@ -1739,10 +1739,6 @@ static const struct amdgpu_vm_pte_funcs sdma_v3_0_vm_pte_funcs = { .copy_pte = sdma_v3_0_vm_copy_pte, .write_pte = sdma_v3_0_vm_write_pte, - -/* not 0x3fffff due to HW limitation */ - .set_max_nums_pte_pde = 0x3fffe0 >> 3, - .set_pte_pde_num_dw = 10, .set_pte_pde = sdma_v3_0_vm_set_pte_pde, };
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -3
@@ -1686,9 +1686,6 @@ static const struct amdgpu_vm_pte_funcs sdma_v4_0_vm_pte_funcs = { .copy_pte = sdma_v4_0_vm_copy_pte, .write_pte = sdma_v4_0_vm_write_pte, - - .set_max_nums_pte_pde = 0x400000 >> 3, - .set_pte_pde_num_dw = 10, .set_pte_pde = sdma_v4_0_vm_set_pte_pde, };
drivers/gpu/drm/amd/amdgpu/si_dma.c +0 -3
@@ -875,9 +875,6 @@ static const struct amdgpu_vm_pte_funcs si_dma_vm_pte_funcs = { .copy_pte = si_dma_vm_copy_pte, .write_pte = si_dma_vm_write_pte, - - .set_max_nums_pte_pde = 0xffff8 >> 3, - .set_pte_pde_num_dw = 9, .set_pte_pde = si_dma_vm_set_pte_pde, };
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 drm/amdgpu: fill only the lower range with ATS entries
In reply to a message not in the archiveAt least on x86-64 the upper range is purely used by the kernel, avoid creating any ATS mappings there as security precaution and to allow proper page fault reporting in the upper range.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 83 ++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +54 -29
@@ -267,24 +267,34 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)* Root PD needs to be reserved when calling this. */ static int amdgpu_vm_clear_bo (struct amdgpu_device *adev, -struct amdgpu_vm *vm, -struct amdgpu_bo *bo, -unsigned level) +struct amdgpu_vm *vm,struct amdgpu_bo *bo, +unsigned level,bool pte_support_ats) {struct ttm_operation_ctx ctx = { true, false };struct dma_fence *fence =NULL ; -uint64_t addr, init_value; +unsigned entries, ats_entries; +uint64_t addr, ats_value;struct amdgpu_ring *ring;struct amdgpu_job *job; -unsigned entries;int r; -if (vm->pte_support_ats) { - init_value =AMDGPU_PTE_DEFAULT_ATC ; -if (level !=AMDGPU_VM_PTB ) - init_value |=AMDGPU_PDE_PTE ; + addr =amdgpu_bo_gpu_offset (bo); + entries =amdgpu_bo_size (bo) /8 ; + +if (pte_support_ats) { +if (level == adev->vm_manager.root_level) { + ats_entries =amdgpu_vm_level_shift (adev, level); + ats_entries +=AMDGPU_GPU_PAGE_SHIFT ; + ats_entries =AMDGPU_VA_HOLE_START >> ats_entries; + ats_entries =min (ats_entries, entries); + entries -= ats_entries; + }else { + ats_entries = entries; + entries =0 ; + } }else { - init_value =0 ; + ats_entries =0 ; + ats_value =0 ; } ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);
@@ -297,15 +307,26 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,if (r) goto error; - addr =amdgpu_bo_gpu_offset (bo); - entries =amdgpu_bo_size (bo) /8 ; - r =amdgpu_job_alloc_with_ib (adev,64 , &job);if (r) goto error; -amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , - entries,0 , init_value); +if (ats_entries) { +uint64_t ats_value; + + ats_value =AMDGPU_PTE_DEFAULT_ATC ; +if (level !=AMDGPU_VM_PTB ) + ats_value |=AMDGPU_PDE_PTE ; + +amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , + ats_entries,0 , ats_value); + addr += ats_entries *8 ; + } + +if (entries) +amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , + entries,0 ,0 ); +amdgpu_ring_pad_ib (ring, &job->ibs[0 ]);WARN_ON (job->ibs[0 ].length_dw >64 );
@@ -339,7 +360,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,struct amdgpu_vm *vm, struct amdgpu_vm_pt *parent, uint64_t saddr, uint64_t eaddr, - unsigned level) + unsigned level, bool ats) { unsigned shift = amdgpu_vm_level_shift(adev, level);unsigned pt_idx, from, to;
@@ -389,7 +410,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,if (r)return r; - r =amdgpu_vm_clear_bo (adev, vm, pt, level); + r =amdgpu_vm_clear_bo (adev, vm, pt, level, ats);if (r) {amdgpu_bo_unref (&pt);return r;
@@ -421,7 +442,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,uint64_t sub_eaddr = (pt_idx == to) ? eaddr : ((1 << shift) -1 ); r =amdgpu_vm_alloc_levels (adev, vm, entry, sub_saddr, - sub_eaddr, level); + sub_eaddr, level, ats);if (r)return r; }
@@ -444,26 +465,29 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,struct amdgpu_vm *vm, uint64_t saddr, uint64_t size) { - uint64_t last_pfn; uint64_t eaddr; +bool ats = false;/* validate the parameters */ if (saddr &AMDGPU_GPU_PAGE_MASK || size &AMDGPU_GPU_PAGE_MASK )return -EINVAL ; eaddr = saddr + size -1 ; - last_pfn = eaddr /AMDGPU_GPU_PAGE_SIZE ; -if (last_pfn >= adev->vm_manager.max_pfn) { -dev_err (adev->dev,"va above limit (0x%08llX >= 0x%08llX)\n" , - last_pfn, adev->vm_manager.max_pfn); -return -EINVAL ; - } + +if (vm->pte_support_ats) + ats = saddr <AMDGPU_VA_HOLE_START ; saddr /=AMDGPU_GPU_PAGE_SIZE ; eaddr /=AMDGPU_GPU_PAGE_SIZE ; +if (eaddr >= adev->vm_manager.max_pfn) { +dev_err (adev->dev,"va above limit (0x%08llX >= 0x%08llX)\n" , + eaddr, adev->vm_manager.max_pfn); +return -EINVAL ; + } +return amdgpu_vm_alloc_levels (adev, vm, &vm->root, saddr, eaddr, - adev->vm_manager.root_level); + adev->vm_manager.root_level, ats); }/**
@@ -1665,16 +1689,16 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev, struct dma_fence **fence) {struct amdgpu_bo_va_mapping *mapping; +uint64_t init_pte_value =0 ;struct dma_fence *f =NULL ;int r; -uint64_t init_pte_value =0 ;while (!list_empty (&vm->freed)) { mapping =list_first_entry (&vm->freed, struct amdgpu_bo_va_mapping, list);list_del (&mapping->list); -if (vm->pte_support_ats) +if (vm->pte_support_ats && mapping->start <AMDGPU_VA_HOLE_START ) init_pte_value =AMDGPU_PTE_DEFAULT_ATC ; r = amdgpu_vm_bo_update_mapping(adev, NULL, NULL, vm,
@@ -2367,7 +2391,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto error_free_root; r =amdgpu_vm_clear_bo (adev, vm, vm->root.base.bo, - adev->vm_manager.root_level); + adev->vm_manager.root_level, + vm->pte_support_ats);if (r) goto error_unreserve;
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180126100442.1856-4-christian.koenig-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 4/4] drm/amdgpu: fill only the lower range with ATS entries
Shouldn't this change come before all the reverts? Otherwise you're briefly breaking ATS support on Raven for KFD.
Regards,
Felix
Quoted 175 lines · Christian König
At least on x86-64 the upper range is purely used by the kernel, avoid creating any ATS mappings there as security precaution and to allow proper page fault reporting in the upper range.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 83 ++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +52
-28@@ -267,24 +267,34 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)* Root PD needs to be reserved when calling this. */ static int amdgpu_vm_clear_bo (struct amdgpu_device *adev, -struct amdgpu_vm *vm, -struct amdgpu_bo *bo, -unsigned level) +struct amdgpu_vm *vm,struct amdgpu_bo *bo, +unsigned level,bool pte_support_ats) {struct ttm_operation_ctx ctx = { true, false };struct dma_fence *fence =NULL ; -uint64_t addr, init_value; +unsigned entries, ats_entries; +uint64_t addr, ats_value;struct amdgpu_ring *ring;struct amdgpu_job *job; -unsigned entries;int r; -if (vm->pte_support_ats) { - init_value =AMDGPU_PTE_DEFAULT_ATC ; -if (level !=AMDGPU_VM_PTB ) - init_value |=AMDGPU_PDE_PTE ; + addr =amdgpu_bo_gpu_offset (bo); + entries =amdgpu_bo_size (bo) /8 ; + +if (pte_support_ats) { +if (level == adev->vm_manager.root_level) { + ats_entries =amdgpu_vm_level_shift (adev, level); + ats_entries +=AMDGPU_GPU_PAGE_SHIFT ; + ats_entries =AMDGPU_VA_HOLE_START >> ats_entries; + ats_entries =min (ats_entries, entries); + entries -= ats_entries; + }else { + ats_entries = entries; + entries =0 ; + } }else { - init_value =0 ; + ats_entries =0 ; + ats_value =0 ; } ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);@@ -297,15 +307,26 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,if (r) goto error; - addr =amdgpu_bo_gpu_offset (bo); - entries =amdgpu_bo_size (bo) /8 ; - r =amdgpu_job_alloc_with_ib (adev,64 , &job);if (r) goto error; -amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , - entries,0 , init_value); +if (ats_entries) { +uint64_t ats_value; + + ats_value =AMDGPU_PTE_DEFAULT_ATC ; +if (level !=AMDGPU_VM_PTB ) + ats_value |=AMDGPU_PDE_PTE ; + +amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , + ats_entries,0 , ats_value); + addr += ats_entries *8 ; + } + +if (entries) +amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , + entries,0 ,0 ); +amdgpu_ring_pad_ib (ring, &job->ibs[0 ]);WARN_ON (job->ibs[0 ].length_dw >64 );@@ -339,7 +360,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,struct amdgpu_vm *vm, struct amdgpu_vm_pt *parent, uint64_t saddr, uint64_t eaddr, - unsigned level) + unsigned level, bool ats) { unsigned shift = amdgpu_vm_level_shift(adev, level);unsigned pt_idx, from, to;@@ -389,7 +410,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,if (r)return r; - r =amdgpu_vm_clear_bo (adev, vm, pt, level); + r =amdgpu_vm_clear_bo (adev, vm, pt, level, ats);if (r) {amdgpu_bo_unref (&pt);return r;@@ -421,7 +442,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,uint64_t sub_eaddr = (pt_idx == to) ? eaddr : ((1 << shift) -1 ); r =amdgpu_vm_alloc_levels (adev, vm, entry, sub_saddr, - sub_eaddr, level); + sub_eaddr, level, ats);if (r)return r; }@@ -444,26 +465,29 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,struct amdgpu_vm *vm, uint64_t saddr, uint64_t size) { - uint64_t last_pfn; uint64_t eaddr; +bool ats = false;/* validate the parameters */ if (saddr &AMDGPU_GPU_PAGE_MASK || size &AMDGPU_GPU_PAGE_MASK )return -EINVAL ; eaddr = saddr + size -1 ; - last_pfn = eaddr /AMDGPU_GPU_PAGE_SIZE ; -if (last_pfn >= adev->vm_manager.max_pfn) { -dev_err (adev->dev,"va above limit (0x%08llX >= 0x%08llX)\n" , - last_pfn, adev->vm_manager.max_pfn); -return -EINVAL ; - } + +if (vm->pte_support_ats) + ats = saddr <AMDGPU_VA_HOLE_START ; saddr /=AMDGPU_GPU_PAGE_SIZE ; eaddr /=AMDGPU_GPU_PAGE_SIZE ; +if (eaddr >= adev->vm_manager.max_pfn) { +dev_err (adev->dev,"va above limit (0x%08llX >= 0x%08llX)\n" , + eaddr, adev->vm_manager.max_pfn); +return -EINVAL ; + } +return amdgpu_vm_alloc_levels (adev, vm, &vm->root, saddr, eaddr, - adev->vm_manager.root_level); + adev->vm_manager.root_level, ats); }/** @@ -1665,16 +1689,16 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev, struct dma_fence **fence) {struct amdgpu_bo_va_mapping *mapping; +uint64_t init_pte_value =0 ;struct dma_fence *f =NULL ;int r; -uint64_t init_pte_value =0 ;while (!list_empty (&vm->freed)) { mapping =list_first_entry (&vm->freed, struct amdgpu_bo_va_mapping, list);list_del (&mapping->list); -if (vm->pte_support_ats) +if (vm->pte_support_ats && mapping->start <AMDGPU_VA_HOLE_START ) init_pte_value =AMDGPU_PTE_DEFAULT_ATC ; r = amdgpu_vm_bo_update_mapping(adev, NULL, NULL, vm,
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, · line 2398
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -2367,7 +2391,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto error_free_root; r =amdgpu_vm_clear_bo (adev, vm, vm->root.base.bo, - adev->vm_manager.root_level); + adev->vm_manager.root_level, + vm->pte_support_ats);if (r) goto error_unreserve;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): aa16d6ac-643a-45cf-d530-2776a66c7339-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 4/4] drm/amdgpu: fill only the lower range with ATS entries
The amdgpu_vm_clear_bo function takes over this functionality in the first patch.
This patch only limits filling in the ats values in the lower halve of the address range (previously it was filled in the whole address space).
Regards,
Christian.
Am 26.01.2018 um 21:18 schrieb Felix Kuehling:
Quoted 185 lines
Shouldn't this change come before all the reverts? Otherwise you're briefly breaking ATS support on Raven for KFD.
Regards,
FelixQuoted 177 lines · Christian König
At least on x86-64 the upper range is purely used by the kernel, avoid creating any ATS mappings there as security precaution and to allow proper page fault reporting in the upper range.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 83 ++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +52
-28@@ -267,24 +267,34 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)* Root PD needs to be reserved when calling this. */ static int amdgpu_vm_clear_bo (struct amdgpu_device *adev, -struct amdgpu_vm *vm, -struct amdgpu_bo *bo, -unsigned level) +struct amdgpu_vm *vm,struct amdgpu_bo *bo, +unsigned level,bool pte_support_ats) {struct ttm_operation_ctx ctx = { true, false };struct dma_fence *fence =NULL ; -uint64_t addr, init_value; +unsigned entries, ats_entries; +uint64_t addr, ats_value;struct amdgpu_ring *ring;struct amdgpu_job *job; -unsigned entries;int r; -if (vm->pte_support_ats) { - init_value =AMDGPU_PTE_DEFAULT_ATC ; -if (level !=AMDGPU_VM_PTB ) - init_value |=AMDGPU_PDE_PTE ; + addr =amdgpu_bo_gpu_offset (bo); + entries =amdgpu_bo_size (bo) /8 ; + +if (pte_support_ats) { +if (level == adev->vm_manager.root_level) { + ats_entries =amdgpu_vm_level_shift (adev, level); + ats_entries +=AMDGPU_GPU_PAGE_SHIFT ; + ats_entries =AMDGPU_VA_HOLE_START >> ats_entries; + ats_entries =min (ats_entries, entries); + entries -= ats_entries; + }else { + ats_entries = entries; + entries =0 ; + } }else { - init_value =0 ; + ats_entries =0 ; + ats_value =0 ; } ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);@@ -297,15 +307,26 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,if (r) goto error; - addr =amdgpu_bo_gpu_offset (bo); - entries =amdgpu_bo_size (bo) /8 ; - r =amdgpu_job_alloc_with_ib (adev,64 , &job);if (r) goto error; -amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , - entries,0 , init_value); +if (ats_entries) { +uint64_t ats_value; + + ats_value =AMDGPU_PTE_DEFAULT_ATC ; +if (level !=AMDGPU_VM_PTB ) + ats_value |=AMDGPU_PDE_PTE ; + +amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , + ats_entries,0 , ats_value); + addr += ats_entries *8 ; + } + +if (entries) +amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , + entries,0 ,0 ); +amdgpu_ring_pad_ib (ring, &job->ibs[0 ]);WARN_ON (job->ibs[0 ].length_dw >64 );@@ -339,7 +360,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,struct amdgpu_vm *vm, struct amdgpu_vm_pt *parent, uint64_t saddr, uint64_t eaddr, - unsigned level) + unsigned level, bool ats) { unsigned shift = amdgpu_vm_level_shift(adev, level);unsigned pt_idx, from, to;@@ -389,7 +410,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,if (r)return r; - r =amdgpu_vm_clear_bo (adev, vm, pt, level); + r =amdgpu_vm_clear_bo (adev, vm, pt, level, ats);if (r) {amdgpu_bo_unref (&pt);return r;@@ -421,7 +442,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,uint64_t sub_eaddr = (pt_idx == to) ? eaddr : ((1 << shift) -1 ); r =amdgpu_vm_alloc_levels (adev, vm, entry, sub_saddr, - sub_eaddr, level); + sub_eaddr, level, ats);if (r)return r; }@@ -444,26 +465,29 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,struct amdgpu_vm *vm, uint64_t saddr, uint64_t size) { - uint64_t last_pfn; uint64_t eaddr; +bool ats = false;/* validate the parameters */ if (saddr &AMDGPU_GPU_PAGE_MASK || size &AMDGPU_GPU_PAGE_MASK )return -EINVAL ; eaddr = saddr + size -1 ; - last_pfn = eaddr /AMDGPU_GPU_PAGE_SIZE ; -if (last_pfn >= adev->vm_manager.max_pfn) { -dev_err (adev->dev,"va above limit (0x%08llX >= 0x%08llX)\n" , - last_pfn, adev->vm_manager.max_pfn); -return -EINVAL ; - } + +if (vm->pte_support_ats) + ats = saddr <AMDGPU_VA_HOLE_START ; saddr /=AMDGPU_GPU_PAGE_SIZE ; eaddr /=AMDGPU_GPU_PAGE_SIZE ; +if (eaddr >= adev->vm_manager.max_pfn) { +dev_err (adev->dev,"va above limit (0x%08llX >= 0x%08llX)\n" , + eaddr, adev->vm_manager.max_pfn); +return -EINVAL ; + } +return amdgpu_vm_alloc_levels (adev, vm, &vm->root, saddr, eaddr, - adev->vm_manager.root_level); + adev->vm_manager.root_level, ats); }/** @@ -1665,16 +1689,16 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev, struct dma_fence **fence) {struct amdgpu_bo_va_mapping *mapping; +uint64_t init_pte_value =0 ;struct dma_fence *f =NULL ;int r; -uint64_t init_pte_value =0 ;while (!list_empty (&vm->freed)) { mapping =list_first_entry (&vm->freed, struct amdgpu_bo_va_mapping, list);list_del (&mapping->list); -if (vm->pte_support_ats) +if (vm->pte_support_ats && mapping->start <AMDGPU_VA_HOLE_START ) init_pte_value =AMDGPU_PTE_DEFAULT_ATC ; r = amdgpu_vm_bo_update_mapping(adev, NULL, NULL, vm,@@ -2367,7 +2391,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto error_free_root;
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, · line 2398
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1r =amdgpu_vm_clear_bo (adev, vm, vm->root.base.bo, - adev->vm_manager.root_level); + adev->vm_manager.root_level, + vm->pte_support_ats);if (r) goto error_unreserve;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): a1448771-71db-41c8-97fa-c9b5743aaef6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 4/4] drm/amdgpu: fill only the lower range with ATS entries
So the first patch is not a straight revert, although the title looks like it is. I'll read the first patch more carefully.
Quoted 190 lines · Christian König
The
amdgpu_vm_clear_bofunction takes over this functionality in the first patch.This patch only limits filling in the ats values in the lower halve of the address range (previously it was filled in the whole address space).
Regards,
Christian.Am 26.01.2018 um 21:18 schrieb Felix Kuehling:
Quoted 180 lines
Shouldn't this change come before all the reverts? Otherwise you're briefly breaking ATS support on Raven for KFD.
Regards,
FelixQuoted 172 lines · Christian König
At least on x86-64 the upper range is purely used by the kernel, avoid creating any ATS mappings there as security precaution and to allow proper page fault reporting in the upper range.
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c| 83
++++++++++++++++++++++------------1 file changed, 54 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +37
-13@@ -267,24 +267,34 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)* Root PD needs to be reserved when calling this. */ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev, - struct amdgpu_vm *vm, - struct amdgpu_bo *bo, - unsigned level) + struct amdgpu_vm *vm, struct amdgpu_bo *bo, + unsigned level, bool pte_support_ats) { struct ttm_operation_ctx ctx = { true, false }; struct dma_fence *fence = NULL; - uint64_t addr, init_value; + unsigned entries, ats_entries; + uint64_t addr, ats_value; struct amdgpu_ring *ring; struct amdgpu_job *job; - unsigned entries; int r; - if (vm->pte_support_ats) { - init_value = AMDGPU_PTE_DEFAULT_ATC; - if (level != AMDGPU_VM_PTB) - init_value |= AMDGPU_PDE_PTE; + addr = amdgpu_bo_gpu_offset(bo); + entries = amdgpu_bo_size(bo) / 8; + + if (pte_support_ats) { + if (level == adev->vm_manager.root_level) { + ats_entries = amdgpu_vm_level_shift(adev, level); + ats_entries += AMDGPU_GPU_PAGE_SHIFT; + ats_entries = AMDGPU_VA_HOLE_START >> ats_entries; + ats_entries = min(ats_entries, entries); + entries -= ats_entries; + } else { + ats_entries = entries; + entries = 0; + } } else { - init_value = 0; + ats_entries = 0; + ats_value = 0; } ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);@@ -297,15 +307,26 @@ static int amdgpu_vm_clear_bo(structamdgpu_device *adev, if (r) goto error; - addr = amdgpu_bo_gpu_offset(bo); - entries = amdgpu_bo_size(bo) / 8; - r = amdgpu_job_alloc_with_ib(adev, 64, &job); if (r) goto error; - amdgpu_vm_set_pte_pde(adev, &job->ibs[0], addr, 0, - entries, 0, init_value); + if (ats_entries) { + uint64_t ats_value; + + ats_value = AMDGPU_PTE_DEFAULT_ATC; + if (level != AMDGPU_VM_PTB) + ats_value |= AMDGPU_PDE_PTE; + + amdgpu_vm_set_pte_pde(adev, &job->ibs[0], addr, 0, + ats_entries, 0, ats_value); + addr += ats_entries * 8; + } + + if (entries) + amdgpu_vm_set_pte_pde(adev, &job->ibs[0], addr, 0, + entries, 0, 0); + amdgpu_ring_pad_ib(ring, &job->ibs[0]); WARN_ON(job->ibs[0].length_dw > 64);@@ -339,7 +360,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, struct amdgpu_vm *vm, struct amdgpu_vm_pt *parent, uint64_t saddr, uint64_t eaddr, - unsigned level) + unsigned level, bool ats) { unsigned shift = amdgpu_vm_level_shift(adev, level);unsigned
pt_idx, from, to;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0@@ -389,7 +410,7 @@ static int amdgpu_vm_alloc_levels(structamdgpu_device *adev, if (r) return r; - r = amdgpu_vm_clear_bo(adev, vm, pt, level); + r = amdgpu_vm_clear_bo(adev, vm, pt, level, ats); if (r) { amdgpu_bo_unref(&pt);return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -421,7 +442,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,
uint64_tsub_eaddr= (pt_idx== to) ? eaddr :
((1 << shift) - 1);
r =amdgpu_vm_alloc_levels(adev, vm, entry, sub_saddr, - sub_eaddr, level);
+sub_eaddr, level, ats);
if (r)
return r;
}drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +12
-9@@ -444,26 +465,29 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev, struct amdgpu_vm *vm, uint64_t saddr, uint64_t size) { - uint64_t last_pfn; uint64_t eaddr; + bool ats = false; /* validate the parameters */ if (saddr & AMDGPU_GPU_PAGE_MASK || size & AMDGPU_GPU_PAGE_MASK) return -EINVAL; eaddr = saddr + size - 1; - last_pfn = eaddr / AMDGPU_GPU_PAGE_SIZE; - if (last_pfn >= adev->vm_manager.max_pfn) { - dev_err(adev->dev, "va above limit (0x%08llX >= 0x%08llX)\n", - last_pfn, adev->vm_manager.max_pfn); - return -EINVAL; - } + + if (vm->pte_support_ats) + ats = saddr < AMDGPU_VA_HOLE_START; saddr /= AMDGPU_GPU_PAGE_SIZE; eaddr /= AMDGPU_GPU_PAGE_SIZE; + if (eaddr >= adev->vm_manager.max_pfn) { + dev_err(adev->dev, "va above limit (0x%08llX >= 0x%08llX)\n", + eaddr, adev->vm_manager.max_pfn); + return -EINVAL; + } + return amdgpu_vm_alloc_levels(adev, vm, &vm->root, saddr, eaddr, - adev->vm_manager.root_level); + adev->vm_manager.root_level, ats); } /**@@ -1665,16 +1689,16 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev, struct dma_fence **fence) { struct amdgpu_bo_va_mapping *mapping; + uint64_t init_pte_value = 0; struct dma_fence *f = NULL; int r; - uint64_t init_pte_value = 0; while (!list_empty(&vm->freed)) { mapping = list_first_entry(&vm->freed, struct amdgpu_bo_va_mapping, list); list_del(&mapping->list); - if (vm->pte_support_ats) + if (vm->pte_support_ats && mapping->start <AMDGPU_VA_HOLE_START ) init_pte_value = AMDGPU_PTE_DEFAULT_ATC; r = amdgpu_vm_bo_update_mapping(adev, NULL, NULL, vm,@@ -2367,7 +2391,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1goto error_free_root; r = amdgpu_vm_clear_bo(adev, vm, vm->root.base.bo, - adev->vm_manager.root_level); + adev->vm_manager.root_level, + vm->pte_support_ats); if (r) goto error_unreserve;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): acbd7b9a-15bb-295b-25c1-2a4955b3935a-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 4/4] drm/amdgpu: fill only the lower range with ATS entries
Yeah, good point. I should better note that in the first patch.
Christian.
Am 26.01.2018 um 21:24 schrieb Felix Kuehling:
Quoted 199 lines
So the first patch is not a straight revert, although the title looks like it is. I'll read the first patch more carefully.
Quoted 194 lines · Christian König
The
amdgpu_vm_clear_bofunction takes over this functionality in the first patch.This patch only limits filling in the ats values in the lower halve of the address range (previously it was filled in the whole address space).
Regards,
Christian.Am 26.01.2018 um 21:18 schrieb Felix Kuehling:
Quoted 184 lines
Shouldn't this change come before all the reverts? Otherwise you're briefly breaking ATS support on Raven for KFD.
Regards,
FelixQuoted 176 lines · Christian König
At least on x86-64 the upper range is purely used by the kernel, avoid creating any ATS mappings there as security precaution and to allow proper page fault reporting in the upper range.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 83 ++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +37
-13@@ -267,24 +267,34 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)* Root PD needs to be reserved when calling this. */ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev, - struct amdgpu_vm *vm, - struct amdgpu_bo *bo, - unsigned level) + struct amdgpu_vm *vm, struct amdgpu_bo *bo, + unsigned level, bool pte_support_ats) { struct ttm_operation_ctx ctx = { true, false }; struct dma_fence *fence = NULL; - uint64_t addr, init_value; + unsigned entries, ats_entries; + uint64_t addr, ats_value; struct amdgpu_ring *ring; struct amdgpu_job *job; - unsigned entries; int r; - if (vm->pte_support_ats) { - init_value = AMDGPU_PTE_DEFAULT_ATC; - if (level != AMDGPU_VM_PTB) - init_value |= AMDGPU_PDE_PTE; + addr = amdgpu_bo_gpu_offset(bo); + entries = amdgpu_bo_size(bo) / 8; + + if (pte_support_ats) { + if (level == adev->vm_manager.root_level) { + ats_entries = amdgpu_vm_level_shift(adev, level); + ats_entries += AMDGPU_GPU_PAGE_SHIFT; + ats_entries = AMDGPU_VA_HOLE_START >> ats_entries; + ats_entries = min(ats_entries, entries); + entries -= ats_entries; + } else { + ats_entries = entries; + entries = 0; + } } else { - init_value = 0; + ats_entries = 0; + ats_value = 0; } ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);@@ -297,15 +307,26 @@ static int amdgpu_vm_clear_bo(structamdgpu_device *adev, if (r) goto error; - addr = amdgpu_bo_gpu_offset(bo); - entries = amdgpu_bo_size(bo) / 8; - r = amdgpu_job_alloc_with_ib(adev, 64, &job); if (r) goto error; - amdgpu_vm_set_pte_pde(adev, &job->ibs[0], addr, 0, - entries, 0, init_value); + if (ats_entries) { + uint64_t ats_value; + + ats_value = AMDGPU_PTE_DEFAULT_ATC; + if (level != AMDGPU_VM_PTB) + ats_value |= AMDGPU_PDE_PTE; + + amdgpu_vm_set_pte_pde(adev, &job->ibs[0], addr, 0, + ats_entries, 0, ats_value); + addr += ats_entries * 8; + } + + if (entries) + amdgpu_vm_set_pte_pde(adev, &job->ibs[0], addr, 0, + entries, 0, 0); + amdgpu_ring_pad_ib(ring, &job->ibs[0]); WARN_ON(job->ibs[0].length_dw > 64);@@ -339,7 +360,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, struct amdgpu_vm *vm, struct amdgpu_vm_pt *parent, uint64_t saddr, uint64_t eaddr, - unsigned level) + unsigned level, bool ats) { unsigned shift = amdgpu_vm_level_shift(adev, level);unsigned
pt_idx, from, to;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -389,7 +410,7 @@ static int amdgpu_vm_alloc_levels(structamdgpu_device *adev, if (r) return r; - r = amdgpu_vm_clear_bo(adev, vm, pt, level); + r = amdgpu_vm_clear_bo(adev, vm, pt, level, ats); if (r) { amdgpu_bo_unref(&pt); return r;@@ -421,7 +442,7 @@ static int amdgpu_vm_alloc_levels(structamdgpu_device *adev, uint64_t sub_eaddr = (pt_idx == to) ? eaddr : ((1 << shift) - 1); r = amdgpu_vm_alloc_levels(adev, vm, entry, sub_saddr, - sub_eaddr, level); + sub_eaddr, level, ats); if (r) return r;}
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +13
-10@@ -444,26 +465,29 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev, struct amdgpu_vm *vm, uint64_t saddr, uint64_t size) { - uint64_t last_pfn; uint64_t eaddr; + bool ats = false; /* validate the parameters */ if (saddr & AMDGPU_GPU_PAGE_MASK || size & AMDGPU_GPU_PAGE_MASK) return -EINVAL; eaddr = saddr + size - 1; - last_pfn = eaddr / AMDGPU_GPU_PAGE_SIZE; - if (last_pfn >= adev->vm_manager.max_pfn) { - dev_err(adev->dev, "va above limit (0x%08llX >= 0x%08llX)\n", - last_pfn, adev->vm_manager.max_pfn); - return -EINVAL; - } + + if (vm->pte_support_ats) + ats = saddr < AMDGPU_VA_HOLE_START; saddr /= AMDGPU_GPU_PAGE_SIZE; eaddr /= AMDGPU_GPU_PAGE_SIZE; + if (eaddr >= adev->vm_manager.max_pfn) { + dev_err(adev->dev, "va above limit (0x%08llX >= 0x%08llX)\n", + eaddr, adev->vm_manager.max_pfn); + return -EINVAL; + } + return amdgpu_vm_alloc_levels(adev, vm, &vm->root, saddr, eaddr, - adev->vm_manager.root_level); + adev->vm_manager.root_level, ats); } /**@@ -1665,16 +1689,16 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev, struct dma_fence **fence) { struct amdgpu_bo_va_mapping *mapping; + uint64_t init_pte_value = 0; struct dma_fence *f = NULL; int r; - uint64_t init_pte_value = 0; while (!list_empty(&vm->freed)) { mapping = list_first_entry(&vm->freed, struct amdgpu_bo_va_mapping, list); list_del(&mapping->list); - if (vm->pte_support_ats) + if (vm->pte_support_ats && mapping->start <AMDGPU_VA_HOLE_START ) init_pte_value = AMDGPU_PTE_DEFAULT_ATC; r = amdgpu_vm_bo_update_mapping(adev, NULL, NULL, vm,@@ -2367,7 +2391,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev,struct amdgpu_vm *vm, goto error_free_root; r = amdgpu_vm_clear_bo(adev, vm, vm->root.base.bo, - adev->vm_manager.root_level); + adev->vm_manager.root_level,
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device *adev, · line 2398
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0+ vm->pte_support_ats); if (r) goto error_unreserve;_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 4/4] drm/amdgpu: fill only the lower range with ATS entries
In reply to a message not in the archiveOne minor nit-pick inline. Other than that and the confusing headline on Patch 1 the series is Reviewed-by: Felix Kuehling <[email protected]>
Quoted 45 lines · Christian König
At least on x86-64 the upper range is purely used by the kernel, avoid creating any ATS mappings there as security precaution and to allow proper page fault reporting in the upper range.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 83 ++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +12
-9@@ -267,24 +267,34 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)* Root PD needs to be reserved when calling this. */ static int amdgpu_vm_clear_bo (struct amdgpu_device *adev, -struct amdgpu_vm *vm, -struct amdgpu_bo *bo, -unsigned level) +struct amdgpu_vm *vm,struct amdgpu_bo *bo, +unsigned level,bool pte_support_ats) {struct ttm_operation_ctx ctx = { true, false };struct dma_fence *fence =NULL ; -uint64_t addr, init_value; +unsigned entries, ats_entries; +uint64_t addr, ats_value;struct amdgpu_ring *ring;struct amdgpu_job *job; -unsigned entries;int r; -if (vm->pte_support_ats) { - init_value =AMDGPU_PTE_DEFAULT_ATC ; -if (level !=AMDGPU_VM_PTB ) - init_value |=AMDGPU_PDE_PTE ; + addr =amdgpu_bo_gpu_offset (bo); + entries =amdgpu_bo_size (bo) /8 ; + +if (pte_support_ats) { +if (level == adev->vm_manager.root_level) { + ats_entries =amdgpu_vm_level_shift (adev, level); + ats_entries +=AMDGPU_GPU_PAGE_SHIFT ; + ats_entries =AMDGPU_VA_HOLE_START >> ats_entries;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c bool amdgpu_vm_ready(struct amdgpu_vm *vm) · line 297
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-1+ ats_entries =min (ats_entries, entries); + entries -= ats_entries; + }else { + ats_entries = entries; + entries =0 ; + } }else { - init_value =0 ; + ats_entries =0 ; + ats_value =0 ;
You don't need to initialize ats_value here. It won't be used, and for the ATS case it's actually initialized below anyway.
Regards,
Felix
Quoted 120 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +32
-18} ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);@@ -297,15 +307,26 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,if (r) goto error; - addr =amdgpu_bo_gpu_offset (bo); - entries =amdgpu_bo_size (bo) /8 ; - r =amdgpu_job_alloc_with_ib (adev,64 , &job);if (r) goto error; -amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , - entries,0 , init_value); +if (ats_entries) { +uint64_t ats_value; + + ats_value =AMDGPU_PTE_DEFAULT_ATC ; +if (level !=AMDGPU_VM_PTB ) + ats_value |=AMDGPU_PDE_PTE ; + +amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , + ats_entries,0 , ats_value); + addr += ats_entries *8 ; + } + +if (entries) +amdgpu_vm_set_pte_pde (adev, &job->ibs[0 ], addr,0 , + entries,0 ,0 ); +amdgpu_ring_pad_ib (ring, &job->ibs[0 ]);WARN_ON (job->ibs[0 ].length_dw >64 );@@ -339,7 +360,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,struct amdgpu_vm *vm, struct amdgpu_vm_pt *parent, uint64_t saddr, uint64_t eaddr, - unsigned level) + unsigned level, bool ats) { unsigned shift = amdgpu_vm_level_shift(adev, level);unsigned pt_idx, from, to;@@ -389,7 +410,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,if (r)return r; - r =amdgpu_vm_clear_bo (adev, vm, pt, level); + r =amdgpu_vm_clear_bo (adev, vm, pt, level, ats);if (r) {amdgpu_bo_unref (&pt);return r;@@ -421,7 +442,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,uint64_t sub_eaddr = (pt_idx == to) ? eaddr : ((1 << shift) -1 ); r =amdgpu_vm_alloc_levels (adev, vm, entry, sub_saddr, - sub_eaddr, level); + sub_eaddr, level, ats);if (r)return r; }@@ -444,26 +465,29 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,struct amdgpu_vm *vm, uint64_t saddr, uint64_t size) { - uint64_t last_pfn; uint64_t eaddr; +bool ats = false;/* validate the parameters */ if (saddr &AMDGPU_GPU_PAGE_MASK || size &AMDGPU_GPU_PAGE_MASK )return -EINVAL ; eaddr = saddr + size -1 ; - last_pfn = eaddr /AMDGPU_GPU_PAGE_SIZE ; -if (last_pfn >= adev->vm_manager.max_pfn) { -dev_err (adev->dev,"va above limit (0x%08llX >= 0x%08llX)\n" , - last_pfn, adev->vm_manager.max_pfn); -return -EINVAL ; - } + +if (vm->pte_support_ats) + ats = saddr <AMDGPU_VA_HOLE_START ; saddr /=AMDGPU_GPU_PAGE_SIZE ; eaddr /=AMDGPU_GPU_PAGE_SIZE ; +if (eaddr >= adev->vm_manager.max_pfn) { +dev_err (adev->dev,"va above limit (0x%08llX >= 0x%08llX)\n" , + eaddr, adev->vm_manager.max_pfn); +return -EINVAL ; + } +return amdgpu_vm_alloc_levels (adev, vm, &vm->root, saddr, eaddr, - adev->vm_manager.root_level); + adev->vm_manager.root_level, ats); }/** @@ -1665,16 +1689,16 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev, struct dma_fence **fence) {struct amdgpu_bo_va_mapping *mapping; +uint64_t init_pte_value =0 ;struct dma_fence *f =NULL ;int r; -uint64_t init_pte_value =0 ;while (!list_empty (&vm->freed)) { mapping =list_first_entry (&vm->freed, struct amdgpu_bo_va_mapping, list);list_del (&mapping->list); -if (vm->pte_support_ats) +if (vm->pte_support_ats && mapping->start <AMDGPU_VA_HOLE_START ) init_pte_value =AMDGPU_PTE_DEFAULT_ATC ; r = amdgpu_vm_bo_update_mapping(adev, NULL, NULL, vm,
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, · line 2398
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -2367,7 +2391,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto error_free_root; r =amdgpu_vm_clear_bo (adev, vm, vm->root.base.bo, - adev->vm_manager.root_level); + adev->vm_manager.root_level, + vm->pte_support_ats);if (r) goto error_unreserve;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx