[PATCH 1/4] amdgpu: use drm_amdgpu_fence instead of amdgpu_cs_fence in semaphore structure

Chunming Zhou David1.Zhou at amd.com
Thu Aug 18 07:55:56 UTC 2016


semaphore just need to store ctx id not context itself,
which will bring convenience for sharing semaphore accross process.

Change-Id: I46cf54c61ee6143a77d18510c3591bcc97fa8b24
Signed-off-by: Chunming Zhou <David1.Zhou at amd.com>
---
 amdgpu/amdgpu_cs.c       | 20 ++++++++++----------
 amdgpu/amdgpu_internal.h |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index bb0d79b..c76a675 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -284,13 +284,13 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
 		}
 		sem_count = 0;
 		LIST_FOR_EACH_ENTRY_SAFE(sem, tmp, sem_list, list) {
-			struct amdgpu_cs_fence *info = &sem->signal_fence;
+			struct drm_amdgpu_fence *info = &sem->signal_fence;
 			struct drm_amdgpu_cs_chunk_dep *dep = &sem_dependencies[sem_count++];
 			dep->ip_type = info->ip_type;
 			dep->ip_instance = info->ip_instance;
 			dep->ring = info->ring;
-			dep->ctx_id = info->context->id;
-			dep->handle = info->fence;
+			dep->ctx_id = info->ctx_id;
+			dep->handle = info->seq_no;
 
 			list_del(&sem->list);
 			amdgpu_cs_reset_sem(sem);
@@ -550,14 +550,14 @@ int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx,
 	if (NULL == sem)
 		return -EINVAL;
 	/* sem has been signaled */
-	if (sem->signal_fence.context)
+	if (sem->signal_fence.ctx_id)
 		return -EINVAL;
 	pthread_mutex_lock(&ctx->sequence_mutex);
-	sem->signal_fence.context = ctx;
+	sem->signal_fence.ctx_id = ctx->id;
 	sem->signal_fence.ip_type = ip_type;
 	sem->signal_fence.ip_instance = ip_instance;
 	sem->signal_fence.ring = ring;
-	sem->signal_fence.fence = ctx->last_seq[ip_type][ip_instance][ring];
+	sem->signal_fence.seq_no = ctx->last_seq[ip_type][ip_instance][ring];
 	update_references(NULL, &sem->refcount);
 	pthread_mutex_unlock(&ctx->sequence_mutex);
 	return 0;
@@ -578,7 +578,7 @@ int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
 	if (NULL == sem)
 		return -EINVAL;
 	/* must signal first */
-	if (NULL == sem->signal_fence.context)
+	if (0 == sem->signal_fence.ctx_id)
 		return -EINVAL;
 
 	pthread_mutex_lock(&ctx->sequence_mutex);
@@ -591,14 +591,14 @@ static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem)
 {
 	if (NULL == sem)
 		return -EINVAL;
-	if (NULL == sem->signal_fence.context)
+	if (0 == sem->signal_fence.ctx_id)
 		return -EINVAL;
 
-	sem->signal_fence.context = NULL;;
+	sem->signal_fence.ctx_id = 0;
 	sem->signal_fence.ip_type = 0;
 	sem->signal_fence.ip_instance = 0;
 	sem->signal_fence.ring = 0;
-	sem->signal_fence.fence = 0;
+	sem->signal_fence.seq_no = 0;
 
 	return 0;
 }
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
index 1160a12..ccc85d7 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -133,7 +133,7 @@ struct amdgpu_context {
 struct amdgpu_semaphore {
 	atomic_t refcount;
 	struct list_head list;
-	struct amdgpu_cs_fence signal_fence;
+	struct drm_amdgpu_fence signal_fence;
 };
 
 /**
-- 
1.9.1



More information about the amd-gfx mailing list