All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Souza, Jose" <jose.souza@intel.com>
To: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"Dugast, Francois" <francois.dugast@intel.com>
Subject: Re: [Intel-xe] [PATCH v1 5/8] drm/xe/uapi: Align on a common way to return arrays (memory regions)
Date: Thu, 16 Nov 2023 20:39:16 +0000	[thread overview]
Message-ID: <a8ebae3289945717ef6b13eb025896fb400c238d.camel@intel.com> (raw)
In-Reply-To: <20231116144316.7-6-francois.dugast@intel.com>

On Thu, 2023-11-16 at 14:43 +0000, Francois Dugast wrote:
> The uAPI provides queries which return arrays of elements. As of now
> the format used in the struct is different depending on which element
> is queried. Fix this for memory regions by applying the pattern below:
> 
>     struct drm_xe_query_X {
>        __u32 num_X;
>        struct drm_xe_X Xs[];
>        ...
>     }
> 
> This removes "query" in the name of struct drm_xe_query_mem_region
> as it is not returned from the query IOCTL. There is no functional
> change.
> 
> Signed-off-by: Francois Dugast <francois.dugast@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_query.c | 44 ++++++++++++++++++-----------------
>  include/uapi/drm/xe_drm.h     | 22 +++++++++---------
>  2 files changed, 34 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c
> index 0cbfeaeb1330..b31e00bd29bc 100644
> --- a/drivers/gpu/drm/xe/xe_query.c
> +++ b/drivers/gpu/drm/xe/xe_query.c
> @@ -240,15 +240,15 @@ static size_t calc_mem_regions_size(struct xe_device *xe)
>  		if (ttm_manager_type(&xe->ttm, i))
>  			num_managers++;
>  
> -	return offsetof(struct drm_xe_query_mem_regions, regions[num_managers]);
> +	return offsetof(struct drm_xe_query_mem_region, mem_regions[num_managers]);
>  }
>  
> -static int query_mem_regions(struct xe_device *xe,
> -			     struct drm_xe_device_query *query)
> +static int query_mem_region(struct xe_device *xe,
> +			    struct drm_xe_device_query *query)
>  {
>  	size_t size = calc_mem_regions_size(xe);
> -	struct drm_xe_query_mem_regions *usage;
> -	struct drm_xe_query_mem_regions __user *query_ptr =
> +	struct drm_xe_query_mem_region *usage;
> +	struct drm_xe_query_mem_region __user *query_ptr =
>  		u64_to_user_ptr(query->data);
>  	struct ttm_resource_manager *man;
>  	int ret, i;
> @@ -265,36 +265,38 @@ static int query_mem_regions(struct xe_device *xe,
>  		return -ENOMEM;
>  
>  	man = ttm_manager_type(&xe->ttm, XE_PL_TT);
> -	usage->regions[0].mem_class = DRM_XE_MEM_REGION_CLASS_SYSMEM;
> -	usage->regions[0].instance = 0;
> -	usage->regions[0].min_page_size = PAGE_SIZE;
> -	usage->regions[0].total_size = man->size << PAGE_SHIFT;
> +	usage->mem_regions[0].mem_class = DRM_XE_MEM_REGION_CLASS_SYSMEM;
> +	usage->mem_regions[0].instance = 0;
> +	usage->mem_regions[0].min_page_size = PAGE_SIZE;
> +	usage->mem_regions[0].total_size = man->size << PAGE_SHIFT;
>  	if (perfmon_capable())
> -		usage->regions[0].used = ttm_resource_manager_usage(man);
> -	usage->num_regions = 1;
> +		usage->mem_regions[0].used = ttm_resource_manager_usage(man);
> +	usage->num_mem_regions = 1;
>  
>  	for (i = XE_PL_VRAM0; i <= XE_PL_VRAM1; ++i) {
>  		man = ttm_manager_type(&xe->ttm, i);
>  		if (man) {
> -			usage->regions[usage->num_regions].mem_class =
> +			usage->mem_regions[usage->num_mem_regions].mem_class =
>  				DRM_XE_MEM_REGION_CLASS_VRAM;
> -			usage->regions[usage->num_regions].instance =
> -				usage->num_regions;
> -			usage->regions[usage->num_regions].min_page_size =
> +			usage->mem_regions[usage->num_mem_regions].instance =
> +				usage->num_mem_regions;
> +			usage->mem_regions[usage->num_mem_regions].min_page_size =
>  				xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K ?
>  				SZ_64K : PAGE_SIZE;
> -			usage->regions[usage->num_regions].total_size =
> +			usage->mem_regions[usage->num_mem_regions].total_size =
>  				man->size;
>  
>  			if (perfmon_capable()) {
>  				xe_ttm_vram_get_used(man,
> -						     &usage->regions[usage->num_regions].used,
> -						     &usage->regions[usage->num_regions].cpu_visible_used);
> +						     &usage->mem_regions
> +						     [usage->num_mem_regions].used,
> +						     &usage->mem_regions
> +						     [usage->num_mem_regions].cpu_visible_used);
>  			}
>  
> -			usage->regions[usage->num_regions].cpu_visible_size =
> +			usage->mem_regions[usage->num_mem_regions].cpu_visible_size =
>  				xe_ttm_vram_get_cpu_visible_size(man);
> -			usage->num_regions++;
> +			usage->num_mem_regions++;
>  		}
>  	}
>  
> @@ -500,7 +502,7 @@ static int query_gt_topology(struct xe_device *xe,
>  static int (* const xe_query_funcs[])(struct xe_device *xe,
>  				      struct drm_xe_device_query *query) = {
>  	query_engines,
> -	query_mem_regions,
> +	query_mem_region,
>  	query_config,
>  	query_gt_list,
>  	query_hwconfig,
> diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
> index e02bef8dc229..f54e545cc4fb 100644
> --- a/include/uapi/drm/xe_drm.h
> +++ b/include/uapi/drm/xe_drm.h
> @@ -182,10 +182,10 @@ enum drm_xe_memory_class {
>  };
>  
>  /**
> - * struct drm_xe_query_mem_region - Describes some region as known to
> + * struct drm_xe_mem_region - Describes some region as known to
>   * the driver.
>   */
> -struct drm_xe_query_mem_region {
> +struct drm_xe_mem_region {
>  	/**
>  	 * @mem_class: The memory class describing this region.
>  	 *
> @@ -315,19 +315,19 @@ struct drm_xe_query_engine_cycles {
>  };
>  
>  /**
> - * struct drm_xe_query_mem_regions - describe memory regions
> + * struct drm_xe_query_mem_region - describe memory regions
>   *
>   * If a query is made with a struct drm_xe_device_query where .query
> - * is equal to DRM_XE_DEVICE_QUERY_MEM_REGIONS, then the reply uses
> - * struct drm_xe_query_mem_regions in .data.
> + * is equal to DRM_XE_DEVICE_QUERY_MEM_REGION, then the reply uses
> + * struct drm_xe_query_mem_region in .data.
>   */
> -struct drm_xe_query_mem_regions {
> -	/** @num_regions: number of memory regions returned in @regions */
> -	__u32 num_regions;
> +struct drm_xe_query_mem_region {

ack on s/drm_xe_query_mem_region/drm_xe_mem_region but not on s/drm_xe_query_mem_regions/drm_xe_query_mem_region, the second one can return more than
one region.

> +	/** @num_mem_regions: number of memory regions returned in @mem_regions */
> +	__u32 num_mem_regions;
>  	/** @pad: MBZ */
>  	__u32 pad;
> -	/** @regions: The returned regions for this device */
> -	struct drm_xe_query_mem_region regions[];
> +	/** @mem_regions: The returned memory regions for this device */
> +	struct drm_xe_mem_region mem_regions[];
>  };
>  
>  /**
> @@ -493,7 +493,7 @@ struct drm_xe_device_query {
>  	__u64 extensions;
>  
>  #define DRM_XE_DEVICE_QUERY_ENGINES		0
> -#define DRM_XE_DEVICE_QUERY_MEM_REGIONS		1
> +#define DRM_XE_DEVICE_QUERY_MEM_REGION		1
>  #define DRM_XE_DEVICE_QUERY_CONFIG		2
>  #define DRM_XE_DEVICE_QUERY_GT_LIST		3
>  #define DRM_XE_DEVICE_QUERY_HWCONFIG		4


  reply	other threads:[~2023-11-16 20:39 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 14:43 [Intel-xe] [PATCH v1 0/8] uAPI Alignment - Cleanup and future proof Francois Dugast
2023-11-16 14:43 ` [Intel-xe] [PATCH v1 1/8] drm/xe: Extend drm_xe_vm_bind_op Francois Dugast
2023-11-16 20:57   ` Rodrigo Vivi
2023-11-16 14:43 ` [Intel-xe] [PATCH v1 2/8] drm/xe/uapi: Separate bo_create placement from flags Francois Dugast
2023-11-16 14:43 ` [Intel-xe] [PATCH v1 3/8] drm/xe: Make DRM_XE_DEVICE_QUERY_ENGINES future proof Francois Dugast
2023-11-16 14:43 ` [Intel-xe] [PATCH v1 4/8] drm/xe/uapi: Reject bo creation of unaligned size Francois Dugast
2023-11-16 14:43 ` [Intel-xe] [PATCH v1 5/8] drm/xe/uapi: Align on a common way to return arrays (memory regions) Francois Dugast
2023-11-16 20:39   ` Souza, Jose [this message]
2023-11-16 14:43 ` [Intel-xe] [PATCH v1 6/8] drm/xe/uapi: Align on a common way to return arrays (gt) Francois Dugast
2023-11-16 20:40   ` Souza, Jose
2023-11-16 20:56     ` Rodrigo Vivi
2023-11-16 21:28       ` Matt Roper
2023-11-16 14:43 ` [Intel-xe] [PATCH v1 7/8] drm/xe/uapi: Align on a common way to return arrays (engines) Francois Dugast
2023-11-16 20:42   ` Souza, Jose
2023-11-16 14:43 ` [Intel-xe] [PATCH v1 8/8] drm/xe/uapi: Add Tile ID information to the GT info query Francois Dugast
2023-11-16 20:44   ` Souza, Jose
2023-11-16 20:52     ` Rodrigo Vivi
2023-11-16 20:54       ` Souza, Jose
2023-11-17  4:06         ` [Intel-xe] [PATCH] drm/xe/uapi: Fix various struct padding for 64b alignment Rodrigo Vivi
2023-11-17 14:25           ` Souza, Jose
2023-11-17 20:48             ` [Intel-gfx] " Rodrigo Vivi
2023-11-17 20:57               ` Souza, Jose
2023-11-17 16:24           ` [Intel-xe] " Matt Roper
2023-11-16 14:46 ` [Intel-xe] ✗ CI.Patch_applied: failure for uAPI Alignment - Cleanup and future proof Patchwork
2023-11-17 23:39 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/xe/uapi: Fix various struct padding for 64b alignment Patchwork
2023-11-18  3:14 ` [Intel-xe] ✓ CI.Patch_applied: success for uAPI Alignment - Cleanup and future proof Patchwork
2023-11-18  3:14 ` [Intel-xe] ✓ CI.checkpatch: " Patchwork
2023-11-18  3:15 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-11-18  3:23 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-11-18  3:23 ` [Intel-xe] ✗ CI.Hooks: failure " Patchwork
2023-11-18  3:24 ` [Intel-xe] ✓ CI.checksparse: success " Patchwork
2023-11-18  3:59 ` [Intel-xe] ✗ CI.BAT: failure " Patchwork
2023-11-20 12:44 ` [Intel-xe] ✗ CI.Patch_applied: failure for uAPI Alignment - Cleanup and future proof (rev3) 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=a8ebae3289945717ef6b13eb025896fb400c238d.camel@intel.com \
    --to=jose.souza@intel.com \
    --cc=francois.dugast@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /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.