hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/include/uapi/linux/kfd_ioctl.h
....@@ -26,8 +26,12 @@
2626 #include <drm/drm.h>
2727 #include <linux/ioctl.h>
2828
29
+/*
30
+ * - 1.1 - initial version
31
+ * - 1.3 - Add SMI events support
32
+ */
2933 #define KFD_IOCTL_MAJOR_VERSION 1
30
-#define KFD_IOCTL_MINOR_VERSION 1
34
+#define KFD_IOCTL_MINOR_VERSION 3
3135
3236 struct kfd_ioctl_get_version_args {
3337 __u32 major_version; /* from KFD */
....@@ -35,9 +39,10 @@
3539 };
3640
3741 /* For kfd_ioctl_create_queue_args.queue_type. */
38
-#define KFD_IOC_QUEUE_TYPE_COMPUTE 0
39
-#define KFD_IOC_QUEUE_TYPE_SDMA 1
40
-#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 2
42
+#define KFD_IOC_QUEUE_TYPE_COMPUTE 0x0
43
+#define KFD_IOC_QUEUE_TYPE_SDMA 0x1
44
+#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 0x2
45
+#define KFD_IOC_QUEUE_TYPE_SDMA_XGMI 0x3
4146
4247 #define KFD_MAX_QUEUE_PERCENTAGE 100
4348 #define KFD_MAX_QUEUE_PRIORITY 15
....@@ -80,6 +85,14 @@
8085 __u32 queue_id; /* to KFD */
8186 __u32 num_cu_mask; /* to KFD */
8287 __u64 cu_mask_ptr; /* to KFD */
88
+};
89
+
90
+struct kfd_ioctl_get_queue_wave_state_args {
91
+ __u64 ctl_stack_address; /* to KFD */
92
+ __u32 ctl_stack_used_size; /* from KFD */
93
+ __u32 save_area_used_size; /* from KFD */
94
+ __u32 queue_id; /* to KFD */
95
+ __u32 pad;
8396 };
8497
8598 /* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */
....@@ -203,6 +216,11 @@
203216 #define KFD_HW_EXCEPTION_GPU_HANG 0
204217 #define KFD_HW_EXCEPTION_ECC 1
205218
219
+/* For kfd_hsa_memory_exception_data.ErrorType */
220
+#define KFD_MEM_ERR_NO_RAS 0
221
+#define KFD_MEM_ERR_SRAM_ECC 1
222
+#define KFD_MEM_ERR_POISON_CONSUMED 2
223
+#define KFD_MEM_ERR_GPU_HANG 3
206224
207225 struct kfd_ioctl_create_event_args {
208226 __u64 event_page_offset; /* from KFD */
....@@ -237,12 +255,17 @@
237255 __u32 imprecise; /* Can't determine the exact fault address */
238256 };
239257
240
-/* memory exception data*/
258
+/* memory exception data */
241259 struct kfd_hsa_memory_exception_data {
242260 struct kfd_memory_exception_failure failure;
243261 __u64 va;
244262 __u32 gpu_id;
245
- __u32 pad;
263
+ __u32 ErrorType; /* 0 = no RAS error,
264
+ * 1 = ECC_SRAM,
265
+ * 2 = Link_SYNFLOOD (poison),
266
+ * 3 = GPU hang (not attributable to a specific cause),
267
+ * other values reserved
268
+ */
246269 };
247270
248271 /* hw exception data */
....@@ -320,6 +343,7 @@
320343 #define KFD_IOC_ALLOC_MEM_FLAGS_GTT (1 << 1)
321344 #define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR (1 << 2)
322345 #define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL (1 << 3)
346
+#define KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP (1 << 4)
323347 /* Allocation flags: attributes/access options */
324348 #define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE (1 << 31)
325349 #define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE (1 << 30)
....@@ -388,6 +412,63 @@
388412 __u64 device_ids_array_ptr; /* to KFD */
389413 __u32 n_devices; /* to KFD */
390414 __u32 n_success; /* to/from KFD */
415
+};
416
+
417
+/* Allocate GWS for specific queue
418
+ *
419
+ * @queue_id: queue's id that GWS is allocated for
420
+ * @num_gws: how many GWS to allocate
421
+ * @first_gws: index of the first GWS allocated.
422
+ * only support contiguous GWS allocation
423
+ */
424
+struct kfd_ioctl_alloc_queue_gws_args {
425
+ __u32 queue_id; /* to KFD */
426
+ __u32 num_gws; /* to KFD */
427
+ __u32 first_gws; /* from KFD */
428
+ __u32 pad;
429
+};
430
+
431
+struct kfd_ioctl_get_dmabuf_info_args {
432
+ __u64 size; /* from KFD */
433
+ __u64 metadata_ptr; /* to KFD */
434
+ __u32 metadata_size; /* to KFD (space allocated by user)
435
+ * from KFD (actual metadata size)
436
+ */
437
+ __u32 gpu_id; /* from KFD */
438
+ __u32 flags; /* from KFD (KFD_IOC_ALLOC_MEM_FLAGS) */
439
+ __u32 dmabuf_fd; /* to KFD */
440
+};
441
+
442
+struct kfd_ioctl_import_dmabuf_args {
443
+ __u64 va_addr; /* to KFD */
444
+ __u64 handle; /* from KFD */
445
+ __u32 gpu_id; /* to KFD */
446
+ __u32 dmabuf_fd; /* to KFD */
447
+};
448
+
449
+/*
450
+ * KFD SMI(System Management Interface) events
451
+ */
452
+enum kfd_smi_event {
453
+ KFD_SMI_EVENT_NONE = 0, /* not used */
454
+ KFD_SMI_EVENT_VMFAULT = 1, /* event start counting at 1 */
455
+ KFD_SMI_EVENT_THERMAL_THROTTLE = 2,
456
+ KFD_SMI_EVENT_GPU_PRE_RESET = 3,
457
+ KFD_SMI_EVENT_GPU_POST_RESET = 4,
458
+};
459
+
460
+#define KFD_SMI_EVENT_MASK_FROM_INDEX(i) (1ULL << ((i) - 1))
461
+
462
+struct kfd_ioctl_smi_events_args {
463
+ __u32 gpuid; /* to KFD */
464
+ __u32 anon_fd; /* from KFD */
465
+};
466
+
467
+/* Register offset inside the remapped mmio page
468
+ */
469
+enum kfd_mmio_remap {
470
+ KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL = 0,
471
+ KFD_MMIO_REMAP_HDP_REG_FLUSH_CNTL = 4,
391472 };
392473
393474 #define AMDKFD_IOCTL_BASE 'K'
....@@ -475,7 +556,22 @@
475556 #define AMDKFD_IOC_SET_CU_MASK \
476557 AMDKFD_IOW(0x1A, struct kfd_ioctl_set_cu_mask_args)
477558
559
+#define AMDKFD_IOC_GET_QUEUE_WAVE_STATE \
560
+ AMDKFD_IOWR(0x1B, struct kfd_ioctl_get_queue_wave_state_args)
561
+
562
+#define AMDKFD_IOC_GET_DMABUF_INFO \
563
+ AMDKFD_IOWR(0x1C, struct kfd_ioctl_get_dmabuf_info_args)
564
+
565
+#define AMDKFD_IOC_IMPORT_DMABUF \
566
+ AMDKFD_IOWR(0x1D, struct kfd_ioctl_import_dmabuf_args)
567
+
568
+#define AMDKFD_IOC_ALLOC_QUEUE_GWS \
569
+ AMDKFD_IOWR(0x1E, struct kfd_ioctl_alloc_queue_gws_args)
570
+
571
+#define AMDKFD_IOC_SMI_EVENTS \
572
+ AMDKFD_IOWR(0x1F, struct kfd_ioctl_smi_events_args)
573
+
478574 #define AMDKFD_COMMAND_START 0x01
479
-#define AMDKFD_COMMAND_END 0x1B
575
+#define AMDKFD_COMMAND_END 0x20
480576
481577 #endif