linux/drivers/accel/habanalabs/common/mmu/mmu_v2_hr.c

// SPDX-License-Identifier: GPL-2.0

/*
 * Copyright 2020-2022 HabanaLabs, Ltd.
 * All Rights Reserved.
 */

#include "../habanalabs.h"
#include "../../include/hw_ip/mmu/mmu_general.h"

#include <linux/slab.h>

static struct pgt_info *hl_mmu_v2_hr_get_pgt_info(struct hl_ctx *ctx, u64 phys_hop_addr)
{}

static void hl_mmu_v2_hr_add_pgt_info(struct hl_ctx *ctx, struct pgt_info *pgt_info,
					dma_addr_t phys_addr)
{}

static struct pgt_info *hl_mmu_v2_hr_get_hop0_pgt_info(struct hl_ctx *ctx)
{}

/**
 * hl_mmu_v2_hr_init() - initialize the MMU module.
 * @hdev: habanalabs device structure.
 *
 * This function does the following:
 * - Create a pool of pages for pgt_infos.
 * - Create a shadow table for pgt
 *
 * Return: 0 for success, non-zero for failure.
 */
static inline int hl_mmu_v2_hr_init(struct hl_device *hdev)
{}

/**
 * hl_mmu_v2_hr_fini() - release the MMU module.
 * @hdev: habanalabs device structure.
 *
 * This function does the following:
 * - Disable MMU in H/W.
 * - Free the pgt_infos pool.
 *
 * All contexts should be freed before calling this function.
 */
static inline void hl_mmu_v2_hr_fini(struct hl_device *hdev)
{}

/**
 * hl_mmu_v2_hr_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_hr_ctx_init(struct hl_ctx *ctx)
{}

/*
 * hl_mmu_v2_hr_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_hr_ctx_fini(struct hl_ctx *ctx)
{}

static int _hl_mmu_v2_hr_unmap(struct hl_ctx *ctx,
				u64 virt_addr, bool is_dram_addr)
{}

static int hl_mmu_v2_get_last_hop(struct hl_mmu_properties *mmu_prop, u32 page_size)
{}

static int _hl_mmu_v2_hr_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_hr_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_hr_swap_in(struct hl_ctx *ctx)
{}

static int hl_mmu_v2_hr_get_tlb_mapping_params(struct hl_device *hdev,
							struct hl_mmu_properties **mmu_prop,
							struct hl_mmu_hop_info *hops,
							u64 virt_addr, bool *is_huge)
{}

static int hl_mmu_v2_hr_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_hr_set_funcs(struct hl_device *hdev, struct hl_mmu_funcs *mmu)
{}