History

Merge tag 'misc-habanalabs-next-2021-10-18' of https://git.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux into char-misc-next

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 ...

Greg Kroah-Hartman committed 5 years ago

Commit be24dd42 parents 2b74240 b2faac327 files · +1309 −305Browse files

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

Unified · Split

include/uapi/misc/habanalabs.h+59−25
@@ -272,6 +272,16 @@ enum hl_gaudi_pll_index { · 271 unmodified lines
272272 HL_GAUDI_PLL_MAX
273273 };
274274
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+ */
275285 enum hl_device_status {
276286 HL_DEVICE_STATUS_OPERATIONAL,
277287 HL_DEVICE_STATUS_IN_RESET,
@@ -556,33 +566,30 @@ enum gaudi_dcores { · 278 unmodified lines
556566 HL_GAUDI_ES_DCORE
557567 };
558568
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+ */
559584 struct hl_info_args {
560− /* Location of relevant struct in userspace */
561585 __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− */
569586 __u32 return_size;
570−
571− /* HL_INFO_* */
572587 __u32 op;
573588
574589 union {
575− /* Dcore id for which the information is relevant.
576− * For Gaudi refer to 'enum gaudi_dcores'
577− */
578590 __u32 dcore_id;
579− /* Context ID - Currently not in use */
580591 __u32 ctx_id;
581− /* Period value for utilization rate (100ms - 1000ms, in 100ms
582− * resolution.
583− */
584592 __u32 period_ms;
585− /* PLL frequency retrieval */
586593 __u32 pll_index;
587594 };
588595
@@ -890,11 +897,7 @@ struct hl_wait_cs_in { · 301 unmodified lines
890897 */
891898 __u64 addr;
892899 /* 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;
898901 };
899902 };
900903
@@ -910,7 +913,12 @@ struct hl_wait_cs_in { · 9 unmodified lines
910913
911914 /* Multi CS API info- valid entries in multi-CS array */
912915 __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;
914922 };
915923
916924 #define HL_WAIT_CS_STATUS_COMPLETED 0
@@ -952,6 +960,10 @@ union hl_wait_cs_args { · 35 unmodified lines
952960 #define HL_MEM_OP_UNMAP 3
953961 /* Opcode to map a hw block */
954962 #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
955967
956968 /* Memory flags */
957969 #define HL_MEM_CONTIGUOUS 0x1
@@ -1023,11 +1035,26 @@ struct hl_mem_in { · 65 unmodified lines
10231035 /* Virtual address returned from HL_MEM_OP_MAP */
10241036 __u64 device_virt_addr;
10251037 } 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;
10261050 };
10271051
10281052 /* HL_MEM_OP_* */
10291053 __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+ */
10311058 __u32 flags;
10321059 /* Context ID - Currently not in use */
10331060 __u32 ctx_id;
@@ -1064,6 +1091,13 @@ struct hl_mem_out { · 30 unmodified lines
10641091
10651092 __u32 pad;
10661093 };
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;
10671101 };
10681102 };
10691103