aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/msm/msm_submitqueue.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/msm/msm_submitqueue.c')
-rw-r--r--drivers/gpu/drm/msm/msm_submitqueue.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/gpu/drm/msm/msm_submitqueue.c b/drivers/gpu/drm/msm/msm_submitqueue.c
index 593c3b5f44cd..5115f75b5b7f 100644
--- a/drivers/gpu/drm/msm/msm_submitqueue.c
+++ b/drivers/gpu/drm/msm/msm_submitqueue.c
@@ -60,9 +60,10 @@ void msm_submitqueue_close(struct msm_file_private *ctx)
60 msm_submitqueue_put(entry); 60 msm_submitqueue_put(entry);
61} 61}
62 62
63int msm_submitqueue_create(struct msm_file_private *ctx, u32 prio, u32 flags, 63int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
64 u32 *id) 64 u32 prio, u32 flags, u32 *id)
65{ 65{
66 struct msm_drm_private *priv = drm->dev_private;
66 struct msm_gpu_submitqueue *queue; 67 struct msm_gpu_submitqueue *queue;
67 68
68 if (!ctx) 69 if (!ctx)
@@ -75,7 +76,13 @@ int msm_submitqueue_create(struct msm_file_private *ctx, u32 prio, u32 flags,
75 76
76 kref_init(&queue->ref); 77 kref_init(&queue->ref);
77 queue->flags = flags; 78 queue->flags = flags;
78 queue->prio = prio; 79
80 if (priv->gpu) {
81 if (prio >= priv->gpu->nr_rings)
82 return -EINVAL;
83
84 queue->prio = prio;
85 }
79 86
80 write_lock(&ctx->queuelock); 87 write_lock(&ctx->queuelock);
81 88
@@ -91,16 +98,26 @@ int msm_submitqueue_create(struct msm_file_private *ctx, u32 prio, u32 flags,
91 return 0; 98 return 0;
92} 99}
93 100
94int msm_submitqueue_init(struct msm_file_private *ctx) 101int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx)
95{ 102{
103 struct msm_drm_private *priv = drm->dev_private;
104 int default_prio;
105
96 if (!ctx) 106 if (!ctx)
97 return 0; 107 return 0;
98 108
109 /*
110 * Select priority 2 as the "default priority" unless nr_rings is less
111 * than 2 and then pick the lowest pirority
112 */
113 default_prio = priv->gpu ?
114 clamp_t(uint32_t, 2, 0, priv->gpu->nr_rings - 1) : 0;
115
99 INIT_LIST_HEAD(&ctx->submitqueues); 116 INIT_LIST_HEAD(&ctx->submitqueues);
100 117
101 rwlock_init(&ctx->queuelock); 118 rwlock_init(&ctx->queuelock);
102 119
103 return msm_submitqueue_create(ctx, 2, 0, NULL); 120 return msm_submitqueue_create(drm, ctx, default_prio, 0, NULL);
104} 121}
105 122
106int msm_submitqueue_remove(struct msm_file_private *ctx, u32 id) 123int msm_submitqueue_remove(struct msm_file_private *ctx, u32 id)