History

drm/xe/uapi: Align on a common way to return arrays (engines)

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 engines by applying the pattern below: struct drm_xe_query_Xs { __u32 num_Xs; struct drm_xe_X Xs[]; ... } Instead of directly returning an array of struct drm_xe_query_engine_info, a new struct drm_xe_query_engines is introduced. It contains itself an array of struct drm_xe_engine which holds the information about each engine. v2: Use plural for struct drm_xe_query_engines as multiple engines are returned (José Roberto de Souza)

Francois Dugast committed 2 years ago

Commit 60a6a841 parent 71c625a2 files · +65 −44Browse files

Showing the changes to include/uapi (1 of 2 files). Show all

Unified · Split

include/uapi/drm/xe_drm.h+47−31
@@ -127,9 +127,9 @@ struct xe_user_extension { · 126 unmodified lines
127/**127/**
128 * struct drm_xe_engine_class_instance - instance of an engine class128 * struct drm_xe_engine_class_instance - instance of an engine class
129 *129 *
130 * It is returned as part of the @drm_xe_query_engine_info, but it also is130 * It is returned as part of the @drm_xe_engine, but it also is used as
131 * used as the input of engine selection for both @drm_xe_exec_queue_create131 * the input of engine selection for both @drm_xe_exec_queue_create and
132 * and @drm_xe_query_engine_cycles132 * @drm_xe_query_engine_cycles
133 */133 */
134struct drm_xe_engine_class_instance {134struct drm_xe_engine_class_instance {
135#define DRM_XE_ENGINE_CLASS_RENDER 0135#define DRM_XE_ENGINE_CLASS_RENDER 0
@@ -154,13 +154,9 @@ struct drm_xe_engine_class_instance { · 18 unmodified lines
154};154};
155 155
156/**156/**
157 * struct drm_xe_query_engine_info - describe hardware engine157 * struct drm_xe_engine - describe hardware engine
158 *
159 * If a query is made with a struct @drm_xe_device_query where .query
160 * is equal to %DRM_XE_DEVICE_QUERY_ENGINES, then the reply uses an array of
161 * struct @drm_xe_query_engine_info in .data.
162 */158 */
163struct drm_xe_query_engine_info {159struct drm_xe_engine {
164 /** @instance: The @drm_xe_engine_class_instance */160 /** @instance: The @drm_xe_engine_class_instance */
165 struct drm_xe_engine_class_instance instance;161 struct drm_xe_engine_class_instance instance;
166 162
@@ -168,6 +164,22 @@ struct drm_xe_query_engine_info { · 1 unmodified line
168 __u64 reserved[3];164 __u64 reserved[3];
169};165};
170 166
167/**
168 * struct drm_xe_query_engines - describe engines
169 *
170 * If a query is made with a struct @drm_xe_device_query where .query
171 * is equal to %DRM_XE_DEVICE_QUERY_ENGINES, then the reply uses an array of
172 * struct @drm_xe_query_engines in .data.
173 */
174struct drm_xe_query_engines {
175 /** @num_engines: number of engines returned in @engines */
176 __u32 num_engines;
177 /** @pad: MBZ */
178 __u32 pad;
179 /** @engines: The returned engines for this device */
180 struct drm_xe_engine engines[];
181};
182
171/**183/**
172 * enum drm_xe_memory_class - Supported memory classes.184 * enum drm_xe_memory_class - Supported memory classes.
173 */185 */
@@ -467,28 +479,32 @@ struct drm_xe_query_topology_mask { · 293 unmodified lines
467 *479 *
468 * .. code-block:: C480 * .. code-block:: C
469 *481 *
470 * struct drm_xe_engine_class_instance *hwe;482 * struct drm_xe_query_engines *engines;
471 * struct drm_xe_device_query query = {483 * struct drm_xe_device_query query = {
472 * .extensions = 0,484 * .extensions = 0,
473 * .query = DRM_XE_DEVICE_QUERY_ENGINES,485 * .query = DRM_XE_DEVICE_QUERY_ENGINES,
474 * .size = 0,486 * .size = 0,
475 * .data = 0,487 * .data = 0,
476 * };488 * };
477 * ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query);489 * ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query);
478 * hwe = malloc(query.size);490 * engines = malloc(query.size);
479 * query.data = (uintptr_t)hwe;491 * query.data = (uintptr_t)engines;
480 * ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query);492 * ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query);
481 * int num_engines = query.size / sizeof(*hwe);493 * for (int i = 0; i < engines->num_engines; i++) {
482 * for (int i = 0; i < num_engines; i++) {494 * printf("Engine %d: %s\n", i,
483 * printf("Engine %d: %s\n", i,495 * engines->engines[i].instance.engine_class ==
484 * hwe[i].engine_class == DRM_XE_ENGINE_CLASS_RENDER ? "RENDER":496 * DRM_XE_ENGINE_CLASS_RENDER ? "RENDER":
485 * hwe[i].engine_class == DRM_XE_ENGINE_CLASS_COPY ? "COPY":497 * engines->engines[i].instance.engine_class ==
486 * hwe[i].engine_class == DRM_XE_ENGINE_CLASS_VIDEO_DECODE ? "VIDEO_DECODE":498 * DRM_XE_ENGINE_CLASS_COPY ? "COPY":
487 * hwe[i].engine_class == DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE ? "VIDEO_ENHANCE":499 * engines->engines[i].instance.engine_class ==
488 * hwe[i].engine_class == DRM_XE_ENGINE_CLASS_COMPUTE ? "COMPUTE":500 * DRM_XE_ENGINE_CLASS_VIDEO_DECODE ? "VIDEO_DECODE":
489 * "UNKNOWN");501 * engines->engines[i].instance.engine_class ==
490 * }502 * DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE ? "VIDEO_ENHANCE":
491 * free(hwe);503 * engines->engines[i].instance.engine_class ==
504 * DRM_XE_ENGINE_CLASS_COMPUTE ? "COMPUTE":
505 * "UNKNOWN");
506 * }
507 * free(engines);
492 */508 */
493struct drm_xe_device_query {509struct drm_xe_device_query {
494 /** @extensions: Pointer to the first extension struct, if any */510 /** @extensions: Pointer to the first extension struct, if any */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t