diff options
author | Christian König <christian.koenig@amd.com> | 2018-08-24 08:48:02 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-08-27 16:12:17 -0400 |
commit | 4f9ea1d0d1ed914092d9e03d87d80fa7e63ecc8f (patch) | |
tree | c6c198ee4870eba7c64b734606136bb87e7c4594 /drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |
parent | 85eff20020a656b2d13b33dc4681523508fee037 (diff) |
drm/amdgpu: fix holding mn_lock while allocating memory
We can't hold the mn_lock while allocating memory.
Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index adc6a43e2333..dd734970e167 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -1194,26 +1194,24 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | |||
1194 | 1194 | ||
1195 | int r; | 1195 | int r; |
1196 | 1196 | ||
1197 | job = p->job; | ||
1198 | p->job = NULL; | ||
1199 | |||
1200 | r = drm_sched_job_init(&job->base, entity, p->filp); | ||
1201 | if (r) | ||
1202 | goto error_unlock; | ||
1203 | |||
1204 | /* No memory allocation is allowed while holding the mn lock */ | ||
1197 | amdgpu_mn_lock(p->mn); | 1205 | amdgpu_mn_lock(p->mn); |
1198 | amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) { | 1206 | amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) { |
1199 | struct amdgpu_bo *bo = e->robj; | 1207 | struct amdgpu_bo *bo = e->robj; |
1200 | 1208 | ||
1201 | if (amdgpu_ttm_tt_userptr_needs_pages(bo->tbo.ttm)) { | 1209 | if (amdgpu_ttm_tt_userptr_needs_pages(bo->tbo.ttm)) { |
1202 | amdgpu_mn_unlock(p->mn); | 1210 | r = -ERESTARTSYS; |
1203 | return -ERESTARTSYS; | 1211 | goto error_abort; |
1204 | } | 1212 | } |
1205 | } | 1213 | } |
1206 | 1214 | ||
1207 | job = p->job; | ||
1208 | p->job = NULL; | ||
1209 | |||
1210 | r = drm_sched_job_init(&job->base, entity, p->filp); | ||
1211 | if (r) { | ||
1212 | amdgpu_job_free(job); | ||
1213 | amdgpu_mn_unlock(p->mn); | ||
1214 | return r; | ||
1215 | } | ||
1216 | |||
1217 | job->owner = p->filp; | 1215 | job->owner = p->filp; |
1218 | p->fence = dma_fence_get(&job->base.s_fence->finished); | 1216 | p->fence = dma_fence_get(&job->base.s_fence->finished); |
1219 | 1217 | ||
@@ -1243,6 +1241,15 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | |||
1243 | amdgpu_mn_unlock(p->mn); | 1241 | amdgpu_mn_unlock(p->mn); |
1244 | 1242 | ||
1245 | return 0; | 1243 | return 0; |
1244 | |||
1245 | error_abort: | ||
1246 | dma_fence_put(&job->base.s_fence->finished); | ||
1247 | job->base.s_fence = NULL; | ||
1248 | |||
1249 | error_unlock: | ||
1250 | amdgpu_job_free(job); | ||
1251 | amdgpu_mn_unlock(p->mn); | ||
1252 | return r; | ||
1246 | } | 1253 | } |
1247 | 1254 | ||
1248 | int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | 1255 | int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) |