1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright �� 2022 Intel Corporation
4 */
5
6#ifndef _XE_TTM_VRAM_MGR_H_
7#define _XE_TTM_VRAM_MGR_H_
8
9#include "xe_ttm_vram_mgr_types.h"
10
11enum dma_data_direction;
12struct xe_device;
13struct xe_tile;
14
15int __xe_ttm_vram_mgr_init(struct xe_device *xe, struct xe_ttm_vram_mgr *mgr,
16			   u32 mem_type, u64 size, u64 io_size,
17			   u64 default_page_size);
18int xe_ttm_vram_mgr_init(struct xe_tile *tile, struct xe_ttm_vram_mgr *mgr);
19int xe_ttm_vram_mgr_alloc_sgt(struct xe_device *xe,
20			      struct ttm_resource *res,
21			      u64 offset, u64 length,
22			      struct device *dev,
23			      enum dma_data_direction dir,
24			      struct sg_table **sgt);
25void xe_ttm_vram_mgr_free_sgt(struct device *dev, enum dma_data_direction dir,
26			      struct sg_table *sgt);
27
28u64 xe_ttm_vram_get_cpu_visible_size(struct ttm_resource_manager *man);
29void xe_ttm_vram_get_used(struct ttm_resource_manager *man,
30			  u64 *used, u64 *used_visible);
31
32static inline struct xe_ttm_vram_mgr_resource *
33to_xe_ttm_vram_mgr_resource(struct ttm_resource *res)
34{
35	return container_of(res, struct xe_ttm_vram_mgr_resource, base);
36}
37
38static inline struct xe_ttm_vram_mgr *
39to_xe_ttm_vram_mgr(struct ttm_resource_manager *man)
40{
41	return container_of(man, struct xe_ttm_vram_mgr, manager);
42}
43
44#endif
45