1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright �� 2022 Intel Corporation
4 */
5
6#ifndef _XE_TTM_VRAM_MGR_TYPES_H_
7#define _XE_TTM_VRAM_MGR_TYPES_H_
8
9#include <drm/drm_buddy.h>
10#include <drm/ttm/ttm_device.h>
11
12struct xe_mem_region;
13
14/**
15 * struct xe_ttm_vram_mgr - XE TTM VRAM manager
16 *
17 * Manages placement of TTM resource in VRAM.
18 */
19struct xe_ttm_vram_mgr {
20	/** @manager: Base TTM resource manager */
21	struct ttm_resource_manager manager;
22	/** @mm: DRM buddy allocator which manages the VRAM */
23	struct drm_buddy mm;
24	/** @vram: ptr to details of associated VRAM region */
25	struct xe_mem_region *vram;
26	/** @visible_size: Proped size of the CPU visible portion */
27	u64 visible_size;
28	/** @visible_avail: CPU visible portion still unallocated */
29	u64 visible_avail;
30	/** @default_page_size: default page size */
31	u64 default_page_size;
32	/** @lock: protects allocations of VRAM */
33	struct mutex lock;
34	/** @mem_type: The TTM memory type */
35	u32 mem_type;
36};
37
38/**
39 * struct xe_ttm_vram_mgr_resource - XE TTM VRAM resource
40 */
41struct xe_ttm_vram_mgr_resource {
42	/** @base: Base TTM resource */
43	struct ttm_resource base;
44	/** @blocks: list of DRM buddy blocks */
45	struct list_head blocks;
46	/** @used_visible_size: How many CPU visible bytes this resource is using */
47	u64 used_visible_size;
48	/** @flags: flags associated with the resource */
49	unsigned long flags;
50};
51
52#endif
53