[Intel-xe] [PATCH v2 08/14] drm/xe/uapi: Split xe_sync types from flags
Matthew Brost
matthew.brost at intel.com
Tue Nov 28 21:19:31 UTC 2023
On Wed, Nov 22, 2023 at 02:38:27PM +0000, Francois Dugast wrote:
> 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>
Reviewed-by: Matthew Brost <matthew.brost 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 | 16 ++++++++--------
> 3 files changed, 16 insertions(+), 24 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 fe911728fd97..f2bdc6e323e4 100644
> --- a/include/uapi/drm/xe_drm.h
> +++ b/include/uapi/drm/xe_drm.h
> @@ -880,16 +880,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 {
> __u32 handle;
>
> --
> 2.34.1
>
More information about the Intel-xe
mailing list