History

accel/amdxdna: Add query functions

Add GET_INFO ioctl to retrieve hardware information, including AIE, clock, hardware context etc.

Lizhi Hou committed 1 year ago

Commit 850d71f1 parent 4fd4ca96 files · +476 −0Browse files

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

Unified · Split

include/uapi/drm/amdxdna_accel.h+166−0
@@ -32,6 +32,7 @@ enum amdxdna_drm_ioctl_id { · 31 unmodified lines
3232 DRM_AMDXDNA_GET_BO_INFO,
3333 DRM_AMDXDNA_SYNC_BO,
3434 DRM_AMDXDNA_EXEC_CMD,
35+ DRM_AMDXDNA_GET_INFO,
3536 };
3637
3738 /**
@@ -235,6 +236,167 @@ struct amdxdna_drm_exec_cmd { · 197 unmodified lines
235236 __u64 seq;
236237 };
237238
239+/**
240+ * struct amdxdna_drm_query_aie_status - Query the status of the AIE hardware
241+ * @buffer: The user space buffer that will return the AIE status.
242+ * @buffer_size: The size of the user space buffer.
243+ * @cols_filled: A bitmap of AIE columns whose data has been returned in the buffer.
244+ */
245+struct amdxdna_drm_query_aie_status {
246+ __u64 buffer; /* out */
247+ __u32 buffer_size; /* in */
248+ __u32 cols_filled; /* out */
249+};
250+
251+/**
252+ * struct amdxdna_drm_query_aie_version - Query the version of the AIE hardware
253+ * @major: The major version number.
254+ * @minor: The minor version number.
255+ */
256+struct amdxdna_drm_query_aie_version {
257+ __u32 major; /* out */
258+ __u32 minor; /* out */
259+};
260+
261+/**
262+ * struct amdxdna_drm_query_aie_tile_metadata - Query the metadata of AIE tile (core, mem, shim)
263+ * @row_count: The number of rows.
264+ * @row_start: The starting row number.
265+ * @dma_channel_count: The number of dma channels.
266+ * @lock_count: The number of locks.
267+ * @event_reg_count: The number of events.
268+ * @pad: Structure padding.
269+ */
270+struct amdxdna_drm_query_aie_tile_metadata {
271+ __u16 row_count;
272+ __u16 row_start;
273+ __u16 dma_channel_count;
274+ __u16 lock_count;
275+ __u16 event_reg_count;
276+ __u16 pad[3];
277+};
278+
279+/**
280+ * struct amdxdna_drm_query_aie_metadata - Query the metadata of the AIE hardware
281+ * @col_size: The size of a column in bytes.
282+ * @cols: The total number of columns.
283+ * @rows: The total number of rows.
284+ * @version: The version of the AIE hardware.
285+ * @core: The metadata for all core tiles.
286+ * @mem: The metadata for all mem tiles.
287+ * @shim: The metadata for all shim tiles.
288+ */
289+struct amdxdna_drm_query_aie_metadata {
290+ __u32 col_size;
291+ __u16 cols;
292+ __u16 rows;
293+ struct amdxdna_drm_query_aie_version version;
294+ struct amdxdna_drm_query_aie_tile_metadata core;
295+ struct amdxdna_drm_query_aie_tile_metadata mem;
296+ struct amdxdna_drm_query_aie_tile_metadata shim;
297+};
298+
299+/**
300+ * struct amdxdna_drm_query_clock - Metadata for a clock
301+ * @name: The clock name.
302+ * @freq_mhz: The clock frequency.
303+ * @pad: Structure padding.
304+ */
305+struct amdxdna_drm_query_clock {
306+ __u8 name[16];
307+ __u32 freq_mhz;
308+ __u32 pad;
309+};
310+
311+/**
312+ * struct amdxdna_drm_query_clock_metadata - Query metadata for clocks
313+ * @mp_npu_clock: The metadata for MP-NPU clock.
314+ * @h_clock: The metadata for H clock.
315+ */
316+struct amdxdna_drm_query_clock_metadata {
317+ struct amdxdna_drm_query_clock mp_npu_clock;
318+ struct amdxdna_drm_query_clock h_clock;
319+};
320+
321+enum amdxdna_sensor_type {
322+ AMDXDNA_SENSOR_TYPE_POWER
323+};
324+
325+/**
326+ * struct amdxdna_drm_query_sensor - The data for single sensor.
327+ * @label: The name for a sensor.
328+ * @input: The current value of the sensor.
329+ * @max: The maximum value possible for the sensor.
330+ * @average: The average value of the sensor.
331+ * @highest: The highest recorded sensor value for this driver load for the sensor.
332+ * @status: The sensor status.
333+ * @units: The sensor units.
334+ * @unitm: Translates value member variables into the correct unit via (pow(10, unitm) * value).
335+ * @type: The sensor type from enum amdxdna_sensor_type.
336+ * @pad: Structure padding.
337+ */
338+struct amdxdna_drm_query_sensor {
339+ __u8 label[64];
340+ __u32 input;
341+ __u32 max;
342+ __u32 average;
343+ __u32 highest;
344+ __u8 status[64];
345+ __u8 units[16];
346+ __s8 unitm;
347+ __u8 type;
348+ __u8 pad[6];
349+};
350+
351+/**
352+ * struct amdxdna_drm_query_hwctx - The data for single context.
353+ * @context_id: The ID for this context.
354+ * @start_col: The starting column for the partition assigned to this context.
355+ * @num_col: The number of columns in the partition assigned to this context.
356+ * @pad: Structure padding.
357+ * @pid: The Process ID of the process that created this context.
358+ * @command_submissions: The number of commands submitted to this context.
359+ * @command_completions: The number of commands completed by this context.
360+ * @migrations: The number of times this context has been moved to a different partition.
361+ * @preemptions: The number of times this context has been preempted by another context in the
362+ * same partition.
363+ * @errors: The errors for this context.
364+ */
365+struct amdxdna_drm_query_hwctx {
366+ __u32 context_id;
367+ __u32 start_col;
368+ __u32 num_col;
369+ __u32 pad;
370+ __s64 pid;
371+ __u64 command_submissions;
372+ __u64 command_completions;
373+ __u64 migrations;
374+ __u64 preemptions;
375+ __u64 errors;
376+};
377+
378+enum amdxdna_drm_get_param {
379+ DRM_AMDXDNA_QUERY_AIE_STATUS,
380+ DRM_AMDXDNA_QUERY_AIE_METADATA,
381+ DRM_AMDXDNA_QUERY_AIE_VERSION,
382+ DRM_AMDXDNA_QUERY_CLOCK_METADATA,
383+ DRM_AMDXDNA_QUERY_SENSORS,
384+ DRM_AMDXDNA_QUERY_HW_CONTEXTS,
385+ DRM_AMDXDNA_NUM_GET_PARAM,
386+};
387+
388+/**
389+ * struct amdxdna_drm_get_info - Get some information from the AIE hardware.
390+ * @param: Value in enum amdxdna_drm_get_param. Specifies the structure passed in the buffer.
391+ * @buffer_size: Size of the input buffer. Size needed/written by the kernel.
392+ * @buffer: A structure specified by the param struct member.
393+ */
394+struct amdxdna_drm_get_info {
395+ __u32 param; /* in */
396+ __u32 buffer_size; /* in/out */
397+ __u64 buffer; /* in/out */
398+};
399+
238400 #define DRM_IOCTL_AMDXDNA_CREATE_HWCTX \
239401 DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_CREATE_HWCTX, \
240402 struct amdxdna_drm_create_hwctx)
@@ -263,6 +425,10 @@ struct amdxdna_drm_exec_cmd { · 22 unmodified lines
263425 DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_EXEC_CMD, \
264426 struct amdxdna_drm_exec_cmd)
265427
428+#define DRM_IOCTL_AMDXDNA_GET_INFO \
429+ DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDXDNA_GET_INFO, \
430+ struct amdxdna_drm_get_info)
431+
266432 #if defined(__cplusplus)
267433 } /* extern c end */
268434 #endif