Commit 7aa2227a authored by Oded Gabbay's avatar Oded Gabbay

habanalabs: initialize MMU context for driver

This patch initializes the MMU structures for the kernel context. This is
needed before we can configure mappings for the kernel context.
Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
parent 37d68ce5
...@@ -36,6 +36,8 @@ static void hl_ctx_fini(struct hl_ctx *ctx) ...@@ -36,6 +36,8 @@ static void hl_ctx_fini(struct hl_ctx *ctx)
hl_vm_ctx_fini(ctx); hl_vm_ctx_fini(ctx);
hl_asid_free(hdev, ctx->asid); hl_asid_free(hdev, ctx->asid);
} else {
hl_mmu_ctx_fini(ctx);
} }
} }
...@@ -119,6 +121,11 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx) ...@@ -119,6 +121,11 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx)
if (is_kernel_ctx) { if (is_kernel_ctx) {
ctx->asid = HL_KERNEL_ASID_ID; /* KMD gets ASID 0 */ ctx->asid = HL_KERNEL_ASID_ID; /* KMD gets ASID 0 */
rc = hl_mmu_ctx_init(ctx);
if (rc) {
dev_err(hdev->dev, "Failed to init mmu ctx module\n");
goto mem_ctx_err;
}
} else { } else {
ctx->asid = hl_asid_alloc(hdev); ctx->asid = hl_asid_alloc(hdev);
if (!ctx->asid) { if (!ctx->asid) {
......
...@@ -241,8 +241,9 @@ static int dram_default_mapping_init(struct hl_ctx *ctx) ...@@ -241,8 +241,9 @@ static int dram_default_mapping_init(struct hl_ctx *ctx)
hop2_pte_addr, hop3_pte_addr, pte_val; hop2_pte_addr, hop3_pte_addr, pte_val;
int rc, i, j, hop3_allocated = 0; int rc, i, j, hop3_allocated = 0;
if (!hdev->dram_supports_virtual_memory || if ((!hdev->dram_supports_virtual_memory) ||
!hdev->dram_default_page_mapping) (!hdev->dram_default_page_mapping) ||
(ctx->asid == HL_KERNEL_ASID_ID))
return 0; return 0;
num_of_hop3 = prop->dram_size_for_default_page_mapping; num_of_hop3 = prop->dram_size_for_default_page_mapping;
...@@ -340,8 +341,9 @@ static void dram_default_mapping_fini(struct hl_ctx *ctx) ...@@ -340,8 +341,9 @@ static void dram_default_mapping_fini(struct hl_ctx *ctx)
hop2_pte_addr, hop3_pte_addr; hop2_pte_addr, hop3_pte_addr;
int i, j; int i, j;
if (!hdev->dram_supports_virtual_memory || if ((!hdev->dram_supports_virtual_memory) ||
!hdev->dram_default_page_mapping) (!hdev->dram_default_page_mapping) ||
(ctx->asid == HL_KERNEL_ASID_ID))
return; return;
num_of_hop3 = prop->dram_size_for_default_page_mapping; num_of_hop3 = prop->dram_size_for_default_page_mapping;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment