drm/amdgpu: avoid the modulo in amdgpu_vm_get_entry
authorChristian König <christian.koenig@amd.com>
Fri, 1 Dec 2017 12:28:46 +0000 (13:28 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 12 Dec 2017 19:45:54 +0000 (14:45 -0500)
We can do this with a simple mask as well.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

index 1c3dd6e0ed3341ef72044e85054066318dc4d0c6..bd6296a6dab1d7362f90793f1bae448191e8ad7d 100644 (file)
@@ -1285,11 +1285,11 @@ void amdgpu_vm_get_entry(struct amdgpu_pte_update_params *p, uint64_t addr,
        *parent = NULL;
        *entry = &p->vm->root;
        while ((*entry)->entries) {
-               unsigned idx = addr >> amdgpu_vm_level_shift(p->adev, level++);
+               unsigned shift = amdgpu_vm_level_shift(p->adev, level++);
 
-               idx %= amdgpu_bo_size((*entry)->base.bo) / 8;
                *parent = *entry;
-               *entry = &(*entry)->entries[idx];
+               *entry = &(*entry)->entries[addr >> shift];
+               addr &= (1ULL << shift) - 1;
        }
 
        if (level != p->adev->vm_manager.num_level)