Commit 86c2a0f0 authored by Rob Clark's avatar Rob Clark

drm/msm: Small submitqueue creation cleanup

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: default avatarRob Clark <robdclark@chromium.org>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20210728010632.2633470-3-robdclark@gmail.comSigned-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 375f9a63
...@@ -66,6 +66,12 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx, ...@@ -66,6 +66,12 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
if (!ctx) if (!ctx)
return -ENODEV; return -ENODEV;
if (!priv->gpu)
return -ENODEV;
if (prio >= priv->gpu->nr_rings)
return -EINVAL;
queue = kzalloc(sizeof(*queue), GFP_KERNEL); queue = kzalloc(sizeof(*queue), GFP_KERNEL);
if (!queue) if (!queue)
...@@ -73,15 +79,7 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx, ...@@ -73,15 +79,7 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
kref_init(&queue->ref); kref_init(&queue->ref);
queue->flags = flags; queue->flags = flags;
queue->prio = prio;
if (priv->gpu) {
if (prio >= priv->gpu->nr_rings) {
kfree(queue);
return -EINVAL;
}
queue->prio = prio;
}
write_lock(&ctx->queuelock); write_lock(&ctx->queuelock);
...@@ -107,12 +105,14 @@ int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx) ...@@ -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; struct msm_drm_private *priv = drm->dev_private;
int default_prio; int default_prio;
if (!priv->gpu)
return -ENODEV;
/* /*
* Select priority 2 as the "default priority" unless nr_rings is less * Select priority 2 as the "default priority" unless nr_rings is less
* than 2 and then pick the lowest priority * than 2 and then pick the lowest priority
*/ */
default_prio = priv->gpu ? default_prio = clamp_t(uint32_t, 2, 0, priv->gpu->nr_rings - 1);
clamp_t(uint32_t, 2, 0, priv->gpu->nr_rings - 1) : 0;
INIT_LIST_HEAD(&ctx->submitqueues); INIT_LIST_HEAD(&ctx->submitqueues);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment