From: Christopher Snowhill <kode54@gmail.com>
To: intel-xe@lists.freedesktop.org
Cc: Ryan Houdek <sonicadvance1@gmail.com>
Subject: [Intel-xe] [RFC PATCH 1/2] drm/xe: Reshuffle all of the uAPI structs
Date: Thu, 25 May 2023 17:32:20 -0700 [thread overview]
Message-ID: <20230526003221.3874899-2-kode54@gmail.com> (raw)
In-Reply-To: <20230526003221.3874899-1-kode54@gmail.com>
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@gmail.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Christopher Snowhill <kode54@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
next prev parent reply other threads:[~2023-05-26 0:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 0:32 [Intel-xe] [RFC PATCH 0/2] Draft: Update Xe uAPI for 32-bit compat, invasively Christopher Snowhill
2023-05-26 0:32 ` Christopher Snowhill [this message]
2023-05-26 0:32 ` [Intel-xe] [RFC PATCH 2/2] drm/xe: Validate uAPI padding and reserved fields Christopher Snowhill
2023-05-26 0:34 ` [Intel-xe] ✓ CI.Patch_applied: success for Draft: Update Xe uAPI for 32-bit compat, invasively Patchwork
2023-05-26 0:36 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-05-26 0:40 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-05-26 1:09 ` [Intel-xe] ○ CI.BAT: info " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230526003221.3874899-2-kode54@gmail.com \
--to=kode54@gmail.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=sonicadvance1@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.