å?¨ 2018/8/24 20:50, Christian König å??é??: > We can't hold the mn_lock while allocating memory. if you could add some comments from what you discussed with Michal to explain why, it would be better. With that fixed, Acked-by: Chunming Zhou <david1.zhou at amd.com> David > > Signed-off-by: Christian König <christian.koenig at amd.com> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 30 +++++++++++++++----------- > 1 file changed, 18 insertions(+), 12 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > index 80ad23061f1c..34d18d9dfcbd 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > @@ -1194,26 +1194,23 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, > > int r; > > + job = p->job; > + p->job = NULL; > + > + r = drm_sched_job_init(&job->base, entity, p->filp); > + if (r) > + goto error_unlock; > + > amdgpu_mn_lock(p->mn); > amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) { > struct amdgpu_bo *bo = e->robj; > > if (amdgpu_ttm_tt_userptr_needs_pages(bo->tbo.ttm)) { > - amdgpu_mn_unlock(p->mn); > - return -ERESTARTSYS; > + r = -ERESTARTSYS; > + goto error_abort; > } > } > > - job = p->job; > - p->job = NULL; > - > - r = drm_sched_job_init(&job->base, entity, p->filp); > - if (r) { > - amdgpu_job_free(job); > - amdgpu_mn_unlock(p->mn); > - return r; > - } > - > job->owner = p->filp; > p->fence = dma_fence_get(&job->base.s_fence->finished); > > @@ -1243,6 +1240,15 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, > amdgpu_mn_unlock(p->mn); > > return 0; > + > +error_abort: > + dma_fence_put(&job->base.s_fence->finished); > + job->base.s_fence = NULL; > + > +error_unlock: > + amdgpu_job_free(job); > + amdgpu_mn_unlock(p->mn); > + return r; > } > > int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)