This source file includes following definitions.
- vmw_validation_has_bos
- vmw_validation_set_val_mem
- vmw_validation_set_ht
- vmw_validation_bo_reserve
- vmw_validation_bo_backoff
- vmw_validation_bo_fence
- vmw_validation_context_init
- vmw_validation_align
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 #ifndef _VMWGFX_VALIDATION_H_
29 #define _VMWGFX_VALIDATION_H_
30
31 #include <linux/list.h>
32 #include <linux/ww_mutex.h>
33
34 #include <drm/drm_hashtab.h>
35 #include <drm/ttm/ttm_execbuf_util.h>
36
37 #define VMW_RES_DIRTY_NONE 0
38 #define VMW_RES_DIRTY_SET BIT(0)
39 #define VMW_RES_DIRTY_CLEAR BIT(1)
40
41
42
43
44
45
46
47
48
49
50 struct vmw_validation_mem {
51 int (*reserve_mem)(struct vmw_validation_mem *m, size_t size);
52 void (*unreserve_mem)(struct vmw_validation_mem *m, size_t size);
53 size_t gran;
54 };
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75 struct vmw_validation_context {
76 struct drm_open_hash *ht;
77 struct list_head resource_list;
78 struct list_head resource_ctx_list;
79 struct list_head bo_list;
80 struct list_head page_list;
81 struct ww_acquire_ctx ticket;
82 struct mutex *res_mutex;
83 unsigned int merge_dups;
84 unsigned int mem_size_left;
85 u8 *page_address;
86 struct vmw_validation_mem *vm;
87 size_t vm_size_left;
88 size_t total_mem;
89 };
90
91 struct vmw_buffer_object;
92 struct vmw_resource;
93 struct vmw_fence_obj;
94
95 #if 0
96
97
98
99
100
101
102
103
104
105 #endif
106 #define DECLARE_VAL_CONTEXT(_name, _ht, _merge_dups) \
107 struct vmw_validation_context _name = \
108 { .ht = _ht, \
109 .resource_list = LIST_HEAD_INIT((_name).resource_list), \
110 .resource_ctx_list = LIST_HEAD_INIT((_name).resource_ctx_list), \
111 .bo_list = LIST_HEAD_INIT((_name).bo_list), \
112 .page_list = LIST_HEAD_INIT((_name).page_list), \
113 .res_mutex = NULL, \
114 .merge_dups = _merge_dups, \
115 .mem_size_left = 0, \
116 }
117
118
119
120
121
122
123
124
125 static inline bool
126 vmw_validation_has_bos(struct vmw_validation_context *ctx)
127 {
128 return !list_empty(&ctx->bo_list);
129 }
130
131
132
133
134
135
136
137
138
139 static inline void
140 vmw_validation_set_val_mem(struct vmw_validation_context *ctx,
141 struct vmw_validation_mem *vm)
142 {
143 ctx->vm = vm;
144 }
145
146
147
148
149
150
151
152
153 static inline void vmw_validation_set_ht(struct vmw_validation_context *ctx,
154 struct drm_open_hash *ht)
155 {
156 ctx->ht = ht;
157 }
158
159
160
161
162
163
164
165
166
167
168 static inline int
169 vmw_validation_bo_reserve(struct vmw_validation_context *ctx,
170 bool intr)
171 {
172 return ttm_eu_reserve_buffers(&ctx->ticket, &ctx->bo_list, intr,
173 NULL, true);
174 }
175
176
177
178
179
180
181
182
183
184 static inline void
185 vmw_validation_bo_backoff(struct vmw_validation_context *ctx)
186 {
187 ttm_eu_backoff_reservation(&ctx->ticket, &ctx->bo_list);
188 }
189
190
191
192
193
194
195
196
197
198 static inline void
199 vmw_validation_bo_fence(struct vmw_validation_context *ctx,
200 struct vmw_fence_obj *fence)
201 {
202 ttm_eu_fence_buffer_objects(&ctx->ticket, &ctx->bo_list,
203 (void *) fence);
204 }
205
206
207
208
209
210
211
212
213 static inline void
214 vmw_validation_context_init(struct vmw_validation_context *ctx)
215 {
216 memset(ctx, 0, sizeof(*ctx));
217 INIT_LIST_HEAD(&ctx->resource_list);
218 INIT_LIST_HEAD(&ctx->resource_ctx_list);
219 INIT_LIST_HEAD(&ctx->bo_list);
220 }
221
222
223
224
225
226
227
228
229 static inline unsigned int vmw_validation_align(unsigned int val)
230 {
231 return ALIGN(val, sizeof(long));
232 }
233
234 int vmw_validation_add_bo(struct vmw_validation_context *ctx,
235 struct vmw_buffer_object *vbo,
236 bool as_mob, bool cpu_blit);
237 int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo,
238 bool interruptible,
239 bool validate_as_mob);
240 int vmw_validation_bo_validate(struct vmw_validation_context *ctx, bool intr);
241 void vmw_validation_unref_lists(struct vmw_validation_context *ctx);
242 int vmw_validation_add_resource(struct vmw_validation_context *ctx,
243 struct vmw_resource *res,
244 size_t priv_size,
245 u32 dirty,
246 void **p_node,
247 bool *first_usage);
248 void vmw_validation_drop_ht(struct vmw_validation_context *ctx);
249 int vmw_validation_res_reserve(struct vmw_validation_context *ctx,
250 bool intr);
251 void vmw_validation_res_unreserve(struct vmw_validation_context *ctx,
252 bool backoff);
253 void vmw_validation_res_switch_backup(struct vmw_validation_context *ctx,
254 void *val_private,
255 struct vmw_buffer_object *vbo,
256 unsigned long backup_offset);
257 int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr);
258
259 int vmw_validation_prepare(struct vmw_validation_context *ctx,
260 struct mutex *mutex, bool intr);
261 void vmw_validation_revert(struct vmw_validation_context *ctx);
262 void vmw_validation_done(struct vmw_validation_context *ctx,
263 struct vmw_fence_obj *fence);
264
265 void *vmw_validation_mem_alloc(struct vmw_validation_context *ctx,
266 unsigned int size);
267 int vmw_validation_preload_bo(struct vmw_validation_context *ctx);
268 int vmw_validation_preload_res(struct vmw_validation_context *ctx,
269 unsigned int size);
270 void vmw_validation_res_set_dirty(struct vmw_validation_context *ctx,
271 void *val_private, u32 dirty);
272 #endif