Skip to content

Commit 76d2e56

Browse files
ChristianKoenigAMDgregkh
authored andcommitted
drm/amdgpu: fix max_entries calculation v4
[ Upstream commit ee354ff ] 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 Signed-off-by: Christian König <christian.koenig@amd.com> Fixes: 1e691e2 drm/amdgpu: stop allocating dummy GTT nodes Reviewed-by: xinhui pan <xinhui.pan@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e18e036 commit 76d2e56

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,13 +1691,13 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
16911691
uint64_t max_entries;
16921692
uint64_t addr, last;
16931693

1694+
max_entries = mapping->last - start + 1;
16941695
if (nodes) {
16951696
addr = nodes->start << PAGE_SHIFT;
1696-
max_entries = (nodes->size - pfn) *
1697-
AMDGPU_GPU_PAGES_IN_CPU_PAGE;
1697+
max_entries = min((nodes->size - pfn) *
1698+
AMDGPU_GPU_PAGES_IN_CPU_PAGE, max_entries);
16981699
} else {
16991700
addr = 0;
1700-
max_entries = S64_MAX;
17011701
}
17021702

17031703
if (pages_addr) {
@@ -1727,7 +1727,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
17271727
addr += pfn << PAGE_SHIFT;
17281728
}
17291729

1730-
last = min((uint64_t)mapping->last, start + max_entries - 1);
1730+
last = start + max_entries - 1;
17311731
r = amdgpu_vm_bo_update_mapping(adev, vm, false, false, resv,
17321732
start, last, flags, addr,
17331733
dma_addr, fence);

0 commit comments

Comments
 (0)