This source file includes following definitions.
- is_active
- is_purgeable
- is_vunmapable
1
2
3
4
5
6
7 #ifndef __MSM_GEM_H__
8 #define __MSM_GEM_H__
9
10 #include <linux/kref.h>
11 #include <linux/dma-resv.h>
12 #include "msm_drv.h"
13
14
15 #define MSM_BO_STOLEN 0x10000000
16
17 struct msm_gem_address_space {
18 const char *name;
19
20
21
22 struct drm_mm mm;
23 spinlock_t lock;
24 struct msm_mmu *mmu;
25 struct kref kref;
26 };
27
28 struct msm_gem_vma {
29 struct drm_mm_node node;
30 uint64_t iova;
31 struct msm_gem_address_space *aspace;
32 struct list_head list;
33 bool mapped;
34 int inuse;
35 };
36
37 struct msm_gem_object {
38 struct drm_gem_object base;
39
40 uint32_t flags;
41
42
43
44
45 uint8_t madv;
46
47
48
49
50 uint8_t vmap_count;
51
52
53
54
55
56
57
58
59
60 struct list_head mm_list;
61 struct msm_gpu *gpu;
62
63
64
65
66
67
68 struct list_head submit_entry;
69
70 struct page **pages;
71 struct sg_table *sgt;
72 void *vaddr;
73
74 struct list_head vmas;
75
76 struct llist_node freed;
77
78
79
80
81 struct drm_mm_node *vram_node;
82 struct mutex lock;
83
84 char name[32];
85 };
86 #define to_msm_bo(x) container_of(x, struct msm_gem_object, base)
87
88 static inline bool is_active(struct msm_gem_object *msm_obj)
89 {
90 return msm_obj->gpu != NULL;
91 }
92
93 static inline bool is_purgeable(struct msm_gem_object *msm_obj)
94 {
95 WARN_ON(!mutex_is_locked(&msm_obj->base.dev->struct_mutex));
96 return (msm_obj->madv == MSM_MADV_DONTNEED) && msm_obj->sgt &&
97 !msm_obj->base.dma_buf && !msm_obj->base.import_attach;
98 }
99
100 static inline bool is_vunmapable(struct msm_gem_object *msm_obj)
101 {
102 return (msm_obj->vmap_count == 0) && msm_obj->vaddr;
103 }
104
105
106
107
108
109
110
111
112
113
114
115
116 enum msm_gem_lock {
117 OBJ_LOCK_NORMAL,
118 OBJ_LOCK_SHRINKER,
119 };
120
121 void msm_gem_purge(struct drm_gem_object *obj, enum msm_gem_lock subclass);
122 void msm_gem_vunmap(struct drm_gem_object *obj, enum msm_gem_lock subclass);
123 void msm_gem_free_work(struct work_struct *work);
124
125
126
127
128
129
130 struct msm_gem_submit {
131 struct drm_device *dev;
132 struct msm_gpu *gpu;
133 struct msm_gem_address_space *aspace;
134 struct list_head node;
135 struct list_head bo_list;
136 struct ww_acquire_ctx ticket;
137 uint32_t seqno;
138 struct dma_fence *fence;
139 struct msm_gpu_submitqueue *queue;
140 struct pid *pid;
141 bool valid;
142 bool in_rb;
143 struct msm_ringbuffer *ring;
144 unsigned int nr_cmds;
145 unsigned int nr_bos;
146 u32 ident;
147 struct {
148 uint32_t type;
149 uint32_t size;
150 uint64_t iova;
151 uint32_t idx;
152 } *cmd;
153 struct {
154 uint32_t flags;
155 union {
156 struct msm_gem_object *obj;
157 uint32_t handle;
158 };
159 uint64_t iova;
160 } bos[0];
161 };
162
163 #endif