Skip to contentSkip to conversation

drm/amdgpu: add sched sync for amdgpu job

PATCH In review Chunming Zhou 2 participants 2 messages May 9, 2017 1 message not in the archive

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

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

Change-Id I26d3a2794272ba94b25753d4bf367326d12f6939
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c  | 7 ++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 ++++-
 3 files changed, 11 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 +6 -1
index 2c6624d..86ad507 100644
@@ -121,6 +121,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
 {
 	struct amdgpu_device *adev = ring->adev;
 	struct amdgpu_ib *ib = &ibs[0];
+	struct fence *tmp;
 	bool skip_preamble, need_ctx_switch;
 	unsigned patch_offset = ~0;
 	struct amdgpu_vm *vm;
@@ -167,8 +168,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): 1494317990-25036-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 33 lines · Chunming Zhou
Change-Id I26d3a2794272ba94b25753d4bf367326d12f6939
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c  | 7 ++++++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 ++++-
  3 files changed, 11 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 +1 -0
index 2c6624d..86ad507 100644
@@ -121,6 +121,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
  {
  	struct amdgpu_device *adev = ring->adev;
  	struct amdgpu_ib *ib = &ibs[0];
+	struct fence *tmp;
  	bool skip_preamble, need_ctx_switch;
  	unsigned patch_offset = ~0;
  	struct amdgpu_vm *vm;

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

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +3 -1
@@ -167,8 +168,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;

We might remove need_pipeline_sync now.

Jerry

Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2 -0
  		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