drm/amdgpu: set the VM pointer to NULL in amdgpu_job_prepare
authorChristian König <christian.koenig@amd.com>
Thu, 12 Dec 2024 15:43:45 +0000 (16:43 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 18 Dec 2024 17:39:07 +0000 (12:39 -0500)
As soon as the prepare phase is completed the VM might be released,
better set it to NULL.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c

index 2e7e1c7dfe7c8affb3a1e9cab56acff8f8003ae7..04691753cabf948288c8e6f4cff1f714d821a986 100644 (file)
@@ -361,6 +361,13 @@ amdgpu_job_prepare_job(struct drm_sched_job *sched_job,
                        dev_err(ring->adev->dev, "Error getting VM ID (%d)\n", r);
                        goto error;
                }
+               /*
+                * The VM structure might be released after the VMID is
+                * assigned, we had multiple problems with people trying to use
+                * the VM pointer so better set it to NULL.
+                */
+               if (!fence)
+                       job->vm = NULL;
        }
 
        return fence;