habanalabs: expose number of user interrupts
authorOded Gabbay <ogabbay@kernel.org>
Tue, 18 Jan 2022 12:58:30 +0000 (14:58 +0200)
committerOded Gabbay <ogabbay@kernel.org>
Mon, 28 Feb 2022 12:22:03 +0000 (14:22 +0200)
Currently we only expose to the user the ID of the first available
user interrupt. To make user interrupts allocation truly dynamic, we
need to also expose the number of user interrupts.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/habanalabs_ioctl.c
include/uapi/misc/habanalabs.h

index d190975..c13a3c2 100644 (file)
@@ -92,8 +92,8 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args)
        hw_ip.psoc_pci_pll_od = prop->psoc_pci_pll_od;
        hw_ip.psoc_pci_pll_div_factor = prop->psoc_pci_pll_div_factor;
 
-       hw_ip.first_available_interrupt_id =
-                       prop->first_available_user_msix_interrupt;
+       hw_ip.first_available_interrupt_id = prop->first_available_user_msix_interrupt;
+       hw_ip.number_of_user_interrupts = prop->user_interrupt_count;
        hw_ip.server_type = prop->server_type;
 
        return copy_to_user(out, &hw_ip,
index 371dfc4..12976f7 100644 (file)
@@ -404,6 +404,8 @@ enum hl_server_type {
  * @cpucp_version: The CPUCP f/w version.
  * @card_name: The card name as passed by the f/w.
  * @dram_page_size: The DRAM physical page size.
+ * @number_of_user_interrupts: The number of interrupts that are available to the userspace
+ *                             application to use. Relevant for Gaudi2 and later.
  */
 struct hl_info_hw_ip_info {
        __u64 sram_base_address;
@@ -428,6 +430,9 @@ struct hl_info_hw_ip_info {
        __u8 card_name[HL_INFO_CARD_NAME_MAX_LEN];
        __u64 reserved2;
        __u64 dram_page_size;
+       __u32 reserved3;
+       __u16 number_of_user_interrupts;
+       __u16 pad2;
 };
 
 struct hl_info_dram_usage {