All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Souza, Jose" <jose.souza@intel.com>
To: "Brost, Matthew" <matthew.brost@intel.com>,
	"Vivi, Rodrigo" <rodrigo.vivi@intel.com>
Cc: "Dugast, Francois" <francois.dugast@intel.com>,
	"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>
Subject: Re: [Intel-xe] [PATCH v2 03/14] drm/xe: Make DRM_XE_DEVICE_QUERY_ENGINES future proof
Date: Wed, 29 Nov 2023 20:04:37 +0000	[thread overview]
Message-ID: <7b38be287ab91b8efc73544f2448520214b8c604.camel@intel.com> (raw)
In-Reply-To: <ZWcwLhlAGj/o5xaJ@DUT025-TGLU.fm.intel.com>

On Wed, 2023-11-29 at 12:35 +0000, Matthew Brost wrote:
> On Wed, Nov 29, 2023 at 11:54:51AM -0500, Rodrigo Vivi wrote:
> > On Tue, Nov 28, 2023 at 09:17:51PM +0000, Matthew Brost wrote:
> > > On Wed, Nov 22, 2023 at 02:38:22PM +0000, Francois Dugast wrote:
> > > > From: José Roberto de Souza <jose.souza@intel.com>
> > > > 
> > > > We have at least 2 future features(OA and future media engines
> > > > capabilities) that will require Xe to provide more information about
> > > > engines to UMDs.
> > > > 
> > > > But this information should not just be added to
> > > > drm_xe_engine_class_instance for a couple of reasons:
> > > > - drm_xe_engine_class_instance is used as input to other structs/uAPIs
> > > > and those uAPIs don't care about any of these future new engine fields
> > > > - those new fields are useless information after initialization for
> > > > some UMDs, so it should not need to carry that around
> > > > 
> > > > So here my proposal is to make DRM_XE_DEVICE_QUERY_ENGINES return an
> > > > array of drm_xe_query_engine_info that contain
> > > > drm_xe_engine_class_instance and 3 u64s to be used for future features.
> > > 
> > > There is 5 u64 in this patch.
> > 
> > my bad, sorry. just trying to prepare for the many capabilities and other
> > stuff we will likely need. But likely 3 would be enough.
> > 
> > > 
> > > Anyways agree this better but what if we improve this a bit more making
> > > each __drm_xe_query_engine_info a dynamic size.
> > 
> > hmmm... I think I like this idea. pahole seems to have a good output
> > with our other existent dynamic array.
> > 
> 
> Cool, looking forward to what we come up with.

v2 of drm_xe_query_engine_info would be something like this?

struct drm_xe_query_engine_info {
    struct drm_xe_engine_class_instance instance;
    __u64 foo;
    __u64 reserved[0];
}

maybe already add a pad enough for the OA counter and media engine capabilities usages and leave reserved[0] at the end for future.


> 
> > > 
> > > e.g.
> > > struct __drm_xe_query_engine_info {	/* Bad name, just for example */
> > >      /** @instance: The @drm_xe_engine_class_instance */
> > >      struct drm_xe_engine_class_instance instance;
> > > 
> > >      /** @reserved: Reserved, dynamic size */
> > >      __u64 reserved[0];
> > 
> > I believe [] instead of [0] is the preferred way nowadays.
> > 
> 
> Yep.
> 
> Matt
> 
> > > };
> > > 
> > > struct drm_xe_query_engine_info {
> > >      /** @num_engines: Number engines */
> > >      __u64 num_engines;
> > >      /** @engine_info: Array of engine info */
> > >      struct __drm_xe_query_engine_info engine_info[0];
> > > };
> > > 
> > > The size of __drm_xe_query_engine_info then change and can be calculated
> > > to be:
> > > 
> > > (returned size of query - sizoeof(__u64)) / drm_xe_query_engine_info.num_engines
> > > 
> > > We then should be able to add additional fields to
> > > __drm_xe_query_engine_info indefinitely.
> > > 
> > > What does everyone think? We likely can apply this idea to other
> > > queries too as it makes sense.
> > > 
> > > Matt
> > > 
> > > > 
> > > > Reference OA:
> > > > https://patchwork.freedesktop.org/patch/558362/?series=121084&rev=6
> > > > 
> > > > Cc: Francois Dugast <francois.dugast@intel.com>
> > > > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > > Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
> > > > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > > [Rodrigo Rebased]
> > > > Signed-off-by: Francois Dugast <francois.dugast@intel.com>
> > > > ---
> > > >  drivers/gpu/drm/xe/xe_query.c | 15 ++++++++-------
> > > >  include/uapi/drm/xe_drm.h     | 24 +++++++++++++++++++++++-
> > > >  2 files changed, 31 insertions(+), 8 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c
> > > > index 61a7d92b7e88..0cbfeaeb1330 100644
> > > > --- a/drivers/gpu/drm/xe/xe_query.c
> > > > +++ b/drivers/gpu/drm/xe/xe_query.c
> > > > @@ -53,7 +53,7 @@ static size_t calc_hw_engine_info_size(struct xe_device *xe)
> > > >  			i++;
> > > >  		}
> > > >  
> > > > -	return i * sizeof(struct drm_xe_engine_class_instance);
> > > > +	return i * sizeof(struct drm_xe_query_engine_info);
> > > >  }
> > > >  
> > > >  typedef u64 (*__ktime_func_t)(void);
> > > > @@ -186,9 +186,9 @@ static int query_engines(struct xe_device *xe,
> > > >  			 struct drm_xe_device_query *query)
> > > >  {
> > > >  	size_t size = calc_hw_engine_info_size(xe);
> > > > -	struct drm_xe_engine_class_instance __user *query_ptr =
> > > > +	struct drm_xe_query_engine_info __user *query_ptr =
> > > >  		u64_to_user_ptr(query->data);
> > > > -	struct drm_xe_engine_class_instance *hw_engine_info;
> > > > +	struct drm_xe_query_engine_info *hw_engine_info;
> > > >  	struct xe_hw_engine *hwe;
> > > >  	enum xe_hw_engine_id id;
> > > >  	struct xe_gt *gt;
> > > > @@ -211,12 +211,13 @@ static int query_engines(struct xe_device *xe,
> > > >  			if (xe_hw_engine_is_reserved(hwe))
> > > >  				continue;
> > > >  
> > > > -			hw_engine_info[i].engine_class =
> > > > +			hw_engine_info[i].instance.engine_class =
> > > >  				xe_to_user_engine_class[hwe->class];
> > > > -			hw_engine_info[i].engine_instance =
> > > > +			hw_engine_info[i].instance.engine_instance =
> > > >  				hwe->logical_instance;
> > > > -			hw_engine_info[i].gt_id = gt->info.id;
> > > > -			hw_engine_info[i].pad = 0;
> > > > +			hw_engine_info[i].instance.gt_id = gt->info.id;
> > > > +			hw_engine_info[i].instance.pad = 0;
> > > > +			memset(hw_engine_info->reserved, 0, sizeof(hw_engine_info->reserved));
> > > >  
> > > >  			i++;
> > > >  		}
> > > > diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
> > > > index 1bdd20d3c4a8..c80e03b61489 100644
> > > > --- a/include/uapi/drm/xe_drm.h
> > > > +++ b/include/uapi/drm/xe_drm.h
> > > > @@ -124,7 +124,14 @@ struct xe_user_extension {
> > > >  #define DRM_IOCTL_XE_EXEC_QUEUE_GET_PROPERTY	DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_EXEC_QUEUE_GET_PROPERTY, struct drm_xe_exec_queue_get_property)
> > > >  #define DRM_IOCTL_XE_WAIT_USER_FENCE		DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_WAIT_USER_FENCE, struct drm_xe_wait_user_fence)
> > > >  
> > > > -/** struct drm_xe_engine_class_instance - instance of an engine class */
> > > > +/**
> > > > + * struct drm_xe_engine_class_instance - instance of an engine class
> > > > + *
> > > > + * It is returned as part of the @drm_xe_query_engine_info, but it also is
> > > > + * used as the input of engine selection for both @drm_xe_exec_queue_create
> > > > + * and @drm_xe_query_engine_cycles
> > > > + *
> > > > + */
> > > >  struct drm_xe_engine_class_instance {
> > > >  #define DRM_XE_ENGINE_CLASS_RENDER		0
> > > >  #define DRM_XE_ENGINE_CLASS_COPY		1
> > > > @@ -145,6 +152,21 @@ struct drm_xe_engine_class_instance {
> > > >  	__u16 pad;
> > > >  };
> > > >  
> > > > +/**
> > > > + * struct drm_xe_query_engine_info - describe hardware engine
> > > > + *
> > > > + * If a query is made with a struct @drm_xe_device_query where .query
> > > > + * is equal to %DRM_XE_DEVICE_QUERY_ENGINES, then the reply uses an array of
> > > > + * struct @drm_xe_query_engine_info in .data.
> > > > + */
> > > > +struct drm_xe_query_engine_info {
> > > > +	/** @instance: The @drm_xe_engine_class_instance */
> > > > +	struct drm_xe_engine_class_instance instance;
> > 
> > > > +
> > > > +	/** @reserved: Reserved */
> > > > +	__u64 reserved[5];
> > > > +};
> > > > +
> > > >  /**
> > > >   * enum drm_xe_memory_class - Supported memory classes.
> > > >   */
> > > > -- 
> > > > 2.34.1
> > > > 


  reply	other threads:[~2023-11-29 20:04 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 [this message]
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
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=7b38be287ab91b8efc73544f2448520214b8c604.camel@intel.com \
    --to=jose.souza@intel.com \
    --cc=francois.dugast@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@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.