drm/amdgpu: fix max_entries calculation v4
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix max_entries calculation v4
Calculate the correct value for max_entries or we might run after the page_address array.
v2: Xinhui pointed out we don't need the shift
v3: use local copy of start and simplify some calculation
v4: fix the case that we map less VA range than BO size
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -4
@@ -1691,13 +1691,13 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,uint64_t max_entries;uint64_t addr, last; + max_entries = mapping->last - start +1 ;if (nodes) { addr = nodes->start <<PAGE_SHIFT ; - max_entries = (nodes->size - pfn) * -AMDGPU_GPU_PAGES_IN_CPU_PAGE ; + max_entries =min ((nodes->size - pfn) * +AMDGPU_GPU_PAGES_IN_CPU_PAGE , max_entries); }else { addr =0 ; - max_entries =S64_MAX ; }if (pages_addr) {
@@ -1727,7 +1727,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, addr += pfn <<PAGE_SHIFT ; } - last =min ((uint64_t )mapping->last, start + max_entries -1 ); + last = start + max_entries -1 ; r =amdgpu_vm_bo_update_mapping (adev, vm, false, false, resv, start, last, flags, addr, dma_addr, fence);
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 48 lines
2020年9月3日 17:03,Christian König <[email protected]> 写道:
Calculate the correct value for
max_entriesor we might run after thepage_addressarray.v2: Xinhui pointed out we don't need the shift
v3: use local copy of start and simplify some calculation
v4: fix the case that we map less VA range than BO sizeSigned-off-by Christian König <[email protected]>Fixes 1e691e244487 drm/amdgpu: stop allocating dummy GTT nodes---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c| 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-4@@ -1691,13 +1691,13 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,uint64_t max_entries;uint64_t addr, last; + max_entries = mapping->last - start +1 ;if (nodes) { addr = nodes->start <<PAGE_SHIFT ; - max_entries = (nodes->size - pfn) * -AMDGPU_GPU_PAGES_IN_CPU_PAGE ; + max_entries =min ((nodes->size - pfn) * +AMDGPU_GPU_PAGES_IN_CPU_PAGE , max_entries); }else { addr =0 ; - max_entries =S64_MAX ; }if (pages_addr) {@@ -1727,7 +1727,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, addr += pfn <<PAGE_SHIFT ; } - last =min ((uint64_t )mapping->last, start + max_entries -1 ); + last = start + max_entries -1 ; r =amdgpu_vm_bo_update_mapping (adev, vm, false, false, resv, start, last, flags, addr, dma_addr, fence);Signature · 1 line
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx