habanalabs: add num_hops to hl_mmu_properties
authorMoti Haimovski <mhaimovski@habana.ai>
Sun, 23 Aug 2020 10:23:13 +0000 (13:23 +0300)
committerOded Gabbay <oded.gabbay@gmail.com>
Tue, 22 Sep 2020 15:49:53 +0000 (18:49 +0300)
This commit adds the number of HOPs supported by the device to the
device MMU properties.

Signed-off-by: Moti Haimovski <mhaimovski@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/misc/habanalabs/common/habanalabs.h
drivers/misc/habanalabs/gaudi/gaudi.c
drivers/misc/habanalabs/goya/goya.c
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h

index 15e746a5fe352d47d4b1006d22ea83b5213a8669..8ef61926ed3ba9cdd4b6d3397aa3ea52294da9e0 100644 (file)
@@ -236,12 +236,15 @@ enum hl_device_hw_state {
  * @hop2_shift: shift of hop 2 mask.
  * @hop3_shift: shift of hop 3 mask.
  * @hop4_shift: shift of hop 4 mask.
+ * @hop5_shift: shift of hop 5 mask.
  * @hop0_mask: mask to get the PTE address in hop 0.
  * @hop1_mask: mask to get the PTE address in hop 1.
  * @hop2_mask: mask to get the PTE address in hop 2.
  * @hop3_mask: mask to get the PTE address in hop 3.
  * @hop4_mask: mask to get the PTE address in hop 4.
+ * @hop5_mask: mask to get the PTE address in hop 5.
  * @page_size: default page size used to allocate memory.
+ * @num_hops: The amount of hops supported by the translation table.
  */
 struct hl_mmu_properties {
        u64     start_addr;
@@ -251,12 +254,15 @@ struct hl_mmu_properties {
        u64     hop2_shift;
        u64     hop3_shift;
        u64     hop4_shift;
+       u64     hop5_shift;
        u64     hop0_mask;
        u64     hop1_mask;
        u64     hop2_mask;
        u64     hop3_mask;
        u64     hop4_mask;
+       u64     hop5_mask;
        u32     page_size;
+       u32     num_hops;
 };
 
 /**
index 483989500863a944e3cddc033e72b230bc53ef90..bf010ff31ceda2ed99fbe12d96f9077265b4a305 100644 (file)
@@ -441,6 +441,7 @@ static int gaudi_get_fixed_properties(struct hl_device *hdev)
        prop->pmmu.end_addr =
                        (VA_HOST_SPACE_START + VA_HOST_SPACE_SIZE / 2) - 1;
        prop->pmmu.page_size = PAGE_SIZE_4KB;
+       prop->pmmu.num_hops = MMU_ARCH_5_HOPS;
 
        /* PMMU and HPMMU are the same except of page size */
        memcpy(&prop->pmmu_huge, &prop->pmmu, sizeof(prop->pmmu));
index 46a900fb3ef8ba2cfdb908fb42088c7bcc927943..6f831cc54d37cdee127099290f91bf3ef0906bb4 100644 (file)
@@ -426,12 +426,14 @@ int goya_get_fixed_properties(struct hl_device *hdev)
        prop->dmmu.start_addr = VA_DDR_SPACE_START;
        prop->dmmu.end_addr = VA_DDR_SPACE_END;
        prop->dmmu.page_size = PAGE_SIZE_2MB;
+       prop->dmmu.num_hops = MMU_ARCH_5_HOPS;
 
        /* shifts and masks are the same in PMMU and DMMU */
        memcpy(&prop->pmmu, &prop->dmmu, sizeof(prop->dmmu));
        prop->pmmu.start_addr = VA_HOST_SPACE_START;
        prop->pmmu.end_addr = VA_HOST_SPACE_END;
        prop->pmmu.page_size = PAGE_SIZE_4KB;
+       prop->pmmu.num_hops = MMU_ARCH_5_HOPS;
 
        /* PMMU and HPMMU are the same except of page size */
        memcpy(&prop->pmmu_huge, &prop->pmmu, sizeof(prop->pmmu));
index 468bb045fbd1a8ac730c9e415a1b4f8df4ba3dcf..dedf20e8f956f9610673d25db7334bb150f94e7a 100644 (file)
@@ -29,6 +29,8 @@
 #define HOP3_SHIFT                     21
 #define HOP4_SHIFT                     12
 
+#define MMU_ARCH_5_HOPS                        5
+
 #define HOP_PHYS_ADDR_MASK             (~FLAGS_MASK)
 
 #define HL_PTE_SIZE                    sizeof(u64)