A remap does not map anything new. It splits an existing mapping and
re-creates the parts the request did not cover, and that mapping is handed
to the callback in op->remap.unmap->va, carrying the &drm_gpuvm_bo those
parts belong to.

However, pvr_vm_gpuva_remap() linked the parts to
pvr_vm_bind_op::gpuvm_bo, which belongs to the object the request maps
rather than the object the parts came from.

Fixes: ff5f643de0bf ("drm/imagination: Add GEM and VM related code")
Signed-off-by: Gyeyoung Baek <[email protected]>
---
 drivers/gpu/drm/imagination/pvr_vm.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/imagination/pvr_vm.c 
b/drivers/gpu/drm/imagination/pvr_vm.c
index 396d349fb6c..608e8c0467d 100644
--- a/drivers/gpu/drm/imagination/pvr_vm.c
+++ b/drivers/gpu/drm/imagination/pvr_vm.c
@@ -418,6 +418,8 @@ pvr_vm_gpuva_unmap(struct drm_gpuva_op *op, void *op_ctx)
 static int
 pvr_vm_gpuva_remap(struct drm_gpuva_op *op, void *op_ctx)
 {
+       struct drm_gpuva *unmap_va = op->remap.unmap->va;
+       struct drm_gpuvm_bo *vm_bo = unmap_va->vm_bo;
        struct pvr_vm_bind_op *ctx = op_ctx;
        u64 va_start = 0, va_range = 0;
        int err;
@@ -434,18 +436,18 @@ pvr_vm_gpuva_remap(struct drm_gpuva_op *op, void *op_ctx)
 
        if (op->remap.prev) {
                pvr_gem_object_get(gem_to_pvr_gem(ctx->prev_va->base.gem.obj));
-               drm_gpuva_link(&ctx->prev_va->base, ctx->gpuvm_bo);
+               drm_gpuva_link(&ctx->prev_va->base, vm_bo);
                ctx->prev_va = NULL;
        }
 
        if (op->remap.next) {
                pvr_gem_object_get(gem_to_pvr_gem(ctx->next_va->base.gem.obj));
-               drm_gpuva_link(&ctx->next_va->base, ctx->gpuvm_bo);
+               drm_gpuva_link(&ctx->next_va->base, vm_bo);
                ctx->next_va = NULL;
        }
 
-       drm_gpuva_unlink(op->remap.unmap->va);
-       kfree(to_pvr_vm_gpuva(op->remap.unmap->va));
+       drm_gpuva_unlink(unmap_va);
+       kfree(to_pvr_vm_gpuva(unmap_va));
 
        return 0;
 }

-- 
2.43.0

Reply via email to