[Intel-xe] [RFC PATCH 1/2] drm/xe: Reshuffle all of the uAPI structs

Christopher Snowhill kode54 at gmail.com
Fri May 26 00:32:20 UTC 2023


Verified through pahole:
I've created a hdrtest.c with these contents:

struct xe_user_extension               __PASTE(dummy, __LINE__);
struct drm_xe_engine_class_instance    __PASTE(dummy, __LINE__);
struct drm_xe_query_mem_usage          __PASTE(dummy, __LINE__);
struct drm_xe_query_config             __PASTE(dummy, __LINE__);
struct drm_xe_query_gts                __PASTE(dummy, __LINE__);
struct drm_xe_query_topology_mask      __PASTE(dummy, __LINE__);
struct drm_xe_device_query             __PASTE(dummy, __LINE__);
struct drm_xe_gem_create               __PASTE(dummy, __LINE__);
struct drm_xe_gem_mmap_offset          __PASTE(dummy, __LINE__);
struct drm_xe_vm_bind_op_error_capture __PASTE(dummy, __LINE__);
struct drm_xe_ext_vm_set_property      __PASTE(dummy, __LINE__);
struct drm_xe_vm_create                __PASTE(dummy, __LINE__);
struct drm_xe_vm_destroy               __PASTE(dummy, __LINE__);
struct drm_xe_vm_bind_op               __PASTE(dummy, __LINE__);
struct drm_xe_vm_bind                  __PASTE(dummy, __LINE__);
struct drm_xe_ext_engine_set_property  __PASTE(dummy, __LINE__);
struct drm_xe_engine_set_property      __PASTE(dummy, __LINE__);
struct drm_xe_engine_create            __PASTE(dummy, __LINE__);
struct drm_xe_engine_get_property      __PASTE(dummy, __LINE__);
struct drm_xe_engine_destroy           __PASTE(dummy, __LINE__);
struct drm_xe_sync                     __PASTE(dummy, __LINE__);
struct drm_xe_exec                     __PASTE(dummy, __LINE__);
struct drm_xe_mmio                     __PASTE(dummy, __LINE__);
struct drm_xe_wait_user_fence          __PASTE(dummy, __LINE__);
struct drm_xe_vm_madvise               __PASTE(dummy, __LINE__);

and then ran the resulting .o file through pahole.

All padding holes are gone on 64-bits, some through extending the width
of some members, others by reorganizing, and even more by explicitly
adding padding.

v2:
	Applied suggested changes from original reviews
	Split the validation into a second patch
	Changed one padding member to avoid changing num_batch_buffer size

Suggested-by: Ryan Houdek <sonicadvance1 at gmail.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Signed-off-by: Christopher Snowhill <kode54 at gmail.com>
---
 include/uapi/drm/xe_drm.h | 64 +++++++++++++++++++++++++++------------
 1 file changed, 45 insertions(+), 19 deletions(-)

diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
index b0b80aae3ee8..a2c39f736f06 100644
--- a/include/uapi/drm/xe_drm.h
+++ b/include/uapi/drm/xe_drm.h
@@ -91,7 +91,7 @@ struct xe_user_extension {
 	 */
 	__u32 name;
 	/**
-	 * @flags: MBZ
+	 * @pad: MBZ
 	 *
 	 * All undefined bits must be zero.
 	 */
@@ -150,8 +150,8 @@ struct drm_xe_engine_class_instance {
 	 */
 #define DRM_XE_ENGINE_CLASS_VM_BIND		5
 
-	__u16 engine_instance;
 	__u16 gt_id;
+	__u32 engine_instance;
 };
 
 #define XE_MEM_REGION_CLASS_SYSMEM	0
@@ -291,6 +291,13 @@ struct drm_xe_gem_create {
 	 */
 	__u32 handle;
 
+	/**
+	 * @pad: MBZ
+	 *
+	 * All undefined bits must be zero.
+	 */
+	__u32 pad;
+
 	/** @reserved: Reserved */
 	__u64 reserved[2];
 };
@@ -335,6 +342,9 @@ struct drm_xe_ext_vm_set_property {
 #define XE_VM_PROPERTY_BIND_OP_ERROR_CAPTURE_ADDRESS		0
 	__u32 property;
 
+	/** @pad: MBZ */
+	__u32 pad;
+
 	/** @value: property value */
 	__u64 value;
 
@@ -379,6 +389,9 @@ struct drm_xe_vm_bind_op {
 	 */
 	__u32 obj;
 
+	/** @pad: MBZ */
+	__u32 pad;
+
 	union {
 		/**
 		 * @obj_offset: Offset into the object, MBZ for CLEAR_RANGE,
@@ -469,6 +482,12 @@ struct drm_xe_vm_bind {
 	/** @num_binds: number of binds in this IOCTL */
 	__u32 num_binds;
 
+	/** @num_syncs: amount of syncs to wait on */
+	__u32 num_syncs;
+
+	/** @syncs: pointer to struct drm_xe_sync array */
+	__u64 syncs;
+
 	union {
 		/** @bind: used if num_binds == 1 */
 		struct drm_xe_vm_bind_op bind;
@@ -479,12 +498,6 @@ struct drm_xe_vm_bind {
 		__u64 vector_of_binds;
 	};
 
-	/** @num_syncs: amount of syncs to wait on */
-	__u32 num_syncs;
-
-	/** @syncs: pointer to struct drm_xe_sync array */
-	__u64 syncs;
-
 	/** @reserved: Reserved */
 	__u64 reserved[2];
 };
@@ -497,6 +510,9 @@ struct drm_xe_ext_engine_set_property {
 	/** @property: property to set */
 	__u32 property;
 
+	/** @pad: MBZ */
+	__u32 pad;
+
 	/** @value: property value */
 	__u64 value;
 };
@@ -604,6 +620,7 @@ struct drm_xe_sync {
 	/** @extensions: Pointer to the first extension struct, if any */
 	__u64 extensions;
 
+	/** @flags: One of DRM_XE_SYNC_* flags */
 	__u32 flags;
 
 #define DRM_XE_SYNC_SYNCOBJ		0x0
@@ -612,6 +629,9 @@ struct drm_xe_sync {
 #define DRM_XE_SYNC_USER_FENCE		0x3
 #define DRM_XE_SYNC_SIGNAL		0x10
 
+	/** @pad: MBZ */
+	__u32 pad;
+
 	union {
 		__u32 handle;
 		/**
@@ -656,6 +676,9 @@ struct drm_xe_exec {
 	 */
 	__u16 num_batch_buffer;
 
+	/** @pad: MBZ */
+	__u16 pad[3];
+
 	/** @reserved: Reserved */
 	__u64 reserved[2];
 };
@@ -664,8 +687,10 @@ struct drm_xe_mmio {
 	/** @extensions: Pointer to the first extension struct, if any */
 	__u64 extensions;
 
+	/** @addr: Address in mmio space to do an op on */
 	__u32 addr;
 
+	/** @flags: Combination of DRM_XE_MMIO_* flags */
 	__u32 flags;
 
 #define DRM_XE_MMIO_8BIT	0x0
@@ -712,12 +737,13 @@ struct drm_xe_wait_user_fence {
 #define DRM_XE_UFENCE_WAIT_GTE	3
 #define DRM_XE_UFENCE_WAIT_LT	4
 #define DRM_XE_UFENCE_WAIT_LTE	5
-	__u16 op;
+	__u32 op;
 	/** @flags: wait flags */
 #define DRM_XE_UFENCE_WAIT_SOFT_OP	(1 << 0)	/* e.g. Wait on VM bind */
 #define DRM_XE_UFENCE_WAIT_ABSTIME	(1 << 1)
 #define DRM_XE_UFENCE_WAIT_VM_ERROR	(1 << 2)
-	__u16 flags;
+	__u32 flags;
+
 	/** @value: compare value */
 	__u64 value;
 	/** @mask: comparison mask */
@@ -747,15 +773,21 @@ struct drm_xe_vm_madvise {
 	/** @extensions: Pointer to the first extension struct, if any */
 	__u64 extensions;
 
-	/** @vm_id: The ID VM in which the VMA exists */
-	__u32 vm_id;
-
 	/** @range: Number of bytes in the VMA */
 	__u64 range;
 
 	/** @addr: Address of the VMA to operation on */
 	__u64 addr;
 
+	/** @vm_id: The ID VM in which the VMA exists */
+	__u32 vm_id;
+
+	/** @property: property to set (DRM_XE_VM_MADVISE_*) */
+	__u32 property;
+
+	/** @value: property value */
+	__u64 value;
+
 	/*
 	 * Setting the preferred location will trigger a migrate of the VMA
 	 * backing store to new location if the backing store is already
@@ -791,12 +823,6 @@ struct drm_xe_vm_madvise {
 	/* Pin the VMA in memory, must be elevated user */
 #define DRM_XE_VM_MADVISE_PIN			6
 
-	/** @property: property to set */
-	__u32 property;
-
-	/** @value: property value */
-	__u64 value;
-
 	/** @reserved: Reserved */
 	__u64 reserved[2];
 };
-- 
2.40.1



More information about the Intel-xe mailing list