Skip to contentSkip to conversation

drm/amd: fix init order of sched job

PATCH In review Chunming Zhou 3 participants 9 messages May 9, 2017 – May 10, 2017 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/amd: fix init order of sched job

Change-Id Iced391f5c24a79ad7aecae33e22ff089f68f1337
---
 drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +1 -1
index 80bc4f7..3c258c3 100644
@@ -460,9 +460,9 @@ int amd_sched_job_init(struct amd_sched_job *job,
 	job->sched = sched;
 	job->s_entity = entity;
 	job->s_fence = amd_sched_fence_create(entity, owner);
-	job->id = atomic64_inc_return(&sched->job_id_count);
 	if (!job->s_fence)
 		return -ENOMEM;
+	job->id = atomic64_inc_return(&sched->job_id_count);
 
 	INIT_WORK(&job->finish_work, amd_sched_job_finish);
 	INIT_LIST_HEAD(&job->node);
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1494317649-16751-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/3 drm/amdgpu: fix dependency issue

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
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index dd2bd9a..787acd7 100644
@@ -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;
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2 -0
index 06202e2..2c6624d 100644
@@ -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);
 	if (vm) {
 		amdgpu_ring_insert_nop(ring, extra_nop); /* prevent CE go too fast than DE */
 
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4 -0
index 690ef3d..cfa97ab 100644
@@ -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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
index b35b853..b4f83fc 100644
@@ -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) {
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +17 -0
index 3c258c3..fec870a 100644
@@ -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;
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +2 -0
index 2531b41..bfda90f 100644
@@ -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
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1494317649-16751-2-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 2/3] drm/amdgpu: fix dependency issue

Quoted 67 lines · 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
---
  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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index dd2bd9a..787acd7 100644
@@ -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;
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2 -0
index 06202e2..2c6624d 100644
@@ -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);
  	if (vm) {
  		amdgpu_ring_insert_nop(ring, extra_nop); /* prevent CE go too fast than DE */
 
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4 -0
index 690ef3d..cfa97ab 100644
@@ -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;
  }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index b35b853..b4f83fc 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) · line 741

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -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)

Perhaps we could emit pipeline sync regardless of the flag need_pipeline_sync. Could you explain the reason about this change?

Jerry

Quoted 37 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
  		amdgpu_ring_emit_pipeline_sync(ring);
 
  	if (ring->funcs->emit_vm_flush && vm_flush_needed) {
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +17 -0
index 3c258c3..fec870a 100644
@@ -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;
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +0 -0
index 2531b41..bfda90f 100644

drivers/gpu/drm/amd/scheduler/gpu_scheduler.h int amd_sched_job_init(struct amd_sched_job *job, · line 167

Quoted 6 lines
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +2 -0
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw

Re: [PATCH 2/3] drm/amdgpu: fix dependency issue

In reply to a message not in the archive

Am 09.05.2017 um 10:14 schrieb Chunming Zhou:

Quoted 32 lines

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
---
  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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index dd2bd9a..787acd7 100644
@@ -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;
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0 -0
index 06202e2..2c6624d 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, · line 171

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2 -0
@@ -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 <[email protected]>.

Quoted 71 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0 -0
  	if (vm) {
  		amdgpu_ring_insert_nop(ring, extra_nop); /* prevent CE go too fast than DE */
 
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4 -0
index 690ef3d..cfa97ab 100644
@@ -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;
  }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
index b35b853..b4f83fc 100644
@@ -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) {
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +17 -0
index 3c258c3..fec870a 100644
@@ -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;
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +0 -0
index 2531b41..bfda90f 100644

drivers/gpu/drm/amd/scheduler/gpu_scheduler.h int amd_sched_job_init(struct amd_sched_job *job, · line 167

Quoted 6 lines
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +2 -0
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#6 lore raw

PATCH 3/3 drm/amdgpu: add sched sync for amdgpu job

In reply to a message not in the archive
Change-Id I26d3a2794272ba94b25753d4bf367326d12f6939
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c  | 6 +++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 ++++-
 3 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 787acd7..ef018bf 100644
@@ -1162,6 +1162,7 @@ struct amdgpu_job {
 	struct amdgpu_vm	*vm;
 	struct amdgpu_ring	*ring;
 	struct amdgpu_sync	sync;
+	struct amdgpu_sync	sched_sync;
 	struct amdgpu_ib	*ibs;
 	struct fence		*fence; /* the hw fence */
 	uint32_t		preamble_status;
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +5 -1
index 2c6624d..d7f75bc 100644
@@ -167,8 +167,12 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
 		return r;
 	}
 
-	if (ring->funcs->emit_pipeline_sync && job && job->need_pipeline_sync)
+	if (ring->funcs->emit_pipeline_sync && job &&
+	    (tmp = amdgpu_sync_get_fence(&job->sched_sync))) {
+		job->need_pipeline_sync = true;
 		amdgpu_ring_emit_pipeline_sync(ring);
+		fence_put(tmp);
+	}
 	if (vm) {
 		amdgpu_ring_insert_nop(ring, extra_nop); /* prevent CE go too fast than DE */
 
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4 -1
index cfa97ab..fa0c8b1 100644
@@ -60,6 +60,7 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
 	(*job)->need_pipeline_sync = false;
 
 	amdgpu_sync_create(&(*job)->sync);
+	amdgpu_sync_create(&(*job)->sched_sync);
 
 	return 0;
 }
@@ -98,6 +99,7 @@ static void amdgpu_job_free_cb(struct amd_sched_job *s_job)
 
 	fence_put(job->fence);
 	amdgpu_sync_free(&job->sync);
+	amdgpu_sync_free(&job->sched_sync);
 	kfree(job);
 }
 
@@ -107,6 +109,7 @@ void amdgpu_job_free(struct amdgpu_job *job)
 
 	fence_put(job->fence);
 	amdgpu_sync_free(&job->sync);
+	amdgpu_sync_free(&job->sched_sync);
 	kfree(job);
 }
 
@@ -154,7 +157,7 @@ static struct fence *amdgpu_job_dependency(struct amd_sched_job *sched_job)
 	}
 
 	if (amd_sched_dependency_optimized(fence, sched_job->s_entity))
-		job->need_pipeline_sync = true;
+		amdgpu_sync_fence(job->adev, &job->sched_sync, fence);
 
 	return fence;
 }
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1494317649-16751-3-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org

#8 lore raw

Re: [PATCH 3/3] drm/amdgpu: add sched sync for amdgpu job

What's the background of this change? E.g. why it is needed?

Christian.

Am 09.05.2017 um 10:14 schrieb Chunming Zhou:

Quoted 67 lines
Change-Id I26d3a2794272ba94b25753d4bf367326d12f6939
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c  | 6 +++++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 ++++-
  3 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 787acd7..ef018bf 100644
@@ -1162,6 +1162,7 @@ struct amdgpu_job {
  	struct amdgpu_vm	*vm;
  	struct amdgpu_ring	*ring;
  	struct amdgpu_sync	sync;
+	struct amdgpu_sync	sched_sync;
  	struct amdgpu_ib	*ibs;
  	struct fence		*fence; /* the hw fence */
  	uint32_t		preamble_status;
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +5 -1
index 2c6624d..d7f75bc 100644
@@ -167,8 +167,12 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
  		return r;
  	}
 
-	if (ring->funcs->emit_pipeline_sync && job && job->need_pipeline_sync)
+	if (ring->funcs->emit_pipeline_sync && job &&
+	    (tmp = amdgpu_sync_get_fence(&job->sched_sync))) {
+		job->need_pipeline_sync = true;
  		amdgpu_ring_emit_pipeline_sync(ring);
+		fence_put(tmp);
+	}
  	if (vm) {
  		amdgpu_ring_insert_nop(ring, extra_nop); /* prevent CE go too fast than DE */
 
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +3 -0
index cfa97ab..fa0c8b1 100644
@@ -60,6 +60,7 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
  	(*job)->need_pipeline_sync = false;
 
  	amdgpu_sync_create(&(*job)->sync);
+	amdgpu_sync_create(&(*job)->sched_sync);
 
  	return 0;
  }
@@ -98,6 +99,7 @@ static void amdgpu_job_free_cb(struct amd_sched_job *s_job)
 
  	fence_put(job->fence);
  	amdgpu_sync_free(&job->sync);
+	amdgpu_sync_free(&job->sched_sync);
  	kfree(job);
  }
 
@@ -107,6 +109,7 @@ void amdgpu_job_free(struct amdgpu_job *job)
 
  	fence_put(job->fence);
  	amdgpu_sync_free(&job->sync);
+	amdgpu_sync_free(&job->sched_sync);
  	kfree(job);
  }
 

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c static struct fence *amdgpu_job_dependency(struct amd_sched_job *sched_job) · line 163

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
@@ -154,7 +157,7 @@ static struct fence *amdgpu_job_dependency(struct amd_sched_job *sched_job)
  	}
 
  	if (amd_sched_dependency_optimized(fence, sched_job->s_entity))
-		job->need_pipeline_sync = true;
+		amdgpu_sync_fence(job->adev, &job->sched_sync, fence);
 
  	return fence;
  }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1ccd8f37-0297-315e-0355-f38b1b511924-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#10 lore raw

Re: [PATCH 3/3] drm/amdgpu: add sched sync for amdgpu job

Quoted 1 line · Christian König

What's the background of this change? E.g. why it is needed?

price question, maybe I should describe more in patch comment, I think this is an improvement for previous patch, the sched_sync is to store fence that could be skipped as scheduled, when job is executed, we didn't need pipeline_sync if all fences in sched_sync are signalled, otherwise insert pipeline_sync still.

Regards,
David Zhou

Quoted 68 lines

Christian.

Am 09.05.2017 um 10:14 schrieb Chunming Zhou:

Quoted 64 lines
Change-Id I26d3a2794272ba94b25753d4bf367326d12f6939
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c  | 6 +++++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 ++++-
  3 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 787acd7..ef018bf 100644
@@ -1162,6 +1162,7 @@ struct amdgpu_job {
      struct amdgpu_vm    *vm;
      struct amdgpu_ring    *ring;
      struct amdgpu_sync    sync;
+    struct amdgpu_sync    sched_sync;
      struct amdgpu_ib    *ibs;
      struct fence        *fence; /* the hw fence */
      uint32_t        preamble_status;
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +5 -0
index 2c6624d..d7f75bc 100644
@@ -167,8 +167,12 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, 
 unsigned num_ibs,
          return r;
      }
  -    if (ring->funcs->emit_pipeline_sync && job && 
 job->need_pipeline_sync)
+    if (ring->funcs->emit_pipeline_sync && job &&
+        (tmp = amdgpu_sync_get_fence(&job->sched_sync))) {
+        job->need_pipeline_sync = true;
          amdgpu_ring_emit_pipeline_sync(ring);
+        fence_put(tmp);
+    }
      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 cfa97ab..fa0c8b1 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
@@ -60,6 +60,7 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, 
 unsigned num_ibs,
      (*job)->need_pipeline_sync = false;
        amdgpu_sync_create(&(*job)->sync);
+    amdgpu_sync_create(&(*job)->sched_sync);
        return 0;
  }
@@ -98,6 +99,7 @@ static void amdgpu_job_free_cb(struct amd_sched_job 
 *s_job)
        fence_put(job->fence);
      amdgpu_sync_free(&job->sync);
+    amdgpu_sync_free(&job->sched_sync);
      kfree(job);
  }
  @@ -107,6 +109,7 @@ void amdgpu_job_free(struct amdgpu_job *job)
        fence_put(job->fence);
      amdgpu_sync_free(&job->sync);
+    amdgpu_sync_free(&job->sched_sync);
      kfree(job);

}

Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c static struct fence *amdgpu_job_dependency(struct amd_sched_job *sched_job) · line 163

Quoted 8 lines

@@ -154,7 +157,7 @@ static struct fence
*amdgpu_job_dependency(struct amd_sched_job *sched_job)

      }
        if (amd_sched_dependency_optimized(fence, sched_job->s_entity))
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
-        job->need_pipeline_sync = true;
+        amdgpu_sync_fence(job->adev, &job->sched_sync, fence);
        return fence;
  }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by Junwei Zhang
#11 lore raw
In reply to a message not in the archive
Quoted 2 lines · Chunming Zhou
Change-Id Iced391f5c24a79ad7aecae33e22ff089f68f1337

Good catch!

Quoted 10 lines
---
  drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +0 -0
index 80bc4f7..3c258c3 100644

drivers/gpu/drm/amd/scheduler/gpu_scheduler.c int amd_sched_job_init(struct amd_sched_job *job, · line 468

Quoted 10 lines
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +1 -1
@@ -460,9 +460,9 @@ int amd_sched_job_init(struct amd_sched_job *job,
  	job->sched = sched;
  	job->s_entity = entity;
  	job->s_fence = amd_sched_fence_create(entity, owner);
-	job->id = atomic64_inc_return(&sched->job_id_count);
  	if (!job->s_fence)
  		return -ENOMEM;
+	job->id = atomic64_inc_return(&sched->job_id_count);
 
  	INIT_WORK(&job->finish_work, amd_sched_job_finish);
  	INIT_LIST_HEAD(&job->node);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#13 lore raw

Am 09.05.2017 um 10:33 schrieb Zhang, Jerry (Junwei):

Quoted 6 lines · Chunming Zhou
Quoted 2 lines
Change-Id Iced391f5c24a79ad7aecae33e22ff089f68f1337

Good catch!

Indeed, nice catch.

Quoted 18 lines
Quoted 18 lines
---
  drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +1 -1
index 80bc4f7..3c258c3 100644
@@ -460,9 +460,9 @@ int amd_sched_job_init(struct amd_sched_job *job,
      job->sched = sched;
      job->s_entity = entity;
      job->s_fence = amd_sched_fence_create(entity, owner);
-    job->id = atomic64_inc_return(&sched->job_id_count);
      if (!job->s_fence)
          return -ENOMEM;
+    job->id = atomic64_inc_return(&sched->job_id_count);
 
Quoted 7 lines

drivers/gpu/drm/amd/scheduler/gpu_scheduler.c int amd_sched_job_init(struct amd_sched_job *job, · line 468

Quoted 3 lines
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +0 -0
      INIT_WORK(&job->finish_work, amd_sched_job_finish);
      INIT_LIST_HEAD(&job->node);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx