diff options
author | Christian König <christian.koenig@amd.com> | 2018-08-30 15:55:54 +0200 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-09-11 16:30:32 -0500 |
commit | 1c860a022f65224d6e8af71cc9f1411cb779f666 (patch) | |
tree | 60f77c254f6028a40bda905215a0fc2ed9b6d55e /drivers/gpu | |
parent | ba79fde47b9b3a04932a5385e5530616a77d4536 (diff) |
drm/amdgpu: add amdgpu_vm_update_func
Add helper to call the update function for both BO and shadow.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 92c34e4290a8..e793a7855bb3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -1113,6 +1113,22 @@ static int amdgpu_vm_wait_pd(struct amdgpu_device *adev, struct amdgpu_vm *vm, return r; } +/** + * amdgpu_vm_update_func - helper to call update function + * + * Calls the update function for both the given BO as well as its shadow. + */ +static void amdgpu_vm_update_func(struct amdgpu_pte_update_params *params, + struct amdgpu_bo *bo, + uint64_t pe, uint64_t addr, + unsigned count, uint32_t incr, + uint64_t flags) +{ + if (bo->shadow) + params->func(params, bo->shadow, pe, addr, count, incr, flags); + params->func(params, bo, pe, addr, count, incr, flags); +} + /* * amdgpu_vm_update_pde - update a single level in the hierarchy * @@ -1142,9 +1158,7 @@ static void amdgpu_vm_update_pde(struct amdgpu_pte_update_params *params, level += params->adev->vm_manager.root_level; amdgpu_gmc_get_pde_for_bo(entry->base.bo, level, &pt, &flags); pde = (entry - parent->entries) * 8; - if (bo->shadow) - params->func(params, bo->shadow, pde, pt, 1, 0, flags); - params->func(params, bo, pde, pt, 1, 0, flags); + amdgpu_vm_update_func(params, bo, pde, pt, 1, 0, flags); } /* @@ -1351,9 +1365,7 @@ static void amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p, amdgpu_gmc_get_vm_pde(p->adev, AMDGPU_VM_PDB0, &dst, &flags); pde = (entry - parent->entries) * 8; - if (parent->base.bo->shadow) - p->func(p, parent->base.bo->shadow, pde, dst, 1, 0, flags); - p->func(p, parent->base.bo, pde, dst, 1, 0, flags); + amdgpu_vm_update_func(p, parent->base.bo, pde, dst, 1, 0, flags); } /** @@ -1403,11 +1415,9 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, pt = entry->base.bo; pe_start = (addr & mask) * 8; - if (pt->shadow) - params->func(params, pt->shadow, pe_start, dst, nptes, - AMDGPU_GPU_PAGE_SIZE, flags); - params->func(params, pt, pe_start, dst, nptes, - AMDGPU_GPU_PAGE_SIZE, flags); + amdgpu_vm_update_func(params, pt, pe_start, dst, nptes, + AMDGPU_GPU_PAGE_SIZE, flags); + } return 0; |