Commit 535881a8 authored by Rodrigo Vivi's avatar Rodrigo Vivi

drm/xe/uapi: Document the memory_region bitmask

The uAPI should stay generic in regarding to the bitmask. It is
the userspace responsibility to check for the type/class of the
memory, without any assumption.

Also add comments inside the code to explain how it is actually
constructed so we don't accidentally change the assignment of
the instance and the masks.

No functional change in this patch. It only explains and document
the memory_region masks. A further follow-up work with the
organization of all memory regions around struct xe_mem_regions
is desired, but not part of this patch.
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Acked-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
Acked-by: default avatarMateusz Naklicki <mateusz.naklicki@intel.com>
Signed-off-by: default avatarFrancois Dugast <francois.dugast@intel.com>
parent 4b437893
...@@ -266,6 +266,11 @@ static int query_mem_regions(struct xe_device *xe, ...@@ -266,6 +266,11 @@ static int query_mem_regions(struct xe_device *xe,
man = ttm_manager_type(&xe->ttm, XE_PL_TT); man = ttm_manager_type(&xe->ttm, XE_PL_TT);
mem_regions->mem_regions[0].mem_class = DRM_XE_MEM_REGION_CLASS_SYSMEM; mem_regions->mem_regions[0].mem_class = DRM_XE_MEM_REGION_CLASS_SYSMEM;
/*
* The instance needs to be a unique number that represents the index
* in the placement mask used at xe_gem_create_ioctl() for the
* xe_bo_create() placement.
*/
mem_regions->mem_regions[0].instance = 0; mem_regions->mem_regions[0].instance = 0;
mem_regions->mem_regions[0].min_page_size = PAGE_SIZE; mem_regions->mem_regions[0].min_page_size = PAGE_SIZE;
mem_regions->mem_regions[0].total_size = man->size << PAGE_SHIFT; mem_regions->mem_regions[0].total_size = man->size << PAGE_SHIFT;
...@@ -381,6 +386,20 @@ static int query_gt_list(struct xe_device *xe, struct drm_xe_device_query *query ...@@ -381,6 +386,20 @@ static int query_gt_list(struct xe_device *xe, struct drm_xe_device_query *query
gt_list->gt_list[id].tile_id = gt_to_tile(gt)->id; gt_list->gt_list[id].tile_id = gt_to_tile(gt)->id;
gt_list->gt_list[id].gt_id = gt->info.id; gt_list->gt_list[id].gt_id = gt->info.id;
gt_list->gt_list[id].reference_clock = gt->info.reference_clock; gt_list->gt_list[id].reference_clock = gt->info.reference_clock;
/*
* The mem_regions indexes in the mask below need to
* directly identify the struct
* drm_xe_query_mem_regions' instance constructed at
* query_mem_regions()
*
* For our current platforms:
* Bit 0 -> System Memory
* Bit 1 -> VRAM0 on Tile0
* Bit 2 -> VRAM1 on Tile1
* However the uAPI is generic and it's userspace's
* responsibility to check the mem_class, without any
* assumption.
*/
if (!IS_DGFX(xe)) if (!IS_DGFX(xe))
gt_list->gt_list[id].near_mem_regions = 0x1; gt_list->gt_list[id].near_mem_regions = 0x1;
else else
......
...@@ -256,10 +256,9 @@ struct drm_xe_mem_region { ...@@ -256,10 +256,9 @@ struct drm_xe_mem_region {
*/ */
__u16 mem_class; __u16 mem_class;
/** /**
* @instance: The instance for this region. * @instance: The unique ID for this region, which serves as the
* * index in the placement bitmask used as argument for
* The @mem_class and @instance taken together will always give * &DRM_IOCTL_XE_GEM_CREATE
* a unique pair.
*/ */
__u16 instance; __u16 instance;
/** /**
...@@ -404,6 +403,10 @@ struct drm_xe_gt { ...@@ -404,6 +403,10 @@ struct drm_xe_gt {
* @near_mem_regions: Bit mask of instances from * @near_mem_regions: Bit mask of instances from
* drm_xe_query_mem_regions that are nearest to the current engines * drm_xe_query_mem_regions that are nearest to the current engines
* of this GT. * of this GT.
* Each index in this mask refers directly to the struct
* drm_xe_query_mem_regions' instance, no assumptions should
* be made about order. The type of each region is described
* by struct drm_xe_query_mem_regions' mem_class.
*/ */
__u64 near_mem_regions; __u64 near_mem_regions;
/** /**
...@@ -412,6 +415,10 @@ struct drm_xe_gt { ...@@ -412,6 +415,10 @@ struct drm_xe_gt {
* In general, they have extra indirections when compared to the * In general, they have extra indirections when compared to the
* @near_mem_regions. For a discrete device this could mean system * @near_mem_regions. For a discrete device this could mean system
* memory and memory living in a different tile. * memory and memory living in a different tile.
* Each index in this mask refers directly to the struct
* drm_xe_query_mem_regions' instance, no assumptions should
* be made about order. The type of each region is described
* by struct drm_xe_query_mem_regions' mem_class.
*/ */
__u64 far_mem_regions; __u64 far_mem_regions;
/** @reserved: Reserved */ /** @reserved: Reserved */
...@@ -652,7 +659,13 @@ struct drm_xe_gem_create { ...@@ -652,7 +659,13 @@ struct drm_xe_gem_create {
*/ */
__u64 size; __u64 size;
/** @placement: A mask of memory instances of where BO can be placed. */ /**
* @placement: A mask of memory instances of where BO can be placed.
* Each index in this mask refers directly to the struct
* drm_xe_query_mem_regions' instance, no assumptions should
* be made about order. The type of each region is described
* by struct drm_xe_query_mem_regions' mem_class.
*/
__u32 placement; __u32 placement;
#define DRM_XE_GEM_CREATE_FLAG_DEFER_BACKING (1 << 0) #define DRM_XE_GEM_CREATE_FLAG_DEFER_BACKING (1 << 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment