habanalabs: make last_mask an MMU property
PATCH 1/1 habanalabs: make last_mask an MMU property
From: Yuri Nudelman <[email protected]>
Currently LAST_MASK is a global, but really it is an MMU implementation specific. We need this change for future ASICs.
Signed-off-by Yuri Nudelman <[email protected]>
Reviewed-by Oded Gabbay <[email protected]>
Signed-off-by Oded Gabbay <[email protected]>
--- drivers/misc/habanalabs/common/habanalabs.h | 2 ++ drivers/misc/habanalabs/common/mmu/mmu_v1.c | 10 +++++----- drivers/misc/habanalabs/gaudi/gaudi.c | 1 + drivers/misc/habanalabs/goya/goya.c | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-)
drivers/misc/habanalabs/common/habanalabs.h +2 -0
@@ -382,6 +382,7 @@ enum hl_device_hw_state {* @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. +* @last_mask: mask to get the bit indicating this is the last hop. * @page_size: default page size used to allocate memory. * @num_hops: The amount of hops supported by the translation table. * @host_resident: Should the MMU page table reside in host memory or in the
@@ -402,6 +403,7 @@ struct hl_mmu_properties {u64 hop3_mask;u64 hop4_mask;u64 hop5_mask; +u64 last_mask;u32 page_size;u32 num_hops;u8 host_resident;
drivers/misc/habanalabs/common/mmu/mmu_v1.c +5 -5
@@ -573,7 +573,7 @@ static int _hl_mmu_v1_unmap(struct hl_ctx *ctx, curr_pte = *(u64 *) (uintptr_t ) hop3_pte_addr; - is_huge = curr_pte &LAST_MASK ; + is_huge = curr_pte & mmu_prop->last_mask;if (is_dram_addr && !is_huge) { dev_err(hdev->dev,
@@ -597,7 +597,7 @@ static int _hl_mmu_v1_unmap(struct hl_ctx *ctx,if (hdev->dram_default_page_mapping && is_dram_addr) {u64 default_pte = (prop->mmu_dram_default_page_addr & -HOP_PHYS_ADDR_MASK ) |LAST_MASK | +HOP_PHYS_ADDR_MASK ) | mmu_prop->last_mask |PAGE_PRESENT_MASK ;if (curr_pte == default_pte) { dev_err(hdev->dev,
@@ -729,7 +729,7 @@ static int _hl_mmu_v1_map(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr,if (hdev->dram_default_page_mapping && is_dram_addr) {u64 default_pte = (prop->mmu_dram_default_page_addr & -HOP_PHYS_ADDR_MASK ) |LAST_MASK | +HOP_PHYS_ADDR_MASK ) | mmu_prop->last_mask |PAGE_PRESENT_MASK ;if (curr_pte != default_pte) {
@@ -769,7 +769,7 @@ static int _hl_mmu_v1_map(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr, goto err; } - curr_pte = (phys_addr &HOP_PHYS_ADDR_MASK ) |LAST_MASK + curr_pte = (phys_addr &HOP_PHYS_ADDR_MASK ) | mmu_prop->last_mask |PAGE_PRESENT_MASK ;if (is_huge)
@@ -930,7 +930,7 @@ static int hl_mmu_v1_get_tlb_info(struct hl_ctx *ctx, u64 virt_addr,if (!(hops->hop_info[i].hop_pte_val &PAGE_PRESENT_MASK ))return -EFAULT ; -if (hops->hop_info[i].hop_pte_val &LAST_MASK ) +if (hops->hop_info[i].hop_pte_val & mmu_prop->last_mask)break ; }
drivers/misc/habanalabs/gaudi/gaudi.c +1 -0
@@ -613,6 +613,7 @@ static int gaudi_set_fixed_properties(struct hl_device *hdev) (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 ; + prop->pmmu.last_mask =LAST_MASK ;/* PMMU and HPMMU are the same except of page size */ memcpy (&prop->pmmu_huge, &prop->pmmu,sizeof (prop->pmmu));
drivers/misc/habanalabs/goya/goya.c +2 -0
@@ -429,6 +429,7 @@ int goya_set_fixed_properties(struct hl_device *hdev) prop->dmmu.end_addr =VA_DDR_SPACE_END ; prop->dmmu.page_size =PAGE_SIZE_2MB ; prop->dmmu.num_hops =MMU_ARCH_5_HOPS ; + prop->dmmu.last_mask =LAST_MASK ;/* shifts and masks are the same in PMMU and DMMU */ memcpy (&prop->pmmu, &prop->dmmu,sizeof (prop->dmmu));
@@ -436,6 +437,7 @@ int goya_set_fixed_properties(struct hl_device *hdev) prop->pmmu.end_addr =VA_HOST_SPACE_END ; prop->pmmu.page_size =PAGE_SIZE_4KB ; prop->pmmu.num_hops =MMU_ARCH_5_HOPS ; + prop->pmmu.last_mask =LAST_MASK ;/* PMMU and HPMMU are the same except of page size */ memcpy (&prop->pmmu_huge, &prop->pmmu,sizeof (prop->pmmu));
Signature · 1 line
2.25.1