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 15:50:56 -0400 |
commit | 4a2de54dc1d7668fa364d8483420ba64b120963b (patch) | |
tree | dd30344ce3d833b037c9104a9e02aa26ba94c8f4 /drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |
parent | 72ef23de207bad349ddc648296f330e176ac175b (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 09703c87d676..b6e9df11115d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -1203,26 +1203,24 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | |||
1203 | 1203 | ||
1204 | int r; | 1204 | int r; |
1205 | 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 */ | ||
1206 | amdgpu_mn_lock(p->mn); | 1214 | amdgpu_mn_lock(p->mn); |
1207 | amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) { | 1215 | amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) { |
1208 | struct amdgpu_bo *bo = e->robj; | 1216 | struct amdgpu_bo *bo = e->robj; |
1209 | 1217 | ||
1210 | if (amdgpu_ttm_tt_userptr_needs_pages(bo->tbo.ttm)) { | 1218 | if (amdgpu_ttm_tt_userptr_needs_pages(bo->tbo.ttm)) { |
1211 | amdgpu_mn_unlock(p->mn); | 1219 | r = -ERESTARTSYS; |
1212 | return -ERESTARTSYS; | 1220 | goto error_abort; |
1213 | } | 1221 | } |
1214 | } | 1222 | } |
1215 | 1223 | ||
1216 | job = p->job; | ||
1217 | p->job = NULL; | ||
1218 | |||
1219 | r = drm_sched_job_init(&job->base, entity, p->filp); | ||
1220 | if (r) { | ||
1221 | amdgpu_job_free(job); | ||
1222 | amdgpu_mn_unlock(p->mn); | ||
1223 | return r; | ||
1224 | } | ||
1225 | |||
1226 | job->owner = p->filp; | 1224 | job->owner = p->filp; |
1227 | p->fence = dma_fence_get(&job->base.s_fence->finished); | 1225 | p->fence = dma_fence_get(&job->base.s_fence->finished); |
1228 | 1226 | ||
@@ -1260,6 +1258,15 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | |||
1260 | amdgpu_mn_unlock(p->mn); | 1258 | amdgpu_mn_unlock(p->mn); |
1261 | 1259 | ||
1262 | return 0; | 1260 | return 0; |
1261 | |||
1262 | error_abort: | ||
1263 | dma_fence_put(&job->base.s_fence->finished); | ||
1264 | job->base.s_fence = NULL; | ||
1265 | |||
1266 | error_unlock: | ||
1267 | amdgpu_job_free(job); | ||
1268 | amdgpu_mn_unlock(p->mn); | ||
1269 | return r; | ||
1263 | } | 1270 | } |
1264 | 1271 | ||
1265 | int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | 1272 | int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) |