drm/msm: Small submitqueue creation cleanup
authorRob Clark <robdclark@chromium.org>
Wed, 28 Jul 2021 01:06:07 +0000 (18:06 -0700)
committerRob Clark <robdclark@chromium.org>
Wed, 28 Jul 2021 01:09:17 +0000 (18:09 -0700)
If we don't have a gpu, there is no need to create a submitqueue, which
lets us simplify the error handling and submitqueue creation.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Acked-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20210728010632.2633470-3-robdclark@gmail.com
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/msm_submitqueue.c

index e5eef11ed0149a5f25e40622e374cb7b223ae5c1..9e9fec61d629541a047086bb78e586a5e7c83e05 100644 (file)
@@ -66,6 +66,12 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
        if (!ctx)
                return -ENODEV;
 
+       if (!priv->gpu)
+               return -ENODEV;
+
+       if (prio >= priv->gpu->nr_rings)
+               return -EINVAL;
+
        queue = kzalloc(sizeof(*queue), GFP_KERNEL);
 
        if (!queue)
@@ -73,15 +79,7 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
 
        kref_init(&queue->ref);
        queue->flags = flags;
-
-       if (priv->gpu) {
-               if (prio >= priv->gpu->nr_rings) {
-                       kfree(queue);
-                       return -EINVAL;
-               }
-
-               queue->prio = prio;
-       }
+       queue->prio = prio;
 
        write_lock(&ctx->queuelock);
 
@@ -107,12 +105,14 @@ int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx)
        struct msm_drm_private *priv = drm->dev_private;
        int default_prio;
 
+       if (!priv->gpu)
+               return -ENODEV;
+
        /*
         * Select priority 2 as the "default priority" unless nr_rings is less
         * than 2 and then pick the lowest priority
         */
-       default_prio = priv->gpu ?
-               clamp_t(uint32_t, 2, 0, priv->gpu->nr_rings - 1) : 0;
+       default_prio = clamp_t(uint32_t, 2, 0, priv->gpu->nr_rings - 1);
 
        INIT_LIST_HEAD(&ctx->submitqueues);