All of lore.kernel.org
 help / color / mirror / Atom feed
From: Francois Dugast <francois.dugast@intel.com>
To: "Souza, Jose" <jose.souza@intel.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"Vivi,  Rodrigo" <rodrigo.vivi@intel.com>
Subject: Re: [Intel-xe] [PATCH v2 13/14] drm/xe/uapi: Fix various struct padding for 64b alignment
Date: Wed, 29 Nov 2023 18:39:01 +0100	[thread overview]
Message-ID: <ZWd3NSH-SGtamUMz@fdugast-desk.home> (raw)
In-Reply-To: <cce23fbe34b769dc27a4f70f62b04c1c0f4850bd.camel@intel.com>

On Wed, Nov 29, 2023 at 06:02:54PM +0100, Souza, Jose wrote:
> On Wed, 2023-11-22 at 14:38 +0000, Francois Dugast wrote:
> > From: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > 
> > Let's respect Documentation/process/botching-up-ioctls.rst
> > and add the proper padding for a 64b alignment with all as
> > well as all the required checks and settings for the pads
> > and the reserved entries.
> 
> Now that the PAT uAPI landed this patch needs alignment fixes in drm_xe_gem_create.

I will fix it during rebase, thanks.

Francois

> 
> > 
> > v2: Fix remaining wholes and double check with pahole (Jose)
> >     Ensure with pahole that both 32b and 64b have exact same
> >     layout (Thomas)
> >     Do not set query's pad and reserved bits to zero since it
> >     is redundant and already done by kzalloc (Matt)
> > 
> > Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > Cc: Francois Dugast <francois.dugast@intel.com>
> > Cc: José Roberto de Souza <jose.souza@intel.com>
> > Cc: Matt Roper <matthew.d.roper@intel.com>
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > Signed-off-by: Francois Dugast <francois.dugast@intel.com>
> > Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_query.c |  1 +
> >  drivers/gpu/drm/xe/xe_vm.c    |  8 ++++++++
> >  include/uapi/drm/xe_drm.h     | 19 +++++++++++--------
> >  3 files changed, 20 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c
> > index 095f1b8c2290..d0523dfc488f 100644
> > --- a/drivers/gpu/drm/xe/xe_query.c
> > +++ b/drivers/gpu/drm/xe/xe_query.c
> > @@ -371,6 +371,7 @@ static int query_gt_list(struct xe_device *xe, struct drm_xe_device_query *query
> >  		return -ENOMEM;
> >  
> >  	gt_list->num_gt = xe->info.gt_count;
> > +
> >  	for_each_gt(gt, xe, id) {
> >  		if (xe_gt_is_media_type(gt))
> >  			gt_list->gt_list[id].type = DRM_XE_QUERY_GT_TYPE_MEDIA;
> > diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> > index ccd2821e61f8..1dbd6e948741 100644
> > --- a/drivers/gpu/drm/xe/xe_vm.c
> > +++ b/drivers/gpu/drm/xe/xe_vm.c
> > @@ -2817,6 +2817,10 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe,
> >  	int err;
> >  	int i;
> >  
> > +	if (XE_IOCTL_DBG(xe, args->pad || args->pad2) ||
> > +	    XE_IOCTL_DBG(xe, args->reserved[0] || args->reserved[1]))
> > +		return -EINVAL;
> > +
> >  	if (XE_IOCTL_DBG(xe, args->extensions) ||
> >  	    XE_IOCTL_DBG(xe, !args->num_binds) ||
> >  	    XE_IOCTL_DBG(xe, args->num_binds > MAX_BINDS))
> > @@ -2933,6 +2937,10 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> >  	if (err)
> >  		return err;
> >  
> > +	if (XE_IOCTL_DBG(xe, args->pad || args->pad2) ||
> > +	    XE_IOCTL_DBG(xe, args->reserved[0] || args->reserved[1]))
> > +		return -EINVAL;
> > +
> >  	if (args->exec_queue_id) {
> >  		q = xe_exec_queue_lookup(xef, args->exec_queue_id);
> >  		if (XE_IOCTL_DBG(xe, !q)) {
> > diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
> > index b0ef1f62fd99..4c175946547c 100644
> > --- a/include/uapi/drm/xe_drm.h
> > +++ b/include/uapi/drm/xe_drm.h
> > @@ -211,8 +211,6 @@ struct drm_xe_mem_region {
> >  	 * a unique pair.
> >  	 */
> >  	__u16 instance;
> > -	/** @pad: MBZ */
> > -	__u32 pad;
> >  	/**
> >  	 * @min_page_size: Min page-size in bytes for this region.
> >  	 *
> > @@ -381,6 +379,8 @@ struct drm_xe_gt {
> >  	__u16 tile_id;
> >  	/** @gt_id: Unique ID of this GT within the PCI Device */
> >  	__u16 gt_id;
> > +	/** @pad: MBZ */
> > +	__u16 pad[3];
> >  	/** @reference_clock: A clock frequency for timestamp */
> >  	__u32 reference_clock;
> >  	/**
> > @@ -715,6 +715,9 @@ struct drm_xe_vm_bind_op {
> >  	 */
> >  	__u32 prefetch_mem_region_instance;
> >  
> > +	/** @pad: MBZ */
> > +	__u32 pad2;
> > +
> >  	/** @reserved: Reserved */
> >  	__u64 reserved[3];
> >  };
> > @@ -733,12 +736,12 @@ struct drm_xe_vm_bind {
> >  	 */
> >  	__u32 exec_queue_id;
> >  
> > -	/** @num_binds: number of binds in this IOCTL */
> > -	__u32 num_binds;
> > -
> >  	/** @pad: MBZ */
> >  	__u32 pad;
> >  
> > +	/** @num_binds: number of binds in this IOCTL */
> > +	__u32 num_binds;
> > +
> >  	union {
> >  		/** @bind: used if num_binds == 1 */
> >  		struct drm_xe_vm_bind_op bind;
> > @@ -750,12 +753,12 @@ struct drm_xe_vm_bind {
> >  		__u64 vector_of_binds;
> >  	};
> >  
> > +	/** @pad: MBZ */
> > +	__u32 pad2;
> > +
> >  	/** @num_syncs: amount of syncs to wait on */
> >  	__u32 num_syncs;
> >  
> > -	/** @pad2: MBZ */
> > -	__u32 pad2;
> > -
> >  	/** @syncs: pointer to struct drm_xe_sync array */
> >  	__u64 syncs;
> >  
> 

  reply	other threads:[~2023-11-29 17:39 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22 14:38 [Intel-xe] [PATCH v2 00/14] uAPI Alignment - Cleanup and future proof Francois Dugast
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 01/14] drm/xe: Extend drm_xe_vm_bind_op Francois Dugast
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 02/14] drm/xe/uapi: Separate bo_create placement from flags Francois Dugast
2023-11-29 19:36   ` Welty, Brian
2023-11-29 20:41     ` Rodrigo Vivi
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 03/14] drm/xe: Make DRM_XE_DEVICE_QUERY_ENGINES future proof Francois Dugast
2023-11-28 21:17   ` Matthew Brost
2023-11-29 16:54     ` Rodrigo Vivi
2023-11-29 12:35       ` Matthew Brost
2023-11-29 20:04         ` Souza, Jose
2023-11-29 22:52           ` Rodrigo Vivi
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 04/14] drm/xe/uapi: Reject bo creation of unaligned size Francois Dugast
2023-11-24 18:15   ` Souza, Jose
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 05/14] drm/xe/uapi: Align on a common way to return arrays (memory regions) Francois Dugast
2023-11-24 18:19   ` Souza, Jose
2023-11-28 20:51     ` Rodrigo Vivi
2023-11-29 12:33       ` Francois Dugast
2023-11-30 20:53   ` Dixit, Ashutosh
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 06/14] drm/xe/uapi: Align on a common way to return arrays (gt) Francois Dugast
2023-11-28 20:51   ` Rodrigo Vivi
2023-11-29 18:30   ` Matt Roper
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 07/14] drm/xe/uapi: Align on a common way to return arrays (engines) Francois Dugast
2023-11-28 20:56   ` Rodrigo Vivi
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 08/14] drm/xe/uapi: Split xe_sync types from flags Francois Dugast
2023-11-28 21:19   ` Matthew Brost
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 09/14] drm/xe/uapi: Kill tile_mask Francois Dugast
2023-11-29  9:07   ` Matthew Brost
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 10/14] drm/xe/uapi: Crystal Reference Clock updates Francois Dugast
2023-11-24 18:38   ` Souza, Jose
2023-11-29 14:08     ` Francois Dugast
2023-11-29 18:33       ` Souza, Jose
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 11/14] drm/xe/uapi: Remove bogus engine list from the wait_user_fence IOCTL Francois Dugast
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 12/14] drm/xe/uapi: Add Tile ID information to the GT info query Francois Dugast
2023-11-24 18:45   ` Souza, Jose
2023-11-27 14:08     ` Francois Dugast
2023-11-27 14:20       ` Souza, Jose
2023-11-29 18:33         ` Souza, Jose
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 13/14] drm/xe/uapi: Fix various struct padding for 64b alignment Francois Dugast
2023-11-29 17:02   ` Souza, Jose
2023-11-29 17:39     ` Francois Dugast [this message]
2023-11-22 14:38 ` [Intel-xe] [PATCH v2 14/14] drm/xe/uapi: Move xe_exec after xe_exec_queue Francois Dugast
2023-11-29 18:34   ` Souza, Jose
2023-11-23 14:14 ` [Intel-xe] ✓ CI.Patch_applied: success for uAPI Alignment - Cleanup and future proof (rev5) Patchwork
2023-11-23 14:14 ` [Intel-xe] ✗ CI.checkpatch: warning " Patchwork
2023-11-23 14:15 ` [Intel-xe] ✓ CI.KUnit: success " Patchwork
2023-11-23 14:23 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-11-23 14:23 ` [Intel-xe] ✗ CI.Hooks: failure " Patchwork
2023-11-23 14:24 ` [Intel-xe] ✓ CI.checksparse: success " Patchwork
2023-11-23 15:01 ` [Intel-xe] ✗ CI.BAT: failure " 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=ZWd3NSH-SGtamUMz@fdugast-desk.home \
    --to=francois.dugast@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jose.souza@intel.com \
    --cc=rodrigo.vivi@intel.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.