[Intel-xe] [PATCH v3 26/43] drm/xe/uapi: Split xe_sync types from flags
Francois Dugast
francois.dugast at intel.com
Thu Nov 9 15:44:40 UTC 2023
From: Rodrigo Vivi <rodrigo.vivi at intel.com>
Let's continue on the uapi clean-up with more splits
with stuff into their own exclusive fields instead of
reusing stuff.
Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
Signed-off-by: Francois Dugast <francois.dugast at intel.com>
---
drivers/gpu/drm/xe/xe_sync.c | 23 +++++++----------------
drivers/gpu/drm/xe/xe_sync_types.h | 1 +
include/uapi/drm/xe_drm.h | 26 +++++++++++++-------------
3 files changed, 21 insertions(+), 29 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c
index eafe53c2f55d..883987b27c4e 100644
--- a/drivers/gpu/drm/xe/xe_sync.c
+++ b/drivers/gpu/drm/xe/xe_sync.c
@@ -17,8 +17,6 @@
#include "xe_macros.h"
#include "xe_sched_job_types.h"
-#define SYNC_FLAGS_TYPE_MASK 0x3
-
struct user_fence {
struct xe_device *xe;
struct kref refcount;
@@ -109,15 +107,13 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
if (copy_from_user(&sync_in, sync_user, sizeof(*sync_user)))
return -EFAULT;
- if (XE_IOCTL_DBG(xe, sync_in.flags &
- ~(SYNC_FLAGS_TYPE_MASK | DRM_XE_SYNC_FLAG_SIGNAL)) ||
- XE_IOCTL_DBG(xe, sync_in.pad) ||
+ if (XE_IOCTL_DBG(xe, sync_in.flags & ~DRM_XE_SYNC_FLAG_SIGNAL) ||
XE_IOCTL_DBG(xe, sync_in.reserved[0] || sync_in.reserved[1]))
return -EINVAL;
signal = sync_in.flags & DRM_XE_SYNC_FLAG_SIGNAL;
- switch (sync_in.flags & SYNC_FLAGS_TYPE_MASK) {
- case DRM_XE_SYNC_FLAG_SYNCOBJ:
+ switch (sync_in.type) {
+ case DRM_XE_SYNC_TYPE_SYNCOBJ:
if (XE_IOCTL_DBG(xe, no_dma_fences && signal))
return -EOPNOTSUPP;
@@ -135,7 +131,7 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
}
break;
- case DRM_XE_SYNC_FLAG_TIMELINE_SYNCOBJ:
+ case DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ:
if (XE_IOCTL_DBG(xe, no_dma_fences && signal))
return -EOPNOTSUPP;
@@ -165,12 +161,7 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
}
break;
- case DRM_XE_SYNC_FLAG_DMA_BUF:
- if (XE_IOCTL_DBG(xe, "TODO"))
- return -EINVAL;
- break;
-
- case DRM_XE_SYNC_FLAG_USER_FENCE:
+ case DRM_XE_SYNC_TYPE_USER_FENCE:
if (XE_IOCTL_DBG(xe, !signal))
return -EOPNOTSUPP;
@@ -192,6 +183,7 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
return -EINVAL;
}
+ sync->type = sync_in.type;
sync->flags = sync_in.flags;
sync->timeline_value = sync_in.timeline_value;
@@ -252,8 +244,7 @@ void xe_sync_entry_signal(struct xe_sync_entry *sync, struct xe_sched_job *job,
user_fence_put(sync->ufence);
dma_fence_put(fence);
}
- } else if ((sync->flags & SYNC_FLAGS_TYPE_MASK) ==
- DRM_XE_SYNC_FLAG_USER_FENCE) {
+ } else if (sync->type == DRM_XE_SYNC_TYPE_USER_FENCE) {
job->user_fence.used = true;
job->user_fence.addr = sync->addr;
job->user_fence.value = sync->timeline_value;
diff --git a/drivers/gpu/drm/xe/xe_sync_types.h b/drivers/gpu/drm/xe/xe_sync_types.h
index 24fccc26cb53..852db5e7884f 100644
--- a/drivers/gpu/drm/xe/xe_sync_types.h
+++ b/drivers/gpu/drm/xe/xe_sync_types.h
@@ -21,6 +21,7 @@ struct xe_sync_entry {
struct user_fence *ufence;
u64 addr;
u64 timeline_value;
+ u32 type;
u32 flags;
};
diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
index 65cbeaeacedb..0c004b24f820 100644
--- a/include/uapi/drm/xe_drm.h
+++ b/include/uapi/drm/xe_drm.h
@@ -932,11 +932,12 @@ struct drm_xe_vm_bind {
*
* This can be used with both @drm_xe_exec or with @drm_xe_vm_bind
*
+ * The @type can be:
+ * - %DRM_XE_SYNC_TYPE_SYNCOBJ - A simple drm sync object
+ * - %DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ - A timelined sync object
+ * - %DRM_XE_SYNC_TYPE_USER_FENCE - A user fence
+ *
* The @flags can be:
- * - %DRM_XE_SYNC_FLAG_SYNCOBJ
- * - %DRM_XE_SYNC_FLAG_TIMELINE_SYNCOBJ
- * - %DRM_XE_SYNC_FLAG_DMA_BUF
- * - %DRM_XE_SYNC_FLAG_USER_FENCE
* - %DRM_XE_SYNC_FLAG_SIGNAL
*
*/
@@ -944,17 +945,16 @@ struct drm_xe_sync {
/** @extensions: Pointer to the first extension struct, if any */
__u64 extensions;
-#define DRM_XE_SYNC_FLAG_SYNCOBJ 0x0
-#define DRM_XE_SYNC_FLAG_TIMELINE_SYNCOBJ 0x1
-#define DRM_XE_SYNC_FLAG_DMA_BUF 0x2
-#define DRM_XE_SYNC_FLAG_USER_FENCE 0x3
-#define DRM_XE_SYNC_FLAG_SIGNAL 0x10
+#define DRM_XE_SYNC_TYPE_SYNCOBJ 0x0
+#define DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ 0x1
+#define DRM_XE_SYNC_TYPE_USER_FENCE 0x2
+ /** @type: Type of the this sync object */
+ __u32 type;
+
+#define DRM_XE_SYNC_FLAG_SIGNAL (1 << 0)
/** @flags: Sync Flags */
__u32 flags;
- /** @pad: MBZ */
- __u32 pad;
-
union {
/** @handle: Handle to the sync object */
__u32 handle;
@@ -972,7 +972,7 @@ struct drm_xe_sync {
/**
* @timeline_value: Input for the timeline sync object. Needs to be
- * different than 0 when used with %DRM_XE_SYNC_FLAG_TIMELINE_SYNCOBJ.
+ * different than 0 when used with %DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ.
*/
__u64 timeline_value;
--
2.34.1
More information about the Intel-xe
mailing list