aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 502b94fb116a..b6e9df11115d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -1012,13 +1012,9 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
1012 if (r) 1012 if (r)
1013 return r; 1013 return r;
1014 1014
1015 if (chunk_ib->flags & AMDGPU_IB_FLAG_PREAMBLE) { 1015 if (chunk_ib->flags & AMDGPU_IB_FLAG_PREAMBLE)
1016 parser->job->preamble_status |= AMDGPU_PREAMBLE_IB_PRESENT; 1016 parser->job->preamble_status |=
1017 if (!parser->ctx->preamble_presented) { 1017 AMDGPU_PREAMBLE_IB_PRESENT;
1018 parser->job->preamble_status |= AMDGPU_PREAMBLE_IB_PRESENT_FIRST;
1019 parser->ctx->preamble_presented = true;
1020 }
1021 }
1022 1018
1023 if (parser->ring && parser->ring != ring) 1019 if (parser->ring && parser->ring != ring)
1024 return -EINVAL; 1020 return -EINVAL;
@@ -1207,26 +1203,24 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
1207 1203
1208 int r; 1204 int r;
1209 1205
1206 job = p->job;
1207 p->job = NULL;
1208
1209 r = drm_sched_job_init(&job->base, entity, p->filp);
1210 if (r)
1211 goto error_unlock;
1212
1213 /* No memory allocation is allowed while holding the mn lock */
1210 amdgpu_mn_lock(p->mn); 1214 amdgpu_mn_lock(p->mn);
1211 amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) { 1215 amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) {
1212 struct amdgpu_bo *bo = e->robj; 1216 struct amdgpu_bo *bo = e->robj;
1213 1217
1214 if (amdgpu_ttm_tt_userptr_needs_pages(bo->tbo.ttm)) { 1218 if (amdgpu_ttm_tt_userptr_needs_pages(bo->tbo.ttm)) {
1215 amdgpu_mn_unlock(p->mn); 1219 r = -ERESTARTSYS;
1216 return -ERESTARTSYS; 1220 goto error_abort;
1217 } 1221 }
1218 } 1222 }
1219 1223
1220 job = p->job;
1221 p->job = NULL;
1222
1223 r = drm_sched_job_init(&job->base, entity, p->filp);
1224 if (r) {
1225 amdgpu_job_free(job);
1226 amdgpu_mn_unlock(p->mn);
1227 return r;
1228 }
1229
1230 job->owner = p->filp; 1224 job->owner = p->filp;
1231 p->fence = dma_fence_get(&job->base.s_fence->finished); 1225 p->fence = dma_fence_get(&job->base.s_fence->finished);
1232 1226
@@ -1241,6 +1235,12 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
1241 1235
1242 amdgpu_cs_post_dependencies(p); 1236 amdgpu_cs_post_dependencies(p);
1243 1237
1238 if ((job->preamble_status & AMDGPU_PREAMBLE_IB_PRESENT) &&
1239 !p->ctx->preamble_presented) {
1240 job->preamble_status |= AMDGPU_PREAMBLE_IB_PRESENT_FIRST;
1241 p->ctx->preamble_presented = true;
1242 }
1243
1244 cs->out.handle = seq; 1244 cs->out.handle = seq;
1245 job->uf_sequence = seq; 1245 job->uf_sequence = seq;
1246 1246
@@ -1258,6 +1258,15 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
1258 amdgpu_mn_unlock(p->mn); 1258 amdgpu_mn_unlock(p->mn);
1259 1259
1260 return 0; 1260 return 0;
1261
1262error_abort:
1263 dma_fence_put(&job->base.s_fence->finished);
1264 job->base.s_fence = NULL;
1265
1266error_unlock:
1267 amdgpu_job_free(job);
1268 amdgpu_mn_unlock(p->mn);
1269 return r;
1261} 1270}
1262 1271
1263int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) 1272int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)