Merge tag 'amd-drm-next-5.15-2021-07-29' of https://gitlab.freedesktop.org/agd5f...
[sfrench/cifs-2.6.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_amdkfd_gpuvm.c
index 4fb15750b9bb4c682ba00ae933a6001545216671..c4b3eeeab0a199342d3118cb429cb2ba5b005edc 100644 (file)
@@ -1285,11 +1285,22 @@ int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct kgd_dev *kgd,
        if (avm->process_info)
                return -EINVAL;
 
+       /* Free the original amdgpu allocated pasid,
+        * will be replaced with kfd allocated pasid.
+        */
+       if (avm->pasid) {
+               amdgpu_pasid_free(avm->pasid);
+               amdgpu_vm_set_pasid(adev, avm, 0);
+       }
+
        /* Convert VM into a compute VM */
-       ret = amdgpu_vm_make_compute(adev, avm, pasid);
+       ret = amdgpu_vm_make_compute(adev, avm);
        if (ret)
                return ret;
 
+       ret = amdgpu_vm_set_pasid(adev, avm, pasid);
+       if (ret)
+               return ret;
        /* Initialize KFD part of the VM and process info */
        ret = init_kfd_vm(avm, process_info, ef);
        if (ret)