Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm: Split out idr_lock

Otherwise if we hit reclaim pinning objects in the submit path, we'll be
blocking retire_worker trying to free a submit.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Patchwork: https://patchwork.freedesktop.org/patch/496116/
Link: https://lore.kernel.org/r/20220802155152.1727594-4-robdclark@gmail.com

+14 -5
+2 -2
drivers/gpu/drm/msm/msm_drv.c
··· 883 883 * retired, so if the fence is not found it means there is nothing 884 884 * to wait for 885 885 */ 886 - ret = mutex_lock_interruptible(&queue->lock); 886 + ret = mutex_lock_interruptible(&queue->idr_lock); 887 887 if (ret) 888 888 return ret; 889 889 fence = idr_find(&queue->fence_idr, fence_id); 890 890 if (fence) 891 891 fence = dma_fence_get_rcu(fence); 892 - mutex_unlock(&queue->lock); 892 + mutex_unlock(&queue->idr_lock); 893 893 894 894 if (!fence) 895 895 return 0;
+8 -2
drivers/gpu/drm/msm/msm_gem_submit.c
··· 72 72 unsigned i; 73 73 74 74 if (submit->fence_id) { 75 - mutex_lock(&submit->queue->lock); 75 + mutex_lock(&submit->queue->idr_lock); 76 76 idr_remove(&submit->queue->fence_idr, submit->fence_id); 77 - mutex_unlock(&submit->queue->lock); 77 + mutex_unlock(&submit->queue->idr_lock); 78 78 } 79 79 80 80 dma_fence_put(submit->user_fence); ··· 881 881 882 882 submit->nr_cmds = i; 883 883 884 + mutex_lock(&queue->idr_lock); 885 + 884 886 /* 885 887 * If using userspace provided seqno fence, validate that the id 886 888 * is available before arming sched job. Since access to fence_idr ··· 891 889 */ 892 890 if ((args->flags & MSM_SUBMIT_FENCE_SN_IN) && 893 891 idr_find(&queue->fence_idr, args->fence)) { 892 + mutex_unlock(&queue->idr_lock); 894 893 ret = -EINVAL; 895 894 goto out; 896 895 } ··· 924 921 submit->user_fence, 1, 925 922 INT_MAX, GFP_KERNEL); 926 923 } 924 + 925 + mutex_unlock(&queue->idr_lock); 926 + 927 927 if (submit->fence_id < 0) { 928 928 ret = submit->fence_id; 929 929 submit->fence_id = 0;
+3 -1
drivers/gpu/drm/msm/msm_gpu.h
··· 466 466 * @node: node in the context's list of submitqueues 467 467 * @fence_idr: maps fence-id to dma_fence for userspace visible fence 468 468 * seqno, protected by submitqueue lock 469 - * @lock: submitqueue lock 469 + * @idr_lock: for serializing access to fence_idr 470 + * @lock: submitqueue lock for serializing submits on a queue 470 471 * @ref: reference count 471 472 * @entity: the submit job-queue 472 473 */ ··· 480 479 struct msm_file_private *ctx; 481 480 struct list_head node; 482 481 struct idr fence_idr; 482 + struct mutex idr_lock; 483 483 struct mutex lock; 484 484 struct kref ref; 485 485 struct drm_sched_entity *entity;
+1
drivers/gpu/drm/msm/msm_submitqueue.c
··· 200 200 *id = queue->id; 201 201 202 202 idr_init(&queue->fence_idr); 203 + mutex_init(&queue->idr_lock); 203 204 mutex_init(&queue->lock); 204 205 205 206 list_add_tail(&queue->node, &ctx->submitqueues);