[PATCH 3/5] drm/amdgpu: add syncfile support to wait ioctl

Chunming Zhou David1.Zhou at amd.com
Tue Sep 12 10:23:45 UTC 2017


Change-Id: I79155cef5ee798899cd51a88825512cbf0d8ad82
Signed-off-by: Chunming Zhou <David1.Zhou at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 10 +++++++++-
 include/uapi/drm/amdgpu_drm.h          |  2 ++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index d048802..6c0ea9a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -1178,6 +1178,14 @@ int amdgpu_cs_wait_ioctl(struct drm_device *dev, void *data,
 	if (amdgpu_kms_vram_lost(adev, fpriv))
 		return -ENODEV;
 
+	if (wait->in.sf_fd > 0) {
+		struct dma_fence *fence = sync_file_get_fence(wait->in.sf_fd);
+
+		WARN_ONCE(fence, "get fence failed from syncfile fd!");
+		r = kcl_fence_wait_timeout(fence, true, timeout);
+		dma_fence_put(fence);
+		goto out;
+	}
 	ctx = amdgpu_ctx_get(filp->driver_priv, wait->in.ctx_id);
 	if (ctx == NULL)
 		return -EINVAL;
@@ -1202,7 +1210,7 @@ int amdgpu_cs_wait_ioctl(struct drm_device *dev, void *data,
 	amdgpu_ctx_put(ctx);
 	if (r < 0)
 		return r;
-
+out:
 	memset(wait, 0, sizeof(*wait));
 	wait->out.status = (r == 0);
 
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 19b4fea..ce110d9 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -399,6 +399,8 @@ struct drm_amdgpu_wait_cs_in {
 	__u32 ip_instance;
 	__u32 ring;
 	__u32 ctx_id;
+	int32_t sf_fd;
+	int32_t _pad;
 };
 
 struct drm_amdgpu_wait_cs_out {
-- 
1.9.1



More information about the amd-gfx mailing list