accel/habanalabs: expose engine core int reg address
authorOfir Bitton <obitton@habana.ai>
Sun, 22 Jan 2023 12:06:15 +0000 (14:06 +0200)
committerOded Gabbay <ogabbay@kernel.org>
Wed, 15 Mar 2023 11:29:12 +0000 (13:29 +0200)
In order for engine cores to raise interrupts towards FW, They need
to know which register the event data should be written to.
Hence, we forward the relevant scratchpad register received during
dynamic regs handshake with FW.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
drivers/accel/habanalabs/common/habanalabs.h
drivers/accel/habanalabs/common/habanalabs_ioctl.c
drivers/accel/habanalabs/gaudi2/gaudi2.c
include/uapi/drm/habanalabs_accel.h

index 176a2e2c050dc3c8f0c5cae836b26df47df63e2c..bf81eda88e2ea3ae5fc9cfaff06852897ebd1b89 100644 (file)
@@ -592,6 +592,8 @@ struct hl_hints_range {
  * @host_base_address: host physical start address for host DMA from device
  * @host_end_address: host physical end address for host DMA from device
  * @max_freq_value: current max clk frequency.
+ * @engine_core_interrupt_reg_addr: interrupt register address for engine core to use
+ *                                  in order to raise events toward FW.
  * @clk_pll_index: clock PLL index that specify which PLL determines the clock
  *                 we display to the user
  * @mmu_pgt_size: MMU page tables total size.
@@ -739,6 +741,7 @@ struct asic_fixed_properties {
        u64                             host_base_address;
        u64                             host_end_address;
        u64                             max_freq_value;
+       u64                             engine_core_interrupt_reg_addr;
        u32                             clk_pll_index;
        u32                             mmu_pgt_size;
        u32                             mmu_pte_size;
index 13cd5013c72a00157e157eaa89c270ab644e787a..448cdd2501d87b233ff9092803e199856754e4d9 100644 (file)
@@ -107,6 +107,7 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args)
        hw_ip.server_type = prop->server_type;
        hw_ip.security_enabled = prop->fw_security_enabled;
        hw_ip.revision_id = hdev->pdev->revision;
+       hw_ip.engine_core_interrupt_reg_addr = prop->engine_core_interrupt_reg_addr;
 
        return copy_to_user(out, &hw_ip,
                min((size_t) size, sizeof(hw_ip))) ? -EFAULT : 0;
index 6926af5b5ed14a1d249954de4e15b35a025f3c34..220d46d95abfbf0ff6cee9665cc01a97b3f5b42c 100644 (file)
@@ -2933,6 +2933,7 @@ static bool gaudi2_is_arc_tpc_owned(u64 arc_id)
 
 static void gaudi2_init_arcs(struct hl_device *hdev)
 {
+       struct cpu_dyn_regs *dyn_regs = &hdev->fw_loader.dynamic_loader.comm_desc.cpu_dyn_regs;
        struct gaudi2_device *gaudi2 = hdev->asic_specific;
        u64 arc_id;
        u32 i;
@@ -2962,6 +2963,10 @@ static void gaudi2_init_arcs(struct hl_device *hdev)
 
                gaudi2_set_arc_id_cap(hdev, arc_id);
        }
+
+       /* Fetch ARC scratchpad address */
+       hdev->asic_prop.engine_core_interrupt_reg_addr =
+               CFG_BASE + le32_to_cpu(dyn_regs->eng_arc_irq_ctrl);
 }
 
 static int gaudi2_scrub_arc_dccm(struct hl_device *hdev, u32 cpu_id)
index 3a62652a6452e9e5785d6b877b578bdda4e0c527..c1fdbb85d1d5ed186c8cd741ebaa7dc52e8c9472 100644 (file)
@@ -885,6 +885,8 @@ enum hl_server_type {
  *                             application to use. Relevant for Gaudi2 and later.
  * @device_mem_alloc_default_page_size: default page size used in device memory allocation.
  * @revision_id: PCI revision ID of the ASIC.
+ * @engine_core_interrupt_reg_addr: interrupt register address for engine core to use
+ *                                  in order to raise events toward FW.
  */
 struct hl_info_hw_ip_info {
        __u64 sram_base_address;
@@ -921,6 +923,9 @@ struct hl_info_hw_ip_info {
        __u8 reserved8;
        __u8 revision_id;
        __u8 pad[2];
+       __u32 reserved9;
+       __u8 pad3[4];
+       __u64 engine_core_interrupt_reg_addr;
 };
 
 struct hl_info_dram_usage {