drm/amdkfd: Enforce queue BO's adev
authorHarish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Mon, 22 Apr 2024 21:03:46 +0000 (17:03 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 26 Apr 2024 21:22:42 +0000 (17:22 -0400)
Queue buffer, though it is in system memory, has to be created using the
correct amdgpu device. Enforce this as the BO needs to mapped to the
GART for MES Hardware scheduler to access it.

Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

index 55aa74cbc5325e23451aa255dd5ce016e0aa4df8..6b713fb0b818fb4bd8ca6303810356263ea60735 100644 (file)
@@ -371,6 +371,11 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
                        err = -EINVAL;
                        goto err_wptr_map_gart;
                }
+               if (dev->adev != amdgpu_ttm_adev(wptr_bo->tbo.bdev)) {
+                       pr_err("Queue memory allocated to wrong device\n");
+                       err = -EINVAL;
+                       goto err_wptr_map_gart;
+               }
 
                err = amdgpu_amdkfd_map_gtt_bo_to_gart(wptr_bo);
                if (err) {