History

Merge tag 'amd-drm-next-6.5-2023-06-09' of https://gitlab.freedesktop.org/agd5f/linux into drm-next

amd-drm-next-6.5-2023-06-02: amdgpu: - SR-IOV fixes - Warning fixes - Misc code cleanups and spelling fixes - DCN 3.2 updates - Improved DC FAMS support for better power management - Improved DC SubVP support for better power management - DCN 3.1.x fixes - Max IB size query - DC GPU reset fixes - RAS updates - DCN 3.0.x fixes - S/G display fixes - CP shadow buffer support - Implement connector force callback - Z8 power improvements - PSP 13.0.10 vbflash support - Mode2 reset fixes - Store MQDs in VRAM to improve queue switch latency - VCN 3.x fixes - JPEG 3.x fixes - Enable DC_FP on LoongArch - GFXOFF fixes - GC 9.4.3 partition support - SDMA 4.4.2 partition support - VCN/JPEG 4.0.3 partition support - VCN 4.0.3 updates - NBIO 7.9 updates - GC 9.4.3 updates - Take NUMA into account when allocating memory - Handle NUMA for partitions - SMU 13.0.6 updates - GC 9.4.3 RAS updates - Stop including unused swiotlb.h - SMU 13.0.7 fixes - Fix clock output ordering on some APUs - Clean up DC FPGA code - GFX9 preemption fixes - Misc irq fixes - S0ix fixes - Add new DRM_AMDGPU_WERROR config parameter to help with CI - PCIe fix for RDNA2 - kdoc fixes - Documentation updates amdkfd: - Query TTM mem limit rather than hardcoding it - GC 9.4.3 partition support - Handle NUMA for partitions radeon: - Fix possible double free - Stop including unused swiotlb.h - Fix possible division by zero ttm: - Add query for TTM mem limit - Add NUMA awareness to pools - Export ttm_pool_fini() UAPI: - Add new ctx query flag to better handle GPU resets Mesa MR: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22290 - Add new interface to query and set shadow buffer for RDNA3 Mesa MR: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21986 - Add new INFO query for max IB size Proposed userspace: https://gitlab.freedesktop.org/bnieuwenhuizen/mesa/-/commits/ib-rejection-v3 amd-drm-next-6.5-2023-06-09: amdgpu: - S0ix fixes - Initial SMU13 Overdrive support - kdoc fixes - Misc clode cleanups - Flexible array fixes - Display OTG fixes - SMU 13.0.6 updates - Revert some broken clock counter updates - Misc display fixes - GFX9 preemption fixes - Add support for newer EEPROM bad page table format - Add missing radeon secondary id - Add support for new colorspace KMS API - CSA fix - Stable pstate fixes for APUs - make vbl interface admin only - Handle PCI accelerator class amdkfd: - Add debugger support for gdb radeon: - Fix possible UAF drm: - Add Colorspace functionality UAPI: - Add debugger interface for enabling gdb Proposed userspace: https://github.com/ROCm-Developer-Tools/ROCdbgapi/tree/wip-dbgapi - Add KMS colorspace API Discussion: https://lists.freedesktop.org/archives/dri-devel/2023-June/408128.html

Dave Airlie committed 3 years ago

Commit 901bdf52 parents ba57b9b 3b718dc498 files · +45770 −8019Browse files

Showing the changes to include/uapi (3 of 498 files). Show all

Unified · Split

3 files
  1. include/uapi/drm/amdgpu_drm.h +22 −0
  2. include/uapi/linux/kfd_ioctl.h +669 −2
  3. include/uapi/linux/kfd_sysfs.h +15 −0
include/uapi/drm/amdgpu_drm.h+22−0
@@ -245,6 +245,8 @@ union drm_amdgpu_bo_list { · 244 unmodified lines
245/* indicate some errors are detected by RAS */245/* indicate some errors are detected by RAS */
246#define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE (1<<3)246#define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE (1<<3)
247#define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE (1<<4)247#define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE (1<<4)
248/* indicate that the reset hasn't completed yet */
249#define AMDGPU_CTX_QUERY2_FLAGS_RESET_IN_PROGRESS (1<<5)
248 250
249/* Context priority level */251/* Context priority level */
250#define AMDGPU_CTX_PRIORITY_UNSET -2048252#define AMDGPU_CTX_PRIORITY_UNSET -2048
@@ -592,6 +594,7 @@ struct drm_amdgpu_gem_va { · 341 unmodified lines
592#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07594#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
593#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08595#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08
594#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09596#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09
597#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW 0x0a
595 598
596struct drm_amdgpu_cs_chunk {599struct drm_amdgpu_cs_chunk {
597 __u32 chunk_id;600 __u32 chunk_id;
@@ -708,6 +711,15 @@ struct drm_amdgpu_cs_chunk_data { · 110 unmodified lines
708 };711 };
709};712};
710 713
714#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW 0x1
715
716struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
717 __u64 shadow_va;
718 __u64 csa_va;
719 __u64 gds_va;
720 __u64 flags;
721};
722
711/*723/*
712 * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU724 * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
713 *725 *
@@ -876,6 +888,8 @@ struct drm_amdgpu_cs_chunk_data { · 162 unmodified lines
876 #define AMDGPU_INFO_VIDEO_CAPS_DECODE 0888 #define AMDGPU_INFO_VIDEO_CAPS_DECODE 0
877 /* Subquery id: Encode */889 /* Subquery id: Encode */
878 #define AMDGPU_INFO_VIDEO_CAPS_ENCODE 1890 #define AMDGPU_INFO_VIDEO_CAPS_ENCODE 1
891/* Query the max number of IBs per gang per submission */
892#define AMDGPU_INFO_MAX_IBS 0x22
879 893
880#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0894#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
881#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff895#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
@@ -1126,6 +1140,14 @@ struct drm_amdgpu_info_device { · 244 unmodified lines
1126 __u64 mall_size; /* AKA infinity cache */1140 __u64 mall_size; /* AKA infinity cache */
1127 /* high 32 bits of the rb pipes mask */1141 /* high 32 bits of the rb pipes mask */
1128 __u32 enabled_rb_pipes_mask_hi;1142 __u32 enabled_rb_pipes_mask_hi;
1143 /* shadow area size for gfx11 */
1144 __u32 shadow_size;
1145 /* shadow area base virtual alignment for gfx11 */
1146 __u32 shadow_alignment;
1147 /* context save area size for gfx11 */
1148 __u32 csa_size;
1149 /* context save area base virtual alignment for gfx11 */
1150 __u32 csa_alignment;
1129};1151};
1130 1152
1131struct drm_amdgpu_info_hw_ip {1153struct drm_amdgpu_info_hw_ip {
include/uapi/linux/kfd_ioctl.h+669−2
@@ -38,9 +38,10 @@ · 37 unmodified lines
38 * - 1.10 - Add SMI profiler event log38 * - 1.10 - Add SMI profiler event log
39 * - 1.11 - Add unified memory for ctx save/restore area39 * - 1.11 - Add unified memory for ctx save/restore area
40 * - 1.12 - Add DMA buf export ioctl40 * - 1.12 - Add DMA buf export ioctl
41 * - 1.13 - Add debugger API
41 */42 */
42#define KFD_IOCTL_MAJOR_VERSION 143#define KFD_IOCTL_MAJOR_VERSION 1
43#define KFD_IOCTL_MINOR_VERSION 1244#define KFD_IOCTL_MINOR_VERSION 13
44 45
45struct kfd_ioctl_get_version_args {46struct kfd_ioctl_get_version_args {
46 __u32 major_version; /* from KFD */47 __u32 major_version; /* from KFD */
@@ -110,6 +111,32 @@ struct kfd_ioctl_get_available_memory_args { · 63 unmodified lines
110 __u32 pad;111 __u32 pad;
111};112};
112 113
114struct kfd_dbg_device_info_entry {
115 __u64 exception_status;
116 __u64 lds_base;
117 __u64 lds_limit;
118 __u64 scratch_base;
119 __u64 scratch_limit;
120 __u64 gpuvm_base;
121 __u64 gpuvm_limit;
122 __u32 gpu_id;
123 __u32 location_id;
124 __u32 vendor_id;
125 __u32 device_id;
126 __u32 revision_id;
127 __u32 subsystem_vendor_id;
128 __u32 subsystem_device_id;
129 __u32 fw_version;
130 __u32 gfx_target_version;
131 __u32 simd_count;
132 __u32 max_waves_per_simd;
133 __u32 array_count;
134 __u32 simd_arrays_per_engine;
135 __u32 num_xcc;
136 __u32 capability;
137 __u32 debug_prop;
138};
139
113/* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */140/* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */
114#define KFD_IOC_CACHE_POLICY_COHERENT 0141#define KFD_IOC_CACHE_POLICY_COHERENT 0
115#define KFD_IOC_CACHE_POLICY_NONCOHERENT 1142#define KFD_IOC_CACHE_POLICY_NONCOHERENT 1
@@ -773,6 +800,640 @@ struct kfd_ioctl_set_xnack_mode_args { · 657 unmodified lines
773 __s32 xnack_enabled;800 __s32 xnack_enabled;
774};801};
775 802
803/* Wave launch override modes */
804enum kfd_dbg_trap_override_mode {
805 KFD_DBG_TRAP_OVERRIDE_OR = 0,
806 KFD_DBG_TRAP_OVERRIDE_REPLACE = 1
807};
808
809/* Wave launch overrides */
810enum kfd_dbg_trap_mask {
811 KFD_DBG_TRAP_MASK_FP_INVALID = 1,
812 KFD_DBG_TRAP_MASK_FP_INPUT_DENORMAL = 2,
813 KFD_DBG_TRAP_MASK_FP_DIVIDE_BY_ZERO = 4,
814 KFD_DBG_TRAP_MASK_FP_OVERFLOW = 8,
815 KFD_DBG_TRAP_MASK_FP_UNDERFLOW = 16,
816 KFD_DBG_TRAP_MASK_FP_INEXACT = 32,
817 KFD_DBG_TRAP_MASK_INT_DIVIDE_BY_ZERO = 64,
818 KFD_DBG_TRAP_MASK_DBG_ADDRESS_WATCH = 128,
819 KFD_DBG_TRAP_MASK_DBG_MEMORY_VIOLATION = 256,
820 KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_START = (1 << 30),
821 KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_END = (1 << 31)
822};
823
824/* Wave launch modes */
825enum kfd_dbg_trap_wave_launch_mode {
826 KFD_DBG_TRAP_WAVE_LAUNCH_MODE_NORMAL = 0,
827 KFD_DBG_TRAP_WAVE_LAUNCH_MODE_HALT = 1,
828 KFD_DBG_TRAP_WAVE_LAUNCH_MODE_DEBUG = 3
829};
830
831/* Address watch modes */
832enum kfd_dbg_trap_address_watch_mode {
833 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_READ = 0,
834 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_NONREAD = 1,
835 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ATOMIC = 2,
836 KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ALL = 3
837};
838
839/* Additional wave settings */
840enum kfd_dbg_trap_flags {
841 KFD_DBG_TRAP_FLAG_SINGLE_MEM_OP = 1,
842};
843
844/* Trap exceptions */
845enum kfd_dbg_trap_exception_code {
846 EC_NONE = 0,
847 /* per queue */
848 EC_QUEUE_WAVE_ABORT = 1,
849 EC_QUEUE_WAVE_TRAP = 2,
850 EC_QUEUE_WAVE_MATH_ERROR = 3,
851 EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION = 4,
852 EC_QUEUE_WAVE_MEMORY_VIOLATION = 5,
853 EC_QUEUE_WAVE_APERTURE_VIOLATION = 6,
854 EC_QUEUE_PACKET_DISPATCH_DIM_INVALID = 16,
855 EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID = 17,
856 EC_QUEUE_PACKET_DISPATCH_CODE_INVALID = 18,
857 EC_QUEUE_PACKET_RESERVED = 19,
858 EC_QUEUE_PACKET_UNSUPPORTED = 20,
859 EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID = 21,
860 EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID = 22,
861 EC_QUEUE_PACKET_VENDOR_UNSUPPORTED = 23,
862 EC_QUEUE_PREEMPTION_ERROR = 30,
863 EC_QUEUE_NEW = 31,
864 /* per device */
865 EC_DEVICE_QUEUE_DELETE = 32,
866 EC_DEVICE_MEMORY_VIOLATION = 33,
867 EC_DEVICE_RAS_ERROR = 34,
868 EC_DEVICE_FATAL_HALT = 35,
869 EC_DEVICE_NEW = 36,
870 /* per process */
871 EC_PROCESS_RUNTIME = 48,
872 EC_PROCESS_DEVICE_REMOVE = 49,
873 EC_MAX
874};
875
876/* Mask generated by ecode in kfd_dbg_trap_exception_code */
877#define KFD_EC_MASK(ecode) (1ULL << (ecode - 1))
878
879/* Masks for exception code type checks below */
880#define KFD_EC_MASK_QUEUE (KFD_EC_MASK(EC_QUEUE_WAVE_ABORT) | \
881 KFD_EC_MASK(EC_QUEUE_WAVE_TRAP) | \
882 KFD_EC_MASK(EC_QUEUE_WAVE_MATH_ERROR) | \
883 KFD_EC_MASK(EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION) | \
884 KFD_EC_MASK(EC_QUEUE_WAVE_MEMORY_VIOLATION) | \
885 KFD_EC_MASK(EC_QUEUE_WAVE_APERTURE_VIOLATION) | \
886 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_DIM_INVALID) | \
887 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID) | \
888 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_CODE_INVALID) | \
889 KFD_EC_MASK(EC_QUEUE_PACKET_RESERVED) | \
890 KFD_EC_MASK(EC_QUEUE_PACKET_UNSUPPORTED) | \
891 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID) | \
892 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID) | \
893 KFD_EC_MASK(EC_QUEUE_PACKET_VENDOR_UNSUPPORTED) | \
894 KFD_EC_MASK(EC_QUEUE_PREEMPTION_ERROR) | \
895 KFD_EC_MASK(EC_QUEUE_NEW))
896#define KFD_EC_MASK_DEVICE (KFD_EC_MASK(EC_DEVICE_QUEUE_DELETE) | \
897 KFD_EC_MASK(EC_DEVICE_RAS_ERROR) | \
898 KFD_EC_MASK(EC_DEVICE_FATAL_HALT) | \
899 KFD_EC_MASK(EC_DEVICE_MEMORY_VIOLATION) | \
900 KFD_EC_MASK(EC_DEVICE_NEW))
901#define KFD_EC_MASK_PROCESS (KFD_EC_MASK(EC_PROCESS_RUNTIME) | \
902 KFD_EC_MASK(EC_PROCESS_DEVICE_REMOVE))
903
904/* Checks for exception code types for KFD search */
905#define KFD_DBG_EC_TYPE_IS_QUEUE(ecode) \
906 (!!(KFD_EC_MASK(ecode) & KFD_EC_MASK_QUEUE))
907#define KFD_DBG_EC_TYPE_IS_DEVICE(ecode) \
908 (!!(KFD_EC_MASK(ecode) & KFD_EC_MASK_DEVICE))
909#define KFD_DBG_EC_TYPE_IS_PROCESS(ecode) \
910 (!!(KFD_EC_MASK(ecode) & KFD_EC_MASK_PROCESS))
911
912
913/* Runtime enable states */
914enum kfd_dbg_runtime_state {
915 DEBUG_RUNTIME_STATE_DISABLED = 0,
916 DEBUG_RUNTIME_STATE_ENABLED = 1,
917 DEBUG_RUNTIME_STATE_ENABLED_BUSY = 2,
918 DEBUG_RUNTIME_STATE_ENABLED_ERROR = 3
919};
920
921/* Runtime enable status */
922struct kfd_runtime_info {
923 __u64 r_debug;
924 __u32 runtime_state;
925 __u32 ttmp_setup;
926};
927
928/* Enable modes for runtime enable */
929#define KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK 1
930#define KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK 2
931
932/**
933 * kfd_ioctl_runtime_enable_args - Arguments for runtime enable
934 *
935 * Coordinates debug exception signalling and debug device enablement with runtime.
936 *
937 * @r_debug - pointer to user struct for sharing information between ROCr and the debuggger
938 * @mode_mask - mask to set mode
939 * KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK - enable runtime for debugging, otherwise disable
940 * KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK - enable trap temporary setup (ignore on disable)
941 * @capabilities_mask - mask to notify runtime on what KFD supports
942 *
943 * Return - 0 on SUCCESS.
944 * - EBUSY if runtime enable call already pending.
945 * - EEXIST if user queues already active prior to call.
946 * If process is debug enabled, runtime enable will enable debug devices and
947 * wait for debugger process to send runtime exception EC_PROCESS_RUNTIME
948 * to unblock - see kfd_ioctl_dbg_trap_args.
949 *
950 */
951struct kfd_ioctl_runtime_enable_args {
952 __u64 r_debug;
953 __u32 mode_mask;
954 __u32 capabilities_mask;
955};
956
957/* Queue information */
958struct kfd_queue_snapshot_entry {
959 __u64 exception_status;
960 __u64 ring_base_address;
961 __u64 write_pointer_address;
962 __u64 read_pointer_address;
963 __u64 ctx_save_restore_address;
964 __u32 queue_id;
965 __u32 gpu_id;
966 __u32 ring_size;
967 __u32 queue_type;
968 __u32 ctx_save_restore_area_size;
969 __u32 reserved;
970};
971
972/* Queue status return for suspend/resume */
973#define KFD_DBG_QUEUE_ERROR_BIT 30
974#define KFD_DBG_QUEUE_INVALID_BIT 31
975#define KFD_DBG_QUEUE_ERROR_MASK (1 << KFD_DBG_QUEUE_ERROR_BIT)
976#define KFD_DBG_QUEUE_INVALID_MASK (1 << KFD_DBG_QUEUE_INVALID_BIT)
977
978/* Context save area header information */
979struct kfd_context_save_area_header {
980 struct {
981 __u32 control_stack_offset;
982 __u32 control_stack_size;
983 __u32 wave_state_offset;
984 __u32 wave_state_size;
985 } wave_state;
986 __u32 debug_offset;
987 __u32 debug_size;
988 __u64 err_payload_addr;
989 __u32 err_event_id;
990 __u32 reserved1;
991};
992
993/*
994 * Debug operations
995 *
996 * For specifics on usage and return values, see documentation per operation
997 * below. Otherwise, generic error returns apply:
998 * - ESRCH if the process to debug does not exist.
999 *
1000 * - EINVAL (with KFD_IOC_DBG_TRAP_ENABLE exempt) if operation
1001 * KFD_IOC_DBG_TRAP_ENABLE has not succeeded prior.
1002 * Also returns this error if GPU hardware scheduling is not supported.
1003 *
1004 * - EPERM (with KFD_IOC_DBG_TRAP_DISABLE exempt) if target process is not
1005 * PTRACE_ATTACHED. KFD_IOC_DBG_TRAP_DISABLE is exempt to allow
1006 * clean up of debug mode as long as process is debug enabled.
1007 *
1008 * - EACCES if any DBG_HW_OP (debug hardware operation) is requested when
1009 * AMDKFD_IOC_RUNTIME_ENABLE has not succeeded prior.
1010 *
1011 * - ENODEV if any GPU does not support debugging on a DBG_HW_OP call.
1012 *
1013 * - Other errors may be returned when a DBG_HW_OP occurs while the GPU
1014 * is in a fatal state.
1015 *
1016 */
1017enum kfd_dbg_trap_operations {
1018 KFD_IOC_DBG_TRAP_ENABLE = 0,
1019 KFD_IOC_DBG_TRAP_DISABLE = 1,
1020 KFD_IOC_DBG_TRAP_SEND_RUNTIME_EVENT = 2,
1021 KFD_IOC_DBG_TRAP_SET_EXCEPTIONS_ENABLED = 3,
1022 KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVERRIDE = 4, /* DBG_HW_OP */
1023 KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE = 5, /* DBG_HW_OP */
1024 KFD_IOC_DBG_TRAP_SUSPEND_QUEUES = 6, /* DBG_HW_OP */
1025 KFD_IOC_DBG_TRAP_RESUME_QUEUES = 7, /* DBG_HW_OP */
1026 KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH = 8, /* DBG_HW_OP */
1027 KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_WATCH = 9, /* DBG_HW_OP */
1028 KFD_IOC_DBG_TRAP_SET_FLAGS = 10,
1029 KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT = 11,
1030 KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO = 12,
1031 KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT = 13,
1032 KFD_IOC_DBG_TRAP_GET_DEVICE_SNAPSHOT = 14
1033};
1034
1035/**
1036 * kfd_ioctl_dbg_trap_enable_args
1037 *
1038 * Arguments for KFD_IOC_DBG_TRAP_ENABLE.
1039 *
1040 * Enables debug session for target process. Call @op KFD_IOC_DBG_TRAP_DISABLE in
1041 * kfd_ioctl_dbg_trap_args to disable debug session.
1042 *
1043 * @exception_mask (IN) - exceptions to raise to the debugger
1044 * @rinfo_ptr (IN) - pointer to runtime info buffer (see kfd_runtime_info)
1045 * @rinfo_size (IN/OUT) - size of runtime info buffer in bytes
1046 * @dbg_fd (IN) - fd the KFD will nofify the debugger with of raised
1047 * exceptions set in exception_mask.
1048 *
1049 * Generic errors apply (see kfd_dbg_trap_operations).
1050 * Return - 0 on SUCCESS.
1051 * Copies KFD saved kfd_runtime_info to @rinfo_ptr on enable.
1052 * Size of kfd_runtime saved by the KFD returned to @rinfo_size.
1053 * - EBADF if KFD cannot get a reference to dbg_fd.
1054 * - EFAULT if KFD cannot copy runtime info to rinfo_ptr.
1055 * - EINVAL if target process is already debug enabled.
1056 *
1057 */
1058struct kfd_ioctl_dbg_trap_enable_args {
1059 __u64 exception_mask;
1060 __u64 rinfo_ptr;
1061 __u32 rinfo_size;
1062 __u32 dbg_fd;
1063};
1064
1065/**
1066 * kfd_ioctl_dbg_trap_send_runtime_event_args
1067 *
1068 *
1069 * Arguments for KFD_IOC_DBG_TRAP_SEND_RUNTIME_EVENT.
1070 * Raises exceptions to runtime.
1071 *
1072 * @exception_mask (IN) - exceptions to raise to runtime
1073 * @gpu_id (IN) - target device id
1074 * @queue_id (IN) - target queue id
1075 *
1076 * Generic errors apply (see kfd_dbg_trap_operations).
1077 * Return - 0 on SUCCESS.
1078 * - ENODEV if gpu_id not found.
1079 * If exception_mask contains EC_PROCESS_RUNTIME, unblocks pending
1080 * AMDKFD_IOC_RUNTIME_ENABLE call - see kfd_ioctl_runtime_enable_args.
1081 * All other exceptions are raised to runtime through err_payload_addr.
1082 * See kfd_context_save_area_header.
1083 */
1084struct kfd_ioctl_dbg_trap_send_runtime_event_args {
1085 __u64 exception_mask;
1086 __u32 gpu_id;
1087 __u32 queue_id;
1088};
1089
1090/**
1091 * kfd_ioctl_dbg_trap_set_exceptions_enabled_args
1092 *
1093 * Arguments for KFD_IOC_SET_EXCEPTIONS_ENABLED
1094 * Set new exceptions to be raised to the debugger.
1095 *
1096 * @exception_mask (IN) - new exceptions to raise the debugger
1097 *
1098 * Generic errors apply (see kfd_dbg_trap_operations).
1099 * Return - 0 on SUCCESS.
1100 */
1101struct kfd_ioctl_dbg_trap_set_exceptions_enabled_args {
1102 __u64 exception_mask;
1103};
1104
1105/**
1106 * kfd_ioctl_dbg_trap_set_wave_launch_override_args
1107 *
1108 * Arguments for KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVERRIDE
1109 * Enable HW exceptions to raise trap.
1110 *
1111 * @override_mode (IN) - see kfd_dbg_trap_override_mode
1112 * @enable_mask (IN/OUT) - reference kfd_dbg_trap_mask.
1113 * IN is the override modes requested to be enabled.
1114 * OUT is referenced in Return below.
1115 * @support_request_mask (IN/OUT) - reference kfd_dbg_trap_mask.
1116 * IN is the override modes requested for support check.
1117 * OUT is referenced in Return below.
1118 *
1119 * Generic errors apply (see kfd_dbg_trap_operations).
1120 * Return - 0 on SUCCESS.
1121 * Previous enablement is returned in @enable_mask.
1122 * Actual override support is returned in @support_request_mask.
1123 * - EINVAL if override mode is not supported.
1124 * - EACCES if trap support requested is not actually supported.
1125 * i.e. enable_mask (IN) is not a subset of support_request_mask (OUT).
1126 * Otherwise it is considered a generic error (see kfd_dbg_trap_operations).
1127 */
1128struct kfd_ioctl_dbg_trap_set_wave_launch_override_args {
1129 __u32 override_mode;
1130 __u32 enable_mask;
1131 __u32 support_request_mask;
1132 __u32 pad;
1133};
1134
1135/**
1136 * kfd_ioctl_dbg_trap_set_wave_launch_mode_args
1137 *
1138 * Arguments for KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE
1139 * Set wave launch mode.
1140 *
1141 * @mode (IN) - see kfd_dbg_trap_wave_launch_mode
1142 *
1143 * Generic errors apply (see kfd_dbg_trap_operations).
1144 * Return - 0 on SUCCESS.
1145 */
1146struct kfd_ioctl_dbg_trap_set_wave_launch_mode_args {
1147 __u32 launch_mode;
1148 __u32 pad;
1149};
1150
1151/**
1152 * kfd_ioctl_dbg_trap_suspend_queues_ags
1153 *
1154 * Arguments for KFD_IOC_DBG_TRAP_SUSPEND_QUEUES
1155 * Suspend queues.
1156 *
1157 * @exception_mask (IN) - raised exceptions to clear
1158 * @queue_array_ptr (IN) - pointer to array of queue ids (u32 per queue id)
1159 * to suspend
1160 * @num_queues (IN) - number of queues to suspend in @queue_array_ptr
1161 * @grace_period (IN) - wave time allowance before preemption
1162 * per 1K GPU clock cycle unit
1163 *
1164 * Generic errors apply (see kfd_dbg_trap_operations).
1165 * Destruction of a suspended queue is blocked until the queue is
1166 * resumed. This allows the debugger to access queue information and
1167 * the its context save area without running into a race condition on
1168 * queue destruction.
1169 * Automatically copies per queue context save area header information
1170 * into the save area base
1171 * (see kfd_queue_snapshot_entry and kfd_context_save_area_header).
1172 *
1173 * Return - Number of queues suspended on SUCCESS.
1174 * . KFD_DBG_QUEUE_ERROR_MASK and KFD_DBG_QUEUE_INVALID_MASK masked
1175 * for each queue id in @queue_array_ptr array reports unsuccessful
1176 * suspend reason.
1177 * KFD_DBG_QUEUE_ERROR_MASK = HW failure.
1178 * KFD_DBG_QUEUE_INVALID_MASK = queue does not exist, is new or
1179 * is being destroyed.
1180 */
1181struct kfd_ioctl_dbg_trap_suspend_queues_args {
1182 __u64 exception_mask;
1183 __u64 queue_array_ptr;
1184 __u32 num_queues;
1185 __u32 grace_period;
1186};
1187
1188/**
1189 * kfd_ioctl_dbg_trap_resume_queues_args
1190 *
1191 * Arguments for KFD_IOC_DBG_TRAP_RESUME_QUEUES
1192 * Resume queues.
1193 *
1194 * @queue_array_ptr (IN) - pointer to array of queue ids (u32 per queue id)
1195 * to resume
1196 * @num_queues (IN) - number of queues to resume in @queue_array_ptr
1197 *
1198 * Generic errors apply (see kfd_dbg_trap_operations).
1199 * Return - Number of queues resumed on SUCCESS.
1200 * KFD_DBG_QUEUE_ERROR_MASK and KFD_DBG_QUEUE_INVALID_MASK mask
1201 * for each queue id in @queue_array_ptr array reports unsuccessful
1202 * resume reason.
1203 * KFD_DBG_QUEUE_ERROR_MASK = HW failure.
1204 * KFD_DBG_QUEUE_INVALID_MASK = queue does not exist.
1205 */
1206struct kfd_ioctl_dbg_trap_resume_queues_args {
1207 __u64 queue_array_ptr;
1208 __u32 num_queues;
1209 __u32 pad;
1210};
1211
1212/**
1213 * kfd_ioctl_dbg_trap_set_node_address_watch_args
1214 *
1215 * Arguments for KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH
1216 * Sets address watch for device.
1217 *
1218 * @address (IN) - watch address to set
1219 * @mode (IN) - see kfd_dbg_trap_address_watch_mode
1220 * @mask (IN) - watch address mask
1221 * @gpu_id (IN) - target gpu to set watch point
1222 * @id (OUT) - watch id allocated
1223 *
1224 * Generic errors apply (see kfd_dbg_trap_operations).
1225 * Return - 0 on SUCCESS.
1226 * Allocated watch ID returned to @id.
1227 * - ENODEV if gpu_id not found.
1228 * - ENOMEM if watch IDs can be allocated
1229 */
1230struct kfd_ioctl_dbg_trap_set_node_address_watch_args {
1231 __u64 address;
1232 __u32 mode;
1233 __u32 mask;
1234 __u32 gpu_id;
1235 __u32 id;
1236};
1237
1238/**
1239 * kfd_ioctl_dbg_trap_clear_node_address_watch_args
1240 *
1241 * Arguments for KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_WATCH
1242 * Clear address watch for device.
1243 *
1244 * @gpu_id (IN) - target device to clear watch point
1245 * @id (IN) - allocated watch id to clear
1246 *
1247 * Generic errors apply (see kfd_dbg_trap_operations).
1248 * Return - 0 on SUCCESS.
1249 * - ENODEV if gpu_id not found.
1250 * - EINVAL if watch ID has not been allocated.
1251 */
1252struct kfd_ioctl_dbg_trap_clear_node_address_watch_args {
1253 __u32 gpu_id;
1254 __u32 id;
1255};
1256
1257/**
1258 * kfd_ioctl_dbg_trap_set_flags_args
1259 *
1260 * Arguments for KFD_IOC_DBG_TRAP_SET_FLAGS
1261 * Sets flags for wave behaviour.
1262 *
1263 * @flags (IN/OUT) - IN = flags to enable, OUT = flags previously enabled
1264 *
1265 * Generic errors apply (see kfd_dbg_trap_operations).
1266 * Return - 0 on SUCCESS.
1267 * - EACCESS if any debug device does not allow flag options.
1268 */
1269struct kfd_ioctl_dbg_trap_set_flags_args {
1270 __u32 flags;
1271 __u32 pad;
1272};
1273
1274/**
1275 * kfd_ioctl_dbg_trap_query_debug_event_args
1276 *
1277 * Arguments for KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT
1278 *
1279 * Find one or more raised exceptions. This function can return multiple
1280 * exceptions from a single queue or a single device with one call. To find
1281 * all raised exceptions, this function must be called repeatedly until it
1282 * returns -EAGAIN. Returned exceptions can optionally be cleared by
1283 * setting the corresponding bit in the @exception_mask input parameter.
1284 * However, clearing an exception prevents retrieving further information
1285 * about it with KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO.
1286 *
1287 * @exception_mask (IN/OUT) - exception to clear (IN) and raised (OUT)
1288 * @gpu_id (OUT) - gpu id of exceptions raised
1289 * @queue_id (OUT) - queue id of exceptions raised
1290 *
1291 * Generic errors apply (see kfd_dbg_trap_operations).
1292 * Return - 0 on raised exception found
1293 * Raised exceptions found are returned in @exception mask
1294 * with reported source id returned in @gpu_id or @queue_id.
1295 * - EAGAIN if no raised exception has been found
1296 */
1297struct kfd_ioctl_dbg_trap_query_debug_event_args {
1298 __u64 exception_mask;
1299 __u32 gpu_id;
1300 __u32 queue_id;
1301};
1302
1303/**
1304 * kfd_ioctl_dbg_trap_query_exception_info_args
1305 *
1306 * Arguments KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO
1307 * Get additional info on raised exception.
1308 *
1309 * @info_ptr (IN) - pointer to exception info buffer to copy to
1310 * @info_size (IN/OUT) - exception info buffer size (bytes)
1311 * @source_id (IN) - target gpu or queue id
1312 * @exception_code (IN) - target exception
1313 * @clear_exception (IN) - clear raised @exception_code exception
1314 * (0 = false, 1 = true)
1315 *
1316 * Generic errors apply (see kfd_dbg_trap_operations).
1317 * Return - 0 on SUCCESS.
1318 * If @exception_code is EC_DEVICE_MEMORY_VIOLATION, copy @info_size(OUT)
1319 * bytes of memory exception data to @info_ptr.
1320 * If @exception_code is EC_PROCESS_RUNTIME, copy saved
1321 * kfd_runtime_info to @info_ptr.
1322 * Actual required @info_ptr size (bytes) is returned in @info_size.
1323 */
1324struct kfd_ioctl_dbg_trap_query_exception_info_args {
1325 __u64 info_ptr;
1326 __u32 info_size;
1327 __u32 source_id;
1328 __u32 exception_code;
1329 __u32 clear_exception;
1330};
1331
1332/**
1333 * kfd_ioctl_dbg_trap_get_queue_snapshot_args
1334 *
1335 * Arguments KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT
1336 * Get queue information.
1337 *
1338 * @exception_mask (IN) - exceptions raised to clear
1339 * @snapshot_buf_ptr (IN) - queue snapshot entry buffer (see kfd_queue_snapshot_entry)
1340 * @num_queues (IN/OUT) - number of queue snapshot entries
1341 * The debugger specifies the size of the array allocated in @num_queues.
1342 * KFD returns the number of queues that actually existed. If this is
1343 * larger than the size specified by the debugger, KFD will not overflow
1344 * the array allocated by the debugger.
1345 *
1346 * @entry_size (IN/OUT) - size per entry in bytes
1347 * The debugger specifies sizeof(struct kfd_queue_snapshot_entry) in
1348 * @entry_size. KFD returns the number of bytes actually populated per
1349 * entry. The debugger should use the KFD_IOCTL_MINOR_VERSION to determine,
1350 * which fields in struct kfd_queue_snapshot_entry are valid. This allows
1351 * growing the ABI in a backwards compatible manner.
1352 * Note that entry_size(IN) should still be used to stride the snapshot buffer in the
1353 * event that it's larger than actual kfd_queue_snapshot_entry.
1354 *
1355 * Generic errors apply (see kfd_dbg_trap_operations).
1356 * Return - 0 on SUCCESS.
1357 * Copies @num_queues(IN) queue snapshot entries of size @entry_size(IN)
1358 * into @snapshot_buf_ptr if @num_queues(IN) > 0.
1359 * Otherwise return @num_queues(OUT) queue snapshot entries that exist.
1360 */
1361struct kfd_ioctl_dbg_trap_queue_snapshot_args {
1362 __u64 exception_mask;
1363 __u64 snapshot_buf_ptr;
1364 __u32 num_queues;
1365 __u32 entry_size;
1366};
1367
1368/**
1369 * kfd_ioctl_dbg_trap_get_device_snapshot_args
1370 *
1371 * Arguments for KFD_IOC_DBG_TRAP_GET_DEVICE_SNAPSHOT
1372 * Get device information.
1373 *
1374 * @exception_mask (IN) - exceptions raised to clear
1375 * @snapshot_buf_ptr (IN) - pointer to snapshot buffer (see kfd_dbg_device_info_entry)
1376 * @num_devices (IN/OUT) - number of debug devices to snapshot
1377 * The debugger specifies the size of the array allocated in @num_devices.
1378 * KFD returns the number of devices that actually existed. If this is
1379 * larger than the size specified by the debugger, KFD will not overflow
1380 * the array allocated by the debugger.
1381 *
1382 * @entry_size (IN/OUT) - size per entry in bytes
1383 * The debugger specifies sizeof(struct kfd_dbg_device_info_entry) in
1384 * @entry_size. KFD returns the number of bytes actually populated. The
1385 * debugger should use KFD_IOCTL_MINOR_VERSION to determine, which fields
1386 * in struct kfd_dbg_device_info_entry are valid. This allows growing the
1387 * ABI in a backwards compatible manner.
1388 * Note that entry_size(IN) should still be used to stride the snapshot buffer in the
1389 * event that it's larger than actual kfd_dbg_device_info_entry.
1390 *
1391 * Generic errors apply (see kfd_dbg_trap_operations).
1392 * Return - 0 on SUCCESS.
1393 * Copies @num_devices(IN) device snapshot entries of size @entry_size(IN)
1394 * into @snapshot_buf_ptr if @num_devices(IN) > 0.
1395 * Otherwise return @num_devices(OUT) queue snapshot entries that exist.
1396 */
1397struct kfd_ioctl_dbg_trap_device_snapshot_args {
1398 __u64 exception_mask;
1399 __u64 snapshot_buf_ptr;
1400 __u32 num_devices;
1401 __u32 entry_size;
1402};
1403
1404/**
1405 * kfd_ioctl_dbg_trap_args
1406 *
1407 * Arguments to debug target process.
1408 *
1409 * @pid - target process to debug
1410 * @op - debug operation (see kfd_dbg_trap_operations)
1411 *
1412 * @op determines which union struct args to use.
1413 * Refer to kern docs for each kfd_ioctl_dbg_trap_*_args struct.
1414 */
1415struct kfd_ioctl_dbg_trap_args {
1416 __u32 pid;
1417 __u32 op;
1418
1419 union {
1420 struct kfd_ioctl_dbg_trap_enable_args enable;
1421 struct kfd_ioctl_dbg_trap_send_runtime_event_args send_runtime_event;
1422 struct kfd_ioctl_dbg_trap_set_exceptions_enabled_args set_exceptions_enabled;
1423 struct kfd_ioctl_dbg_trap_set_wave_launch_override_args launch_override;
1424 struct kfd_ioctl_dbg_trap_set_wave_launch_mode_args launch_mode;
1425 struct kfd_ioctl_dbg_trap_suspend_queues_args suspend_queues;
1426 struct kfd_ioctl_dbg_trap_resume_queues_args resume_queues;
1427 struct kfd_ioctl_dbg_trap_set_node_address_watch_args set_node_address_watch;
1428 struct kfd_ioctl_dbg_trap_clear_node_address_watch_args clear_node_address_watch;
1429 struct kfd_ioctl_dbg_trap_set_flags_args set_flags;
1430 struct kfd_ioctl_dbg_trap_query_debug_event_args query_debug_event;
1431 struct kfd_ioctl_dbg_trap_query_exception_info_args query_exception_info;
1432 struct kfd_ioctl_dbg_trap_queue_snapshot_args queue_snapshot;
1433 struct kfd_ioctl_dbg_trap_device_snapshot_args device_snapshot;
1434 };
1435};
1436
776#define AMDKFD_IOCTL_BASE 'K'1437#define AMDKFD_IOCTL_BASE 'K'
777#define AMDKFD_IO(nr) _IO(AMDKFD_IOCTL_BASE, nr)1438#define AMDKFD_IO(nr) _IO(AMDKFD_IOCTL_BASE, nr)
778#define AMDKFD_IOR(nr, type) _IOR(AMDKFD_IOCTL_BASE, nr, type)1439#define AMDKFD_IOR(nr, type) _IOR(AMDKFD_IOCTL_BASE, nr, type)
@@ -887,7 +1548,13 @@ struct kfd_ioctl_set_xnack_mode_args { · 108 unmodified lines
887#define AMDKFD_IOC_EXPORT_DMABUF \1548#define AMDKFD_IOC_EXPORT_DMABUF \
888 AMDKFD_IOWR(0x24, struct kfd_ioctl_export_dmabuf_args)1549 AMDKFD_IOWR(0x24, struct kfd_ioctl_export_dmabuf_args)
889 1550
1551#define AMDKFD_IOC_RUNTIME_ENABLE \
1552 AMDKFD_IOWR(0x25, struct kfd_ioctl_runtime_enable_args)
1553
1554#define AMDKFD_IOC_DBG_TRAP \
1555 AMDKFD_IOWR(0x26, struct kfd_ioctl_dbg_trap_args)
1556
890#define AMDKFD_COMMAND_START 0x011557#define AMDKFD_COMMAND_START 0x01
891#define AMDKFD_COMMAND_END 0x251558#define AMDKFD_COMMAND_END 0x27
892 1559
893#endif1560#endif
include/uapi/linux/kfd_sysfs.h+15−0
@@ -43,6 +43,11 @@ · 42 unmodified lines
43#define HSA_CAP_DOORBELL_TYPE_2_0 0x243#define HSA_CAP_DOORBELL_TYPE_2_0 0x2
44#define HSA_CAP_AQL_QUEUE_DOUBLE_MAP 0x0000400044#define HSA_CAP_AQL_QUEUE_DOUBLE_MAP 0x00004000
45 45
46#define HSA_CAP_TRAP_DEBUG_SUPPORT 0x00008000
47#define HSA_CAP_TRAP_DEBUG_WAVE_LAUNCH_TRAP_OVERRIDE_SUPPORTED 0x00010000
48#define HSA_CAP_TRAP_DEBUG_WAVE_LAUNCH_MODE_SUPPORTED 0x00020000
49#define HSA_CAP_TRAP_DEBUG_PRECISE_MEMORY_OPERATIONS_SUPPORTED 0x00040000
50
46/* Old buggy user mode depends on this being 0 */51/* Old buggy user mode depends on this being 0 */
47#define HSA_CAP_RESERVED_WAS_SRAM_EDCSUPPORTED 0x0008000052#define HSA_CAP_RESERVED_WAS_SRAM_EDCSUPPORTED 0x00080000
48 53
@@ -53,8 +58,18 @@ · 4 unmodified lines
53#define HSA_CAP_SRAM_EDCSUPPORTED 0x0400000058#define HSA_CAP_SRAM_EDCSUPPORTED 0x04000000
54#define HSA_CAP_SVMAPI_SUPPORTED 0x0800000059#define HSA_CAP_SVMAPI_SUPPORTED 0x08000000
55#define HSA_CAP_FLAGS_COHERENTHOSTACCESS 0x1000000060#define HSA_CAP_FLAGS_COHERENTHOSTACCESS 0x10000000
61#define HSA_CAP_TRAP_DEBUG_FIRMWARE_SUPPORTED 0x20000000
56#define HSA_CAP_RESERVED 0xe00f800062#define HSA_CAP_RESERVED 0xe00f8000
57 63
64/* debug_prop bits in node properties */
65#define HSA_DBG_WATCH_ADDR_MASK_LO_BIT_MASK 0x0000000f
66#define HSA_DBG_WATCH_ADDR_MASK_LO_BIT_SHIFT 0
67#define HSA_DBG_WATCH_ADDR_MASK_HI_BIT_MASK 0x000003f0
68#define HSA_DBG_WATCH_ADDR_MASK_HI_BIT_SHIFT 4
69#define HSA_DBG_DISPATCH_INFO_ALWAYS_VALID 0x00000400
70#define HSA_DBG_WATCHPOINTS_EXCLUSIVE 0x00000800
71#define HSA_DBG_RESERVED 0xfffffffffffff000ull
72
58/* Heap types in memory properties */73/* Heap types in memory properties */
59#define HSA_MEM_HEAP_TYPE_SYSTEM 074#define HSA_MEM_HEAP_TYPE_SYSTEM 0
60#define HSA_MEM_HEAP_TYPE_FB_PUBLIC 175#define HSA_MEM_HEAP_TYPE_FB_PUBLIC 1

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