Oded writes: This tag contains habanalabs driver changes for v5.16: - Add a new uAPI (under the memory ioctl) to request from the driver to export a DMA-BUF object that represents a memory region on the device's DRAM. This is needed to enable peer-to-peer over PCIe between habana device and an RDMA adapter (e.g. mlnx5 or efa rdma adapter). - Add debugfs node to dynamically configure CS timeout. Up until now, it was only configurable through kernel module parameter. - Fetch more comprehensive power information from the firmware. - Always take timestamp when waiting for user interrupt, as the user needs that information to optimize the graph runtime compilation. - Modify user interrupt to look on 64-bit user value as fence, instead of 32-bit. - Bypass reset in case of repeated h/w error event after device reset. This is to prevent endless loop of resets to the device. - Fix several bugs in multi CS completion code. - Fix race condition in fd close/open. - Update to latest firmware headers - Add select CRC32 in kconfig - Small fixes, cosmetics * tag 'misc-habanalabs-next-2021-10-18' of https://git.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux: (25 commits) habanalabs: refactor fence handling in hl_cs_poll_fences habanalabs: context cleanup cosmetics habanalabs: simplify wait for interrupt with timestamp flow habanalabs: initialize hpriv fields before adding new node habanalabs: Unify frequency set/get functionality habanalabs: select CRC32 habanalabs: add support for dma-buf exporter habanalabs: define uAPI to export FD for DMA-BUF habanalabs: fix NULL pointer dereference habanalabs: fix race condition in multi CS completion habanalabs: use only u32 habanalabs: update firmware files habanalabs: bypass reset for continuous h/w error event habanalabs: take timestamp on wait for interrupt habanalabs: prevent race between fd close/open habanalabs: refactor reset log message habanalabs: define soft-reset as inference op habanalabs: fix debugfs device memory MMU VA translation habanalabs: add support for a long interrupt target value habanalabs: remove redundant cs validity checks ...
Showing the changes to include/uapi (1 of 27 files). Show all
Unified · Split
| @@ -272,6 +272,16 @@ enum hl_gaudi_pll_index { · 271 unmodified lines | ||
| 272 | 272 | HL_GAUDI_PLL_MAX |
| 273 | 273 | }; |
| 274 | 274 | |
| 275 | +/** | |
| 276 | + * enum hl_device_status - Device status information. | |
| 277 | + * @HL_DEVICE_STATUS_OPERATIONAL: Device is operational. | |
| 278 | + * @HL_DEVICE_STATUS_IN_RESET: Device is currently during reset. | |
| 279 | + * @HL_DEVICE_STATUS_MALFUNCTION: Device is unusable. | |
| 280 | + * @HL_DEVICE_STATUS_NEEDS_RESET: Device needs reset because auto reset was disabled. | |
| 281 | + * @HL_DEVICE_STATUS_IN_DEVICE_CREATION: Device is operational but its creation is still in | |
| 282 | + * progress. | |
| 283 | + * @HL_DEVICE_STATUS_LAST: Last status. | |
| 284 | + */ | |
| 275 | 285 | enum hl_device_status { |
| 276 | 286 | HL_DEVICE_STATUS_OPERATIONAL, |
| 277 | 287 | HL_DEVICE_STATUS_IN_RESET, |
| @@ -556,33 +566,30 @@ enum gaudi_dcores { · 278 unmodified lines | ||
| 556 | 566 | HL_GAUDI_ES_DCORE |
| 557 | 567 | }; |
| 558 | 568 | |
| 569 | +/** | |
| 570 | + * struct hl_info_args - Main structure to retrieve device related information. | |
| 571 | + * @return_pointer: User space address of the relevant structure related to HL_INFO_* operation | |
| 572 | + * mentioned in @op. | |
| 573 | + * @return_size: Size of the structure used in @return_pointer, just like "size" in "snprintf", it | |
| 574 | + * limits how many bytes the kernel can write. For hw_events array, the size should be | |
| 575 | + * hl_info_hw_ip_info.num_of_events * sizeof(__u32). | |
| 576 | + * @op: Defines which type of information to be retrieved. Refer HL_INFO_* for details. | |
| 577 | + * @dcore_id: DCORE id for which the information is relevant (for Gaudi refer to enum gaudi_dcores). | |
| 578 | + * @ctx_id: Context ID of the user. Currently not in use. | |
| 579 | + * @period_ms: Period value, in milliseconds, for utilization rate in range 100ms - 1000ms in 100 ms | |
| 580 | + * resolution. Currently not in use. | |
| 581 | + * @pll_index: Index as defined in hl_<asic type>_pll_index enumeration. | |
| 582 | + * @pad: Padding to 64 bit. | |
| 583 | + */ | |
| 559 | 584 | struct hl_info_args { |
| 560 | − /* Location of relevant struct in userspace */ | |
| 561 | 585 | __u64 return_pointer; |
| 562 | − /* | |
| 563 | − * The size of the return value. Just like "size" in "snprintf", | |
| 564 | − * it limits how many bytes the kernel can write | |
| 565 | − * | |
| 566 | − * For hw_events array, the size should be | |
| 567 | − * hl_info_hw_ip_info.num_of_events * sizeof(__u32) | |
| 568 | − */ | |
| 569 | 586 | __u32 return_size; |
| 570 | − | |
| 571 | − /* HL_INFO_* */ | |
| 572 | 587 | __u32 op; |
| 573 | 588 | |
| 574 | 589 | union { |
| 575 | − /* Dcore id for which the information is relevant. | |
| 576 | − * For Gaudi refer to 'enum gaudi_dcores' | |
| 577 | − */ | |
| 578 | 590 | __u32 dcore_id; |
| 579 | − /* Context ID - Currently not in use */ | |
| 580 | 591 | __u32 ctx_id; |
| 581 | − /* Period value for utilization rate (100ms - 1000ms, in 100ms | |
| 582 | − * resolution. | |
| 583 | − */ | |
| 584 | 592 | __u32 period_ms; |
| 585 | − /* PLL frequency retrieval */ | |
| 586 | 593 | __u32 pll_index; |
| 587 | 594 | }; |
| 588 | 595 | |
| @@ -890,11 +897,7 @@ struct hl_wait_cs_in { · 301 unmodified lines | ||
| 890 | 897 | */ |
| 891 | 898 | __u64 addr; |
| 892 | 899 | /* Target value for completion comparison */ |
| 893 | − __u32 target; | |
| 894 | − /* Absolute timeout to wait for interrupt | |
| 895 | − * in microseconds | |
| 896 | − */ | |
| 897 | − __u32 interrupt_timeout_us; | |
| 900 | + __u64 target; | |
| 898 | 901 | }; |
| 899 | 902 | }; |
| 900 | 903 | |
| @@ -910,7 +913,12 @@ struct hl_wait_cs_in { · 9 unmodified lines | ||
| 910 | 913 | |
| 911 | 914 | /* Multi CS API info- valid entries in multi-CS array */ |
| 912 | 915 | __u8 seq_arr_len; |
| 913 | − __u8 pad[7]; | |
| 916 | + __u8 pad[3]; | |
| 917 | + | |
| 918 | + /* Absolute timeout to wait for an interrupt in microseconds. | |
| 919 | + * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set | |
| 920 | + */ | |
| 921 | + __u32 interrupt_timeout_us; | |
| 914 | 922 | }; |
| 915 | 923 | |
| 916 | 924 | #define HL_WAIT_CS_STATUS_COMPLETED 0 |
| @@ -952,6 +960,10 @@ union hl_wait_cs_args { · 35 unmodified lines | ||
| 952 | 960 | #define HL_MEM_OP_UNMAP 3 |
| 953 | 961 | /* Opcode to map a hw block */ |
| 954 | 962 | #define HL_MEM_OP_MAP_BLOCK 4 |
| 963 | +/* Opcode to create DMA-BUF object for an existing device memory allocation | |
| 964 | + * and to export an FD of that DMA-BUF back to the caller | |
| 965 | + */ | |
| 966 | +#define HL_MEM_OP_EXPORT_DMABUF_FD 5 | |
| 955 | 967 | |
| 956 | 968 | /* Memory flags */ |
| 957 | 969 | #define HL_MEM_CONTIGUOUS 0x1 |
| @@ -1023,11 +1035,26 @@ struct hl_mem_in { · 65 unmodified lines | ||
| 1023 | 1035 | /* Virtual address returned from HL_MEM_OP_MAP */ |
| 1024 | 1036 | __u64 device_virt_addr; |
| 1025 | 1037 | } unmap; |
| 1038 | + | |
| 1039 | + /* HL_MEM_OP_EXPORT_DMABUF_FD */ | |
| 1040 | + struct { | |
| 1041 | + /* Handle returned from HL_MEM_OP_ALLOC. In Gaudi, | |
| 1042 | + * where we don't have MMU for the device memory, the | |
| 1043 | + * driver expects a physical address (instead of | |
| 1044 | + * a handle) in the device memory space. | |
| 1045 | + */ | |
| 1046 | + __u64 handle; | |
| 1047 | + /* Size of memory allocation. Relevant only for GAUDI */ | |
| 1048 | + __u64 mem_size; | |
| 1049 | + } export_dmabuf_fd; | |
| 1026 | 1050 | }; |
| 1027 | 1051 | |
| 1028 | 1052 | /* HL_MEM_OP_* */ |
| 1029 | 1053 | __u32 op; |
| 1030 | − /* HL_MEM_* flags */ | |
| 1054 | + /* HL_MEM_* flags. | |
| 1055 | + * For the HL_MEM_OP_EXPORT_DMABUF_FD opcode, this field holds the | |
| 1056 | + * DMA-BUF file/FD flags. | |
| 1057 | + */ | |
| 1031 | 1058 | __u32 flags; |
| 1032 | 1059 | /* Context ID - Currently not in use */ |
| 1033 | 1060 | __u32 ctx_id; |
| @@ -1064,6 +1091,13 @@ struct hl_mem_out { · 30 unmodified lines | ||
| 1064 | 1091 | |
| 1065 | 1092 | __u32 pad; |
| 1066 | 1093 | }; |
| 1094 | + | |
| 1095 | + /* Returned in HL_MEM_OP_EXPORT_DMABUF_FD. Represents the | |
| 1096 | + * DMA-BUF object that was created to describe a memory | |
| 1097 | + * allocation on the device's memory space. The FD should be | |
| 1098 | + * passed to the importer driver | |
| 1099 | + */ | |
| 1100 | + __s32 fd; | |
| 1067 | 1101 | }; |
| 1068 | 1102 | }; |
| 1069 | 1103 | |