From: "Christian König" <deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
To: Chunming Zhou <David1.Zhou-5C7GfCeVMHo@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 2/3] drm/amdgpu: fix dependency issue
Date: Tue, 9 May 2017 13:14:19 +0200 [thread overview]
Message-ID: <c7444009-6097-b2be-f4ad-1d9b846a4ac0@vodafone.de> (raw)
In-Reply-To: <1494317649-16751-2-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
Am 09.05.2017 um 10:14 schrieb Chunming Zhou:
> The problem is that executing the jobs in the right order doesn't give you the right result
> because consecutive jobs executed on the same engine are pipelined.
> In other words job B does it buffer read before job A has written it's result.
>
> Change-Id: I9065abf5bafbda7a92702ca11477315d25c9a347
> Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 +
> drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 ++
> drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 4 ++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-
> drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 17 +++++++++++++++++
> drivers/gpu/drm/amd/scheduler/gpu_scheduler.h | 2 ++
> 6 files changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index dd2bd9a..787acd7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -1169,6 +1169,7 @@ struct amdgpu_job {
> void *owner;
> uint64_t fence_ctx; /* the fence_context this job uses */
> bool vm_needs_flush;
> + bool need_pipeline_sync;
> unsigned vm_id;
> uint64_t vm_pd_addr;
> uint32_t gds_base, gds_size;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
> index 06202e2..2c6624d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
> @@ -167,6 +167,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
> return r;
> }
>
> + if (ring->funcs->emit_pipeline_sync && job && job->need_pipeline_sync)
> + amdgpu_ring_emit_pipeline_sync(ring);
We should probably clean that handling up at some point, but for now it
should work.
Patch is Reviewed-by: Christian König <christian.koenig@amd.com>.
> if (vm) {
> amdgpu_ring_insert_nop(ring, extra_nop); /* prevent CE go too fast than DE */
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> index 690ef3d..cfa97ab 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
> @@ -57,6 +57,7 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
> (*job)->vm = vm;
> (*job)->ibs = (void *)&(*job)[1];
> (*job)->num_ibs = num_ibs;
> + (*job)->need_pipeline_sync = false;
>
> amdgpu_sync_create(&(*job)->sync);
>
> @@ -152,6 +153,9 @@ static struct fence *amdgpu_job_dependency(struct amd_sched_job *sched_job)
> fence = amdgpu_sync_get_fence(&job->sync);
> }
>
> + if (amd_sched_dependency_optimized(fence, sched_job->s_entity))
> + job->need_pipeline_sync = true;
> +
> return fence;
> }
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index b35b853..b4f83fc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -738,7 +738,7 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job)
> if (ring->funcs->init_cond_exec)
> patch_offset = amdgpu_ring_init_cond_exec(ring);
>
> - if (ring->funcs->emit_pipeline_sync)
> + if (ring->funcs->emit_pipeline_sync && !job->need_pipeline_sync)
> amdgpu_ring_emit_pipeline_sync(ring);
>
> if (ring->funcs->emit_vm_flush && vm_flush_needed) {
> diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
> index 3c258c3..fec870a 100644
> --- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
> +++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
> @@ -235,6 +235,23 @@ static void amd_sched_entity_clear_dep(struct fence *f, struct fence_cb *cb)
> fence_put(f);
> }
>
> +bool amd_sched_dependency_optimized(struct fence* fence,
> + struct amd_sched_entity *entity)
> +{
> + struct amd_gpu_scheduler *sched = entity->sched;
> + struct amd_sched_fence *s_fence;
> +
> + if (!fence || fence_is_signaled(fence))
> + return false;
> + if (fence->context == entity->fence_context)
> + return true;
> + s_fence = to_amd_sched_fence(fence);
> + if (s_fence && s_fence->sched == sched)
> + return true;
> +
> + return false;
> +}
> +
> static bool amd_sched_entity_add_dependency_cb(struct amd_sched_entity *entity)
> {
> struct amd_gpu_scheduler *sched = entity->sched;
> diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
> index 2531b41..bfda90f 100644
> --- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
> +++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
> @@ -162,4 +162,6 @@ int amd_sched_job_init(struct amd_sched_job *job,
> void *owner);
> void amd_sched_hw_job_reset(struct amd_gpu_scheduler *sched);
> void amd_sched_job_recovery(struct amd_gpu_scheduler *sched);
> +bool amd_sched_dependency_optimized(struct fence* fence,
> + struct amd_sched_entity *entity);
> #endif
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2017-05-09 11:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-09 8:14 [PATCH 1/3] drm/amd: fix init order of sched job Chunming Zhou
[not found] ` <1494317649-16751-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-05-09 8:14 ` [PATCH 2/3] drm/amdgpu: fix dependency issue Chunming Zhou
[not found] ` <1494317649-16751-2-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-05-09 8:38 ` Zhang, Jerry (Junwei)
2017-05-09 11:14 ` Christian König [this message]
2017-05-09 8:14 ` [PATCH 3/3] drm/amdgpu: add sched sync for amdgpu job Chunming Zhou
[not found] ` <1494317649-16751-3-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-05-09 11:16 ` Christian König
[not found] ` <1ccd8f37-0297-315e-0355-f38b1b511924-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-05-10 1:58 ` zhoucm1
2017-05-09 8:33 ` [PATCH 1/3] drm/amd: fix init order of sched job Zhang, Jerry (Junwei)
[not found] ` <59117EE0.2040007-5C7GfCeVMHo@public.gmane.org>
2017-05-09 11:10 ` Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c7444009-6097-b2be-f4ad-1d9b846a4ac0@vodafone.de \
--to=deathsimple-antagkrnahcb1svskn2v4q@public.gmane.org \
--cc=David1.Zhou-5C7GfCeVMHo@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.