// SPDX-License-Identifier: GPL-2.0 /* * Copyright 2016-2020 HabanaLabs, Ltd. * All Rights Reserved. */ #include "../habanalabs.h" #include "../../include/hw_ip/mmu/mmu_general.h" #include "../../include/hw_ip/mmu/mmu_v2_0.h" #include <linux/slab.h> /** * hl_mmu_v2_ctx_init() - initialize a context for using the MMU module. * @ctx: pointer to the context structure to initialize. * * Initialize a mutex to protect the concurrent mapping flow, a hash to hold all * page tables hops related to this context. * Return: 0 on success, non-zero otherwise. */ static int hl_mmu_v2_ctx_init(struct hl_ctx *ctx) { … } /* * hl_mmu_v2_ctx_fini - disable a ctx from using the mmu module * * @ctx: pointer to the context structure * * This function does the following: * - Free any pgts which were not freed yet * - Free the mutex * - Free DRAM default page mapping hops */ static void hl_mmu_v2_ctx_fini(struct hl_ctx *ctx) { … } static int hl_mmu_v2_unmap(struct hl_ctx *ctx, u64 virt_addr, bool is_dram_addr) { … } static int hl_mmu_v2_map(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr, u32 page_size, bool is_dram_addr) { … } /* * hl_mmu_v2_swap_out - marks all mapping of the given ctx as swapped out * * @ctx: pointer to the context structure * */ static void hl_mmu_v2_swap_out(struct hl_ctx *ctx) { … } /* * hl_mmu_v2_swap_in - marks all mapping of the given ctx as swapped in * * @ctx: pointer to the context structure * */ static void hl_mmu_v2_swap_in(struct hl_ctx *ctx) { … } static int hl_mmu_v2_get_tlb_info(struct hl_ctx *ctx, u64 virt_addr, struct hl_mmu_hop_info *hops) { … } /* * hl_mmu_v2_prepare - prepare mmu_if for working with mmu v2 * * @hdev: pointer to the device structure * @mmu_if: pointer to the mmu interface structure */ void hl_mmu_v2_set_funcs(struct hl_device *hdev, struct hl_mmu_funcs *mmu) { … }