drm/amdkfd: Don't take process mutex for svm ioctls
authorPhilip Yang <Philip.Yang@amd.com>
Mon, 24 Jan 2022 21:40:44 +0000 (16:40 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 27 Jan 2022 20:47:34 +0000 (15:47 -0500)
SVM ioctls take proper svms->lock to handle race conditions, don't need
take process mutex to serialize ioctls. This also fixes circular locking
warning:

WARNING: possible circular locking dependency detected

  Possible unsafe locking scenario:

        CPU0                    CPU1
        ----                    ----
   lock((work_completion)(&svms->deferred_list_work));
                                lock(&process->mutex);
                     lock((work_completion)(&svms->deferred_list_work));
   lock(&process->mutex);

   *** DEADLOCK ***

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

index 26a593b..214a2c6 100644 (file)
@@ -1847,13 +1847,9 @@ static int kfd_ioctl_svm(struct file *filep, struct kfd_process *p, void *data)
        if (!args->start_addr || !args->size)
                return -EINVAL;
 
-       mutex_lock(&p->mutex);
-
        r = svm_ioctl(p, args->op, args->start_addr, args->size, args->nattr,
                      args->attrs);
 
-       mutex_unlock(&p->mutex);
-
        return r;
 }
 #else