summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlora Cui <Flora.Cui@amd.com>2017-01-12 11:03:44 +0800
committerQiang Yu <Qiang.Yu@amd.com>2017-05-17 11:15:03 +0800
commit4b1a756125a0cc53a084656a643d36547ead0c02 (patch)
tree6a5cfb2c76188f566e1e65ee2c3bc35c673b70db
parent4735df3e90422ad11316128b729c23850710e42d (diff)
implement import/export sem
Change-Id: I4900fbb046c912a905eded8a8349fa98b3ba822b Signed-off-by: Flora Cui <Flora.Cui@amd.com> Acked-by: Hawking Zhang <Hawking.Zhang@amd.com>
-rw-r--r--amdgpu/amdgpu.h8
-rw-r--r--amdgpu/amdgpu_cs.c43
-rw-r--r--include/drm/amdgpu_drm.h2
3 files changed, 53 insertions, 0 deletions
diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
index 6b8b3774..233533a3 100644
--- a/amdgpu/amdgpu.h
+++ b/amdgpu/amdgpu.h
@@ -1638,6 +1638,14 @@ int amdgpu_cs_wait_sem(amdgpu_device_handle dev,
uint32_t ring,
amdgpu_sem_handle sem);
+int amdgpu_cs_export_sem(amdgpu_device_handle dev,
+ amdgpu_sem_handle sem,
+ int *shared_handle);
+
+int amdgpu_cs_import_sem(amdgpu_device_handle dev,
+ int shared_handle,
+ amdgpu_sem_handle *sem);
+
/**
* destroy sem
*
diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index e1160a47..087e1d4a 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -668,6 +668,49 @@ int amdgpu_cs_wait_sem(amdgpu_device_handle dev,
return drmCommandWriteRead(dev->fd, DRM_AMDGPU_SEM, &args, sizeof(args));
}
+int amdgpu_cs_export_sem(amdgpu_device_handle dev,
+ amdgpu_sem_handle sem,
+ int *shared_handle)
+{
+ union drm_amdgpu_sem args;
+ int r;
+
+ if (NULL == dev)
+ return -EINVAL;
+
+ /* Create the context */
+ memset(&args, 0, sizeof(args));
+ args.in.op = AMDGPU_SEM_OP_EXPORT_SEM;
+ args.in.handle = sem;
+ r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_SEM, &args, sizeof(args));
+ if (r)
+ return r;
+ *shared_handle = args.out.fd;
+ return 0;
+}
+
+int amdgpu_cs_import_sem(amdgpu_device_handle dev,
+ int shared_handle,
+ amdgpu_sem_handle *sem)
+{
+ union drm_amdgpu_sem args;
+ int r;
+
+ if (NULL == dev)
+ return -EINVAL;
+
+ /* Create the context */
+ memset(&args, 0, sizeof(args));
+ args.in.op = AMDGPU_SEM_OP_IMPORT_SEM;
+ args.in.handle = shared_handle;
+ r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_SEM, &args, sizeof(args));
+ if (r)
+ return r;
+ *sem = args.out.handle;
+ return 0;
+}
+
+
int amdgpu_cs_destroy_sem(amdgpu_device_handle dev,
amdgpu_sem_handle sem)
{
diff --git a/include/drm/amdgpu_drm.h b/include/drm/amdgpu_drm.h
index a551ba7d..5f775c91 100644
--- a/include/drm/amdgpu_drm.h
+++ b/include/drm/amdgpu_drm.h
@@ -214,6 +214,8 @@ union drm_amdgpu_ctx {
#define AMDGPU_SEM_OP_WAIT_SEM 2
#define AMDGPU_SEM_OP_SIGNAL_SEM 3
#define AMDGPU_SEM_OP_DESTROY_SEM 4
+#define AMDGPU_SEM_OP_IMPORT_SEM 5
+#define AMDGPU_SEM_OP_EXPORT_SEM 6
struct drm_amdgpu_sem_in {
/** AMDGPU_SEM_OP_* */