| @@ -1,6 +1,6 @@ |
| 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note |
| 2 | * | 2 | * |
| 3 | * Copyright 2016-2020 HabanaLabs, Ltd. | 3 | * Copyright 2016-2022 HabanaLabs, Ltd. |
| 4 | * All Rights Reserved. | 4 | * All Rights Reserved. |
| 5 | * | 5 | * |
| 6 | */ | 6 | */ |
| @@ -30,6 +30,9 @@ · 23 unmodified lines |
| 30 | */ | 30 | */ |
| 31 | #define GAUDI_FIRST_AVAILABLE_W_S_MONITOR 72 | 31 | #define GAUDI_FIRST_AVAILABLE_W_S_MONITOR 72 |
| 32 | | 32 | |
| | 33 | /* Max number of elements in timestamps registration buffers */ |
| | 34 | #define TS_MAX_ELEMENTS_NUM (1 << 20) /* 1MB */ |
| | 35 | |
| 33 | /* | 36 | /* |
| 34 | * Goya queue Numbering | 37 | * Goya queue Numbering |
| 35 | * | 38 | * |
| @@ -404,6 +407,8 @@ enum hl_server_type { · 368 unmodified lines |
| 404 | * @cpucp_version: The CPUCP f/w version. | 407 | * @cpucp_version: The CPUCP f/w version. |
| 405 | * @card_name: The card name as passed by the f/w. | 408 | * @card_name: The card name as passed by the f/w. |
| 406 | * @dram_page_size: The DRAM physical page size. | 409 | * @dram_page_size: The DRAM physical page size. |
| | 410 | * @number_of_user_interrupts: The number of interrupts that are available to the userspace |
| | 411 | * application to use. Relevant for Gaudi2 and later. |
| 407 | */ | 412 | */ |
| 408 | struct hl_info_hw_ip_info { | 413 | struct hl_info_hw_ip_info { |
| 409 | __u64 sram_base_address; | 414 | __u64 sram_base_address; |
| @@ -428,6 +433,9 @@ struct hl_info_hw_ip_info { · 18 unmodified lines |
| 428 | __u8 card_name[HL_INFO_CARD_NAME_MAX_LEN]; | 433 | __u8 card_name[HL_INFO_CARD_NAME_MAX_LEN]; |
| 429 | __u64 reserved2; | 434 | __u64 reserved2; |
| 430 | __u64 dram_page_size; | 435 | __u64 dram_page_size; |
| | 436 | __u32 reserved3; |
| | 437 | __u16 number_of_user_interrupts; |
| | 438 | __u16 pad2; |
| 431 | }; | 439 | }; |
| 432 | | 440 | |
| 433 | struct hl_info_dram_usage { | 441 | struct hl_info_dram_usage { |
| @@ -690,10 +698,12 @@ struct hl_cb_in { · 256 unmodified lines |
| 690 | __u64 cb_handle; | 698 | __u64 cb_handle; |
| 691 | /* HL_CB_OP_* */ | 699 | /* HL_CB_OP_* */ |
| 692 | __u32 op; | 700 | __u32 op; |
| | 701 | |
| 693 | /* Size of CB. Maximum size is HL_MAX_CB_SIZE. The minimum size that | 702 | /* Size of CB. Maximum size is HL_MAX_CB_SIZE. The minimum size that |
| 694 | * will be allocated, regardless of this parameter's value, is PAGE_SIZE | 703 | * will be allocated, regardless of this parameter's value, is PAGE_SIZE |
| 695 | */ | 704 | */ |
| 696 | __u32 cb_size; | 705 | __u32 cb_size; |
| | 706 | |
| 697 | /* Context ID - Currently not in use */ | 707 | /* Context ID - Currently not in use */ |
| 698 | __u32 ctx_id; | 708 | __u32 ctx_id; |
| 699 | /* HL_CB_FLAGS_* */ | 709 | /* HL_CB_FLAGS_* */ |
| @@ -959,6 +969,7 @@ union hl_cs_args { · 259 unmodified lines |
| 959 | #define HL_WAIT_CS_FLAGS_INTERRUPT_MASK 0xFFF00000 | 969 | #define HL_WAIT_CS_FLAGS_INTERRUPT_MASK 0xFFF00000 |
| 960 | #define HL_WAIT_CS_FLAGS_MULTI_CS 0x4 | 970 | #define HL_WAIT_CS_FLAGS_MULTI_CS 0x4 |
| 961 | #define HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ 0x10 | 971 | #define HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ 0x10 |
| | 972 | #define HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT 0x20 |
| 962 | | 973 | |
| 963 | #define HL_WAIT_MULTI_CS_LIST_MAX_LEN 32 | 974 | #define HL_WAIT_MULTI_CS_LIST_MAX_LEN 32 |
| 964 | | 975 | |
| @@ -1031,6 +1042,20 @@ struct hl_wait_cs_in { · 66 unmodified lines |
| 1031 | * relevant only when HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ is set | 1042 | * relevant only when HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ is set |
| 1032 | */ | 1043 | */ |
| 1033 | __u64 cq_counters_offset; | 1044 | __u64 cq_counters_offset; |
| | 1045 | |
| | 1046 | /* |
| | 1047 | * Timestamp_handle timestamps buffer handle. |
| | 1048 | * relevant only when HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT is set |
| | 1049 | */ |
| | 1050 | __u64 timestamp_handle; |
| | 1051 | |
| | 1052 | /* |
| | 1053 | * Timestamp_offset is offset inside the timestamp buffer pointed by timestamp_handle above. |
| | 1054 | * upon interrupt, if the cq reached the target value then driver will write |
| | 1055 | * timestamp to this offset. |
| | 1056 | * relevant only when HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT is set |
| | 1057 | */ |
| | 1058 | __u64 timestamp_offset; |
| 1034 | }; | 1059 | }; |
| 1035 | | 1060 | |
| 1036 | #define HL_WAIT_CS_STATUS_COMPLETED 0 | 1061 | #define HL_WAIT_CS_STATUS_COMPLETED 0 |
| @@ -1077,100 +1102,119 @@ union hl_wait_cs_args { · 40 unmodified lines |
| 1077 | */ | 1102 | */ |
| 1078 | #define HL_MEM_OP_EXPORT_DMABUF_FD 5 | 1103 | #define HL_MEM_OP_EXPORT_DMABUF_FD 5 |
| 1079 | | 1104 | |
| | 1105 | /* Opcode to create timestamps pool for user interrupts registration support |
| | 1106 | * The memory will be allocated by the kernel driver, A timestamp buffer which the user |
| | 1107 | * will get handle to it for mmap, and another internal buffer used by the |
| | 1108 | * driver for registration management |
| | 1109 | * The memory will be freed when the user closes the file descriptor(ctx close) |
| | 1110 | */ |
| | 1111 | #define HL_MEM_OP_TS_ALLOC 6 |
| | 1112 | |
| 1080 | /* Memory flags */ | 1113 | /* Memory flags */ |
| 1081 | #define HL_MEM_CONTIGUOUS 0x1 | 1114 | #define HL_MEM_CONTIGUOUS 0x1 |
| 1082 | #define HL_MEM_SHARED 0x2 | 1115 | #define HL_MEM_SHARED 0x2 |
| 1083 | #define HL_MEM_USERPTR 0x4 | 1116 | #define HL_MEM_USERPTR 0x4 |
| 1084 | #define HL_MEM_FORCE_HINT 0x8 | 1117 | #define HL_MEM_FORCE_HINT 0x8 |
| 1085 | | 1118 | |
| | 1119 | /** |
| | 1120 | * structure hl_mem_in - structure that handle input args for memory IOCTL |
| | 1121 | * @union arg: union of structures to be used based on the input operation |
| | 1122 | * @op: specify the requested memory operation (one of the HL_MEM_OP_* definitions). |
| | 1123 | * @flags: flags for the memory operation (one of the HL_MEM_* definitions). |
| | 1124 | * For the HL_MEM_OP_EXPORT_DMABUF_FD opcode, this field holds the DMA-BUF file/FD flags. |
| | 1125 | * @ctx_id: context ID - currently not in use. |
| | 1126 | * @num_of_elements: number of timestamp elements used only with HL_MEM_OP_TS_ALLOC opcode. |
| | 1127 | */ |
| 1086 | struct hl_mem_in { | 1128 | struct hl_mem_in { |
| 1087 | union { | 1129 | union { |
| 1088 | /* HL_MEM_OP_ALLOC- allocate device memory */ | 1130 | /** |
| | 1131 | * structure for device memory allocation (used with the HL_MEM_OP_ALLOC op) |
| | 1132 | * @mem_size: memory size to allocate |
| | 1133 | * @page_size: page size to use on allocation. when the value is 0 the default page |
| | 1134 | * size will be taken. |
| | 1135 | */ |
| 1089 | struct { | 1136 | struct { |
| 1090 | /* Size to alloc */ | | |
| 1091 | __u64 mem_size; | 1137 | __u64 mem_size; |
| | 1138 | __u64 page_size; |
| 1092 | } alloc; | 1139 | } alloc; |
| 1093 | | 1140 | |
| 1094 | /* HL_MEM_OP_FREE - free device memory */ | 1141 | /** |
| | 1142 | * structure for free-ing device memory (used with the HL_MEM_OP_FREE op) |
| | 1143 | * @handle: handle returned from HL_MEM_OP_ALLOC |
| | 1144 | */ |
| 1095 | struct { | 1145 | struct { |
| 1096 | /* Handle returned from HL_MEM_OP_ALLOC */ | | |
| 1097 | __u64 handle; | 1146 | __u64 handle; |
| 1098 | } free; | 1147 | } free; |
| 1099 | | 1148 | |
| 1100 | /* HL_MEM_OP_MAP - map device memory */ | 1149 | /** |
| | 1150 | * structure for mapping device memory (used with the HL_MEM_OP_MAP op) |
| | 1151 | * @hint_addr: requested virtual address of mapped memory. |
| | 1152 | * the driver will try to map the requested region to this hint |
| | 1153 | * address, as long as the address is valid and not already mapped. |
| | 1154 | * the user should check the returned address of the IOCTL to make |
| | 1155 | * sure he got the hint address. |
| | 1156 | * passing 0 here means that the driver will choose the address itself. |
| | 1157 | * @handle: handle returned from HL_MEM_OP_ALLOC. |
| | 1158 | */ |
| 1101 | struct { | 1159 | struct { |
| 1102 | /* | | |
| 1103 | * Requested virtual address of mapped memory. | | |
| 1104 | * The driver will try to map the requested region to | | |
| 1105 | * this hint address, as long as the address is valid | | |
| 1106 | * and not already mapped. The user should check the | | |
| 1107 | * returned address of the IOCTL to make sure he got | | |
| 1108 | * the hint address. Passing 0 here means that the | | |
| 1109 | * driver will choose the address itself. | | |
| 1110 | */ | | |
| 1111 | __u64 hint_addr; | 1160 | __u64 hint_addr; |
| 1112 | /* Handle returned from HL_MEM_OP_ALLOC */ | | |
| 1113 | __u64 handle; | 1161 | __u64 handle; |
| 1114 | } map_device; | 1162 | } map_device; |
| 1115 | | 1163 | |
| 1116 | /* HL_MEM_OP_MAP - map host memory */ | 1164 | /** |
| | 1165 | * structure for mapping host memory (used with the HL_MEM_OP_MAP op) |
| | 1166 | * @host_virt_addr: address of allocated host memory. |
| | 1167 | * @hint_addr: requested virtual address of mapped memory. |
| | 1168 | * the driver will try to map the requested region to this hint |
| | 1169 | * address, as long as the address is valid and not already mapped. |
| | 1170 | * the user should check the returned address of the IOCTL to make |
| | 1171 | * sure he got the hint address. |
| | 1172 | * passing 0 here means that the driver will choose the address itself. |
| | 1173 | * @size: size of allocated host memory. |
| | 1174 | */ |
| 1117 | struct { | 1175 | struct { |
| 1118 | /* Address of allocated host memory */ | | |
| 1119 | __u64 host_virt_addr; | 1176 | __u64 host_virt_addr; |
| 1120 | /* | | |
| 1121 | * Requested virtual address of mapped memory. | | |
| 1122 | * The driver will try to map the requested region to | | |
| 1123 | * this hint address, as long as the address is valid | | |
| 1124 | * and not already mapped. The user should check the | | |
| 1125 | * returned address of the IOCTL to make sure he got | | |
| 1126 | * the hint address. Passing 0 here means that the | | |
| 1127 | * driver will choose the address itself. | | |
| 1128 | */ | | |
| 1129 | __u64 hint_addr; | 1177 | __u64 hint_addr; |
| 1130 | /* Size of allocated host memory */ | | |
| 1131 | __u64 mem_size; | 1178 | __u64 mem_size; |
| 1132 | } map_host; | 1179 | } map_host; |
| 1133 | | 1180 | |
| 1134 | /* HL_MEM_OP_MAP_BLOCK - map a hw block */ | 1181 | /** |
| | 1182 | * structure for mapping hw block (used with the HL_MEM_OP_MAP_BLOCK op) |
| | 1183 | * @block_addr:HW block address to map, a handle and size will be returned |
| | 1184 | * to the user and will be used to mmap the relevant block. |
| | 1185 | * only addresses from configuration space are allowed. |
| | 1186 | */ |
| 1135 | struct { | 1187 | struct { |
| 1136 | /* | | |
| 1137 | * HW block address to map, a handle and size will be | | |
| 1138 | * returned to the user and will be used to mmap the | | |
| 1139 | * relevant block. Only addresses from configuration | | |
| 1140 | * space are allowed. | | |
| 1141 | */ | | |
| 1142 | __u64 block_addr; | 1188 | __u64 block_addr; |
| 1143 | } map_block; | 1189 | } map_block; |
| 1144 | | 1190 | |
| 1145 | /* HL_MEM_OP_UNMAP - unmap host memory */ | 1191 | /** |
| | 1192 | * structure for unmapping host memory (used with the HL_MEM_OP_UNMAP op) |
| | 1193 | * @device_virt_addr: virtual address returned from HL_MEM_OP_MAP |
| | 1194 | */ |
| 1146 | struct { | 1195 | struct { |
| 1147 | /* Virtual address returned from HL_MEM_OP_MAP */ | | |
| 1148 | __u64 device_virt_addr; | 1196 | __u64 device_virt_addr; |
| 1149 | } unmap; | 1197 | } unmap; |
| 1150 | | 1198 | |
| 1151 | /* HL_MEM_OP_EXPORT_DMABUF_FD */ | 1199 | /** |
| | 1200 | * structure for exporting DMABUF object (used with |
| | 1201 | * the HL_MEM_OP_EXPORT_DMABUF_FD op) |
| | 1202 | * @handle: handle returned from HL_MEM_OP_ALLOC. |
| | 1203 | * in Gaudi, where we don't have MMU for the device memory, the |
| | 1204 | * driver expects a physical address (instead of a handle) in the |
| | 1205 | * device memory space. |
| | 1206 | * @mem_size: size of memory allocation. Relevant only for GAUDI |
| | 1207 | */ |
| 1152 | struct { | 1208 | struct { |
| 1153 | /* Handle returned from HL_MEM_OP_ALLOC. In Gaudi, | | |
| 1154 | * where we don't have MMU for the device memory, the | | |
| 1155 | * driver expects a physical address (instead of | | |
| 1156 | * a handle) in the device memory space. | | |
| 1157 | */ | | |
| 1158 | __u64 handle; | 1209 | __u64 handle; |
| 1159 | /* Size of memory allocation. Relevant only for GAUDI */ | | |
| 1160 | __u64 mem_size; | 1210 | __u64 mem_size; |
| 1161 | } export_dmabuf_fd; | 1211 | } export_dmabuf_fd; |
| 1162 | }; | 1212 | }; |
| 1163 | | 1213 | |
| 1164 | /* HL_MEM_OP_* */ | | |
| 1165 | __u32 op; | 1214 | __u32 op; |
| 1166 | /* HL_MEM_* flags. | | |
| 1167 | * For the HL_MEM_OP_EXPORT_DMABUF_FD opcode, this field holds the | | |
| 1168 | * DMA-BUF file/FD flags. | | |
| 1169 | */ | | |
| 1170 | __u32 flags; | 1215 | __u32 flags; |
| 1171 | /* Context ID - Currently not in use */ | | |
| 1172 | __u32 ctx_id; | 1216 | __u32 ctx_id; |
| 1173 | __u32 pad; | 1217 | __u32 num_of_elements; |
| 1174 | }; | 1218 | }; |
| 1175 | | 1219 | |
| 1176 | struct hl_mem_out { | 1220 | struct hl_mem_out { |