Commit 98ae7f98 authored by Felix Kuehling's avatar Felix Kuehling Committed by Alex Deucher

drm/amdgpu: Wait for newly allocated PTs to be idle

When page table are updated by the CPU, synchronize with the
allocation and initialization of newly allocated page tables.
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 194f87dd
...@@ -899,17 +899,17 @@ static void amdgpu_vm_bo_param(struct amdgpu_device *adev, struct amdgpu_vm *vm, ...@@ -899,17 +899,17 @@ static void amdgpu_vm_bo_param(struct amdgpu_device *adev, struct amdgpu_vm *vm,
} }
/** /**
* amdgpu_vm_alloc_pts - Allocate page tables. * amdgpu_vm_alloc_pts - Allocate a specific page table
* *
* @adev: amdgpu_device pointer * @adev: amdgpu_device pointer
* @vm: VM to allocate page tables for * @vm: VM to allocate page tables for
* @saddr: Start address which needs to be allocated * @cursor: Which page table to allocate
* @size: Size from start address we need.
* *
* Make sure the page directories and page tables are allocated * Make sure a specific page table or directory is allocated.
* *
* Returns: * Returns:
* 0 on success, errno otherwise. * 1 if page table needed to be allocated, 0 if page table was already
* allocated, negative errno if an error occurred.
*/ */
static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev, static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
struct amdgpu_vm *vm, struct amdgpu_vm *vm,
...@@ -956,7 +956,7 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev, ...@@ -956,7 +956,7 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
if (r) if (r)
goto error_free_pt; goto error_free_pt;
return 0; return 1;
error_free_pt: error_free_pt:
amdgpu_bo_unref(&pt->shadow); amdgpu_bo_unref(&pt->shadow);
...@@ -1621,10 +1621,12 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, ...@@ -1621,10 +1621,12 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
unsigned shift, parent_shift, mask; unsigned shift, parent_shift, mask;
uint64_t incr, entry_end, pe_start; uint64_t incr, entry_end, pe_start;
struct amdgpu_bo *pt; struct amdgpu_bo *pt;
bool need_to_sync;
r = amdgpu_vm_alloc_pts(params->adev, params->vm, &cursor); r = amdgpu_vm_alloc_pts(params->adev, params->vm, &cursor);
if (r) if (r < 0)
return r; return r;
need_to_sync = (r && params->vm->use_cpu_for_update);
pt = cursor.entry->base.bo; pt = cursor.entry->base.bo;
...@@ -1672,6 +1674,10 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, ...@@ -1672,6 +1674,10 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
entry_end += cursor.pfn & ~(entry_end - 1); entry_end += cursor.pfn & ~(entry_end - 1);
entry_end = min(entry_end, end); entry_end = min(entry_end, end);
if (need_to_sync)
r = amdgpu_bo_sync_wait(params->vm->root.base.bo,
AMDGPU_FENCE_OWNER_VM, true);
do { do {
uint64_t upd_end = min(entry_end, frag_end); uint64_t upd_end = min(entry_end, frag_end);
unsigned nptes = (upd_end - frag_start) >> shift; unsigned nptes = (upd_end - frag_start) >> shift;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment