drm/amdgpu: fix max_entries calculation
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix max_entries calculation
Calculate the correct value for max_entries or we might run after the page_address array.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
@@ -1697,7 +1697,8 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,AMDGPU_GPU_PAGES_IN_CPU_PAGE ; }else { addr =0 ; - max_entries =S64_MAX ; + max_entries = ((mapping->last - mapping->start) >> +AMDGPU_GPU_PAGE_SHIFT ) +1 ; }if (pages_addr) {
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 18 lines
2020年9月2日 20:05,Christian König <[email protected]> 写道:
Calculate the correct value for
max_entriesor we might run after thepage_addressarray.Signed-off-by Christian König <[email protected]>Fixes 1e691e244487 drm/amdgpu: stop allocating dummy GTT nodes---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, · line 1701
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -1697,7 +1697,8 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,AMDGPU_GPU_PAGES_IN_CPU_PAGE ; }else { addr =0 ; - max_entries =S64_MAX ; + max_entries = ((mapping->last - mapping->start) >> +AMDGPU_GPU_PAGE_SHIFT ) +1 ;
should it be like below?max_entries = (mapping->last - mapping->start + 1 - pfn) * AMDGPU_GPU_PAGES_IN_CPU_PAGE;
last and start are already pfns. why still >> AMDGPU_GPU_PAGE_SHIFT? Am I missing something?
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0}if (pages_addr) {Signature · 1 line
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 02.09.20 um 15:02 schrieb Pan, Xinhui:
Quoted 12 lines
Quoted 12 lines
2020年9月2日 20:05,Christian König <[email protected]> 写道:
Calculate the correct value for
max_entriesor we might run after thepage_addressarray.Signed-off-by Christian König <[email protected]>Fixes 1e691e244487 drm/amdgpu: stop allocating dummy GTT nodes---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, · line 1701
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -1697,7 +1697,8 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,AMDGPU_GPU_PAGES_IN_CPU_PAGE ; }else { addr =0 ; - max_entries =S64_MAX ; + max_entries = ((mapping->last - mapping->start) >> +AMDGPU_GPU_PAGE_SHIFT ) +1 ;should it be like below?
max_entries= (mapping->last-mapping->start+ 1 - pfn) *AMDGPU_GPU_PAGES_IN_CPU_PAGE;
Still not correct, but mine wasn't correct either.
Quoted 1 line
last and start are already pfns. why still >>
AMDGPU_GPU_PAGE_SHIFT? Am I missing something?
Yeah, that's wrong.
But this is in AMDGPU_GPU_PAGE_SIZE units and not PAGE_SIZE units, so multiplying it with AMDGPU_GPU_PAGES_IN_CPU_PAGE doesn't make to much sense either.
Christian.
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0}if (pages_addr) {Signature · 1 line
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx