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
127127 /**
128128 * struct drm_xe_engine_class_instance - instance of an engine class
129129 *
130− * It is returned as part of the @drm_xe_query_engine_info, but it also is
131− * used as the input of engine selection for both @drm_xe_exec_queue_create
132− * and @drm_xe_query_engine_cycles
130+ * It is returned as part of the @drm_xe_engine, but it also is used as
131+ * the input of engine selection for both @drm_xe_exec_queue_create and
132+ * @drm_xe_query_engine_cycles
133133 */
134134 struct drm_xe_engine_class_instance {
135135 #define DRM_XE_ENGINE_CLASS_RENDER 0
@@ -154,13 +154,9 @@ struct drm_xe_engine_class_instance { · 18 unmodified lines
154154 };
155155
156156 /**
157− * struct drm_xe_query_engine_info - 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.
157+ * struct drm_xe_engine - describe hardware engine
162158 */
163−struct drm_xe_query_engine_info {
159+struct drm_xe_engine {
164160 /** @instance: The @drm_xe_engine_class_instance */
165161 struct drm_xe_engine_class_instance instance;
166162
@@ -168,6 +164,22 @@ struct drm_xe_query_engine_info { · 1 unmodified line
168164 __u64 reserved[3];
169165 };
170166
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+ */
174+struct 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+
171183 /**
172184 * enum drm_xe_memory_class - Supported memory classes.
173185 */
@@ -467,28 +479,32 @@ struct drm_xe_query_topology_mask { · 293 unmodified lines
467479 *
468480 * .. code-block:: C
469481 *
470− * struct drm_xe_engine_class_instance *hwe;
471− * struct drm_xe_device_query query = {
472− * .extensions = 0,
473− * .query = DRM_XE_DEVICE_QUERY_ENGINES,
474− * .size = 0,
475− * .data = 0,
476− * };
477− * ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query);
478− * hwe = malloc(query.size);
479− * query.data = (uintptr_t)hwe;
480− * ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query);
481− * int num_engines = query.size / sizeof(*hwe);
482− * for (int i = 0; i < num_engines; i++) {
483− * printf("Engine %d: %s\n", i,
484− * hwe[i].engine_class == DRM_XE_ENGINE_CLASS_RENDER ? "RENDER":
485− * hwe[i].engine_class == DRM_XE_ENGINE_CLASS_COPY ? "COPY":
486− * hwe[i].engine_class == DRM_XE_ENGINE_CLASS_VIDEO_DECODE ? "VIDEO_DECODE":
487− * hwe[i].engine_class == DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE ? "VIDEO_ENHANCE":
488− * hwe[i].engine_class == DRM_XE_ENGINE_CLASS_COMPUTE ? "COMPUTE":
489− * "UNKNOWN");
490− * }
491− * free(hwe);
482+ * struct drm_xe_query_engines *engines;
483+ * struct drm_xe_device_query query = {
484+ * .extensions = 0,
485+ * .query = DRM_XE_DEVICE_QUERY_ENGINES,
486+ * .size = 0,
487+ * .data = 0,
488+ * };
489+ * ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query);
490+ * engines = malloc(query.size);
491+ * query.data = (uintptr_t)engines;
492+ * ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, &query);
493+ * for (int i = 0; i < engines->num_engines; i++) {
494+ * printf("Engine %d: %s\n", i,
495+ * engines->engines[i].instance.engine_class ==
496+ * DRM_XE_ENGINE_CLASS_RENDER ? "RENDER":
497+ * engines->engines[i].instance.engine_class ==
498+ * DRM_XE_ENGINE_CLASS_COPY ? "COPY":
499+ * engines->engines[i].instance.engine_class ==
500+ * DRM_XE_ENGINE_CLASS_VIDEO_DECODE ? "VIDEO_DECODE":
501+ * engines->engines[i].instance.engine_class ==
502+ * DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE ? "VIDEO_ENHANCE":
503+ * engines->engines[i].instance.engine_class ==
504+ * DRM_XE_ENGINE_CLASS_COMPUTE ? "COMPUTE":
505+ * "UNKNOWN");
506+ * }
507+ * free(engines);
492508 */
493509 struct drm_xe_device_query {
494510 /** @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