habanalabs: implement INFO IOCTL
This patch implements the INFO IOCTL. That IOCTL is used by the user to query information that is relevant/needed by the user in order to submit deep learning jobs to Goya. The information is divided into several categories, such as H/W IP, Events that happened, DDR usage and more. Reviewed-by: Mike Rapoport <rppt@linux.ibm.com> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0feaf86d4e
commit
d8dd7b0a81
@@ -45,6 +45,62 @@ enum goya_queue_id {
|
||||
GOYA_QUEUE_ID_SIZE
|
||||
};
|
||||
|
||||
/* Opcode for management ioctl */
|
||||
#define HL_INFO_HW_IP_INFO 0
|
||||
#define HL_INFO_HW_EVENTS 1
|
||||
#define HL_INFO_DRAM_USAGE 2
|
||||
#define HL_INFO_HW_IDLE 3
|
||||
|
||||
#define HL_INFO_VERSION_MAX_LEN 128
|
||||
|
||||
struct hl_info_hw_ip_info {
|
||||
__u64 sram_base_address;
|
||||
__u64 dram_base_address;
|
||||
__u64 dram_size;
|
||||
__u32 sram_size;
|
||||
__u32 num_of_events;
|
||||
__u32 device_id; /* PCI Device ID */
|
||||
__u32 reserved[3];
|
||||
__u32 armcp_cpld_version;
|
||||
__u32 psoc_pci_pll_nr;
|
||||
__u32 psoc_pci_pll_nf;
|
||||
__u32 psoc_pci_pll_od;
|
||||
__u32 psoc_pci_pll_div_factor;
|
||||
__u8 tpc_enabled_mask;
|
||||
__u8 dram_enabled;
|
||||
__u8 pad[2];
|
||||
__u8 armcp_version[HL_INFO_VERSION_MAX_LEN];
|
||||
};
|
||||
|
||||
struct hl_info_dram_usage {
|
||||
__u64 dram_free_mem;
|
||||
__u64 ctx_dram_mem;
|
||||
};
|
||||
|
||||
struct hl_info_hw_idle {
|
||||
__u32 is_idle;
|
||||
__u32 pad;
|
||||
};
|
||||
|
||||
struct hl_info_args {
|
||||
/* Location of relevant struct in userspace */
|
||||
__u64 return_pointer;
|
||||
/*
|
||||
* The size of the return value. Just like "size" in "snprintf",
|
||||
* it limits how many bytes the kernel can write
|
||||
*
|
||||
* For hw_events array, the size should be
|
||||
* hl_info_hw_ip_info.num_of_events * sizeof(__u32)
|
||||
*/
|
||||
__u32 return_size;
|
||||
|
||||
/* HL_INFO_* */
|
||||
__u32 op;
|
||||
|
||||
/* Context ID - Currently not in use */
|
||||
__u32 ctx_id;
|
||||
__u32 pad;
|
||||
};
|
||||
|
||||
/* Opcode to create a new command buffer */
|
||||
#define HL_CB_OP_CREATE 0
|
||||
@@ -264,6 +320,23 @@ union hl_mem_args {
|
||||
struct hl_mem_out out;
|
||||
};
|
||||
|
||||
/*
|
||||
* Various information operations such as:
|
||||
* - H/W IP information
|
||||
* - Current dram usage
|
||||
*
|
||||
* The user calls this IOCTL with an opcode that describes the required
|
||||
* information. The user should supply a pointer to a user-allocated memory
|
||||
* chunk, which will be filled by the driver with the requested information.
|
||||
*
|
||||
* The user supplies the maximum amount of size to copy into the user's memory,
|
||||
* in order to prevent data corruption in case of differences between the
|
||||
* definitions of structures in kernel and userspace, e.g. in case of old
|
||||
* userspace and new kernel driver
|
||||
*/
|
||||
#define HL_IOCTL_INFO \
|
||||
_IOWR('H', 0x01, struct hl_info_args)
|
||||
|
||||
/*
|
||||
* Command Buffer
|
||||
* - Request a Command Buffer
|
||||
@@ -365,7 +438,7 @@ union hl_mem_args {
|
||||
#define HL_IOCTL_MEMORY \
|
||||
_IOWR('H', 0x05, union hl_mem_args)
|
||||
|
||||
#define HL_COMMAND_START 0x02
|
||||
#define HL_COMMAND_START 0x01
|
||||
#define HL_COMMAND_END 0x06
|
||||
|
||||
#endif /* HABANALABS_H_ */
|
||||
|
||||
Reference in New Issue
Block a user