1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2020 Intel Corporation
4  */
5 
6 #ifndef __I915_GEM_GTT_H__
7 #define __I915_GEM_GTT_H__
8 
9 #include <linux/io-mapping.h>
10 #include <linux/types.h>
11 
12 #include <drm/drm_mm.h>
13 
14 #include "gt/intel_gtt.h"
15 #include "i915_scatterlist.h"
16 
17 struct drm_i915_gem_object;
18 struct i915_address_space;
19 struct i915_gem_ww_ctx;
20 
21 int __must_check i915_gem_gtt_prepare_pages(struct drm_i915_gem_object *obj,
22 					    struct sg_table *pages);
23 void i915_gem_gtt_finish_pages(struct drm_i915_gem_object *obj,
24 			       struct sg_table *pages);
25 
26 int i915_gem_gtt_reserve(struct i915_address_space *vm,
27 			 struct i915_gem_ww_ctx *ww,
28 			 struct drm_mm_node *node,
29 			 u64 size, u64 offset, unsigned long color,
30 			 unsigned int flags);
31 
32 int i915_gem_gtt_insert(struct i915_address_space *vm,
33 			struct i915_gem_ww_ctx *ww,
34 			struct drm_mm_node *node,
35 			u64 size, u64 alignment, unsigned long color,
36 			u64 start, u64 end, unsigned int flags);
37 
38 /* Flags used by pin/bind&friends. */
39 #define PIN_NOEVICT		BIT_ULL(0)
40 #define PIN_NOSEARCH		BIT_ULL(1)
41 #define PIN_NONBLOCK		BIT_ULL(2)
42 #define PIN_MAPPABLE		BIT_ULL(3)
43 #define PIN_ZONE_4G		BIT_ULL(4)
44 #define PIN_HIGH		BIT_ULL(5)
45 #define PIN_OFFSET_BIAS		BIT_ULL(6)
46 #define PIN_OFFSET_FIXED	BIT_ULL(7)
47 #define PIN_VALIDATE		BIT_ULL(8) /* validate placement only, no need to call unpin() */
48 
49 #define PIN_GLOBAL		BIT_ULL(10) /* I915_VMA_GLOBAL_BIND */
50 #define PIN_USER		BIT_ULL(11) /* I915_VMA_LOCAL_BIND */
51 
52 #define PIN_OFFSET_MASK		I915_GTT_PAGE_MASK
53 
54 #endif
55