habanalabs: add asic property of host dma offset
authorOded Gabbay <ogabbay@kernel.org>
Sat, 10 Jul 2021 18:12:45 +0000 (21:12 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Sun, 29 Aug 2021 06:47:47 +0000 (09:47 +0300)
Each ASIC can have a different offset to add to a host dma address,
to enable the ASIC to access that host memory.

The usage for this can be common code so add this to the asic
property structure.

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

index 6affad6bc1b9f580f7dc9379523104520fdf6aa0..9782bb50931ab229090812ad06c793b21280d71c 100644 (file)
@@ -434,6 +434,8 @@ struct hl_hints_range {
  *                  the device's MMU.
  * @dram_hints_align_mask: dram va hint addresses alignment mask which is used
  *                  for hints validity check.
+ * device_dma_offset_for_host_access: the offset to add to host DMA addresses
+ *                                    to enable the device to access them.
  * @mmu_pgt_size: MMU page tables total size.
  * @mmu_pte_size: PTE size in MMU page tables.
  * @mmu_hop_table_size: MMU hop table size.
@@ -527,6 +529,7 @@ struct asic_fixed_properties {
        u64                             cb_va_start_addr;
        u64                             cb_va_end_addr;
        u64                             dram_hints_align_mask;
+       u64                             device_dma_offset_for_host_access;
        u32                             mmu_pgt_size;
        u32                             mmu_pte_size;
        u32                             mmu_hop_table_size;
index 14d0f6d9a383343cb583888cb8926d5bf6d10426..fdbe8155ef3cceba8a7713492510f764b0c1fb5a 100644 (file)
@@ -537,6 +537,7 @@ static int gaudi_set_fixed_properties(struct hl_device *hdev)
                                                get_collective_mode(hdev, i);
        }
 
+       prop->device_dma_offset_for_host_access = HOST_PHYS_BASE;
        prop->completion_queues_count = NUMBER_OF_CMPLT_QUEUES;
        prop->collective_first_sob = 0;
        prop->collective_first_mon = 0;
index 017c913f7b5ab0e116aac8ebc3d3fcb62fabb11e..ae9871928369195c24e41643f42a3cb55db6e3b7 100644 (file)
@@ -389,6 +389,7 @@ int goya_set_fixed_properties(struct hl_device *hdev)
                prop->hw_queues_props[i].cb_alloc_flags = CB_ALLOC_USER;
        }
 
+       prop->device_dma_offset_for_host_access = HOST_PHYS_BASE;
        prop->completion_queues_count = NUMBER_OF_CMPLT_QUEUES;
 
        prop->dram_base_address = DRAM_PHYS_BASE;