Change-Id: I8245cdad490d2a0b8cf4b9320e53e14db0b6add4 Signed-off-by: Chunming Zhou <David1.Zhou at amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index b149eb9..c0f6479a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -642,6 +642,7 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev, if (vm->page_tables[pt_idx].addr == pt) continue; vm->page_tables[pt_idx].addr = pt; + vm->page_tables[pt_idx].addr_shadow = pt; pde = pd_addr + pt_idx * 8; if (((last_pde + 8 * count) != pde) || @@ -792,7 +793,7 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev, *vm_update_params, struct amdgpu_vm *vm, uint64_t start, uint64_t end, - uint64_t dst, uint32_t flags) + uint64_t dst, uint32_t flags, bool shadow) { const uint64_t mask = AMDGPU_VM_PTE_COUNT - 1; @@ -806,7 +807,8 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev, /* initialize the variables */ addr = start; pt_idx = addr >> amdgpu_vm_block_size; - pt = vm->page_tables[pt_idx].entry.robj; + pt = shadow ? vm->page_tables[pt_idx].entry_shadow.robj : + vm->page_tables[pt_idx].entry.robj; if ((addr & ~mask) == (end & ~mask)) nptes = end - addr; @@ -825,7 +827,8 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev, /* walk over the address space and update the page tables */ while (addr < end) { pt_idx = addr >> amdgpu_vm_block_size; - pt = vm->page_tables[pt_idx].entry.robj; + pt = shadow ? vm->page_tables[pt_idx].entry_shadow.robj : + vm->page_tables[pt_idx].entry.robj; if ((addr & ~mask) == (end & ~mask)) nptes = end - addr; @@ -930,6 +933,8 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, /* two extra commands for begin/end of fragment */ ndw += 2 * 10; } + /* double ndw, since need to update shadow pt bo as well */ + ndw *= 2; r = amdgpu_job_alloc_with_ib(adev, ndw * 4, &job); if (r) @@ -947,7 +952,10 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, goto error_free; amdgpu_vm_update_ptes(adev, &vm_update_params, vm, start, - last + 1, addr, flags); + last + 1, addr, flags, false); + /* update shadow pt bo */ + amdgpu_vm_update_ptes(adev, &vm_update_params, vm, start, + last + 1, addr, flags, true); amdgpu_ring_pad_ib(ring, vm_update_params.ib); WARN_ON(vm_update_params.ib->length_dw > ndw); -- 1.9.1