]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/msm: Split out idr_lock
authorRob Clark <robdclark@chromium.org>
Tue, 2 Aug 2022 15:51:36 +0000 (08:51 -0700)
committerRob Clark <robdclark@chromium.org>
Sat, 27 Aug 2022 16:32:44 +0000 (09:32 -0700)
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
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_gem_submit.c
drivers/gpu/drm/msm/msm_gpu.h
drivers/gpu/drm/msm/msm_submitqueue.c

index 1ed4cd09dbf8bf82b4c2e9f6a385f9c54fe56057..d7ca025457b688c8dc8be2ce2d08c8b65adb120f 100644 (file)
@@ -883,13 +883,13 @@ static int wait_fence(struct msm_gpu_submitqueue *queue, uint32_t fence_id,
         * retired, so if the fence is not found it means there is nothing
         * to wait for
         */
-       ret = mutex_lock_interruptible(&queue->lock);
+       ret = mutex_lock_interruptible(&queue->idr_lock);
        if (ret)
                return ret;
        fence = idr_find(&queue->fence_idr, fence_id);
        if (fence)
                fence = dma_fence_get_rcu(fence);
-       mutex_unlock(&queue->lock);
+       mutex_unlock(&queue->idr_lock);
 
        if (!fence)
                return 0;
index c7819781879c28c32d58312cf6202eb597deaa5c..16c662808522fe66d6156dab495a5a8d34d0ebff 100644 (file)
@@ -72,9 +72,9 @@ void __msm_gem_submit_destroy(struct kref *kref)
        unsigned i;
 
        if (submit->fence_id) {
-               mutex_lock(&submit->queue->lock);
+               mutex_lock(&submit->queue->idr_lock);
                idr_remove(&submit->queue->fence_idr, submit->fence_id);
-               mutex_unlock(&submit->queue->lock);
+               mutex_unlock(&submit->queue->idr_lock);
        }
 
        dma_fence_put(submit->user_fence);
@@ -881,6 +881,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 
        submit->nr_cmds = i;
 
+       mutex_lock(&queue->idr_lock);
+
        /*
         * If using userspace provided seqno fence, validate that the id
         * is available before arming sched job.  Since access to fence_idr
@@ -889,6 +891,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
         */
        if ((args->flags & MSM_SUBMIT_FENCE_SN_IN) &&
                        idr_find(&queue->fence_idr, args->fence)) {
+               mutex_unlock(&queue->idr_lock);
                ret = -EINVAL;
                goto out;
        }
@@ -921,6 +924,9 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
                                                    submit->user_fence, 1,
                                                    INT_MAX, GFP_KERNEL);
        }
+
+       mutex_unlock(&queue->idr_lock);
+
        if (submit->fence_id < 0) {
                ret = submit->fence_id;
                submit->fence_id = 0;
index 4d935fedd2acc7593eb4fad1d71f9f031ea3e4ec..962d2070bcdfb3718e35f264436fb5b1d44847f2 100644 (file)
@@ -466,7 +466,8 @@ static inline int msm_gpu_convert_priority(struct msm_gpu *gpu, int prio,
  * @node:      node in the context's list of submitqueues
  * @fence_idr: maps fence-id to dma_fence for userspace visible fence
  *             seqno, protected by submitqueue lock
- * @lock:      submitqueue lock
+ * @idr_lock:  for serializing access to fence_idr
+ * @lock:      submitqueue lock for serializing submits on a queue
  * @ref:       reference count
  * @entity:    the submit job-queue
  */
@@ -479,6 +480,7 @@ struct msm_gpu_submitqueue {
        struct msm_file_private *ctx;
        struct list_head node;
        struct idr fence_idr;
+       struct mutex idr_lock;
        struct mutex lock;
        struct kref ref;
        struct drm_sched_entity *entity;
index f486a3cd4e5508995c0edd23474d6a445fe705ae..c6929e205b511e923e122e88e6fa32eabce9ab0a 100644 (file)
@@ -200,6 +200,7 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
                *id = queue->id;
 
        idr_init(&queue->fence_idr);
+       mutex_init(&queue->idr_lock);
        mutex_init(&queue->lock);
 
        list_add_tail(&queue->node, &ctx->submitqueues);