* [PATCH 1/2] drm/amdgpu: amdgpu_ctx_add_fence can't fail
@ 2018-08-24 12:50 Christian König
[not found] ` <20180824125016.1315-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Christian König @ 2018-08-24 12:50 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: mhocko-DgEjT+Ai2ygdnm+yROfE0A
No more waiting for a fence done here.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 10 +---------
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 8 +++-----
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 6 +++---
3 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index fd3902983195..80ad23061f1c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -1217,15 +1217,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
job->owner = p->filp;
p->fence = dma_fence_get(&job->base.s_fence->finished);
- r = amdgpu_ctx_add_fence(p->ctx, entity, p->fence, &seq);
- if (r) {
- dma_fence_put(p->fence);
- dma_fence_put(&job->base.s_fence->finished);
- amdgpu_job_free(job);
- amdgpu_mn_unlock(p->mn);
- return r;
- }
-
+ amdgpu_ctx_add_fence(p->ctx, entity, p->fence, &seq);
amdgpu_cs_post_dependencies(p);
if ((job->preamble_status & AMDGPU_PREAMBLE_IB_PRESENT) &&
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 987b7f256463..f9b54236102d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -434,9 +434,9 @@ int amdgpu_ctx_put(struct amdgpu_ctx *ctx)
return 0;
}
-int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx,
- struct drm_sched_entity *entity,
- struct dma_fence *fence, uint64_t* handle)
+void amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx,
+ struct drm_sched_entity *entity,
+ struct dma_fence *fence, uint64_t* handle)
{
struct amdgpu_ctx_entity *centity = to_amdgpu_ctx_entity(entity);
uint64_t seq = centity->sequence;
@@ -458,8 +458,6 @@ int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx,
dma_fence_put(other);
if (handle)
*handle = seq;
-
- return 0;
}
struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h
index d67c1d285a4f..b3b012c0a7da 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h
@@ -65,9 +65,9 @@ int amdgpu_ctx_put(struct amdgpu_ctx *ctx);
int amdgpu_ctx_get_entity(struct amdgpu_ctx *ctx, u32 hw_ip, u32 instance,
u32 ring, struct drm_sched_entity **entity);
-int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx,
- struct drm_sched_entity *entity,
- struct dma_fence *fence, uint64_t *seq);
+void amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx,
+ struct drm_sched_entity *entity,
+ struct dma_fence *fence, uint64_t *seq);
struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
struct drm_sched_entity *entity,
uint64_t seq);
--
2.17.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <20180824125016.1315-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>]
* [PATCH 2/2] drm/amdgpu: fix holding mn_lock while allocating memory [not found] ` <20180824125016.1315-1-christian.koenig-5C7GfCeVMHo@public.gmane.org> @ 2018-08-24 12:50 ` Christian König [not found] ` <20180824125016.1315-2-christian.koenig-5C7GfCeVMHo@public.gmane.org> 2018-08-24 13:24 ` [PATCH 1/2] drm/amdgpu: amdgpu_ctx_add_fence can't fail Chunming Zhou 2018-08-27 2:09 ` Zhang, Jerry (Junwei) 2 siblings, 1 reply; 5+ messages in thread From: Christian König @ 2018-08-24 12:50 UTC (permalink / raw) To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: mhocko-DgEjT+Ai2ygdnm+yROfE0A We can't hold the mn_lock while allocating memory. Signed-off-by: Christian König <christian.koenig@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) -- 2.17.1 _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <20180824125016.1315-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>]
* Re: [PATCH 2/2] drm/amdgpu: fix holding mn_lock while allocating memory [not found] ` <20180824125016.1315-2-christian.koenig-5C7GfCeVMHo@public.gmane.org> @ 2018-08-24 13:35 ` Chunming Zhou 0 siblings, 0 replies; 5+ messages in thread From: Chunming Zhou @ 2018-08-24 13:35 UTC (permalink / raw) To: Christian König, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW Cc: mhocko-DgEjT+Ai2ygdnm+yROfE0A 在 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@amd.com> David > > Signed-off-by: Christian König <christian.koenig@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) _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] drm/amdgpu: amdgpu_ctx_add_fence can't fail [not found] ` <20180824125016.1315-1-christian.koenig-5C7GfCeVMHo@public.gmane.org> 2018-08-24 12:50 ` [PATCH 2/2] drm/amdgpu: fix holding mn_lock while allocating memory Christian König @ 2018-08-24 13:24 ` Chunming Zhou 2018-08-27 2:09 ` Zhang, Jerry (Junwei) 2 siblings, 0 replies; 5+ messages in thread From: Chunming Zhou @ 2018-08-24 13:24 UTC (permalink / raw) To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW 在 2018/8/24 20:50, Christian König 写道: > No more waiting for a fence done here. > > Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Chunming Zhou <david1.zhou@amd.com> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 10 +--------- > drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 8 +++----- > drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 6 +++--- > 3 files changed, 7 insertions(+), 17 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > index fd3902983195..80ad23061f1c 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > @@ -1217,15 +1217,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, > job->owner = p->filp; > p->fence = dma_fence_get(&job->base.s_fence->finished); > > - r = amdgpu_ctx_add_fence(p->ctx, entity, p->fence, &seq); > - if (r) { > - dma_fence_put(p->fence); > - dma_fence_put(&job->base.s_fence->finished); > - amdgpu_job_free(job); > - amdgpu_mn_unlock(p->mn); > - return r; > - } > - > + amdgpu_ctx_add_fence(p->ctx, entity, p->fence, &seq); > amdgpu_cs_post_dependencies(p); > > if ((job->preamble_status & AMDGPU_PREAMBLE_IB_PRESENT) && > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c > index 987b7f256463..f9b54236102d 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c > @@ -434,9 +434,9 @@ int amdgpu_ctx_put(struct amdgpu_ctx *ctx) > return 0; > } > > -int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, > - struct drm_sched_entity *entity, > - struct dma_fence *fence, uint64_t* handle) > +void amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, > + struct drm_sched_entity *entity, > + struct dma_fence *fence, uint64_t* handle) > { > struct amdgpu_ctx_entity *centity = to_amdgpu_ctx_entity(entity); > uint64_t seq = centity->sequence; > @@ -458,8 +458,6 @@ int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, > dma_fence_put(other); > if (handle) > *handle = seq; > - > - return 0; > } > > struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h > index d67c1d285a4f..b3b012c0a7da 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h > @@ -65,9 +65,9 @@ int amdgpu_ctx_put(struct amdgpu_ctx *ctx); > > int amdgpu_ctx_get_entity(struct amdgpu_ctx *ctx, u32 hw_ip, u32 instance, > u32 ring, struct drm_sched_entity **entity); > -int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, > - struct drm_sched_entity *entity, > - struct dma_fence *fence, uint64_t *seq); > +void amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, > + struct drm_sched_entity *entity, > + struct dma_fence *fence, uint64_t *seq); > struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, > struct drm_sched_entity *entity, > uint64_t seq); _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] drm/amdgpu: amdgpu_ctx_add_fence can't fail [not found] ` <20180824125016.1315-1-christian.koenig-5C7GfCeVMHo@public.gmane.org> 2018-08-24 12:50 ` [PATCH 2/2] drm/amdgpu: fix holding mn_lock while allocating memory Christian König 2018-08-24 13:24 ` [PATCH 1/2] drm/amdgpu: amdgpu_ctx_add_fence can't fail Chunming Zhou @ 2018-08-27 2:09 ` Zhang, Jerry (Junwei) 2 siblings, 0 replies; 5+ messages in thread From: Zhang, Jerry (Junwei) @ 2018-08-27 2:09 UTC (permalink / raw) To: Christian König, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW Cc: mhocko-DgEjT+Ai2ygdnm+yROfE0A On 08/24/2018 08:50 PM, Christian König wrote: > No more waiting for a fence done here. > > Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 10 +--------- > drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 8 +++----- > drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 6 +++--- > 3 files changed, 7 insertions(+), 17 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > index fd3902983195..80ad23061f1c 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > @@ -1217,15 +1217,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, > job->owner = p->filp; > p->fence = dma_fence_get(&job->base.s_fence->finished); > > - r = amdgpu_ctx_add_fence(p->ctx, entity, p->fence, &seq); > - if (r) { > - dma_fence_put(p->fence); > - dma_fence_put(&job->base.s_fence->finished); > - amdgpu_job_free(job); > - amdgpu_mn_unlock(p->mn); > - return r; > - } > - > + amdgpu_ctx_add_fence(p->ctx, entity, p->fence, &seq); > amdgpu_cs_post_dependencies(p); > > if ((job->preamble_status & AMDGPU_PREAMBLE_IB_PRESENT) && > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c > index 987b7f256463..f9b54236102d 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c > @@ -434,9 +434,9 @@ int amdgpu_ctx_put(struct amdgpu_ctx *ctx) > return 0; > } > > -int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, > - struct drm_sched_entity *entity, > - struct dma_fence *fence, uint64_t* handle) > +void amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, > + struct drm_sched_entity *entity, > + struct dma_fence *fence, uint64_t* handle) > { > struct amdgpu_ctx_entity *centity = to_amdgpu_ctx_entity(entity); > uint64_t seq = centity->sequence; > @@ -458,8 +458,6 @@ int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, > dma_fence_put(other); > if (handle) > *handle = seq; > - > - return 0; > } > > struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h > index d67c1d285a4f..b3b012c0a7da 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h > @@ -65,9 +65,9 @@ int amdgpu_ctx_put(struct amdgpu_ctx *ctx); > > int amdgpu_ctx_get_entity(struct amdgpu_ctx *ctx, u32 hw_ip, u32 instance, > u32 ring, struct drm_sched_entity **entity); > -int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, > - struct drm_sched_entity *entity, > - struct dma_fence *fence, uint64_t *seq); > +void amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, > + struct drm_sched_entity *entity, > + struct dma_fence *fence, uint64_t *seq); > struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, > struct drm_sched_entity *entity, > uint64_t seq); > _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-08-27 2:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-24 12:50 [PATCH 1/2] drm/amdgpu: amdgpu_ctx_add_fence can't fail Christian König
[not found] ` <20180824125016.1315-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-24 12:50 ` [PATCH 2/2] drm/amdgpu: fix holding mn_lock while allocating memory Christian König
[not found] ` <20180824125016.1315-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-24 13:35 ` Chunming Zhou
2018-08-24 13:24 ` [PATCH 1/2] drm/amdgpu: amdgpu_ctx_add_fence can't fail Chunming Zhou
2018-08-27 2:09 ` Zhang, Jerry (Junwei)
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.