.. | .. |
---|
35 | 35 | |
---|
36 | 36 | #define VMW_RES_HT_ORDER 12 |
---|
37 | 37 | |
---|
| 38 | +/* |
---|
| 39 | + * Helper macro to get dx_ctx_node if available otherwise print an error |
---|
| 40 | + * message. This is for use in command verifier function where if dx_ctx_node |
---|
| 41 | + * is not set then command is invalid. |
---|
| 42 | + */ |
---|
| 43 | +#define VMW_GET_CTX_NODE(__sw_context) \ |
---|
| 44 | +({ \ |
---|
| 45 | + __sw_context->dx_ctx_node ? __sw_context->dx_ctx_node : ({ \ |
---|
| 46 | + VMW_DEBUG_USER("SM context is not set at %s\n", __func__); \ |
---|
| 47 | + __sw_context->dx_ctx_node; \ |
---|
| 48 | + }); \ |
---|
| 49 | +}) |
---|
| 50 | + |
---|
| 51 | +#define VMW_DECLARE_CMD_VAR(__var, __type) \ |
---|
| 52 | + struct { \ |
---|
| 53 | + SVGA3dCmdHeader header; \ |
---|
| 54 | + __type body; \ |
---|
| 55 | + } __var |
---|
| 56 | + |
---|
| 57 | +/** |
---|
| 58 | + * struct vmw_relocation - Buffer object relocation |
---|
| 59 | + * |
---|
| 60 | + * @head: List head for the command submission context's relocation list |
---|
| 61 | + * @vbo: Non ref-counted pointer to buffer object |
---|
| 62 | + * @mob_loc: Pointer to location for mob id to be modified |
---|
| 63 | + * @location: Pointer to location for guest pointer to be modified |
---|
| 64 | + */ |
---|
| 65 | +struct vmw_relocation { |
---|
| 66 | + struct list_head head; |
---|
| 67 | + struct vmw_buffer_object *vbo; |
---|
| 68 | + union { |
---|
| 69 | + SVGAMobId *mob_loc; |
---|
| 70 | + SVGAGuestPtr *location; |
---|
| 71 | + }; |
---|
| 72 | +}; |
---|
| 73 | + |
---|
38 | 74 | /** |
---|
39 | 75 | * enum vmw_resource_relocation_type - Relocation type for resources |
---|
40 | 76 | * |
---|
.. | .. |
---|
42 | 78 | * command stream is replaced with the actual id after validation. |
---|
43 | 79 | * @vmw_res_rel_nop: NOP relocation. The command is unconditionally replaced |
---|
44 | 80 | * with a NOP. |
---|
45 | | - * @vmw_res_rel_cond_nop: Conditional NOP relocation. If the resource id |
---|
46 | | - * after validation is -1, the command is replaced with a NOP. Otherwise no |
---|
47 | | - * action. |
---|
| 81 | + * @vmw_res_rel_cond_nop: Conditional NOP relocation. If the resource id after |
---|
| 82 | + * validation is -1, the command is replaced with a NOP. Otherwise no action. |
---|
48 | 83 | */ |
---|
49 | 84 | enum vmw_resource_relocation_type { |
---|
50 | 85 | vmw_res_rel_normal, |
---|
.. | .. |
---|
58 | 93 | * |
---|
59 | 94 | * @head: List head for the software context's relocation list. |
---|
60 | 95 | * @res: Non-ref-counted pointer to the resource. |
---|
61 | | - * @offset: Offset of single byte entries into the command buffer where the |
---|
62 | | - * id that needs fixup is located. |
---|
| 96 | + * @offset: Offset of single byte entries into the command buffer where the id |
---|
| 97 | + * that needs fixup is located. |
---|
63 | 98 | * @rel_type: Type of relocation. |
---|
64 | 99 | */ |
---|
65 | 100 | struct vmw_resource_relocation { |
---|
.. | .. |
---|
70 | 105 | }; |
---|
71 | 106 | |
---|
72 | 107 | /** |
---|
73 | | - * struct vmw_resource_val_node - Validation info for resources |
---|
| 108 | + * struct vmw_ctx_validation_info - Extra validation metadata for contexts |
---|
74 | 109 | * |
---|
75 | | - * @head: List head for the software context's resource list. |
---|
76 | | - * @hash: Hash entry for quick resouce to val_node lookup. |
---|
77 | | - * @res: Ref-counted pointer to the resource. |
---|
78 | | - * @switch_backup: Boolean whether to switch backup buffer on unreserve. |
---|
79 | | - * @new_backup: Refcounted pointer to the new backup buffer. |
---|
80 | | - * @staged_bindings: If @res is a context, tracks bindings set up during |
---|
81 | | - * the command batch. Otherwise NULL. |
---|
82 | | - * @new_backup_offset: New backup buffer offset if @new_backup is non-NUll. |
---|
83 | | - * @first_usage: Set to true the first time the resource is referenced in |
---|
84 | | - * the command stream. |
---|
85 | | - * @switching_backup: The command stream provides a new backup buffer for a |
---|
86 | | - * resource. |
---|
87 | | - * @no_buffer_needed: This means @switching_backup is true on first buffer |
---|
88 | | - * reference. So resource reservation does not need to allocate a backup |
---|
89 | | - * buffer for the resource. |
---|
| 110 | + * @head: List head of context list |
---|
| 111 | + * @ctx: The context resource |
---|
| 112 | + * @cur: The context's persistent binding state |
---|
| 113 | + * @staged: The binding state changes of this command buffer |
---|
90 | 114 | */ |
---|
91 | | -struct vmw_resource_val_node { |
---|
| 115 | +struct vmw_ctx_validation_info { |
---|
92 | 116 | struct list_head head; |
---|
93 | | - struct drm_hash_item hash; |
---|
94 | | - struct vmw_resource *res; |
---|
95 | | - struct vmw_buffer_object *new_backup; |
---|
96 | | - struct vmw_ctx_binding_state *staged_bindings; |
---|
97 | | - unsigned long new_backup_offset; |
---|
98 | | - u32 first_usage : 1; |
---|
99 | | - u32 switching_backup : 1; |
---|
100 | | - u32 no_buffer_needed : 1; |
---|
| 117 | + struct vmw_resource *ctx; |
---|
| 118 | + struct vmw_ctx_binding_state *cur; |
---|
| 119 | + struct vmw_ctx_binding_state *staged; |
---|
101 | 120 | }; |
---|
102 | 121 | |
---|
103 | 122 | /** |
---|
.. | .. |
---|
127 | 146 | struct vmw_sw_context *sw_context, |
---|
128 | 147 | SVGAMobId *id, |
---|
129 | 148 | struct vmw_buffer_object **vmw_bo_p); |
---|
130 | | -static int vmw_bo_to_validate_list(struct vmw_sw_context *sw_context, |
---|
131 | | - struct vmw_buffer_object *vbo, |
---|
132 | | - bool validate_as_mob, |
---|
133 | | - uint32_t *p_val_node); |
---|
134 | 149 | /** |
---|
135 | 150 | * vmw_ptr_diff - Compute the offset from a to b in bytes |
---|
136 | 151 | * |
---|
.. | .. |
---|
145 | 160 | } |
---|
146 | 161 | |
---|
147 | 162 | /** |
---|
148 | | - * vmw_resources_unreserve - unreserve resources previously reserved for |
---|
149 | | - * command submission. |
---|
| 163 | + * vmw_execbuf_bindings_commit - Commit modified binding state |
---|
150 | 164 | * |
---|
151 | | - * @sw_context: pointer to the software context |
---|
152 | | - * @backoff: Whether command submission failed. |
---|
| 165 | + * @sw_context: The command submission context |
---|
| 166 | + * @backoff: Whether this is part of the error path and binding state changes |
---|
| 167 | + * should be ignored |
---|
153 | 168 | */ |
---|
154 | | -static void vmw_resources_unreserve(struct vmw_sw_context *sw_context, |
---|
155 | | - bool backoff) |
---|
| 169 | +static void vmw_execbuf_bindings_commit(struct vmw_sw_context *sw_context, |
---|
| 170 | + bool backoff) |
---|
156 | 171 | { |
---|
157 | | - struct vmw_resource_val_node *val; |
---|
158 | | - struct list_head *list = &sw_context->resource_list; |
---|
| 172 | + struct vmw_ctx_validation_info *entry; |
---|
159 | 173 | |
---|
160 | | - if (sw_context->dx_query_mob && !backoff) |
---|
161 | | - vmw_context_bind_dx_query(sw_context->dx_query_ctx, |
---|
162 | | - sw_context->dx_query_mob); |
---|
| 174 | + list_for_each_entry(entry, &sw_context->ctx_list, head) { |
---|
| 175 | + if (!backoff) |
---|
| 176 | + vmw_binding_state_commit(entry->cur, entry->staged); |
---|
163 | 177 | |
---|
164 | | - list_for_each_entry(val, list, head) { |
---|
165 | | - struct vmw_resource *res = val->res; |
---|
166 | | - bool switch_backup = |
---|
167 | | - (backoff) ? false : val->switching_backup; |
---|
168 | | - |
---|
169 | | - /* |
---|
170 | | - * Transfer staged context bindings to the |
---|
171 | | - * persistent context binding tracker. |
---|
172 | | - */ |
---|
173 | | - if (unlikely(val->staged_bindings)) { |
---|
174 | | - if (!backoff) { |
---|
175 | | - vmw_binding_state_commit |
---|
176 | | - (vmw_context_binding_state(val->res), |
---|
177 | | - val->staged_bindings); |
---|
178 | | - } |
---|
179 | | - |
---|
180 | | - if (val->staged_bindings != sw_context->staged_bindings) |
---|
181 | | - vmw_binding_state_free(val->staged_bindings); |
---|
182 | | - else |
---|
183 | | - sw_context->staged_bindings_inuse = false; |
---|
184 | | - val->staged_bindings = NULL; |
---|
185 | | - } |
---|
186 | | - vmw_resource_unreserve(res, switch_backup, val->new_backup, |
---|
187 | | - val->new_backup_offset); |
---|
188 | | - vmw_bo_unreference(&val->new_backup); |
---|
| 178 | + if (entry->staged != sw_context->staged_bindings) |
---|
| 179 | + vmw_binding_state_free(entry->staged); |
---|
| 180 | + else |
---|
| 181 | + sw_context->staged_bindings_inuse = false; |
---|
189 | 182 | } |
---|
| 183 | + |
---|
| 184 | + /* List entries are freed with the validation context */ |
---|
| 185 | + INIT_LIST_HEAD(&sw_context->ctx_list); |
---|
190 | 186 | } |
---|
191 | 187 | |
---|
192 | 188 | /** |
---|
193 | | - * vmw_cmd_ctx_first_setup - Perform the setup needed when a context is |
---|
194 | | - * added to the validate list. |
---|
| 189 | + * vmw_bind_dx_query_mob - Bind the DX query MOB if referenced |
---|
| 190 | + * |
---|
| 191 | + * @sw_context: The command submission context |
---|
| 192 | + */ |
---|
| 193 | +static void vmw_bind_dx_query_mob(struct vmw_sw_context *sw_context) |
---|
| 194 | +{ |
---|
| 195 | + if (sw_context->dx_query_mob) |
---|
| 196 | + vmw_context_bind_dx_query(sw_context->dx_query_ctx, |
---|
| 197 | + sw_context->dx_query_mob); |
---|
| 198 | +} |
---|
| 199 | + |
---|
| 200 | +/** |
---|
| 201 | + * vmw_cmd_ctx_first_setup - Perform the setup needed when a context is added to |
---|
| 202 | + * the validate list. |
---|
195 | 203 | * |
---|
196 | 204 | * @dev_priv: Pointer to the device private: |
---|
197 | | - * @sw_context: The validation context: |
---|
198 | | - * @node: The validation node holding this context. |
---|
| 205 | + * @sw_context: The command submission context |
---|
| 206 | + * @node: The validation node holding the context resource metadata |
---|
199 | 207 | */ |
---|
200 | 208 | static int vmw_cmd_ctx_first_setup(struct vmw_private *dev_priv, |
---|
201 | 209 | struct vmw_sw_context *sw_context, |
---|
202 | | - struct vmw_resource_val_node *node) |
---|
| 210 | + struct vmw_resource *res, |
---|
| 211 | + struct vmw_ctx_validation_info *node) |
---|
203 | 212 | { |
---|
204 | 213 | int ret; |
---|
205 | 214 | |
---|
206 | | - ret = vmw_resource_context_res_add(dev_priv, sw_context, node->res); |
---|
| 215 | + ret = vmw_resource_context_res_add(dev_priv, sw_context, res); |
---|
207 | 216 | if (unlikely(ret != 0)) |
---|
208 | 217 | goto out_err; |
---|
209 | 218 | |
---|
210 | 219 | if (!sw_context->staged_bindings) { |
---|
211 | | - sw_context->staged_bindings = |
---|
212 | | - vmw_binding_state_alloc(dev_priv); |
---|
| 220 | + sw_context->staged_bindings = vmw_binding_state_alloc(dev_priv); |
---|
213 | 221 | if (IS_ERR(sw_context->staged_bindings)) { |
---|
214 | | - DRM_ERROR("Failed to allocate context binding " |
---|
215 | | - "information.\n"); |
---|
216 | 222 | ret = PTR_ERR(sw_context->staged_bindings); |
---|
217 | 223 | sw_context->staged_bindings = NULL; |
---|
218 | 224 | goto out_err; |
---|
.. | .. |
---|
220 | 226 | } |
---|
221 | 227 | |
---|
222 | 228 | if (sw_context->staged_bindings_inuse) { |
---|
223 | | - node->staged_bindings = vmw_binding_state_alloc(dev_priv); |
---|
224 | | - if (IS_ERR(node->staged_bindings)) { |
---|
225 | | - DRM_ERROR("Failed to allocate context binding " |
---|
226 | | - "information.\n"); |
---|
227 | | - ret = PTR_ERR(node->staged_bindings); |
---|
228 | | - node->staged_bindings = NULL; |
---|
| 229 | + node->staged = vmw_binding_state_alloc(dev_priv); |
---|
| 230 | + if (IS_ERR(node->staged)) { |
---|
| 231 | + ret = PTR_ERR(node->staged); |
---|
| 232 | + node->staged = NULL; |
---|
229 | 233 | goto out_err; |
---|
230 | 234 | } |
---|
231 | 235 | } else { |
---|
232 | | - node->staged_bindings = sw_context->staged_bindings; |
---|
| 236 | + node->staged = sw_context->staged_bindings; |
---|
233 | 237 | sw_context->staged_bindings_inuse = true; |
---|
234 | 238 | } |
---|
235 | 239 | |
---|
| 240 | + node->ctx = res; |
---|
| 241 | + node->cur = vmw_context_binding_state(res); |
---|
| 242 | + list_add_tail(&node->head, &sw_context->ctx_list); |
---|
| 243 | + |
---|
236 | 244 | return 0; |
---|
| 245 | + |
---|
237 | 246 | out_err: |
---|
238 | 247 | return ret; |
---|
239 | 248 | } |
---|
240 | 249 | |
---|
241 | 250 | /** |
---|
242 | | - * vmw_resource_val_add - Add a resource to the software context's |
---|
243 | | - * resource list if it's not already on it. |
---|
| 251 | + * vmw_execbuf_res_size - calculate extra size fore the resource validation node |
---|
244 | 252 | * |
---|
245 | | - * @sw_context: Pointer to the software context. |
---|
246 | | - * @res: Pointer to the resource. |
---|
247 | | - * @p_node On successful return points to a valid pointer to a |
---|
248 | | - * struct vmw_resource_val_node, if non-NULL on entry. |
---|
| 253 | + * @dev_priv: Pointer to the device private struct. |
---|
| 254 | + * @res_type: The resource type. |
---|
| 255 | + * |
---|
| 256 | + * Guest-backed contexts and DX contexts require extra size to store execbuf |
---|
| 257 | + * private information in the validation node. Typically the binding manager |
---|
| 258 | + * associated data structures. |
---|
| 259 | + * |
---|
| 260 | + * Returns: The extra size requirement based on resource type. |
---|
249 | 261 | */ |
---|
250 | | -static int vmw_resource_val_add(struct vmw_sw_context *sw_context, |
---|
251 | | - struct vmw_resource *res, |
---|
252 | | - struct vmw_resource_val_node **p_node) |
---|
| 262 | +static unsigned int vmw_execbuf_res_size(struct vmw_private *dev_priv, |
---|
| 263 | + enum vmw_res_type res_type) |
---|
253 | 264 | { |
---|
254 | | - struct vmw_private *dev_priv = res->dev_priv; |
---|
255 | | - struct vmw_resource_val_node *node; |
---|
256 | | - struct drm_hash_item *hash; |
---|
257 | | - int ret; |
---|
258 | | - |
---|
259 | | - if (likely(drm_ht_find_item(&sw_context->res_ht, (unsigned long) res, |
---|
260 | | - &hash) == 0)) { |
---|
261 | | - node = container_of(hash, struct vmw_resource_val_node, hash); |
---|
262 | | - node->first_usage = false; |
---|
263 | | - if (unlikely(p_node != NULL)) |
---|
264 | | - *p_node = node; |
---|
265 | | - return 0; |
---|
266 | | - } |
---|
267 | | - |
---|
268 | | - node = kzalloc(sizeof(*node), GFP_KERNEL); |
---|
269 | | - if (unlikely(!node)) { |
---|
270 | | - DRM_ERROR("Failed to allocate a resource validation " |
---|
271 | | - "entry.\n"); |
---|
272 | | - return -ENOMEM; |
---|
273 | | - } |
---|
274 | | - |
---|
275 | | - node->hash.key = (unsigned long) res; |
---|
276 | | - ret = drm_ht_insert_item(&sw_context->res_ht, &node->hash); |
---|
277 | | - if (unlikely(ret != 0)) { |
---|
278 | | - DRM_ERROR("Failed to initialize a resource validation " |
---|
279 | | - "entry.\n"); |
---|
280 | | - kfree(node); |
---|
281 | | - return ret; |
---|
282 | | - } |
---|
283 | | - node->res = vmw_resource_reference(res); |
---|
284 | | - node->first_usage = true; |
---|
285 | | - if (unlikely(p_node != NULL)) |
---|
286 | | - *p_node = node; |
---|
287 | | - |
---|
288 | | - if (!dev_priv->has_mob) { |
---|
289 | | - list_add_tail(&node->head, &sw_context->resource_list); |
---|
290 | | - return 0; |
---|
291 | | - } |
---|
292 | | - |
---|
293 | | - switch (vmw_res_type(res)) { |
---|
294 | | - case vmw_res_context: |
---|
295 | | - case vmw_res_dx_context: |
---|
296 | | - list_add(&node->head, &sw_context->ctx_resource_list); |
---|
297 | | - ret = vmw_cmd_ctx_first_setup(dev_priv, sw_context, node); |
---|
298 | | - break; |
---|
299 | | - case vmw_res_cotable: |
---|
300 | | - list_add_tail(&node->head, &sw_context->ctx_resource_list); |
---|
301 | | - break; |
---|
302 | | - default: |
---|
303 | | - list_add_tail(&node->head, &sw_context->resource_list); |
---|
304 | | - break; |
---|
305 | | - } |
---|
306 | | - |
---|
307 | | - return ret; |
---|
| 265 | + return (res_type == vmw_res_dx_context || |
---|
| 266 | + (res_type == vmw_res_context && dev_priv->has_mob)) ? |
---|
| 267 | + sizeof(struct vmw_ctx_validation_info) : 0; |
---|
308 | 268 | } |
---|
309 | 269 | |
---|
310 | 270 | /** |
---|
311 | | - * vmw_view_res_val_add - Add a view and the surface it's pointing to |
---|
312 | | - * to the validation list |
---|
| 271 | + * vmw_execbuf_rcache_update - Update a resource-node cache entry |
---|
| 272 | + * |
---|
| 273 | + * @rcache: Pointer to the entry to update. |
---|
| 274 | + * @res: Pointer to the resource. |
---|
| 275 | + * @private: Pointer to the execbuf-private space in the resource validation |
---|
| 276 | + * node. |
---|
| 277 | + */ |
---|
| 278 | +static void vmw_execbuf_rcache_update(struct vmw_res_cache_entry *rcache, |
---|
| 279 | + struct vmw_resource *res, |
---|
| 280 | + void *private) |
---|
| 281 | +{ |
---|
| 282 | + rcache->res = res; |
---|
| 283 | + rcache->private = private; |
---|
| 284 | + rcache->valid = 1; |
---|
| 285 | + rcache->valid_handle = 0; |
---|
| 286 | +} |
---|
| 287 | + |
---|
| 288 | +/** |
---|
| 289 | + * vmw_execbuf_res_noref_val_add - Add a resource described by an unreferenced |
---|
| 290 | + * rcu-protected pointer to the validation list. |
---|
| 291 | + * |
---|
| 292 | + * @sw_context: Pointer to the software context. |
---|
| 293 | + * @res: Unreferenced rcu-protected pointer to the resource. |
---|
| 294 | + * @dirty: Whether to change dirty status. |
---|
| 295 | + * |
---|
| 296 | + * Returns: 0 on success. Negative error code on failure. Typical error codes |
---|
| 297 | + * are %-EINVAL on inconsistency and %-ESRCH if the resource was doomed. |
---|
| 298 | + */ |
---|
| 299 | +static int vmw_execbuf_res_noref_val_add(struct vmw_sw_context *sw_context, |
---|
| 300 | + struct vmw_resource *res, |
---|
| 301 | + u32 dirty) |
---|
| 302 | +{ |
---|
| 303 | + struct vmw_private *dev_priv = res->dev_priv; |
---|
| 304 | + int ret; |
---|
| 305 | + enum vmw_res_type res_type = vmw_res_type(res); |
---|
| 306 | + struct vmw_res_cache_entry *rcache; |
---|
| 307 | + struct vmw_ctx_validation_info *ctx_info; |
---|
| 308 | + bool first_usage; |
---|
| 309 | + unsigned int priv_size; |
---|
| 310 | + |
---|
| 311 | + rcache = &sw_context->res_cache[res_type]; |
---|
| 312 | + if (likely(rcache->valid && rcache->res == res)) { |
---|
| 313 | + if (dirty) |
---|
| 314 | + vmw_validation_res_set_dirty(sw_context->ctx, |
---|
| 315 | + rcache->private, dirty); |
---|
| 316 | + vmw_user_resource_noref_release(); |
---|
| 317 | + return 0; |
---|
| 318 | + } |
---|
| 319 | + |
---|
| 320 | + priv_size = vmw_execbuf_res_size(dev_priv, res_type); |
---|
| 321 | + ret = vmw_validation_add_resource(sw_context->ctx, res, priv_size, |
---|
| 322 | + dirty, (void **)&ctx_info, |
---|
| 323 | + &first_usage); |
---|
| 324 | + vmw_user_resource_noref_release(); |
---|
| 325 | + if (ret) |
---|
| 326 | + return ret; |
---|
| 327 | + |
---|
| 328 | + if (priv_size && first_usage) { |
---|
| 329 | + ret = vmw_cmd_ctx_first_setup(dev_priv, sw_context, res, |
---|
| 330 | + ctx_info); |
---|
| 331 | + if (ret) { |
---|
| 332 | + VMW_DEBUG_USER("Failed first usage context setup.\n"); |
---|
| 333 | + return ret; |
---|
| 334 | + } |
---|
| 335 | + } |
---|
| 336 | + |
---|
| 337 | + vmw_execbuf_rcache_update(rcache, res, ctx_info); |
---|
| 338 | + return 0; |
---|
| 339 | +} |
---|
| 340 | + |
---|
| 341 | +/** |
---|
| 342 | + * vmw_execbuf_res_noctx_val_add - Add a non-context resource to the resource |
---|
| 343 | + * validation list if it's not already on it |
---|
| 344 | + * |
---|
| 345 | + * @sw_context: Pointer to the software context. |
---|
| 346 | + * @res: Pointer to the resource. |
---|
| 347 | + * @dirty: Whether to change dirty status. |
---|
| 348 | + * |
---|
| 349 | + * Returns: Zero on success. Negative error code on failure. |
---|
| 350 | + */ |
---|
| 351 | +static int vmw_execbuf_res_noctx_val_add(struct vmw_sw_context *sw_context, |
---|
| 352 | + struct vmw_resource *res, |
---|
| 353 | + u32 dirty) |
---|
| 354 | +{ |
---|
| 355 | + struct vmw_res_cache_entry *rcache; |
---|
| 356 | + enum vmw_res_type res_type = vmw_res_type(res); |
---|
| 357 | + void *ptr; |
---|
| 358 | + int ret; |
---|
| 359 | + |
---|
| 360 | + rcache = &sw_context->res_cache[res_type]; |
---|
| 361 | + if (likely(rcache->valid && rcache->res == res)) { |
---|
| 362 | + if (dirty) |
---|
| 363 | + vmw_validation_res_set_dirty(sw_context->ctx, |
---|
| 364 | + rcache->private, dirty); |
---|
| 365 | + return 0; |
---|
| 366 | + } |
---|
| 367 | + |
---|
| 368 | + ret = vmw_validation_add_resource(sw_context->ctx, res, 0, dirty, |
---|
| 369 | + &ptr, NULL); |
---|
| 370 | + if (ret) |
---|
| 371 | + return ret; |
---|
| 372 | + |
---|
| 373 | + vmw_execbuf_rcache_update(rcache, res, ptr); |
---|
| 374 | + |
---|
| 375 | + return 0; |
---|
| 376 | +} |
---|
| 377 | + |
---|
| 378 | +/** |
---|
| 379 | + * vmw_view_res_val_add - Add a view and the surface it's pointing to to the |
---|
| 380 | + * validation list |
---|
313 | 381 | * |
---|
314 | 382 | * @sw_context: The software context holding the validation list. |
---|
315 | 383 | * @view: Pointer to the view resource. |
---|
.. | .. |
---|
322 | 390 | int ret; |
---|
323 | 391 | |
---|
324 | 392 | /* |
---|
325 | | - * First add the resource the view is pointing to, otherwise |
---|
326 | | - * it may be swapped out when the view is validated. |
---|
| 393 | + * First add the resource the view is pointing to, otherwise it may be |
---|
| 394 | + * swapped out when the view is validated. |
---|
327 | 395 | */ |
---|
328 | | - ret = vmw_resource_val_add(sw_context, vmw_view_srf(view), NULL); |
---|
| 396 | + ret = vmw_execbuf_res_noctx_val_add(sw_context, vmw_view_srf(view), |
---|
| 397 | + vmw_view_dirtying(view)); |
---|
329 | 398 | if (ret) |
---|
330 | 399 | return ret; |
---|
331 | 400 | |
---|
332 | | - return vmw_resource_val_add(sw_context, view, NULL); |
---|
| 401 | + return vmw_execbuf_res_noctx_val_add(sw_context, view, |
---|
| 402 | + VMW_RES_DIRTY_NONE); |
---|
333 | 403 | } |
---|
334 | 404 | |
---|
335 | 405 | /** |
---|
336 | | - * vmw_view_id_val_add - Look up a view and add it and the surface it's |
---|
337 | | - * pointing to to the validation list. |
---|
| 406 | + * vmw_view_id_val_add - Look up a view and add it and the surface it's pointing |
---|
| 407 | + * to to the validation list. |
---|
338 | 408 | * |
---|
339 | 409 | * @sw_context: The software context holding the validation list. |
---|
340 | 410 | * @view_type: The view type to look up. |
---|
341 | 411 | * @id: view id of the view. |
---|
342 | 412 | * |
---|
343 | | - * The view is represented by a view id and the DX context it's created on, |
---|
344 | | - * or scheduled for creation on. If there is no DX context set, the function |
---|
345 | | - * will return -EINVAL. Otherwise returns 0 on success and -EINVAL on failure. |
---|
| 413 | + * The view is represented by a view id and the DX context it's created on, or |
---|
| 414 | + * scheduled for creation on. If there is no DX context set, the function will |
---|
| 415 | + * return an -EINVAL error pointer. |
---|
| 416 | + * |
---|
| 417 | + * Returns: Unreferenced pointer to the resource on success, negative error |
---|
| 418 | + * pointer on failure. |
---|
346 | 419 | */ |
---|
347 | | -static int vmw_view_id_val_add(struct vmw_sw_context *sw_context, |
---|
348 | | - enum vmw_view_type view_type, u32 id) |
---|
| 420 | +static struct vmw_resource * |
---|
| 421 | +vmw_view_id_val_add(struct vmw_sw_context *sw_context, |
---|
| 422 | + enum vmw_view_type view_type, u32 id) |
---|
349 | 423 | { |
---|
350 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
| 424 | + struct vmw_ctx_validation_info *ctx_node = sw_context->dx_ctx_node; |
---|
351 | 425 | struct vmw_resource *view; |
---|
352 | 426 | int ret; |
---|
353 | 427 | |
---|
354 | | - if (!ctx_node) { |
---|
355 | | - DRM_ERROR("DX Context not set.\n"); |
---|
356 | | - return -EINVAL; |
---|
357 | | - } |
---|
| 428 | + if (!ctx_node) |
---|
| 429 | + return ERR_PTR(-EINVAL); |
---|
358 | 430 | |
---|
359 | 431 | view = vmw_view_lookup(sw_context->man, view_type, id); |
---|
360 | 432 | if (IS_ERR(view)) |
---|
361 | | - return PTR_ERR(view); |
---|
| 433 | + return view; |
---|
362 | 434 | |
---|
363 | 435 | ret = vmw_view_res_val_add(sw_context, view); |
---|
364 | | - vmw_resource_unreference(&view); |
---|
| 436 | + if (ret) |
---|
| 437 | + return ERR_PTR(ret); |
---|
365 | 438 | |
---|
366 | | - return ret; |
---|
| 439 | + return view; |
---|
367 | 440 | } |
---|
368 | 441 | |
---|
369 | 442 | /** |
---|
.. | .. |
---|
374 | 447 | * @sw_context: Pointer to a software context used for this command submission |
---|
375 | 448 | * @ctx: Pointer to the context resource |
---|
376 | 449 | * |
---|
377 | | - * This function puts all resources that were previously bound to @ctx on |
---|
378 | | - * the resource validation list. This is part of the context state reemission |
---|
| 450 | + * This function puts all resources that were previously bound to @ctx on the |
---|
| 451 | + * resource validation list. This is part of the context state reemission |
---|
379 | 452 | */ |
---|
380 | 453 | static int vmw_resource_context_res_add(struct vmw_private *dev_priv, |
---|
381 | 454 | struct vmw_sw_context *sw_context, |
---|
.. | .. |
---|
386 | 459 | int ret = 0; |
---|
387 | 460 | struct vmw_resource *res; |
---|
388 | 461 | u32 i; |
---|
| 462 | + u32 cotable_max = has_sm5_context(ctx->dev_priv) ? |
---|
| 463 | + SVGA_COTABLE_MAX : SVGA_COTABLE_DX10_MAX; |
---|
389 | 464 | |
---|
390 | 465 | /* Add all cotables to the validation list. */ |
---|
391 | | - if (dev_priv->has_dx && vmw_res_type(ctx) == vmw_res_dx_context) { |
---|
392 | | - for (i = 0; i < SVGA_COTABLE_DX10_MAX; ++i) { |
---|
| 466 | + if (has_sm4_context(dev_priv) && |
---|
| 467 | + vmw_res_type(ctx) == vmw_res_dx_context) { |
---|
| 468 | + for (i = 0; i < cotable_max; ++i) { |
---|
393 | 469 | res = vmw_context_cotable(ctx, i); |
---|
394 | 470 | if (IS_ERR(res)) |
---|
395 | 471 | continue; |
---|
396 | 472 | |
---|
397 | | - ret = vmw_resource_val_add(sw_context, res, NULL); |
---|
398 | | - vmw_resource_unreference(&res); |
---|
| 473 | + ret = vmw_execbuf_res_noctx_val_add(sw_context, res, |
---|
| 474 | + VMW_RES_DIRTY_SET); |
---|
399 | 475 | if (unlikely(ret != 0)) |
---|
400 | 476 | return ret; |
---|
401 | 477 | } |
---|
402 | 478 | } |
---|
403 | | - |
---|
404 | 479 | |
---|
405 | 480 | /* Add all resources bound to the context to the validation list */ |
---|
406 | 481 | mutex_lock(&dev_priv->binding_mutex); |
---|
407 | 482 | binding_list = vmw_context_binding_list(ctx); |
---|
408 | 483 | |
---|
409 | 484 | list_for_each_entry(entry, binding_list, ctx_list) { |
---|
410 | | - /* entry->res is not refcounted */ |
---|
411 | | - res = vmw_resource_reference_unless_doomed(entry->res); |
---|
412 | | - if (unlikely(res == NULL)) |
---|
413 | | - continue; |
---|
414 | | - |
---|
415 | 485 | if (vmw_res_type(entry->res) == vmw_res_view) |
---|
416 | 486 | ret = vmw_view_res_val_add(sw_context, entry->res); |
---|
417 | 487 | else |
---|
418 | | - ret = vmw_resource_val_add(sw_context, entry->res, |
---|
419 | | - NULL); |
---|
420 | | - vmw_resource_unreference(&res); |
---|
| 488 | + ret = vmw_execbuf_res_noctx_val_add |
---|
| 489 | + (sw_context, entry->res, |
---|
| 490 | + vmw_binding_dirtying(entry->bt)); |
---|
421 | 491 | if (unlikely(ret != 0)) |
---|
422 | 492 | break; |
---|
423 | 493 | } |
---|
424 | 494 | |
---|
425 | | - if (dev_priv->has_dx && vmw_res_type(ctx) == vmw_res_dx_context) { |
---|
| 495 | + if (has_sm4_context(dev_priv) && |
---|
| 496 | + vmw_res_type(ctx) == vmw_res_dx_context) { |
---|
426 | 497 | struct vmw_buffer_object *dx_query_mob; |
---|
427 | 498 | |
---|
428 | 499 | dx_query_mob = vmw_context_get_dx_query_mob(ctx); |
---|
429 | 500 | if (dx_query_mob) |
---|
430 | | - ret = vmw_bo_to_validate_list(sw_context, |
---|
431 | | - dx_query_mob, |
---|
432 | | - true, NULL); |
---|
| 501 | + ret = vmw_validation_add_bo(sw_context->ctx, |
---|
| 502 | + dx_query_mob, true, false); |
---|
433 | 503 | } |
---|
434 | 504 | |
---|
435 | 505 | mutex_unlock(&dev_priv->binding_mutex); |
---|
.. | .. |
---|
441 | 511 | * |
---|
442 | 512 | * @list: Pointer to head of relocation list. |
---|
443 | 513 | * @res: The resource. |
---|
444 | | - * @offset: Offset into the command buffer currently being parsed where the |
---|
445 | | - * id that needs fixup is located. Granularity is one byte. |
---|
| 514 | + * @offset: Offset into the command buffer currently being parsed where the id |
---|
| 515 | + * that needs fixup is located. Granularity is one byte. |
---|
446 | 516 | * @rel_type: Relocation type. |
---|
447 | 517 | */ |
---|
448 | | -static int vmw_resource_relocation_add(struct list_head *list, |
---|
| 518 | +static int vmw_resource_relocation_add(struct vmw_sw_context *sw_context, |
---|
449 | 519 | const struct vmw_resource *res, |
---|
450 | 520 | unsigned long offset, |
---|
451 | 521 | enum vmw_resource_relocation_type |
---|
.. | .. |
---|
453 | 523 | { |
---|
454 | 524 | struct vmw_resource_relocation *rel; |
---|
455 | 525 | |
---|
456 | | - rel = kmalloc(sizeof(*rel), GFP_KERNEL); |
---|
| 526 | + rel = vmw_validation_mem_alloc(sw_context->ctx, sizeof(*rel)); |
---|
457 | 527 | if (unlikely(!rel)) { |
---|
458 | | - DRM_ERROR("Failed to allocate a resource relocation.\n"); |
---|
| 528 | + VMW_DEBUG_USER("Failed to allocate a resource relocation.\n"); |
---|
459 | 529 | return -ENOMEM; |
---|
460 | 530 | } |
---|
461 | 531 | |
---|
462 | 532 | rel->res = res; |
---|
463 | 533 | rel->offset = offset; |
---|
464 | 534 | rel->rel_type = rel_type; |
---|
465 | | - list_add_tail(&rel->head, list); |
---|
| 535 | + list_add_tail(&rel->head, &sw_context->res_relocations); |
---|
466 | 536 | |
---|
467 | 537 | return 0; |
---|
468 | 538 | } |
---|
.. | .. |
---|
470 | 540 | /** |
---|
471 | 541 | * vmw_resource_relocations_free - Free all relocations on a list |
---|
472 | 542 | * |
---|
473 | | - * @list: Pointer to the head of the relocation list. |
---|
| 543 | + * @list: Pointer to the head of the relocation list |
---|
474 | 544 | */ |
---|
475 | 545 | static void vmw_resource_relocations_free(struct list_head *list) |
---|
476 | 546 | { |
---|
477 | | - struct vmw_resource_relocation *rel, *n; |
---|
478 | | - |
---|
479 | | - list_for_each_entry_safe(rel, n, list, head) { |
---|
480 | | - list_del(&rel->head); |
---|
481 | | - kfree(rel); |
---|
482 | | - } |
---|
| 547 | + /* Memory is validation context memory, so no need to free it */ |
---|
| 548 | + INIT_LIST_HEAD(list); |
---|
483 | 549 | } |
---|
484 | 550 | |
---|
485 | 551 | /** |
---|
486 | 552 | * vmw_resource_relocations_apply - Apply all relocations on a list |
---|
487 | 553 | * |
---|
488 | | - * @cb: Pointer to the start of the command buffer bein patch. This need |
---|
489 | | - * not be the same buffer as the one being parsed when the relocation |
---|
490 | | - * list was built, but the contents must be the same modulo the |
---|
491 | | - * resource ids. |
---|
| 554 | + * @cb: Pointer to the start of the command buffer bein patch. This need not be |
---|
| 555 | + * the same buffer as the one being parsed when the relocation list was built, |
---|
| 556 | + * but the contents must be the same modulo the resource ids. |
---|
492 | 557 | * @list: Pointer to the head of the relocation list. |
---|
493 | 558 | */ |
---|
494 | 559 | static void vmw_resource_relocations_apply(uint32_t *cb, |
---|
.. | .. |
---|
532 | 597 | } |
---|
533 | 598 | |
---|
534 | 599 | /** |
---|
535 | | - * vmw_bo_to_validate_list - add a bo to a validate list |
---|
536 | | - * |
---|
537 | | - * @sw_context: The software context used for this command submission batch. |
---|
538 | | - * @bo: The buffer object to add. |
---|
539 | | - * @validate_as_mob: Validate this buffer as a MOB. |
---|
540 | | - * @p_val_node: If non-NULL Will be updated with the validate node number |
---|
541 | | - * on return. |
---|
542 | | - * |
---|
543 | | - * Returns -EINVAL if the limit of number of buffer objects per command |
---|
544 | | - * submission is reached. |
---|
545 | | - */ |
---|
546 | | -static int vmw_bo_to_validate_list(struct vmw_sw_context *sw_context, |
---|
547 | | - struct vmw_buffer_object *vbo, |
---|
548 | | - bool validate_as_mob, |
---|
549 | | - uint32_t *p_val_node) |
---|
550 | | -{ |
---|
551 | | - uint32_t val_node; |
---|
552 | | - struct vmw_validate_buffer *vval_buf; |
---|
553 | | - struct ttm_validate_buffer *val_buf; |
---|
554 | | - struct drm_hash_item *hash; |
---|
555 | | - int ret; |
---|
556 | | - |
---|
557 | | - if (likely(drm_ht_find_item(&sw_context->res_ht, (unsigned long) vbo, |
---|
558 | | - &hash) == 0)) { |
---|
559 | | - vval_buf = container_of(hash, struct vmw_validate_buffer, |
---|
560 | | - hash); |
---|
561 | | - if (unlikely(vval_buf->validate_as_mob != validate_as_mob)) { |
---|
562 | | - DRM_ERROR("Inconsistent buffer usage.\n"); |
---|
563 | | - return -EINVAL; |
---|
564 | | - } |
---|
565 | | - val_buf = &vval_buf->base; |
---|
566 | | - val_node = vval_buf - sw_context->val_bufs; |
---|
567 | | - } else { |
---|
568 | | - val_node = sw_context->cur_val_buf; |
---|
569 | | - if (unlikely(val_node >= VMWGFX_MAX_VALIDATIONS)) { |
---|
570 | | - DRM_ERROR("Max number of DMA buffers per submission " |
---|
571 | | - "exceeded.\n"); |
---|
572 | | - return -EINVAL; |
---|
573 | | - } |
---|
574 | | - vval_buf = &sw_context->val_bufs[val_node]; |
---|
575 | | - vval_buf->hash.key = (unsigned long) vbo; |
---|
576 | | - ret = drm_ht_insert_item(&sw_context->res_ht, &vval_buf->hash); |
---|
577 | | - if (unlikely(ret != 0)) { |
---|
578 | | - DRM_ERROR("Failed to initialize a buffer validation " |
---|
579 | | - "entry.\n"); |
---|
580 | | - return ret; |
---|
581 | | - } |
---|
582 | | - ++sw_context->cur_val_buf; |
---|
583 | | - val_buf = &vval_buf->base; |
---|
584 | | - val_buf->bo = ttm_bo_reference(&vbo->base); |
---|
585 | | - val_buf->shared = false; |
---|
586 | | - list_add_tail(&val_buf->head, &sw_context->validate_nodes); |
---|
587 | | - vval_buf->validate_as_mob = validate_as_mob; |
---|
588 | | - } |
---|
589 | | - |
---|
590 | | - if (p_val_node) |
---|
591 | | - *p_val_node = val_node; |
---|
592 | | - |
---|
593 | | - return 0; |
---|
594 | | -} |
---|
595 | | - |
---|
596 | | -/** |
---|
597 | | - * vmw_resources_reserve - Reserve all resources on the sw_context's |
---|
598 | | - * resource list. |
---|
| 600 | + * vmw_resources_reserve - Reserve all resources on the sw_context's resource |
---|
| 601 | + * list. |
---|
599 | 602 | * |
---|
600 | 603 | * @sw_context: Pointer to the software context. |
---|
601 | 604 | * |
---|
602 | | - * Note that since vmware's command submission currently is protected by |
---|
603 | | - * the cmdbuf mutex, no fancy deadlock avoidance is required for resources, |
---|
604 | | - * since only a single thread at once will attempt this. |
---|
| 605 | + * Note that since vmware's command submission currently is protected by the |
---|
| 606 | + * cmdbuf mutex, no fancy deadlock avoidance is required for resources, since |
---|
| 607 | + * only a single thread at once will attempt this. |
---|
605 | 608 | */ |
---|
606 | 609 | static int vmw_resources_reserve(struct vmw_sw_context *sw_context) |
---|
607 | 610 | { |
---|
608 | | - struct vmw_resource_val_node *val; |
---|
609 | | - int ret = 0; |
---|
| 611 | + int ret; |
---|
610 | 612 | |
---|
611 | | - list_for_each_entry(val, &sw_context->resource_list, head) { |
---|
612 | | - struct vmw_resource *res = val->res; |
---|
613 | | - |
---|
614 | | - ret = vmw_resource_reserve(res, true, val->no_buffer_needed); |
---|
615 | | - if (unlikely(ret != 0)) |
---|
616 | | - return ret; |
---|
617 | | - |
---|
618 | | - if (res->backup) { |
---|
619 | | - struct vmw_buffer_object *vbo = res->backup; |
---|
620 | | - |
---|
621 | | - ret = vmw_bo_to_validate_list |
---|
622 | | - (sw_context, vbo, |
---|
623 | | - vmw_resource_needs_backup(res), NULL); |
---|
624 | | - |
---|
625 | | - if (unlikely(ret != 0)) |
---|
626 | | - return ret; |
---|
627 | | - } |
---|
628 | | - } |
---|
| 613 | + ret = vmw_validation_res_reserve(sw_context->ctx, true); |
---|
| 614 | + if (ret) |
---|
| 615 | + return ret; |
---|
629 | 616 | |
---|
630 | 617 | if (sw_context->dx_query_mob) { |
---|
631 | 618 | struct vmw_buffer_object *expected_dx_query_mob; |
---|
.. | .. |
---|
642 | 629 | } |
---|
643 | 630 | |
---|
644 | 631 | /** |
---|
645 | | - * vmw_resources_validate - Validate all resources on the sw_context's |
---|
646 | | - * resource list. |
---|
647 | | - * |
---|
648 | | - * @sw_context: Pointer to the software context. |
---|
649 | | - * |
---|
650 | | - * Before this function is called, all resource backup buffers must have |
---|
651 | | - * been validated. |
---|
652 | | - */ |
---|
653 | | -static int vmw_resources_validate(struct vmw_sw_context *sw_context) |
---|
654 | | -{ |
---|
655 | | - struct vmw_resource_val_node *val; |
---|
656 | | - int ret; |
---|
657 | | - |
---|
658 | | - list_for_each_entry(val, &sw_context->resource_list, head) { |
---|
659 | | - struct vmw_resource *res = val->res; |
---|
660 | | - struct vmw_buffer_object *backup = res->backup; |
---|
661 | | - |
---|
662 | | - ret = vmw_resource_validate(res); |
---|
663 | | - if (unlikely(ret != 0)) { |
---|
664 | | - if (ret != -ERESTARTSYS) |
---|
665 | | - DRM_ERROR("Failed to validate resource.\n"); |
---|
666 | | - return ret; |
---|
667 | | - } |
---|
668 | | - |
---|
669 | | - /* Check if the resource switched backup buffer */ |
---|
670 | | - if (backup && res->backup && (backup != res->backup)) { |
---|
671 | | - struct vmw_buffer_object *vbo = res->backup; |
---|
672 | | - |
---|
673 | | - ret = vmw_bo_to_validate_list |
---|
674 | | - (sw_context, vbo, |
---|
675 | | - vmw_resource_needs_backup(res), NULL); |
---|
676 | | - if (ret) { |
---|
677 | | - ttm_bo_unreserve(&vbo->base); |
---|
678 | | - return ret; |
---|
679 | | - } |
---|
680 | | - } |
---|
681 | | - } |
---|
682 | | - return 0; |
---|
683 | | -} |
---|
684 | | - |
---|
685 | | -/** |
---|
686 | | - * vmw_cmd_res_reloc_add - Add a resource to a software context's |
---|
687 | | - * relocation- and validation lists. |
---|
688 | | - * |
---|
689 | | - * @dev_priv: Pointer to a struct vmw_private identifying the device. |
---|
690 | | - * @sw_context: Pointer to the software context. |
---|
691 | | - * @id_loc: Pointer to where the id that needs translation is located. |
---|
692 | | - * @res: Valid pointer to a struct vmw_resource. |
---|
693 | | - * @p_val: If non null, a pointer to the struct vmw_resource_validate_node |
---|
694 | | - * used for this resource is returned here. |
---|
695 | | - */ |
---|
696 | | -static int vmw_cmd_res_reloc_add(struct vmw_private *dev_priv, |
---|
697 | | - struct vmw_sw_context *sw_context, |
---|
698 | | - uint32_t *id_loc, |
---|
699 | | - struct vmw_resource *res, |
---|
700 | | - struct vmw_resource_val_node **p_val) |
---|
701 | | -{ |
---|
702 | | - int ret; |
---|
703 | | - struct vmw_resource_val_node *node; |
---|
704 | | - |
---|
705 | | - *p_val = NULL; |
---|
706 | | - ret = vmw_resource_relocation_add(&sw_context->res_relocations, |
---|
707 | | - res, |
---|
708 | | - vmw_ptr_diff(sw_context->buf_start, |
---|
709 | | - id_loc), |
---|
710 | | - vmw_res_rel_normal); |
---|
711 | | - if (unlikely(ret != 0)) |
---|
712 | | - return ret; |
---|
713 | | - |
---|
714 | | - ret = vmw_resource_val_add(sw_context, res, &node); |
---|
715 | | - if (unlikely(ret != 0)) |
---|
716 | | - return ret; |
---|
717 | | - |
---|
718 | | - if (p_val) |
---|
719 | | - *p_val = node; |
---|
720 | | - |
---|
721 | | - return 0; |
---|
722 | | -} |
---|
723 | | - |
---|
724 | | - |
---|
725 | | -/** |
---|
726 | | - * vmw_cmd_res_check - Check that a resource is present and if so, put it |
---|
727 | | - * on the resource validate list unless it's already there. |
---|
| 632 | + * vmw_cmd_res_check - Check that a resource is present and if so, put it on the |
---|
| 633 | + * resource validate list unless it's already there. |
---|
728 | 634 | * |
---|
729 | 635 | * @dev_priv: Pointer to a device private structure. |
---|
730 | 636 | * @sw_context: Pointer to the software context. |
---|
731 | 637 | * @res_type: Resource type. |
---|
| 638 | + * @dirty: Whether to change dirty status. |
---|
732 | 639 | * @converter: User-space visisble type specific information. |
---|
733 | | - * @id_loc: Pointer to the location in the command buffer currently being |
---|
734 | | - * parsed from where the user-space resource id handle is located. |
---|
735 | | - * @p_val: Pointer to pointer to resource validalidation node. Populated |
---|
736 | | - * on exit. |
---|
| 640 | + * @id_loc: Pointer to the location in the command buffer currently being parsed |
---|
| 641 | + * from where the user-space resource id handle is located. |
---|
| 642 | + * @p_val: Pointer to pointer to resource validalidation node. Populated on |
---|
| 643 | + * exit. |
---|
737 | 644 | */ |
---|
738 | 645 | static int |
---|
739 | 646 | vmw_cmd_res_check(struct vmw_private *dev_priv, |
---|
740 | 647 | struct vmw_sw_context *sw_context, |
---|
741 | 648 | enum vmw_res_type res_type, |
---|
| 649 | + u32 dirty, |
---|
742 | 650 | const struct vmw_user_resource_conv *converter, |
---|
743 | 651 | uint32_t *id_loc, |
---|
744 | | - struct vmw_resource_val_node **p_val) |
---|
| 652 | + struct vmw_resource **p_res) |
---|
745 | 653 | { |
---|
746 | | - struct vmw_res_cache_entry *rcache = |
---|
747 | | - &sw_context->res_cache[res_type]; |
---|
| 654 | + struct vmw_res_cache_entry *rcache = &sw_context->res_cache[res_type]; |
---|
748 | 655 | struct vmw_resource *res; |
---|
749 | | - struct vmw_resource_val_node *node; |
---|
750 | 656 | int ret; |
---|
751 | 657 | |
---|
| 658 | + if (p_res) |
---|
| 659 | + *p_res = NULL; |
---|
| 660 | + |
---|
752 | 661 | if (*id_loc == SVGA3D_INVALID_ID) { |
---|
753 | | - if (p_val) |
---|
754 | | - *p_val = NULL; |
---|
755 | 662 | if (res_type == vmw_res_context) { |
---|
756 | | - DRM_ERROR("Illegal context invalid id.\n"); |
---|
| 663 | + VMW_DEBUG_USER("Illegal context invalid id.\n"); |
---|
757 | 664 | return -EINVAL; |
---|
758 | 665 | } |
---|
759 | 666 | return 0; |
---|
760 | 667 | } |
---|
761 | 668 | |
---|
762 | | - /* |
---|
763 | | - * Fastpath in case of repeated commands referencing the same |
---|
764 | | - * resource |
---|
765 | | - */ |
---|
| 669 | + if (likely(rcache->valid_handle && *id_loc == rcache->handle)) { |
---|
| 670 | + res = rcache->res; |
---|
| 671 | + if (dirty) |
---|
| 672 | + vmw_validation_res_set_dirty(sw_context->ctx, |
---|
| 673 | + rcache->private, dirty); |
---|
| 674 | + } else { |
---|
| 675 | + unsigned int size = vmw_execbuf_res_size(dev_priv, res_type); |
---|
766 | 676 | |
---|
767 | | - if (likely(rcache->valid && *id_loc == rcache->handle)) { |
---|
768 | | - const struct vmw_resource *res = rcache->res; |
---|
| 677 | + ret = vmw_validation_preload_res(sw_context->ctx, size); |
---|
| 678 | + if (ret) |
---|
| 679 | + return ret; |
---|
769 | 680 | |
---|
770 | | - rcache->node->first_usage = false; |
---|
771 | | - if (p_val) |
---|
772 | | - *p_val = rcache->node; |
---|
| 681 | + res = vmw_user_resource_noref_lookup_handle |
---|
| 682 | + (dev_priv, sw_context->fp->tfile, *id_loc, converter); |
---|
| 683 | + if (IS_ERR(res)) { |
---|
| 684 | + VMW_DEBUG_USER("Could not find/use resource 0x%08x.\n", |
---|
| 685 | + (unsigned int) *id_loc); |
---|
| 686 | + return PTR_ERR(res); |
---|
| 687 | + } |
---|
773 | 688 | |
---|
774 | | - return vmw_resource_relocation_add |
---|
775 | | - (&sw_context->res_relocations, res, |
---|
776 | | - vmw_ptr_diff(sw_context->buf_start, id_loc), |
---|
777 | | - vmw_res_rel_normal); |
---|
| 689 | + ret = vmw_execbuf_res_noref_val_add(sw_context, res, dirty); |
---|
| 690 | + if (unlikely(ret != 0)) |
---|
| 691 | + return ret; |
---|
| 692 | + |
---|
| 693 | + if (rcache->valid && rcache->res == res) { |
---|
| 694 | + rcache->valid_handle = true; |
---|
| 695 | + rcache->handle = *id_loc; |
---|
| 696 | + } |
---|
778 | 697 | } |
---|
779 | 698 | |
---|
780 | | - ret = vmw_user_resource_lookup_handle(dev_priv, |
---|
781 | | - sw_context->fp->tfile, |
---|
782 | | - *id_loc, |
---|
783 | | - converter, |
---|
784 | | - &res); |
---|
785 | | - if (unlikely(ret != 0)) { |
---|
786 | | - DRM_ERROR("Could not find or use resource 0x%08x.\n", |
---|
787 | | - (unsigned) *id_loc); |
---|
788 | | - dump_stack(); |
---|
789 | | - return ret; |
---|
790 | | - } |
---|
| 699 | + ret = vmw_resource_relocation_add(sw_context, res, |
---|
| 700 | + vmw_ptr_diff(sw_context->buf_start, |
---|
| 701 | + id_loc), |
---|
| 702 | + vmw_res_rel_normal); |
---|
| 703 | + if (p_res) |
---|
| 704 | + *p_res = res; |
---|
791 | 705 | |
---|
792 | | - rcache->valid = true; |
---|
793 | | - rcache->res = res; |
---|
794 | | - rcache->handle = *id_loc; |
---|
795 | | - |
---|
796 | | - ret = vmw_cmd_res_reloc_add(dev_priv, sw_context, id_loc, |
---|
797 | | - res, &node); |
---|
798 | | - if (unlikely(ret != 0)) |
---|
799 | | - goto out_no_reloc; |
---|
800 | | - |
---|
801 | | - rcache->node = node; |
---|
802 | | - if (p_val) |
---|
803 | | - *p_val = node; |
---|
804 | | - vmw_resource_unreference(&res); |
---|
805 | 706 | return 0; |
---|
806 | | - |
---|
807 | | -out_no_reloc: |
---|
808 | | - BUG_ON(sw_context->error_resource != NULL); |
---|
809 | | - sw_context->error_resource = res; |
---|
810 | | - |
---|
811 | | - return ret; |
---|
812 | 707 | } |
---|
813 | 708 | |
---|
814 | 709 | /** |
---|
.. | .. |
---|
822 | 717 | { |
---|
823 | 718 | struct vmw_private *dev_priv = ctx_res->dev_priv; |
---|
824 | 719 | struct vmw_buffer_object *dx_query_mob; |
---|
825 | | - struct { |
---|
826 | | - SVGA3dCmdHeader header; |
---|
827 | | - SVGA3dCmdDXBindAllQuery body; |
---|
828 | | - } *cmd; |
---|
829 | | - |
---|
| 720 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXBindAllQuery); |
---|
830 | 721 | |
---|
831 | 722 | dx_query_mob = vmw_context_get_dx_query_mob(ctx_res); |
---|
832 | 723 | |
---|
833 | 724 | if (!dx_query_mob || dx_query_mob->dx_query_ctx) |
---|
834 | 725 | return 0; |
---|
835 | 726 | |
---|
836 | | - cmd = vmw_fifo_reserve_dx(dev_priv, sizeof(*cmd), ctx_res->id); |
---|
837 | | - |
---|
838 | | - if (cmd == NULL) { |
---|
839 | | - DRM_ERROR("Failed to rebind queries.\n"); |
---|
| 727 | + cmd = VMW_FIFO_RESERVE_DX(dev_priv, sizeof(*cmd), ctx_res->id); |
---|
| 728 | + if (cmd == NULL) |
---|
840 | 729 | return -ENOMEM; |
---|
841 | | - } |
---|
842 | 730 | |
---|
843 | 731 | cmd->header.id = SVGA_3D_CMD_DX_BIND_ALL_QUERY; |
---|
844 | 732 | cmd->header.size = sizeof(cmd->body); |
---|
.. | .. |
---|
852 | 740 | } |
---|
853 | 741 | |
---|
854 | 742 | /** |
---|
855 | | - * vmw_rebind_contexts - Rebind all resources previously bound to |
---|
856 | | - * referenced contexts. |
---|
| 743 | + * vmw_rebind_contexts - Rebind all resources previously bound to referenced |
---|
| 744 | + * contexts. |
---|
857 | 745 | * |
---|
858 | 746 | * @sw_context: Pointer to the software context. |
---|
859 | 747 | * |
---|
.. | .. |
---|
861 | 749 | */ |
---|
862 | 750 | static int vmw_rebind_contexts(struct vmw_sw_context *sw_context) |
---|
863 | 751 | { |
---|
864 | | - struct vmw_resource_val_node *val; |
---|
| 752 | + struct vmw_ctx_validation_info *val; |
---|
865 | 753 | int ret; |
---|
866 | 754 | |
---|
867 | | - list_for_each_entry(val, &sw_context->resource_list, head) { |
---|
868 | | - if (unlikely(!val->staged_bindings)) |
---|
869 | | - break; |
---|
870 | | - |
---|
871 | | - ret = vmw_binding_rebind_all |
---|
872 | | - (vmw_context_binding_state(val->res)); |
---|
| 755 | + list_for_each_entry(val, &sw_context->ctx_list, head) { |
---|
| 756 | + ret = vmw_binding_rebind_all(val->cur); |
---|
873 | 757 | if (unlikely(ret != 0)) { |
---|
874 | 758 | if (ret != -ERESTARTSYS) |
---|
875 | | - DRM_ERROR("Failed to rebind context.\n"); |
---|
| 759 | + VMW_DEBUG_USER("Failed to rebind context.\n"); |
---|
876 | 760 | return ret; |
---|
877 | 761 | } |
---|
878 | 762 | |
---|
879 | | - ret = vmw_rebind_all_dx_query(val->res); |
---|
880 | | - if (ret != 0) |
---|
| 763 | + ret = vmw_rebind_all_dx_query(val->ctx); |
---|
| 764 | + if (ret != 0) { |
---|
| 765 | + VMW_DEBUG_USER("Failed to rebind queries.\n"); |
---|
881 | 766 | return ret; |
---|
| 767 | + } |
---|
882 | 768 | } |
---|
883 | 769 | |
---|
884 | 770 | return 0; |
---|
885 | 771 | } |
---|
886 | 772 | |
---|
887 | 773 | /** |
---|
888 | | - * vmw_view_bindings_add - Add an array of view bindings to a context |
---|
889 | | - * binding state tracker. |
---|
| 774 | + * vmw_view_bindings_add - Add an array of view bindings to a context binding |
---|
| 775 | + * state tracker. |
---|
890 | 776 | * |
---|
891 | 777 | * @sw_context: The execbuf state used for this command. |
---|
892 | 778 | * @view_type: View type for the bindings. |
---|
.. | .. |
---|
903 | 789 | uint32 view_ids[], u32 num_views, |
---|
904 | 790 | u32 first_slot) |
---|
905 | 791 | { |
---|
906 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
907 | | - struct vmw_cmdbuf_res_manager *man; |
---|
| 792 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
908 | 793 | u32 i; |
---|
909 | | - int ret; |
---|
910 | 794 | |
---|
911 | | - if (!ctx_node) { |
---|
912 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 795 | + if (!ctx_node) |
---|
913 | 796 | return -EINVAL; |
---|
914 | | - } |
---|
915 | 797 | |
---|
916 | | - man = sw_context->man; |
---|
917 | 798 | for (i = 0; i < num_views; ++i) { |
---|
918 | 799 | struct vmw_ctx_bindinfo_view binding; |
---|
919 | 800 | struct vmw_resource *view = NULL; |
---|
920 | 801 | |
---|
921 | 802 | if (view_ids[i] != SVGA3D_INVALID_ID) { |
---|
922 | | - view = vmw_view_lookup(man, view_type, view_ids[i]); |
---|
| 803 | + view = vmw_view_id_val_add(sw_context, view_type, |
---|
| 804 | + view_ids[i]); |
---|
923 | 805 | if (IS_ERR(view)) { |
---|
924 | | - DRM_ERROR("View not found.\n"); |
---|
| 806 | + VMW_DEBUG_USER("View not found.\n"); |
---|
925 | 807 | return PTR_ERR(view); |
---|
926 | 808 | } |
---|
927 | | - |
---|
928 | | - ret = vmw_view_res_val_add(sw_context, view); |
---|
929 | | - if (ret) { |
---|
930 | | - DRM_ERROR("Could not add view to " |
---|
931 | | - "validation list.\n"); |
---|
932 | | - vmw_resource_unreference(&view); |
---|
933 | | - return ret; |
---|
934 | | - } |
---|
935 | 809 | } |
---|
936 | | - binding.bi.ctx = ctx_node->res; |
---|
| 810 | + binding.bi.ctx = ctx_node->ctx; |
---|
937 | 811 | binding.bi.res = view; |
---|
938 | 812 | binding.bi.bt = binding_type; |
---|
939 | 813 | binding.shader_slot = shader_slot; |
---|
940 | 814 | binding.slot = first_slot + i; |
---|
941 | | - vmw_binding_add(ctx_node->staged_bindings, &binding.bi, |
---|
| 815 | + vmw_binding_add(ctx_node->staged, &binding.bi, |
---|
942 | 816 | shader_slot, binding.slot); |
---|
943 | | - if (view) |
---|
944 | | - vmw_resource_unreference(&view); |
---|
945 | 817 | } |
---|
946 | 818 | |
---|
947 | 819 | return 0; |
---|
.. | .. |
---|
961 | 833 | struct vmw_sw_context *sw_context, |
---|
962 | 834 | SVGA3dCmdHeader *header) |
---|
963 | 835 | { |
---|
964 | | - struct vmw_cid_cmd { |
---|
965 | | - SVGA3dCmdHeader header; |
---|
966 | | - uint32_t cid; |
---|
967 | | - } *cmd; |
---|
| 836 | + VMW_DECLARE_CMD_VAR(*cmd, uint32_t) = |
---|
| 837 | + container_of(header, typeof(*cmd), header); |
---|
968 | 838 | |
---|
969 | | - cmd = container_of(header, struct vmw_cid_cmd, header); |
---|
970 | 839 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, |
---|
971 | | - user_context_converter, &cmd->cid, NULL); |
---|
| 840 | + VMW_RES_DIRTY_SET, user_context_converter, |
---|
| 841 | + &cmd->body, NULL); |
---|
| 842 | +} |
---|
| 843 | + |
---|
| 844 | +/** |
---|
| 845 | + * vmw_execbuf_info_from_res - Get the private validation metadata for a |
---|
| 846 | + * recently validated resource |
---|
| 847 | + * |
---|
| 848 | + * @sw_context: Pointer to the command submission context |
---|
| 849 | + * @res: The resource |
---|
| 850 | + * |
---|
| 851 | + * The resource pointed to by @res needs to be present in the command submission |
---|
| 852 | + * context's resource cache and hence the last resource of that type to be |
---|
| 853 | + * processed by the validation code. |
---|
| 854 | + * |
---|
| 855 | + * Return: a pointer to the private metadata of the resource, or NULL if it |
---|
| 856 | + * wasn't found |
---|
| 857 | + */ |
---|
| 858 | +static struct vmw_ctx_validation_info * |
---|
| 859 | +vmw_execbuf_info_from_res(struct vmw_sw_context *sw_context, |
---|
| 860 | + struct vmw_resource *res) |
---|
| 861 | +{ |
---|
| 862 | + struct vmw_res_cache_entry *rcache = |
---|
| 863 | + &sw_context->res_cache[vmw_res_type(res)]; |
---|
| 864 | + |
---|
| 865 | + if (rcache->valid && rcache->res == res) |
---|
| 866 | + return rcache->private; |
---|
| 867 | + |
---|
| 868 | + WARN_ON_ONCE(true); |
---|
| 869 | + return NULL; |
---|
972 | 870 | } |
---|
973 | 871 | |
---|
974 | 872 | static int vmw_cmd_set_render_target_check(struct vmw_private *dev_priv, |
---|
975 | 873 | struct vmw_sw_context *sw_context, |
---|
976 | 874 | SVGA3dCmdHeader *header) |
---|
977 | 875 | { |
---|
978 | | - struct vmw_sid_cmd { |
---|
979 | | - SVGA3dCmdHeader header; |
---|
980 | | - SVGA3dCmdSetRenderTarget body; |
---|
981 | | - } *cmd; |
---|
982 | | - struct vmw_resource_val_node *ctx_node; |
---|
983 | | - struct vmw_resource_val_node *res_node; |
---|
| 876 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdSetRenderTarget); |
---|
| 877 | + struct vmw_resource *ctx; |
---|
| 878 | + struct vmw_resource *res; |
---|
984 | 879 | int ret; |
---|
985 | 880 | |
---|
986 | | - cmd = container_of(header, struct vmw_sid_cmd, header); |
---|
| 881 | + cmd = container_of(header, typeof(*cmd), header); |
---|
987 | 882 | |
---|
988 | 883 | if (cmd->body.type >= SVGA3D_RT_MAX) { |
---|
989 | | - DRM_ERROR("Illegal render target type %u.\n", |
---|
990 | | - (unsigned) cmd->body.type); |
---|
| 884 | + VMW_DEBUG_USER("Illegal render target type %u.\n", |
---|
| 885 | + (unsigned int) cmd->body.type); |
---|
991 | 886 | return -EINVAL; |
---|
992 | 887 | } |
---|
993 | 888 | |
---|
994 | 889 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, |
---|
995 | | - user_context_converter, &cmd->body.cid, |
---|
996 | | - &ctx_node); |
---|
| 890 | + VMW_RES_DIRTY_SET, user_context_converter, |
---|
| 891 | + &cmd->body.cid, &ctx); |
---|
997 | 892 | if (unlikely(ret != 0)) |
---|
998 | 893 | return ret; |
---|
999 | 894 | |
---|
1000 | 895 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1001 | | - user_surface_converter, |
---|
1002 | | - &cmd->body.target.sid, &res_node); |
---|
1003 | | - if (unlikely(ret != 0)) |
---|
| 896 | + VMW_RES_DIRTY_SET, user_surface_converter, |
---|
| 897 | + &cmd->body.target.sid, &res); |
---|
| 898 | + if (unlikely(ret)) |
---|
1004 | 899 | return ret; |
---|
1005 | 900 | |
---|
1006 | 901 | if (dev_priv->has_mob) { |
---|
1007 | 902 | struct vmw_ctx_bindinfo_view binding; |
---|
| 903 | + struct vmw_ctx_validation_info *node; |
---|
1008 | 904 | |
---|
1009 | | - binding.bi.ctx = ctx_node->res; |
---|
1010 | | - binding.bi.res = res_node ? res_node->res : NULL; |
---|
| 905 | + node = vmw_execbuf_info_from_res(sw_context, ctx); |
---|
| 906 | + if (!node) |
---|
| 907 | + return -EINVAL; |
---|
| 908 | + |
---|
| 909 | + binding.bi.ctx = ctx; |
---|
| 910 | + binding.bi.res = res; |
---|
1011 | 911 | binding.bi.bt = vmw_ctx_binding_rt; |
---|
1012 | 912 | binding.slot = cmd->body.type; |
---|
1013 | | - vmw_binding_add(ctx_node->staged_bindings, |
---|
1014 | | - &binding.bi, 0, binding.slot); |
---|
| 913 | + vmw_binding_add(node->staged, &binding.bi, 0, binding.slot); |
---|
1015 | 914 | } |
---|
1016 | 915 | |
---|
1017 | 916 | return 0; |
---|
.. | .. |
---|
1021 | 920 | struct vmw_sw_context *sw_context, |
---|
1022 | 921 | SVGA3dCmdHeader *header) |
---|
1023 | 922 | { |
---|
1024 | | - struct vmw_sid_cmd { |
---|
1025 | | - SVGA3dCmdHeader header; |
---|
1026 | | - SVGA3dCmdSurfaceCopy body; |
---|
1027 | | - } *cmd; |
---|
| 923 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdSurfaceCopy); |
---|
1028 | 924 | int ret; |
---|
1029 | 925 | |
---|
1030 | | - cmd = container_of(header, struct vmw_sid_cmd, header); |
---|
| 926 | + cmd = container_of(header, typeof(*cmd), header); |
---|
1031 | 927 | |
---|
1032 | 928 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1033 | | - user_surface_converter, |
---|
| 929 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
1034 | 930 | &cmd->body.src.sid, NULL); |
---|
1035 | 931 | if (ret) |
---|
1036 | 932 | return ret; |
---|
1037 | 933 | |
---|
1038 | 934 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1039 | | - user_surface_converter, |
---|
| 935 | + VMW_RES_DIRTY_SET, user_surface_converter, |
---|
1040 | 936 | &cmd->body.dest.sid, NULL); |
---|
1041 | 937 | } |
---|
1042 | 938 | |
---|
1043 | 939 | static int vmw_cmd_buffer_copy_check(struct vmw_private *dev_priv, |
---|
1044 | | - struct vmw_sw_context *sw_context, |
---|
1045 | | - SVGA3dCmdHeader *header) |
---|
| 940 | + struct vmw_sw_context *sw_context, |
---|
| 941 | + SVGA3dCmdHeader *header) |
---|
1046 | 942 | { |
---|
1047 | | - struct { |
---|
1048 | | - SVGA3dCmdHeader header; |
---|
1049 | | - SVGA3dCmdDXBufferCopy body; |
---|
1050 | | - } *cmd; |
---|
| 943 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXBufferCopy); |
---|
1051 | 944 | int ret; |
---|
1052 | 945 | |
---|
1053 | 946 | cmd = container_of(header, typeof(*cmd), header); |
---|
1054 | 947 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1055 | | - user_surface_converter, |
---|
| 948 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
1056 | 949 | &cmd->body.src, NULL); |
---|
1057 | 950 | if (ret != 0) |
---|
1058 | 951 | return ret; |
---|
1059 | 952 | |
---|
1060 | 953 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1061 | | - user_surface_converter, |
---|
| 954 | + VMW_RES_DIRTY_SET, user_surface_converter, |
---|
1062 | 955 | &cmd->body.dest, NULL); |
---|
1063 | 956 | } |
---|
1064 | 957 | |
---|
.. | .. |
---|
1066 | 959 | struct vmw_sw_context *sw_context, |
---|
1067 | 960 | SVGA3dCmdHeader *header) |
---|
1068 | 961 | { |
---|
1069 | | - struct { |
---|
1070 | | - SVGA3dCmdHeader header; |
---|
1071 | | - SVGA3dCmdDXPredCopyRegion body; |
---|
1072 | | - } *cmd; |
---|
| 962 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXPredCopyRegion); |
---|
1073 | 963 | int ret; |
---|
1074 | 964 | |
---|
1075 | 965 | cmd = container_of(header, typeof(*cmd), header); |
---|
1076 | 966 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1077 | | - user_surface_converter, |
---|
| 967 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
1078 | 968 | &cmd->body.srcSid, NULL); |
---|
1079 | 969 | if (ret != 0) |
---|
1080 | 970 | return ret; |
---|
1081 | 971 | |
---|
1082 | 972 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1083 | | - user_surface_converter, |
---|
| 973 | + VMW_RES_DIRTY_SET, user_surface_converter, |
---|
1084 | 974 | &cmd->body.dstSid, NULL); |
---|
1085 | 975 | } |
---|
1086 | 976 | |
---|
.. | .. |
---|
1088 | 978 | struct vmw_sw_context *sw_context, |
---|
1089 | 979 | SVGA3dCmdHeader *header) |
---|
1090 | 980 | { |
---|
1091 | | - struct vmw_sid_cmd { |
---|
1092 | | - SVGA3dCmdHeader header; |
---|
1093 | | - SVGA3dCmdSurfaceStretchBlt body; |
---|
1094 | | - } *cmd; |
---|
| 981 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdSurfaceStretchBlt); |
---|
1095 | 982 | int ret; |
---|
1096 | 983 | |
---|
1097 | | - cmd = container_of(header, struct vmw_sid_cmd, header); |
---|
| 984 | + cmd = container_of(header, typeof(*cmd), header); |
---|
1098 | 985 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1099 | | - user_surface_converter, |
---|
| 986 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
1100 | 987 | &cmd->body.src.sid, NULL); |
---|
1101 | 988 | if (unlikely(ret != 0)) |
---|
1102 | 989 | return ret; |
---|
| 990 | + |
---|
1103 | 991 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1104 | | - user_surface_converter, |
---|
| 992 | + VMW_RES_DIRTY_SET, user_surface_converter, |
---|
1105 | 993 | &cmd->body.dest.sid, NULL); |
---|
1106 | 994 | } |
---|
1107 | 995 | |
---|
.. | .. |
---|
1109 | 997 | struct vmw_sw_context *sw_context, |
---|
1110 | 998 | SVGA3dCmdHeader *header) |
---|
1111 | 999 | { |
---|
1112 | | - struct vmw_sid_cmd { |
---|
1113 | | - SVGA3dCmdHeader header; |
---|
1114 | | - SVGA3dCmdBlitSurfaceToScreen body; |
---|
1115 | | - } *cmd; |
---|
1116 | | - |
---|
1117 | | - cmd = container_of(header, struct vmw_sid_cmd, header); |
---|
| 1000 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBlitSurfaceToScreen) = |
---|
| 1001 | + container_of(header, typeof(*cmd), header); |
---|
1118 | 1002 | |
---|
1119 | 1003 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1120 | | - user_surface_converter, |
---|
| 1004 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
1121 | 1005 | &cmd->body.srcImage.sid, NULL); |
---|
1122 | 1006 | } |
---|
1123 | 1007 | |
---|
.. | .. |
---|
1125 | 1009 | struct vmw_sw_context *sw_context, |
---|
1126 | 1010 | SVGA3dCmdHeader *header) |
---|
1127 | 1011 | { |
---|
1128 | | - struct vmw_sid_cmd { |
---|
1129 | | - SVGA3dCmdHeader header; |
---|
1130 | | - SVGA3dCmdPresent body; |
---|
1131 | | - } *cmd; |
---|
1132 | | - |
---|
1133 | | - |
---|
1134 | | - cmd = container_of(header, struct vmw_sid_cmd, header); |
---|
| 1012 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdPresent) = |
---|
| 1013 | + container_of(header, typeof(*cmd), header); |
---|
1135 | 1014 | |
---|
1136 | 1015 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1137 | | - user_surface_converter, &cmd->body.sid, |
---|
1138 | | - NULL); |
---|
| 1016 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
| 1017 | + &cmd->body.sid, NULL); |
---|
1139 | 1018 | } |
---|
1140 | 1019 | |
---|
1141 | 1020 | /** |
---|
.. | .. |
---|
1145 | 1024 | * @new_query_bo: The new buffer holding query results. |
---|
1146 | 1025 | * @sw_context: The software context used for this command submission. |
---|
1147 | 1026 | * |
---|
1148 | | - * This function checks whether @new_query_bo is suitable for holding |
---|
1149 | | - * query results, and if another buffer currently is pinned for query |
---|
1150 | | - * results. If so, the function prepares the state of @sw_context for |
---|
1151 | | - * switching pinned buffers after successful submission of the current |
---|
1152 | | - * command batch. |
---|
| 1027 | + * This function checks whether @new_query_bo is suitable for holding query |
---|
| 1028 | + * results, and if another buffer currently is pinned for query results. If so, |
---|
| 1029 | + * the function prepares the state of @sw_context for switching pinned buffers |
---|
| 1030 | + * after successful submission of the current command batch. |
---|
1153 | 1031 | */ |
---|
1154 | 1032 | static int vmw_query_bo_switch_prepare(struct vmw_private *dev_priv, |
---|
1155 | 1033 | struct vmw_buffer_object *new_query_bo, |
---|
.. | .. |
---|
1165 | 1043 | if (unlikely(new_query_bo != sw_context->cur_query_bo)) { |
---|
1166 | 1044 | |
---|
1167 | 1045 | if (unlikely(new_query_bo->base.num_pages > 4)) { |
---|
1168 | | - DRM_ERROR("Query buffer too large.\n"); |
---|
| 1046 | + VMW_DEBUG_USER("Query buffer too large.\n"); |
---|
1169 | 1047 | return -EINVAL; |
---|
1170 | 1048 | } |
---|
1171 | 1049 | |
---|
1172 | 1050 | if (unlikely(sw_context->cur_query_bo != NULL)) { |
---|
1173 | 1051 | sw_context->needs_post_query_barrier = true; |
---|
1174 | | - ret = vmw_bo_to_validate_list(sw_context, |
---|
1175 | | - sw_context->cur_query_bo, |
---|
1176 | | - dev_priv->has_mob, NULL); |
---|
| 1052 | + ret = vmw_validation_add_bo(sw_context->ctx, |
---|
| 1053 | + sw_context->cur_query_bo, |
---|
| 1054 | + dev_priv->has_mob, false); |
---|
1177 | 1055 | if (unlikely(ret != 0)) |
---|
1178 | 1056 | return ret; |
---|
1179 | 1057 | } |
---|
1180 | 1058 | sw_context->cur_query_bo = new_query_bo; |
---|
1181 | 1059 | |
---|
1182 | | - ret = vmw_bo_to_validate_list(sw_context, |
---|
1183 | | - dev_priv->dummy_query_bo, |
---|
1184 | | - dev_priv->has_mob, NULL); |
---|
| 1060 | + ret = vmw_validation_add_bo(sw_context->ctx, |
---|
| 1061 | + dev_priv->dummy_query_bo, |
---|
| 1062 | + dev_priv->has_mob, false); |
---|
1185 | 1063 | if (unlikely(ret != 0)) |
---|
1186 | 1064 | return ret; |
---|
1187 | | - |
---|
1188 | 1065 | } |
---|
1189 | 1066 | |
---|
1190 | 1067 | return 0; |
---|
1191 | 1068 | } |
---|
1192 | | - |
---|
1193 | 1069 | |
---|
1194 | 1070 | /** |
---|
1195 | 1071 | * vmw_query_bo_switch_commit - Finalize switching pinned query buffer |
---|
.. | .. |
---|
1199 | 1075 | * |
---|
1200 | 1076 | * This function will check if we're switching query buffers, and will then, |
---|
1201 | 1077 | * issue a dummy occlusion query wait used as a query barrier. When the fence |
---|
1202 | | - * object following that query wait has signaled, we are sure that all |
---|
1203 | | - * preceding queries have finished, and the old query buffer can be unpinned. |
---|
1204 | | - * However, since both the new query buffer and the old one are fenced with |
---|
1205 | | - * that fence, we can do an asynchronus unpin now, and be sure that the |
---|
1206 | | - * old query buffer won't be moved until the fence has signaled. |
---|
| 1078 | + * object following that query wait has signaled, we are sure that all preceding |
---|
| 1079 | + * queries have finished, and the old query buffer can be unpinned. However, |
---|
| 1080 | + * since both the new query buffer and the old one are fenced with that fence, |
---|
| 1081 | + * we can do an asynchronus unpin now, and be sure that the old query buffer |
---|
| 1082 | + * won't be moved until the fence has signaled. |
---|
1207 | 1083 | * |
---|
1208 | 1084 | * As mentioned above, both the new - and old query buffers need to be fenced |
---|
1209 | 1085 | * using a sequence emitted *after* calling this function. |
---|
.. | .. |
---|
1215 | 1091 | * The validate list should still hold references to all |
---|
1216 | 1092 | * contexts here. |
---|
1217 | 1093 | */ |
---|
1218 | | - |
---|
1219 | 1094 | if (sw_context->needs_post_query_barrier) { |
---|
1220 | 1095 | struct vmw_res_cache_entry *ctx_entry = |
---|
1221 | 1096 | &sw_context->res_cache[vmw_res_context]; |
---|
.. | .. |
---|
1228 | 1103 | ret = vmw_fifo_emit_dummy_query(dev_priv, ctx->id); |
---|
1229 | 1104 | |
---|
1230 | 1105 | if (unlikely(ret != 0)) |
---|
1231 | | - DRM_ERROR("Out of fifo space for dummy query.\n"); |
---|
| 1106 | + VMW_DEBUG_USER("Out of fifo space for dummy query.\n"); |
---|
1232 | 1107 | } |
---|
1233 | 1108 | |
---|
1234 | 1109 | if (dev_priv->pinned_bo != sw_context->cur_query_bo) { |
---|
.. | .. |
---|
1242 | 1117 | |
---|
1243 | 1118 | /* |
---|
1244 | 1119 | * We pin also the dummy_query_bo buffer so that we |
---|
1245 | | - * don't need to validate it when emitting |
---|
1246 | | - * dummy queries in context destroy paths. |
---|
| 1120 | + * don't need to validate it when emitting dummy queries |
---|
| 1121 | + * in context destroy paths. |
---|
1247 | 1122 | */ |
---|
1248 | | - |
---|
1249 | 1123 | if (!dev_priv->dummy_query_bo_pinned) { |
---|
1250 | 1124 | vmw_bo_pin_reserved(dev_priv->dummy_query_bo, |
---|
1251 | 1125 | true); |
---|
.. | .. |
---|
1262 | 1136 | } |
---|
1263 | 1137 | |
---|
1264 | 1138 | /** |
---|
1265 | | - * vmw_translate_mob_pointer - Prepare to translate a user-space buffer |
---|
1266 | | - * handle to a MOB id. |
---|
| 1139 | + * vmw_translate_mob_pointer - Prepare to translate a user-space buffer handle |
---|
| 1140 | + * to a MOB id. |
---|
1267 | 1141 | * |
---|
1268 | 1142 | * @dev_priv: Pointer to a device private structure. |
---|
1269 | 1143 | * @sw_context: The software context used for this command batch validation. |
---|
1270 | 1144 | * @id: Pointer to the user-space handle to be translated. |
---|
1271 | | - * @vmw_bo_p: Points to a location that, on successful return will carry |
---|
1272 | | - * a reference-counted pointer to the DMA buffer identified by the |
---|
| 1145 | + * @vmw_bo_p: Points to a location that, on successful return will carry a |
---|
| 1146 | + * non-reference-counted pointer to the buffer object identified by the |
---|
1273 | 1147 | * user-space handle in @id. |
---|
1274 | 1148 | * |
---|
1275 | 1149 | * This function saves information needed to translate a user-space buffer |
---|
1276 | 1150 | * handle to a MOB id. The translation does not take place immediately, but |
---|
1277 | | - * during a call to vmw_apply_relocations(). This function builds a relocation |
---|
1278 | | - * list and a list of buffers to validate. The former needs to be freed using |
---|
1279 | | - * either vmw_apply_relocations() or vmw_free_relocations(). The latter |
---|
1280 | | - * needs to be freed using vmw_clear_validations. |
---|
| 1151 | + * during a call to vmw_apply_relocations(). |
---|
| 1152 | + * |
---|
| 1153 | + * This function builds a relocation list and a list of buffers to validate. The |
---|
| 1154 | + * former needs to be freed using either vmw_apply_relocations() or |
---|
| 1155 | + * vmw_free_relocations(). The latter needs to be freed using |
---|
| 1156 | + * vmw_clear_validations. |
---|
1281 | 1157 | */ |
---|
1282 | 1158 | static int vmw_translate_mob_ptr(struct vmw_private *dev_priv, |
---|
1283 | 1159 | struct vmw_sw_context *sw_context, |
---|
1284 | 1160 | SVGAMobId *id, |
---|
1285 | 1161 | struct vmw_buffer_object **vmw_bo_p) |
---|
1286 | 1162 | { |
---|
1287 | | - struct vmw_buffer_object *vmw_bo = NULL; |
---|
| 1163 | + struct vmw_buffer_object *vmw_bo; |
---|
1288 | 1164 | uint32_t handle = *id; |
---|
1289 | 1165 | struct vmw_relocation *reloc; |
---|
1290 | 1166 | int ret; |
---|
1291 | 1167 | |
---|
1292 | | - ret = vmw_user_bo_lookup(sw_context->fp->tfile, handle, &vmw_bo, NULL); |
---|
1293 | | - if (unlikely(ret != 0)) { |
---|
1294 | | - DRM_ERROR("Could not find or use MOB buffer.\n"); |
---|
1295 | | - ret = -EINVAL; |
---|
1296 | | - goto out_no_reloc; |
---|
| 1168 | + vmw_validation_preload_bo(sw_context->ctx); |
---|
| 1169 | + vmw_bo = vmw_user_bo_noref_lookup(sw_context->fp->tfile, handle); |
---|
| 1170 | + if (IS_ERR(vmw_bo)) { |
---|
| 1171 | + VMW_DEBUG_USER("Could not find or use MOB buffer.\n"); |
---|
| 1172 | + return PTR_ERR(vmw_bo); |
---|
1297 | 1173 | } |
---|
1298 | 1174 | |
---|
1299 | | - if (unlikely(sw_context->cur_reloc >= VMWGFX_MAX_RELOCATIONS)) { |
---|
1300 | | - DRM_ERROR("Max number relocations per submission" |
---|
1301 | | - " exceeded\n"); |
---|
1302 | | - ret = -EINVAL; |
---|
1303 | | - goto out_no_reloc; |
---|
1304 | | - } |
---|
1305 | | - |
---|
1306 | | - reloc = &sw_context->relocs[sw_context->cur_reloc++]; |
---|
1307 | | - reloc->mob_loc = id; |
---|
1308 | | - reloc->location = NULL; |
---|
1309 | | - |
---|
1310 | | - ret = vmw_bo_to_validate_list(sw_context, vmw_bo, true, &reloc->index); |
---|
| 1175 | + ret = vmw_validation_add_bo(sw_context->ctx, vmw_bo, true, false); |
---|
| 1176 | + vmw_user_bo_noref_release(); |
---|
1311 | 1177 | if (unlikely(ret != 0)) |
---|
1312 | | - goto out_no_reloc; |
---|
| 1178 | + return ret; |
---|
| 1179 | + |
---|
| 1180 | + reloc = vmw_validation_mem_alloc(sw_context->ctx, sizeof(*reloc)); |
---|
| 1181 | + if (!reloc) |
---|
| 1182 | + return -ENOMEM; |
---|
| 1183 | + |
---|
| 1184 | + reloc->mob_loc = id; |
---|
| 1185 | + reloc->vbo = vmw_bo; |
---|
1313 | 1186 | |
---|
1314 | 1187 | *vmw_bo_p = vmw_bo; |
---|
1315 | | - return 0; |
---|
| 1188 | + list_add_tail(&reloc->head, &sw_context->bo_relocations); |
---|
1316 | 1189 | |
---|
1317 | | -out_no_reloc: |
---|
1318 | | - vmw_bo_unreference(&vmw_bo); |
---|
1319 | | - *vmw_bo_p = NULL; |
---|
1320 | | - return ret; |
---|
| 1190 | + return 0; |
---|
1321 | 1191 | } |
---|
1322 | 1192 | |
---|
1323 | 1193 | /** |
---|
1324 | | - * vmw_translate_guest_pointer - Prepare to translate a user-space buffer |
---|
1325 | | - * handle to a valid SVGAGuestPtr |
---|
| 1194 | + * vmw_translate_guest_pointer - Prepare to translate a user-space buffer handle |
---|
| 1195 | + * to a valid SVGAGuestPtr |
---|
1326 | 1196 | * |
---|
1327 | 1197 | * @dev_priv: Pointer to a device private structure. |
---|
1328 | 1198 | * @sw_context: The software context used for this command batch validation. |
---|
1329 | 1199 | * @ptr: Pointer to the user-space handle to be translated. |
---|
1330 | | - * @vmw_bo_p: Points to a location that, on successful return will carry |
---|
1331 | | - * a reference-counted pointer to the DMA buffer identified by the |
---|
1332 | | - * user-space handle in @id. |
---|
| 1200 | + * @vmw_bo_p: Points to a location that, on successful return will carry a |
---|
| 1201 | + * non-reference-counted pointer to the DMA buffer identified by the user-space |
---|
| 1202 | + * handle in @id. |
---|
1333 | 1203 | * |
---|
1334 | 1204 | * This function saves information needed to translate a user-space buffer |
---|
1335 | 1205 | * handle to a valid SVGAGuestPtr. The translation does not take place |
---|
1336 | 1206 | * immediately, but during a call to vmw_apply_relocations(). |
---|
| 1207 | + * |
---|
1337 | 1208 | * This function builds a relocation list and a list of buffers to validate. |
---|
1338 | 1209 | * The former needs to be freed using either vmw_apply_relocations() or |
---|
1339 | 1210 | * vmw_free_relocations(). The latter needs to be freed using |
---|
.. | .. |
---|
1344 | 1215 | SVGAGuestPtr *ptr, |
---|
1345 | 1216 | struct vmw_buffer_object **vmw_bo_p) |
---|
1346 | 1217 | { |
---|
1347 | | - struct vmw_buffer_object *vmw_bo = NULL; |
---|
| 1218 | + struct vmw_buffer_object *vmw_bo; |
---|
1348 | 1219 | uint32_t handle = ptr->gmrId; |
---|
1349 | 1220 | struct vmw_relocation *reloc; |
---|
1350 | 1221 | int ret; |
---|
1351 | 1222 | |
---|
1352 | | - ret = vmw_user_bo_lookup(sw_context->fp->tfile, handle, &vmw_bo, NULL); |
---|
1353 | | - if (unlikely(ret != 0)) { |
---|
1354 | | - DRM_ERROR("Could not find or use GMR region.\n"); |
---|
1355 | | - ret = -EINVAL; |
---|
1356 | | - goto out_no_reloc; |
---|
| 1223 | + vmw_validation_preload_bo(sw_context->ctx); |
---|
| 1224 | + vmw_bo = vmw_user_bo_noref_lookup(sw_context->fp->tfile, handle); |
---|
| 1225 | + if (IS_ERR(vmw_bo)) { |
---|
| 1226 | + VMW_DEBUG_USER("Could not find or use GMR region.\n"); |
---|
| 1227 | + return PTR_ERR(vmw_bo); |
---|
1357 | 1228 | } |
---|
1358 | 1229 | |
---|
1359 | | - if (unlikely(sw_context->cur_reloc >= VMWGFX_MAX_RELOCATIONS)) { |
---|
1360 | | - DRM_ERROR("Max number relocations per submission" |
---|
1361 | | - " exceeded\n"); |
---|
1362 | | - ret = -EINVAL; |
---|
1363 | | - goto out_no_reloc; |
---|
1364 | | - } |
---|
1365 | | - |
---|
1366 | | - reloc = &sw_context->relocs[sw_context->cur_reloc++]; |
---|
1367 | | - reloc->location = ptr; |
---|
1368 | | - |
---|
1369 | | - ret = vmw_bo_to_validate_list(sw_context, vmw_bo, false, &reloc->index); |
---|
| 1230 | + ret = vmw_validation_add_bo(sw_context->ctx, vmw_bo, false, false); |
---|
| 1231 | + vmw_user_bo_noref_release(); |
---|
1370 | 1232 | if (unlikely(ret != 0)) |
---|
1371 | | - goto out_no_reloc; |
---|
| 1233 | + return ret; |
---|
1372 | 1234 | |
---|
| 1235 | + reloc = vmw_validation_mem_alloc(sw_context->ctx, sizeof(*reloc)); |
---|
| 1236 | + if (!reloc) |
---|
| 1237 | + return -ENOMEM; |
---|
| 1238 | + |
---|
| 1239 | + reloc->location = ptr; |
---|
| 1240 | + reloc->vbo = vmw_bo; |
---|
1373 | 1241 | *vmw_bo_p = vmw_bo; |
---|
1374 | | - return 0; |
---|
| 1242 | + list_add_tail(&reloc->head, &sw_context->bo_relocations); |
---|
1375 | 1243 | |
---|
1376 | | -out_no_reloc: |
---|
1377 | | - vmw_bo_unreference(&vmw_bo); |
---|
1378 | | - *vmw_bo_p = NULL; |
---|
1379 | | - return ret; |
---|
| 1244 | + return 0; |
---|
1380 | 1245 | } |
---|
1381 | 1246 | |
---|
1382 | | - |
---|
1383 | | - |
---|
1384 | 1247 | /** |
---|
1385 | | - * vmw_cmd_dx_define_query - validate a SVGA_3D_CMD_DX_DEFINE_QUERY command. |
---|
| 1248 | + * vmw_cmd_dx_define_query - validate SVGA_3D_CMD_DX_DEFINE_QUERY command. |
---|
1386 | 1249 | * |
---|
1387 | 1250 | * @dev_priv: Pointer to a device private struct. |
---|
1388 | 1251 | * @sw_context: The software context used for this command submission. |
---|
.. | .. |
---|
1394 | 1257 | struct vmw_sw_context *sw_context, |
---|
1395 | 1258 | SVGA3dCmdHeader *header) |
---|
1396 | 1259 | { |
---|
1397 | | - struct vmw_dx_define_query_cmd { |
---|
1398 | | - SVGA3dCmdHeader header; |
---|
1399 | | - SVGA3dCmdDXDefineQuery q; |
---|
1400 | | - } *cmd; |
---|
1401 | | - |
---|
1402 | | - int ret; |
---|
1403 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
| 1260 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXDefineQuery); |
---|
| 1261 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
1404 | 1262 | struct vmw_resource *cotable_res; |
---|
| 1263 | + int ret; |
---|
1405 | 1264 | |
---|
1406 | | - |
---|
1407 | | - if (ctx_node == NULL) { |
---|
1408 | | - DRM_ERROR("DX Context not set for query.\n"); |
---|
1409 | | - return -EINVAL; |
---|
1410 | | - } |
---|
1411 | | - |
---|
1412 | | - cmd = container_of(header, struct vmw_dx_define_query_cmd, header); |
---|
1413 | | - |
---|
1414 | | - if (cmd->q.type < SVGA3D_QUERYTYPE_MIN || |
---|
1415 | | - cmd->q.type >= SVGA3D_QUERYTYPE_MAX) |
---|
| 1265 | + if (!ctx_node) |
---|
1416 | 1266 | return -EINVAL; |
---|
1417 | 1267 | |
---|
1418 | | - cotable_res = vmw_context_cotable(ctx_node->res, SVGA_COTABLE_DXQUERY); |
---|
1419 | | - ret = vmw_cotable_notify(cotable_res, cmd->q.queryId); |
---|
1420 | | - vmw_resource_unreference(&cotable_res); |
---|
| 1268 | + cmd = container_of(header, typeof(*cmd), header); |
---|
| 1269 | + |
---|
| 1270 | + if (cmd->body.type < SVGA3D_QUERYTYPE_MIN || |
---|
| 1271 | + cmd->body.type >= SVGA3D_QUERYTYPE_MAX) |
---|
| 1272 | + return -EINVAL; |
---|
| 1273 | + |
---|
| 1274 | + cotable_res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXQUERY); |
---|
| 1275 | + ret = vmw_cotable_notify(cotable_res, cmd->body.queryId); |
---|
1421 | 1276 | |
---|
1422 | 1277 | return ret; |
---|
1423 | 1278 | } |
---|
1424 | 1279 | |
---|
1425 | | - |
---|
1426 | | - |
---|
1427 | 1280 | /** |
---|
1428 | | - * vmw_cmd_dx_bind_query - validate a SVGA_3D_CMD_DX_BIND_QUERY command. |
---|
| 1281 | + * vmw_cmd_dx_bind_query - validate SVGA_3D_CMD_DX_BIND_QUERY command. |
---|
1429 | 1282 | * |
---|
1430 | 1283 | * @dev_priv: Pointer to a device private struct. |
---|
1431 | 1284 | * @sw_context: The software context used for this command submission. |
---|
1432 | 1285 | * @header: Pointer to the command header in the command stream. |
---|
1433 | 1286 | * |
---|
1434 | | - * The query bind operation will eventually associate the query ID |
---|
1435 | | - * with its backing MOB. In this function, we take the user mode |
---|
1436 | | - * MOB ID and use vmw_translate_mob_ptr() to translate it to its |
---|
1437 | | - * kernel mode equivalent. |
---|
| 1287 | + * The query bind operation will eventually associate the query ID with its |
---|
| 1288 | + * backing MOB. In this function, we take the user mode MOB ID and use |
---|
| 1289 | + * vmw_translate_mob_ptr() to translate it to its kernel mode equivalent. |
---|
1438 | 1290 | */ |
---|
1439 | 1291 | static int vmw_cmd_dx_bind_query(struct vmw_private *dev_priv, |
---|
1440 | 1292 | struct vmw_sw_context *sw_context, |
---|
1441 | 1293 | SVGA3dCmdHeader *header) |
---|
1442 | 1294 | { |
---|
1443 | | - struct vmw_dx_bind_query_cmd { |
---|
1444 | | - SVGA3dCmdHeader header; |
---|
1445 | | - SVGA3dCmdDXBindQuery q; |
---|
1446 | | - } *cmd; |
---|
1447 | | - |
---|
| 1295 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXBindQuery); |
---|
1448 | 1296 | struct vmw_buffer_object *vmw_bo; |
---|
1449 | | - int ret; |
---|
| 1297 | + int ret; |
---|
1450 | 1298 | |
---|
1451 | | - |
---|
1452 | | - cmd = container_of(header, struct vmw_dx_bind_query_cmd, header); |
---|
| 1299 | + cmd = container_of(header, typeof(*cmd), header); |
---|
1453 | 1300 | |
---|
1454 | 1301 | /* |
---|
1455 | 1302 | * Look up the buffer pointed to by q.mobid, put it on the relocation |
---|
1456 | 1303 | * list so its kernel mode MOB ID can be filled in later |
---|
1457 | 1304 | */ |
---|
1458 | | - ret = vmw_translate_mob_ptr(dev_priv, sw_context, &cmd->q.mobid, |
---|
| 1305 | + ret = vmw_translate_mob_ptr(dev_priv, sw_context, &cmd->body.mobid, |
---|
1459 | 1306 | &vmw_bo); |
---|
1460 | 1307 | |
---|
1461 | 1308 | if (ret != 0) |
---|
1462 | 1309 | return ret; |
---|
1463 | 1310 | |
---|
1464 | 1311 | sw_context->dx_query_mob = vmw_bo; |
---|
1465 | | - sw_context->dx_query_ctx = sw_context->dx_ctx_node->res; |
---|
1466 | | - |
---|
1467 | | - vmw_bo_unreference(&vmw_bo); |
---|
1468 | | - |
---|
1469 | | - return ret; |
---|
| 1312 | + sw_context->dx_query_ctx = sw_context->dx_ctx_node->ctx; |
---|
| 1313 | + return 0; |
---|
1470 | 1314 | } |
---|
1471 | 1315 | |
---|
1472 | | - |
---|
1473 | | - |
---|
1474 | 1316 | /** |
---|
1475 | | - * vmw_cmd_begin_gb_query - validate a SVGA_3D_CMD_BEGIN_GB_QUERY command. |
---|
| 1317 | + * vmw_cmd_begin_gb_query - validate SVGA_3D_CMD_BEGIN_GB_QUERY command. |
---|
1476 | 1318 | * |
---|
1477 | 1319 | * @dev_priv: Pointer to a device private struct. |
---|
1478 | 1320 | * @sw_context: The software context used for this command submission. |
---|
.. | .. |
---|
1482 | 1324 | struct vmw_sw_context *sw_context, |
---|
1483 | 1325 | SVGA3dCmdHeader *header) |
---|
1484 | 1326 | { |
---|
1485 | | - struct vmw_begin_gb_query_cmd { |
---|
1486 | | - SVGA3dCmdHeader header; |
---|
1487 | | - SVGA3dCmdBeginGBQuery q; |
---|
1488 | | - } *cmd; |
---|
1489 | | - |
---|
1490 | | - cmd = container_of(header, struct vmw_begin_gb_query_cmd, |
---|
1491 | | - header); |
---|
| 1327 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBeginGBQuery) = |
---|
| 1328 | + container_of(header, typeof(*cmd), header); |
---|
1492 | 1329 | |
---|
1493 | 1330 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, |
---|
1494 | | - user_context_converter, &cmd->q.cid, |
---|
1495 | | - NULL); |
---|
| 1331 | + VMW_RES_DIRTY_SET, user_context_converter, |
---|
| 1332 | + &cmd->body.cid, NULL); |
---|
1496 | 1333 | } |
---|
1497 | 1334 | |
---|
1498 | 1335 | /** |
---|
1499 | | - * vmw_cmd_begin_query - validate a SVGA_3D_CMD_BEGIN_QUERY command. |
---|
| 1336 | + * vmw_cmd_begin_query - validate SVGA_3D_CMD_BEGIN_QUERY command. |
---|
1500 | 1337 | * |
---|
1501 | 1338 | * @dev_priv: Pointer to a device private struct. |
---|
1502 | 1339 | * @sw_context: The software context used for this command submission. |
---|
.. | .. |
---|
1506 | 1343 | struct vmw_sw_context *sw_context, |
---|
1507 | 1344 | SVGA3dCmdHeader *header) |
---|
1508 | 1345 | { |
---|
1509 | | - struct vmw_begin_query_cmd { |
---|
1510 | | - SVGA3dCmdHeader header; |
---|
1511 | | - SVGA3dCmdBeginQuery q; |
---|
1512 | | - } *cmd; |
---|
1513 | | - |
---|
1514 | | - cmd = container_of(header, struct vmw_begin_query_cmd, |
---|
1515 | | - header); |
---|
| 1346 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBeginQuery) = |
---|
| 1347 | + container_of(header, typeof(*cmd), header); |
---|
1516 | 1348 | |
---|
1517 | 1349 | if (unlikely(dev_priv->has_mob)) { |
---|
1518 | | - struct { |
---|
1519 | | - SVGA3dCmdHeader header; |
---|
1520 | | - SVGA3dCmdBeginGBQuery q; |
---|
1521 | | - } gb_cmd; |
---|
| 1350 | + VMW_DECLARE_CMD_VAR(gb_cmd, SVGA3dCmdBeginGBQuery); |
---|
1522 | 1351 | |
---|
1523 | 1352 | BUG_ON(sizeof(gb_cmd) != sizeof(*cmd)); |
---|
1524 | 1353 | |
---|
1525 | 1354 | gb_cmd.header.id = SVGA_3D_CMD_BEGIN_GB_QUERY; |
---|
1526 | 1355 | gb_cmd.header.size = cmd->header.size; |
---|
1527 | | - gb_cmd.q.cid = cmd->q.cid; |
---|
1528 | | - gb_cmd.q.type = cmd->q.type; |
---|
| 1356 | + gb_cmd.body.cid = cmd->body.cid; |
---|
| 1357 | + gb_cmd.body.type = cmd->body.type; |
---|
1529 | 1358 | |
---|
1530 | 1359 | memcpy(cmd, &gb_cmd, sizeof(*cmd)); |
---|
1531 | 1360 | return vmw_cmd_begin_gb_query(dev_priv, sw_context, header); |
---|
1532 | 1361 | } |
---|
1533 | 1362 | |
---|
1534 | 1363 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, |
---|
1535 | | - user_context_converter, &cmd->q.cid, |
---|
1536 | | - NULL); |
---|
| 1364 | + VMW_RES_DIRTY_SET, user_context_converter, |
---|
| 1365 | + &cmd->body.cid, NULL); |
---|
1537 | 1366 | } |
---|
1538 | 1367 | |
---|
1539 | 1368 | /** |
---|
1540 | | - * vmw_cmd_end_gb_query - validate a SVGA_3D_CMD_END_GB_QUERY command. |
---|
| 1369 | + * vmw_cmd_end_gb_query - validate SVGA_3D_CMD_END_GB_QUERY command. |
---|
1541 | 1370 | * |
---|
1542 | 1371 | * @dev_priv: Pointer to a device private struct. |
---|
1543 | 1372 | * @sw_context: The software context used for this command submission. |
---|
.. | .. |
---|
1548 | 1377 | SVGA3dCmdHeader *header) |
---|
1549 | 1378 | { |
---|
1550 | 1379 | struct vmw_buffer_object *vmw_bo; |
---|
1551 | | - struct vmw_query_cmd { |
---|
1552 | | - SVGA3dCmdHeader header; |
---|
1553 | | - SVGA3dCmdEndGBQuery q; |
---|
1554 | | - } *cmd; |
---|
| 1380 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdEndGBQuery); |
---|
1555 | 1381 | int ret; |
---|
1556 | 1382 | |
---|
1557 | | - cmd = container_of(header, struct vmw_query_cmd, header); |
---|
| 1383 | + cmd = container_of(header, typeof(*cmd), header); |
---|
1558 | 1384 | ret = vmw_cmd_cid_check(dev_priv, sw_context, header); |
---|
1559 | 1385 | if (unlikely(ret != 0)) |
---|
1560 | 1386 | return ret; |
---|
1561 | 1387 | |
---|
1562 | | - ret = vmw_translate_mob_ptr(dev_priv, sw_context, |
---|
1563 | | - &cmd->q.mobid, |
---|
| 1388 | + ret = vmw_translate_mob_ptr(dev_priv, sw_context, &cmd->body.mobid, |
---|
1564 | 1389 | &vmw_bo); |
---|
1565 | 1390 | if (unlikely(ret != 0)) |
---|
1566 | 1391 | return ret; |
---|
1567 | 1392 | |
---|
1568 | 1393 | ret = vmw_query_bo_switch_prepare(dev_priv, vmw_bo, sw_context); |
---|
1569 | 1394 | |
---|
1570 | | - vmw_bo_unreference(&vmw_bo); |
---|
1571 | 1395 | return ret; |
---|
1572 | 1396 | } |
---|
1573 | 1397 | |
---|
1574 | 1398 | /** |
---|
1575 | | - * vmw_cmd_end_query - validate a SVGA_3D_CMD_END_QUERY command. |
---|
| 1399 | + * vmw_cmd_end_query - validate SVGA_3D_CMD_END_QUERY command. |
---|
1576 | 1400 | * |
---|
1577 | 1401 | * @dev_priv: Pointer to a device private struct. |
---|
1578 | 1402 | * @sw_context: The software context used for this command submission. |
---|
.. | .. |
---|
1583 | 1407 | SVGA3dCmdHeader *header) |
---|
1584 | 1408 | { |
---|
1585 | 1409 | struct vmw_buffer_object *vmw_bo; |
---|
1586 | | - struct vmw_query_cmd { |
---|
1587 | | - SVGA3dCmdHeader header; |
---|
1588 | | - SVGA3dCmdEndQuery q; |
---|
1589 | | - } *cmd; |
---|
| 1410 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdEndQuery); |
---|
1590 | 1411 | int ret; |
---|
1591 | 1412 | |
---|
1592 | | - cmd = container_of(header, struct vmw_query_cmd, header); |
---|
| 1413 | + cmd = container_of(header, typeof(*cmd), header); |
---|
1593 | 1414 | if (dev_priv->has_mob) { |
---|
1594 | | - struct { |
---|
1595 | | - SVGA3dCmdHeader header; |
---|
1596 | | - SVGA3dCmdEndGBQuery q; |
---|
1597 | | - } gb_cmd; |
---|
| 1415 | + VMW_DECLARE_CMD_VAR(gb_cmd, SVGA3dCmdEndGBQuery); |
---|
1598 | 1416 | |
---|
1599 | 1417 | BUG_ON(sizeof(gb_cmd) != sizeof(*cmd)); |
---|
1600 | 1418 | |
---|
1601 | 1419 | gb_cmd.header.id = SVGA_3D_CMD_END_GB_QUERY; |
---|
1602 | 1420 | gb_cmd.header.size = cmd->header.size; |
---|
1603 | | - gb_cmd.q.cid = cmd->q.cid; |
---|
1604 | | - gb_cmd.q.type = cmd->q.type; |
---|
1605 | | - gb_cmd.q.mobid = cmd->q.guestResult.gmrId; |
---|
1606 | | - gb_cmd.q.offset = cmd->q.guestResult.offset; |
---|
| 1421 | + gb_cmd.body.cid = cmd->body.cid; |
---|
| 1422 | + gb_cmd.body.type = cmd->body.type; |
---|
| 1423 | + gb_cmd.body.mobid = cmd->body.guestResult.gmrId; |
---|
| 1424 | + gb_cmd.body.offset = cmd->body.guestResult.offset; |
---|
1607 | 1425 | |
---|
1608 | 1426 | memcpy(cmd, &gb_cmd, sizeof(*cmd)); |
---|
1609 | 1427 | return vmw_cmd_end_gb_query(dev_priv, sw_context, header); |
---|
.. | .. |
---|
1614 | 1432 | return ret; |
---|
1615 | 1433 | |
---|
1616 | 1434 | ret = vmw_translate_guest_ptr(dev_priv, sw_context, |
---|
1617 | | - &cmd->q.guestResult, |
---|
1618 | | - &vmw_bo); |
---|
| 1435 | + &cmd->body.guestResult, &vmw_bo); |
---|
1619 | 1436 | if (unlikely(ret != 0)) |
---|
1620 | 1437 | return ret; |
---|
1621 | 1438 | |
---|
1622 | 1439 | ret = vmw_query_bo_switch_prepare(dev_priv, vmw_bo, sw_context); |
---|
1623 | 1440 | |
---|
1624 | | - vmw_bo_unreference(&vmw_bo); |
---|
1625 | 1441 | return ret; |
---|
1626 | 1442 | } |
---|
1627 | 1443 | |
---|
1628 | 1444 | /** |
---|
1629 | | - * vmw_cmd_wait_gb_query - validate a SVGA_3D_CMD_WAIT_GB_QUERY command. |
---|
| 1445 | + * vmw_cmd_wait_gb_query - validate SVGA_3D_CMD_WAIT_GB_QUERY command. |
---|
1630 | 1446 | * |
---|
1631 | 1447 | * @dev_priv: Pointer to a device private struct. |
---|
1632 | 1448 | * @sw_context: The software context used for this command submission. |
---|
.. | .. |
---|
1637 | 1453 | SVGA3dCmdHeader *header) |
---|
1638 | 1454 | { |
---|
1639 | 1455 | struct vmw_buffer_object *vmw_bo; |
---|
1640 | | - struct vmw_query_cmd { |
---|
1641 | | - SVGA3dCmdHeader header; |
---|
1642 | | - SVGA3dCmdWaitForGBQuery q; |
---|
1643 | | - } *cmd; |
---|
| 1456 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdWaitForGBQuery); |
---|
1644 | 1457 | int ret; |
---|
1645 | 1458 | |
---|
1646 | | - cmd = container_of(header, struct vmw_query_cmd, header); |
---|
| 1459 | + cmd = container_of(header, typeof(*cmd), header); |
---|
1647 | 1460 | ret = vmw_cmd_cid_check(dev_priv, sw_context, header); |
---|
1648 | 1461 | if (unlikely(ret != 0)) |
---|
1649 | 1462 | return ret; |
---|
1650 | 1463 | |
---|
1651 | | - ret = vmw_translate_mob_ptr(dev_priv, sw_context, |
---|
1652 | | - &cmd->q.mobid, |
---|
| 1464 | + ret = vmw_translate_mob_ptr(dev_priv, sw_context, &cmd->body.mobid, |
---|
1653 | 1465 | &vmw_bo); |
---|
1654 | 1466 | if (unlikely(ret != 0)) |
---|
1655 | 1467 | return ret; |
---|
1656 | 1468 | |
---|
1657 | | - vmw_bo_unreference(&vmw_bo); |
---|
1658 | 1469 | return 0; |
---|
1659 | 1470 | } |
---|
1660 | 1471 | |
---|
1661 | 1472 | /** |
---|
1662 | | - * vmw_cmd_wait_query - validate a SVGA_3D_CMD_WAIT_QUERY command. |
---|
| 1473 | + * vmw_cmd_wait_query - validate SVGA_3D_CMD_WAIT_QUERY command. |
---|
1663 | 1474 | * |
---|
1664 | 1475 | * @dev_priv: Pointer to a device private struct. |
---|
1665 | 1476 | * @sw_context: The software context used for this command submission. |
---|
.. | .. |
---|
1670 | 1481 | SVGA3dCmdHeader *header) |
---|
1671 | 1482 | { |
---|
1672 | 1483 | struct vmw_buffer_object *vmw_bo; |
---|
1673 | | - struct vmw_query_cmd { |
---|
1674 | | - SVGA3dCmdHeader header; |
---|
1675 | | - SVGA3dCmdWaitForQuery q; |
---|
1676 | | - } *cmd; |
---|
| 1484 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdWaitForQuery); |
---|
1677 | 1485 | int ret; |
---|
1678 | 1486 | |
---|
1679 | | - cmd = container_of(header, struct vmw_query_cmd, header); |
---|
| 1487 | + cmd = container_of(header, typeof(*cmd), header); |
---|
1680 | 1488 | if (dev_priv->has_mob) { |
---|
1681 | | - struct { |
---|
1682 | | - SVGA3dCmdHeader header; |
---|
1683 | | - SVGA3dCmdWaitForGBQuery q; |
---|
1684 | | - } gb_cmd; |
---|
| 1489 | + VMW_DECLARE_CMD_VAR(gb_cmd, SVGA3dCmdWaitForGBQuery); |
---|
1685 | 1490 | |
---|
1686 | 1491 | BUG_ON(sizeof(gb_cmd) != sizeof(*cmd)); |
---|
1687 | 1492 | |
---|
1688 | 1493 | gb_cmd.header.id = SVGA_3D_CMD_WAIT_FOR_GB_QUERY; |
---|
1689 | 1494 | gb_cmd.header.size = cmd->header.size; |
---|
1690 | | - gb_cmd.q.cid = cmd->q.cid; |
---|
1691 | | - gb_cmd.q.type = cmd->q.type; |
---|
1692 | | - gb_cmd.q.mobid = cmd->q.guestResult.gmrId; |
---|
1693 | | - gb_cmd.q.offset = cmd->q.guestResult.offset; |
---|
| 1495 | + gb_cmd.body.cid = cmd->body.cid; |
---|
| 1496 | + gb_cmd.body.type = cmd->body.type; |
---|
| 1497 | + gb_cmd.body.mobid = cmd->body.guestResult.gmrId; |
---|
| 1498 | + gb_cmd.body.offset = cmd->body.guestResult.offset; |
---|
1694 | 1499 | |
---|
1695 | 1500 | memcpy(cmd, &gb_cmd, sizeof(*cmd)); |
---|
1696 | 1501 | return vmw_cmd_wait_gb_query(dev_priv, sw_context, header); |
---|
.. | .. |
---|
1701 | 1506 | return ret; |
---|
1702 | 1507 | |
---|
1703 | 1508 | ret = vmw_translate_guest_ptr(dev_priv, sw_context, |
---|
1704 | | - &cmd->q.guestResult, |
---|
1705 | | - &vmw_bo); |
---|
| 1509 | + &cmd->body.guestResult, &vmw_bo); |
---|
1706 | 1510 | if (unlikely(ret != 0)) |
---|
1707 | 1511 | return ret; |
---|
1708 | 1512 | |
---|
1709 | | - vmw_bo_unreference(&vmw_bo); |
---|
1710 | 1513 | return 0; |
---|
1711 | 1514 | } |
---|
1712 | 1515 | |
---|
.. | .. |
---|
1716 | 1519 | { |
---|
1717 | 1520 | struct vmw_buffer_object *vmw_bo = NULL; |
---|
1718 | 1521 | struct vmw_surface *srf = NULL; |
---|
1719 | | - struct vmw_dma_cmd { |
---|
1720 | | - SVGA3dCmdHeader header; |
---|
1721 | | - SVGA3dCmdSurfaceDMA dma; |
---|
1722 | | - } *cmd; |
---|
| 1522 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdSurfaceDMA); |
---|
1723 | 1523 | int ret; |
---|
1724 | 1524 | SVGA3dCmdSurfaceDMASuffix *suffix; |
---|
1725 | 1525 | uint32_t bo_size; |
---|
| 1526 | + bool dirty; |
---|
1726 | 1527 | |
---|
1727 | | - cmd = container_of(header, struct vmw_dma_cmd, header); |
---|
1728 | | - suffix = (SVGA3dCmdSurfaceDMASuffix *)((unsigned long) &cmd->dma + |
---|
| 1528 | + cmd = container_of(header, typeof(*cmd), header); |
---|
| 1529 | + suffix = (SVGA3dCmdSurfaceDMASuffix *)((unsigned long) &cmd->body + |
---|
1729 | 1530 | header->size - sizeof(*suffix)); |
---|
1730 | 1531 | |
---|
1731 | 1532 | /* Make sure device and verifier stays in sync. */ |
---|
1732 | 1533 | if (unlikely(suffix->suffixSize != sizeof(*suffix))) { |
---|
1733 | | - DRM_ERROR("Invalid DMA suffix size.\n"); |
---|
| 1534 | + VMW_DEBUG_USER("Invalid DMA suffix size.\n"); |
---|
1734 | 1535 | return -EINVAL; |
---|
1735 | 1536 | } |
---|
1736 | 1537 | |
---|
1737 | 1538 | ret = vmw_translate_guest_ptr(dev_priv, sw_context, |
---|
1738 | | - &cmd->dma.guest.ptr, |
---|
1739 | | - &vmw_bo); |
---|
| 1539 | + &cmd->body.guest.ptr, &vmw_bo); |
---|
1740 | 1540 | if (unlikely(ret != 0)) |
---|
1741 | 1541 | return ret; |
---|
1742 | 1542 | |
---|
1743 | 1543 | /* Make sure DMA doesn't cross BO boundaries. */ |
---|
1744 | 1544 | bo_size = vmw_bo->base.num_pages * PAGE_SIZE; |
---|
1745 | | - if (unlikely(cmd->dma.guest.ptr.offset > bo_size)) { |
---|
1746 | | - DRM_ERROR("Invalid DMA offset.\n"); |
---|
| 1545 | + if (unlikely(cmd->body.guest.ptr.offset > bo_size)) { |
---|
| 1546 | + VMW_DEBUG_USER("Invalid DMA offset.\n"); |
---|
1747 | 1547 | return -EINVAL; |
---|
1748 | 1548 | } |
---|
1749 | 1549 | |
---|
1750 | | - bo_size -= cmd->dma.guest.ptr.offset; |
---|
| 1550 | + bo_size -= cmd->body.guest.ptr.offset; |
---|
1751 | 1551 | if (unlikely(suffix->maximumOffset > bo_size)) |
---|
1752 | 1552 | suffix->maximumOffset = bo_size; |
---|
1753 | 1553 | |
---|
| 1554 | + dirty = (cmd->body.transfer == SVGA3D_WRITE_HOST_VRAM) ? |
---|
| 1555 | + VMW_RES_DIRTY_SET : 0; |
---|
1754 | 1556 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
1755 | | - user_surface_converter, &cmd->dma.host.sid, |
---|
1756 | | - NULL); |
---|
| 1557 | + dirty, user_surface_converter, |
---|
| 1558 | + &cmd->body.host.sid, NULL); |
---|
1757 | 1559 | if (unlikely(ret != 0)) { |
---|
1758 | 1560 | if (unlikely(ret != -ERESTARTSYS)) |
---|
1759 | | - DRM_ERROR("could not find surface for DMA.\n"); |
---|
1760 | | - goto out_no_surface; |
---|
| 1561 | + VMW_DEBUG_USER("could not find surface for DMA.\n"); |
---|
| 1562 | + return ret; |
---|
1761 | 1563 | } |
---|
1762 | 1564 | |
---|
1763 | 1565 | srf = vmw_res_to_srf(sw_context->res_cache[vmw_res_surface].res); |
---|
1764 | 1566 | |
---|
1765 | | - vmw_kms_cursor_snoop(srf, sw_context->fp->tfile, &vmw_bo->base, |
---|
1766 | | - header); |
---|
| 1567 | + vmw_kms_cursor_snoop(srf, sw_context->fp->tfile, &vmw_bo->base, header); |
---|
1767 | 1568 | |
---|
1768 | | -out_no_surface: |
---|
1769 | | - vmw_bo_unreference(&vmw_bo); |
---|
1770 | | - return ret; |
---|
| 1569 | + return 0; |
---|
1771 | 1570 | } |
---|
1772 | 1571 | |
---|
1773 | 1572 | static int vmw_cmd_draw(struct vmw_private *dev_priv, |
---|
1774 | 1573 | struct vmw_sw_context *sw_context, |
---|
1775 | 1574 | SVGA3dCmdHeader *header) |
---|
1776 | 1575 | { |
---|
1777 | | - struct vmw_draw_cmd { |
---|
1778 | | - SVGA3dCmdHeader header; |
---|
1779 | | - SVGA3dCmdDrawPrimitives body; |
---|
1780 | | - } *cmd; |
---|
| 1576 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDrawPrimitives); |
---|
1781 | 1577 | SVGA3dVertexDecl *decl = (SVGA3dVertexDecl *)( |
---|
1782 | 1578 | (unsigned long)header + sizeof(*cmd)); |
---|
1783 | 1579 | SVGA3dPrimitiveRange *range; |
---|
.. | .. |
---|
1789 | 1585 | if (unlikely(ret != 0)) |
---|
1790 | 1586 | return ret; |
---|
1791 | 1587 | |
---|
1792 | | - cmd = container_of(header, struct vmw_draw_cmd, header); |
---|
| 1588 | + cmd = container_of(header, typeof(*cmd), header); |
---|
1793 | 1589 | maxnum = (header->size - sizeof(cmd->body)) / sizeof(*decl); |
---|
1794 | 1590 | |
---|
1795 | 1591 | if (unlikely(cmd->body.numVertexDecls > maxnum)) { |
---|
1796 | | - DRM_ERROR("Illegal number of vertex declarations.\n"); |
---|
| 1592 | + VMW_DEBUG_USER("Illegal number of vertex declarations.\n"); |
---|
1797 | 1593 | return -EINVAL; |
---|
1798 | 1594 | } |
---|
1799 | 1595 | |
---|
1800 | 1596 | for (i = 0; i < cmd->body.numVertexDecls; ++i, ++decl) { |
---|
1801 | 1597 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
| 1598 | + VMW_RES_DIRTY_NONE, |
---|
1802 | 1599 | user_surface_converter, |
---|
1803 | 1600 | &decl->array.surfaceId, NULL); |
---|
1804 | 1601 | if (unlikely(ret != 0)) |
---|
.. | .. |
---|
1808 | 1605 | maxnum = (header->size - sizeof(cmd->body) - |
---|
1809 | 1606 | cmd->body.numVertexDecls * sizeof(*decl)) / sizeof(*range); |
---|
1810 | 1607 | if (unlikely(cmd->body.numRanges > maxnum)) { |
---|
1811 | | - DRM_ERROR("Illegal number of index ranges.\n"); |
---|
| 1608 | + VMW_DEBUG_USER("Illegal number of index ranges.\n"); |
---|
1812 | 1609 | return -EINVAL; |
---|
1813 | 1610 | } |
---|
1814 | 1611 | |
---|
1815 | 1612 | range = (SVGA3dPrimitiveRange *) decl; |
---|
1816 | 1613 | for (i = 0; i < cmd->body.numRanges; ++i, ++range) { |
---|
1817 | 1614 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
| 1615 | + VMW_RES_DIRTY_NONE, |
---|
1818 | 1616 | user_surface_converter, |
---|
1819 | 1617 | &range->indexArray.surfaceId, NULL); |
---|
1820 | 1618 | if (unlikely(ret != 0)) |
---|
.. | .. |
---|
1823 | 1621 | return 0; |
---|
1824 | 1622 | } |
---|
1825 | 1623 | |
---|
1826 | | - |
---|
1827 | 1624 | static int vmw_cmd_tex_state(struct vmw_private *dev_priv, |
---|
1828 | 1625 | struct vmw_sw_context *sw_context, |
---|
1829 | 1626 | SVGA3dCmdHeader *header) |
---|
1830 | 1627 | { |
---|
1831 | | - struct vmw_tex_state_cmd { |
---|
1832 | | - SVGA3dCmdHeader header; |
---|
1833 | | - SVGA3dCmdSetTextureState state; |
---|
1834 | | - } *cmd; |
---|
1835 | | - |
---|
| 1628 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdSetTextureState); |
---|
1836 | 1629 | SVGA3dTextureState *last_state = (SVGA3dTextureState *) |
---|
1837 | 1630 | ((unsigned long) header + header->size + sizeof(header)); |
---|
1838 | 1631 | SVGA3dTextureState *cur_state = (SVGA3dTextureState *) |
---|
1839 | | - ((unsigned long) header + sizeof(struct vmw_tex_state_cmd)); |
---|
1840 | | - struct vmw_resource_val_node *ctx_node; |
---|
1841 | | - struct vmw_resource_val_node *res_node; |
---|
| 1632 | + ((unsigned long) header + sizeof(*cmd)); |
---|
| 1633 | + struct vmw_resource *ctx; |
---|
| 1634 | + struct vmw_resource *res; |
---|
1842 | 1635 | int ret; |
---|
1843 | 1636 | |
---|
1844 | | - cmd = container_of(header, struct vmw_tex_state_cmd, |
---|
1845 | | - header); |
---|
| 1637 | + cmd = container_of(header, typeof(*cmd), header); |
---|
1846 | 1638 | |
---|
1847 | 1639 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, |
---|
1848 | | - user_context_converter, &cmd->state.cid, |
---|
1849 | | - &ctx_node); |
---|
| 1640 | + VMW_RES_DIRTY_SET, user_context_converter, |
---|
| 1641 | + &cmd->body.cid, &ctx); |
---|
1850 | 1642 | if (unlikely(ret != 0)) |
---|
1851 | 1643 | return ret; |
---|
1852 | 1644 | |
---|
.. | .. |
---|
1855 | 1647 | continue; |
---|
1856 | 1648 | |
---|
1857 | 1649 | if (cur_state->stage >= SVGA3D_NUM_TEXTURE_UNITS) { |
---|
1858 | | - DRM_ERROR("Illegal texture/sampler unit %u.\n", |
---|
1859 | | - (unsigned) cur_state->stage); |
---|
| 1650 | + VMW_DEBUG_USER("Illegal texture/sampler unit %u.\n", |
---|
| 1651 | + (unsigned int) cur_state->stage); |
---|
1860 | 1652 | return -EINVAL; |
---|
1861 | 1653 | } |
---|
1862 | 1654 | |
---|
1863 | 1655 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
| 1656 | + VMW_RES_DIRTY_NONE, |
---|
1864 | 1657 | user_surface_converter, |
---|
1865 | | - &cur_state->value, &res_node); |
---|
| 1658 | + &cur_state->value, &res); |
---|
1866 | 1659 | if (unlikely(ret != 0)) |
---|
1867 | 1660 | return ret; |
---|
1868 | 1661 | |
---|
1869 | 1662 | if (dev_priv->has_mob) { |
---|
1870 | 1663 | struct vmw_ctx_bindinfo_tex binding; |
---|
| 1664 | + struct vmw_ctx_validation_info *node; |
---|
1871 | 1665 | |
---|
1872 | | - binding.bi.ctx = ctx_node->res; |
---|
1873 | | - binding.bi.res = res_node ? res_node->res : NULL; |
---|
| 1666 | + node = vmw_execbuf_info_from_res(sw_context, ctx); |
---|
| 1667 | + if (!node) |
---|
| 1668 | + return -EINVAL; |
---|
| 1669 | + |
---|
| 1670 | + binding.bi.ctx = ctx; |
---|
| 1671 | + binding.bi.res = res; |
---|
1874 | 1672 | binding.bi.bt = vmw_ctx_binding_tex; |
---|
1875 | 1673 | binding.texture_stage = cur_state->stage; |
---|
1876 | | - vmw_binding_add(ctx_node->staged_bindings, &binding.bi, |
---|
1877 | | - 0, binding.texture_stage); |
---|
| 1674 | + vmw_binding_add(node->staged, &binding.bi, 0, |
---|
| 1675 | + binding.texture_stage); |
---|
1878 | 1676 | } |
---|
1879 | 1677 | } |
---|
1880 | 1678 | |
---|
.. | .. |
---|
1886 | 1684 | void *buf) |
---|
1887 | 1685 | { |
---|
1888 | 1686 | struct vmw_buffer_object *vmw_bo; |
---|
1889 | | - int ret; |
---|
1890 | 1687 | |
---|
1891 | 1688 | struct { |
---|
1892 | 1689 | uint32_t header; |
---|
1893 | 1690 | SVGAFifoCmdDefineGMRFB body; |
---|
1894 | 1691 | } *cmd = buf; |
---|
1895 | 1692 | |
---|
1896 | | - ret = vmw_translate_guest_ptr(dev_priv, sw_context, |
---|
1897 | | - &cmd->body.ptr, |
---|
1898 | | - &vmw_bo); |
---|
1899 | | - if (unlikely(ret != 0)) |
---|
1900 | | - return ret; |
---|
1901 | | - |
---|
1902 | | - vmw_bo_unreference(&vmw_bo); |
---|
1903 | | - |
---|
1904 | | - return ret; |
---|
| 1693 | + return vmw_translate_guest_ptr(dev_priv, sw_context, &cmd->body.ptr, |
---|
| 1694 | + &vmw_bo); |
---|
1905 | 1695 | } |
---|
1906 | | - |
---|
1907 | 1696 | |
---|
1908 | 1697 | /** |
---|
1909 | 1698 | * vmw_cmd_res_switch_backup - Utility function to handle backup buffer |
---|
.. | .. |
---|
1916 | 1705 | * stream. |
---|
1917 | 1706 | * @backup_offset: Offset of backup into MOB. |
---|
1918 | 1707 | * |
---|
1919 | | - * This function prepares for registering a switch of backup buffers |
---|
1920 | | - * in the resource metadata just prior to unreserving. It's basically a wrapper |
---|
1921 | | - * around vmw_cmd_res_switch_backup with a different interface. |
---|
| 1708 | + * This function prepares for registering a switch of backup buffers in the |
---|
| 1709 | + * resource metadata just prior to unreserving. It's basically a wrapper around |
---|
| 1710 | + * vmw_cmd_res_switch_backup with a different interface. |
---|
1922 | 1711 | */ |
---|
1923 | 1712 | static int vmw_cmd_res_switch_backup(struct vmw_private *dev_priv, |
---|
1924 | 1713 | struct vmw_sw_context *sw_context, |
---|
1925 | | - struct vmw_resource_val_node *val_node, |
---|
1926 | | - uint32_t *buf_id, |
---|
| 1714 | + struct vmw_resource *res, uint32_t *buf_id, |
---|
1927 | 1715 | unsigned long backup_offset) |
---|
1928 | 1716 | { |
---|
1929 | | - struct vmw_buffer_object *dma_buf; |
---|
| 1717 | + struct vmw_buffer_object *vbo; |
---|
| 1718 | + void *info; |
---|
1930 | 1719 | int ret; |
---|
1931 | 1720 | |
---|
1932 | | - ret = vmw_translate_mob_ptr(dev_priv, sw_context, buf_id, &dma_buf); |
---|
| 1721 | + info = vmw_execbuf_info_from_res(sw_context, res); |
---|
| 1722 | + if (!info) |
---|
| 1723 | + return -EINVAL; |
---|
| 1724 | + |
---|
| 1725 | + ret = vmw_translate_mob_ptr(dev_priv, sw_context, buf_id, &vbo); |
---|
1933 | 1726 | if (ret) |
---|
1934 | 1727 | return ret; |
---|
1935 | 1728 | |
---|
1936 | | - val_node->switching_backup = true; |
---|
1937 | | - if (val_node->first_usage) |
---|
1938 | | - val_node->no_buffer_needed = true; |
---|
1939 | | - |
---|
1940 | | - vmw_bo_unreference(&val_node->new_backup); |
---|
1941 | | - val_node->new_backup = dma_buf; |
---|
1942 | | - val_node->new_backup_offset = backup_offset; |
---|
1943 | | - |
---|
| 1729 | + vmw_validation_res_switch_backup(sw_context->ctx, info, vbo, |
---|
| 1730 | + backup_offset); |
---|
1944 | 1731 | return 0; |
---|
1945 | 1732 | } |
---|
1946 | | - |
---|
1947 | 1733 | |
---|
1948 | 1734 | /** |
---|
1949 | 1735 | * vmw_cmd_switch_backup - Utility function to handle backup buffer switching |
---|
.. | .. |
---|
1957 | 1743 | * stream. |
---|
1958 | 1744 | * @backup_offset: Offset of backup into MOB. |
---|
1959 | 1745 | * |
---|
1960 | | - * This function prepares for registering a switch of backup buffers |
---|
1961 | | - * in the resource metadata just prior to unreserving. It's basically a wrapper |
---|
1962 | | - * around vmw_cmd_res_switch_backup with a different interface. |
---|
| 1746 | + * This function prepares for registering a switch of backup buffers in the |
---|
| 1747 | + * resource metadata just prior to unreserving. It's basically a wrapper around |
---|
| 1748 | + * vmw_cmd_res_switch_backup with a different interface. |
---|
1963 | 1749 | */ |
---|
1964 | 1750 | static int vmw_cmd_switch_backup(struct vmw_private *dev_priv, |
---|
1965 | 1751 | struct vmw_sw_context *sw_context, |
---|
1966 | 1752 | enum vmw_res_type res_type, |
---|
1967 | 1753 | const struct vmw_user_resource_conv |
---|
1968 | | - *converter, |
---|
1969 | | - uint32_t *res_id, |
---|
1970 | | - uint32_t *buf_id, |
---|
| 1754 | + *converter, uint32_t *res_id, uint32_t *buf_id, |
---|
1971 | 1755 | unsigned long backup_offset) |
---|
1972 | 1756 | { |
---|
1973 | | - struct vmw_resource_val_node *val_node; |
---|
| 1757 | + struct vmw_resource *res; |
---|
1974 | 1758 | int ret; |
---|
1975 | 1759 | |
---|
1976 | 1760 | ret = vmw_cmd_res_check(dev_priv, sw_context, res_type, |
---|
1977 | | - converter, res_id, &val_node); |
---|
| 1761 | + VMW_RES_DIRTY_NONE, converter, res_id, &res); |
---|
1978 | 1762 | if (ret) |
---|
1979 | 1763 | return ret; |
---|
1980 | 1764 | |
---|
1981 | | - return vmw_cmd_res_switch_backup(dev_priv, sw_context, val_node, |
---|
1982 | | - buf_id, backup_offset); |
---|
| 1765 | + return vmw_cmd_res_switch_backup(dev_priv, sw_context, res, buf_id, |
---|
| 1766 | + backup_offset); |
---|
1983 | 1767 | } |
---|
1984 | 1768 | |
---|
1985 | 1769 | /** |
---|
1986 | | - * vmw_cmd_bind_gb_surface - Validate an SVGA_3D_CMD_BIND_GB_SURFACE |
---|
1987 | | - * command |
---|
| 1770 | + * vmw_cmd_bind_gb_surface - Validate SVGA_3D_CMD_BIND_GB_SURFACE command |
---|
1988 | 1771 | * |
---|
1989 | 1772 | * @dev_priv: Pointer to a device private struct. |
---|
1990 | 1773 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
1994 | 1777 | struct vmw_sw_context *sw_context, |
---|
1995 | 1778 | SVGA3dCmdHeader *header) |
---|
1996 | 1779 | { |
---|
1997 | | - struct vmw_bind_gb_surface_cmd { |
---|
1998 | | - SVGA3dCmdHeader header; |
---|
1999 | | - SVGA3dCmdBindGBSurface body; |
---|
2000 | | - } *cmd; |
---|
2001 | | - |
---|
2002 | | - cmd = container_of(header, struct vmw_bind_gb_surface_cmd, header); |
---|
| 1780 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBindGBSurface) = |
---|
| 1781 | + container_of(header, typeof(*cmd), header); |
---|
2003 | 1782 | |
---|
2004 | 1783 | return vmw_cmd_switch_backup(dev_priv, sw_context, vmw_res_surface, |
---|
2005 | | - user_surface_converter, |
---|
2006 | | - &cmd->body.sid, &cmd->body.mobid, |
---|
2007 | | - 0); |
---|
| 1784 | + user_surface_converter, &cmd->body.sid, |
---|
| 1785 | + &cmd->body.mobid, 0); |
---|
2008 | 1786 | } |
---|
2009 | 1787 | |
---|
2010 | 1788 | /** |
---|
2011 | | - * vmw_cmd_update_gb_image - Validate an SVGA_3D_CMD_UPDATE_GB_IMAGE |
---|
2012 | | - * command |
---|
| 1789 | + * vmw_cmd_update_gb_image - Validate SVGA_3D_CMD_UPDATE_GB_IMAGE command |
---|
2013 | 1790 | * |
---|
2014 | 1791 | * @dev_priv: Pointer to a device private struct. |
---|
2015 | 1792 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2019 | 1796 | struct vmw_sw_context *sw_context, |
---|
2020 | 1797 | SVGA3dCmdHeader *header) |
---|
2021 | 1798 | { |
---|
2022 | | - struct vmw_gb_surface_cmd { |
---|
2023 | | - SVGA3dCmdHeader header; |
---|
2024 | | - SVGA3dCmdUpdateGBImage body; |
---|
2025 | | - } *cmd; |
---|
2026 | | - |
---|
2027 | | - cmd = container_of(header, struct vmw_gb_surface_cmd, header); |
---|
| 1799 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdUpdateGBImage) = |
---|
| 1800 | + container_of(header, typeof(*cmd), header); |
---|
2028 | 1801 | |
---|
2029 | 1802 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
2030 | | - user_surface_converter, |
---|
| 1803 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
2031 | 1804 | &cmd->body.image.sid, NULL); |
---|
2032 | 1805 | } |
---|
2033 | 1806 | |
---|
2034 | 1807 | /** |
---|
2035 | | - * vmw_cmd_update_gb_surface - Validate an SVGA_3D_CMD_UPDATE_GB_SURFACE |
---|
2036 | | - * command |
---|
| 1808 | + * vmw_cmd_update_gb_surface - Validate SVGA_3D_CMD_UPDATE_GB_SURFACE command |
---|
2037 | 1809 | * |
---|
2038 | 1810 | * @dev_priv: Pointer to a device private struct. |
---|
2039 | 1811 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2043 | 1815 | struct vmw_sw_context *sw_context, |
---|
2044 | 1816 | SVGA3dCmdHeader *header) |
---|
2045 | 1817 | { |
---|
2046 | | - struct vmw_gb_surface_cmd { |
---|
2047 | | - SVGA3dCmdHeader header; |
---|
2048 | | - SVGA3dCmdUpdateGBSurface body; |
---|
2049 | | - } *cmd; |
---|
2050 | | - |
---|
2051 | | - cmd = container_of(header, struct vmw_gb_surface_cmd, header); |
---|
| 1818 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdUpdateGBSurface) = |
---|
| 1819 | + container_of(header, typeof(*cmd), header); |
---|
2052 | 1820 | |
---|
2053 | 1821 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
2054 | | - user_surface_converter, |
---|
| 1822 | + VMW_RES_DIRTY_CLEAR, user_surface_converter, |
---|
2055 | 1823 | &cmd->body.sid, NULL); |
---|
2056 | 1824 | } |
---|
2057 | 1825 | |
---|
2058 | 1826 | /** |
---|
2059 | | - * vmw_cmd_readback_gb_image - Validate an SVGA_3D_CMD_READBACK_GB_IMAGE |
---|
2060 | | - * command |
---|
| 1827 | + * vmw_cmd_readback_gb_image - Validate SVGA_3D_CMD_READBACK_GB_IMAGE command |
---|
2061 | 1828 | * |
---|
2062 | 1829 | * @dev_priv: Pointer to a device private struct. |
---|
2063 | 1830 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2067 | 1834 | struct vmw_sw_context *sw_context, |
---|
2068 | 1835 | SVGA3dCmdHeader *header) |
---|
2069 | 1836 | { |
---|
2070 | | - struct vmw_gb_surface_cmd { |
---|
2071 | | - SVGA3dCmdHeader header; |
---|
2072 | | - SVGA3dCmdReadbackGBImage body; |
---|
2073 | | - } *cmd; |
---|
2074 | | - |
---|
2075 | | - cmd = container_of(header, struct vmw_gb_surface_cmd, header); |
---|
| 1837 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdReadbackGBImage) = |
---|
| 1838 | + container_of(header, typeof(*cmd), header); |
---|
2076 | 1839 | |
---|
2077 | 1840 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
2078 | | - user_surface_converter, |
---|
| 1841 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
2079 | 1842 | &cmd->body.image.sid, NULL); |
---|
2080 | 1843 | } |
---|
2081 | 1844 | |
---|
2082 | 1845 | /** |
---|
2083 | | - * vmw_cmd_readback_gb_surface - Validate an SVGA_3D_CMD_READBACK_GB_SURFACE |
---|
| 1846 | + * vmw_cmd_readback_gb_surface - Validate SVGA_3D_CMD_READBACK_GB_SURFACE |
---|
2084 | 1847 | * command |
---|
2085 | 1848 | * |
---|
2086 | 1849 | * @dev_priv: Pointer to a device private struct. |
---|
.. | .. |
---|
2091 | 1854 | struct vmw_sw_context *sw_context, |
---|
2092 | 1855 | SVGA3dCmdHeader *header) |
---|
2093 | 1856 | { |
---|
2094 | | - struct vmw_gb_surface_cmd { |
---|
2095 | | - SVGA3dCmdHeader header; |
---|
2096 | | - SVGA3dCmdReadbackGBSurface body; |
---|
2097 | | - } *cmd; |
---|
2098 | | - |
---|
2099 | | - cmd = container_of(header, struct vmw_gb_surface_cmd, header); |
---|
| 1857 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdReadbackGBSurface) = |
---|
| 1858 | + container_of(header, typeof(*cmd), header); |
---|
2100 | 1859 | |
---|
2101 | 1860 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
2102 | | - user_surface_converter, |
---|
| 1861 | + VMW_RES_DIRTY_CLEAR, user_surface_converter, |
---|
2103 | 1862 | &cmd->body.sid, NULL); |
---|
2104 | 1863 | } |
---|
2105 | 1864 | |
---|
2106 | 1865 | /** |
---|
2107 | | - * vmw_cmd_invalidate_gb_image - Validate an SVGA_3D_CMD_INVALIDATE_GB_IMAGE |
---|
| 1866 | + * vmw_cmd_invalidate_gb_image - Validate SVGA_3D_CMD_INVALIDATE_GB_IMAGE |
---|
2108 | 1867 | * command |
---|
2109 | 1868 | * |
---|
2110 | 1869 | * @dev_priv: Pointer to a device private struct. |
---|
.. | .. |
---|
2115 | 1874 | struct vmw_sw_context *sw_context, |
---|
2116 | 1875 | SVGA3dCmdHeader *header) |
---|
2117 | 1876 | { |
---|
2118 | | - struct vmw_gb_surface_cmd { |
---|
2119 | | - SVGA3dCmdHeader header; |
---|
2120 | | - SVGA3dCmdInvalidateGBImage body; |
---|
2121 | | - } *cmd; |
---|
2122 | | - |
---|
2123 | | - cmd = container_of(header, struct vmw_gb_surface_cmd, header); |
---|
| 1877 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdInvalidateGBImage) = |
---|
| 1878 | + container_of(header, typeof(*cmd), header); |
---|
2124 | 1879 | |
---|
2125 | 1880 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
2126 | | - user_surface_converter, |
---|
| 1881 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
2127 | 1882 | &cmd->body.image.sid, NULL); |
---|
2128 | 1883 | } |
---|
2129 | 1884 | |
---|
2130 | 1885 | /** |
---|
2131 | | - * vmw_cmd_invalidate_gb_surface - Validate an |
---|
2132 | | - * SVGA_3D_CMD_INVALIDATE_GB_SURFACE command |
---|
| 1886 | + * vmw_cmd_invalidate_gb_surface - Validate SVGA_3D_CMD_INVALIDATE_GB_SURFACE |
---|
| 1887 | + * command |
---|
2133 | 1888 | * |
---|
2134 | 1889 | * @dev_priv: Pointer to a device private struct. |
---|
2135 | 1890 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2139 | 1894 | struct vmw_sw_context *sw_context, |
---|
2140 | 1895 | SVGA3dCmdHeader *header) |
---|
2141 | 1896 | { |
---|
2142 | | - struct vmw_gb_surface_cmd { |
---|
2143 | | - SVGA3dCmdHeader header; |
---|
2144 | | - SVGA3dCmdInvalidateGBSurface body; |
---|
2145 | | - } *cmd; |
---|
2146 | | - |
---|
2147 | | - cmd = container_of(header, struct vmw_gb_surface_cmd, header); |
---|
| 1897 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdInvalidateGBSurface) = |
---|
| 1898 | + container_of(header, typeof(*cmd), header); |
---|
2148 | 1899 | |
---|
2149 | 1900 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
2150 | | - user_surface_converter, |
---|
| 1901 | + VMW_RES_DIRTY_CLEAR, user_surface_converter, |
---|
2151 | 1902 | &cmd->body.sid, NULL); |
---|
2152 | 1903 | } |
---|
2153 | 1904 | |
---|
2154 | | - |
---|
2155 | 1905 | /** |
---|
2156 | | - * vmw_cmd_shader_define - Validate an SVGA_3D_CMD_SHADER_DEFINE |
---|
2157 | | - * command |
---|
| 1906 | + * vmw_cmd_shader_define - Validate SVGA_3D_CMD_SHADER_DEFINE command |
---|
2158 | 1907 | * |
---|
2159 | 1908 | * @dev_priv: Pointer to a device private struct. |
---|
2160 | 1909 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2164 | 1913 | struct vmw_sw_context *sw_context, |
---|
2165 | 1914 | SVGA3dCmdHeader *header) |
---|
2166 | 1915 | { |
---|
2167 | | - struct vmw_shader_define_cmd { |
---|
2168 | | - SVGA3dCmdHeader header; |
---|
2169 | | - SVGA3dCmdDefineShader body; |
---|
2170 | | - } *cmd; |
---|
| 1916 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDefineShader); |
---|
2171 | 1917 | int ret; |
---|
2172 | 1918 | size_t size; |
---|
2173 | | - struct vmw_resource_val_node *val; |
---|
| 1919 | + struct vmw_resource *ctx; |
---|
2174 | 1920 | |
---|
2175 | | - cmd = container_of(header, struct vmw_shader_define_cmd, |
---|
2176 | | - header); |
---|
| 1921 | + cmd = container_of(header, typeof(*cmd), header); |
---|
2177 | 1922 | |
---|
2178 | 1923 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, |
---|
2179 | | - user_context_converter, &cmd->body.cid, |
---|
2180 | | - &val); |
---|
| 1924 | + VMW_RES_DIRTY_SET, user_context_converter, |
---|
| 1925 | + &cmd->body.cid, &ctx); |
---|
2181 | 1926 | if (unlikely(ret != 0)) |
---|
2182 | 1927 | return ret; |
---|
2183 | 1928 | |
---|
.. | .. |
---|
2185 | 1930 | return 0; |
---|
2186 | 1931 | |
---|
2187 | 1932 | size = cmd->header.size - sizeof(cmd->body); |
---|
2188 | | - ret = vmw_compat_shader_add(dev_priv, |
---|
2189 | | - vmw_context_res_man(val->res), |
---|
2190 | | - cmd->body.shid, cmd + 1, |
---|
2191 | | - cmd->body.type, size, |
---|
2192 | | - &sw_context->staged_cmd_res); |
---|
| 1933 | + ret = vmw_compat_shader_add(dev_priv, vmw_context_res_man(ctx), |
---|
| 1934 | + cmd->body.shid, cmd + 1, cmd->body.type, |
---|
| 1935 | + size, &sw_context->staged_cmd_res); |
---|
2193 | 1936 | if (unlikely(ret != 0)) |
---|
2194 | 1937 | return ret; |
---|
2195 | 1938 | |
---|
2196 | | - return vmw_resource_relocation_add(&sw_context->res_relocations, |
---|
2197 | | - NULL, |
---|
| 1939 | + return vmw_resource_relocation_add(sw_context, NULL, |
---|
2198 | 1940 | vmw_ptr_diff(sw_context->buf_start, |
---|
2199 | 1941 | &cmd->header.id), |
---|
2200 | 1942 | vmw_res_rel_nop); |
---|
2201 | 1943 | } |
---|
2202 | 1944 | |
---|
2203 | 1945 | /** |
---|
2204 | | - * vmw_cmd_shader_destroy - Validate an SVGA_3D_CMD_SHADER_DESTROY |
---|
2205 | | - * command |
---|
| 1946 | + * vmw_cmd_shader_destroy - Validate SVGA_3D_CMD_SHADER_DESTROY command |
---|
2206 | 1947 | * |
---|
2207 | 1948 | * @dev_priv: Pointer to a device private struct. |
---|
2208 | 1949 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2212 | 1953 | struct vmw_sw_context *sw_context, |
---|
2213 | 1954 | SVGA3dCmdHeader *header) |
---|
2214 | 1955 | { |
---|
2215 | | - struct vmw_shader_destroy_cmd { |
---|
2216 | | - SVGA3dCmdHeader header; |
---|
2217 | | - SVGA3dCmdDestroyShader body; |
---|
2218 | | - } *cmd; |
---|
| 1956 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDestroyShader); |
---|
2219 | 1957 | int ret; |
---|
2220 | | - struct vmw_resource_val_node *val; |
---|
| 1958 | + struct vmw_resource *ctx; |
---|
2221 | 1959 | |
---|
2222 | | - cmd = container_of(header, struct vmw_shader_destroy_cmd, |
---|
2223 | | - header); |
---|
| 1960 | + cmd = container_of(header, typeof(*cmd), header); |
---|
2224 | 1961 | |
---|
2225 | 1962 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, |
---|
2226 | | - user_context_converter, &cmd->body.cid, |
---|
2227 | | - &val); |
---|
| 1963 | + VMW_RES_DIRTY_SET, user_context_converter, |
---|
| 1964 | + &cmd->body.cid, &ctx); |
---|
2228 | 1965 | if (unlikely(ret != 0)) |
---|
2229 | 1966 | return ret; |
---|
2230 | 1967 | |
---|
2231 | 1968 | if (unlikely(!dev_priv->has_mob)) |
---|
2232 | 1969 | return 0; |
---|
2233 | 1970 | |
---|
2234 | | - ret = vmw_shader_remove(vmw_context_res_man(val->res), |
---|
2235 | | - cmd->body.shid, |
---|
2236 | | - cmd->body.type, |
---|
2237 | | - &sw_context->staged_cmd_res); |
---|
| 1971 | + ret = vmw_shader_remove(vmw_context_res_man(ctx), cmd->body.shid, |
---|
| 1972 | + cmd->body.type, &sw_context->staged_cmd_res); |
---|
2238 | 1973 | if (unlikely(ret != 0)) |
---|
2239 | 1974 | return ret; |
---|
2240 | 1975 | |
---|
2241 | | - return vmw_resource_relocation_add(&sw_context->res_relocations, |
---|
2242 | | - NULL, |
---|
| 1976 | + return vmw_resource_relocation_add(sw_context, NULL, |
---|
2243 | 1977 | vmw_ptr_diff(sw_context->buf_start, |
---|
2244 | 1978 | &cmd->header.id), |
---|
2245 | 1979 | vmw_res_rel_nop); |
---|
2246 | 1980 | } |
---|
2247 | 1981 | |
---|
2248 | 1982 | /** |
---|
2249 | | - * vmw_cmd_set_shader - Validate an SVGA_3D_CMD_SET_SHADER |
---|
2250 | | - * command |
---|
| 1983 | + * vmw_cmd_set_shader - Validate SVGA_3D_CMD_SET_SHADER command |
---|
2251 | 1984 | * |
---|
2252 | 1985 | * @dev_priv: Pointer to a device private struct. |
---|
2253 | 1986 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2257 | 1990 | struct vmw_sw_context *sw_context, |
---|
2258 | 1991 | SVGA3dCmdHeader *header) |
---|
2259 | 1992 | { |
---|
2260 | | - struct vmw_set_shader_cmd { |
---|
2261 | | - SVGA3dCmdHeader header; |
---|
2262 | | - SVGA3dCmdSetShader body; |
---|
2263 | | - } *cmd; |
---|
2264 | | - struct vmw_resource_val_node *ctx_node, *res_node = NULL; |
---|
| 1993 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdSetShader); |
---|
2265 | 1994 | struct vmw_ctx_bindinfo_shader binding; |
---|
2266 | | - struct vmw_resource *res = NULL; |
---|
| 1995 | + struct vmw_resource *ctx, *res = NULL; |
---|
| 1996 | + struct vmw_ctx_validation_info *ctx_info; |
---|
2267 | 1997 | int ret; |
---|
2268 | 1998 | |
---|
2269 | | - cmd = container_of(header, struct vmw_set_shader_cmd, |
---|
2270 | | - header); |
---|
| 1999 | + cmd = container_of(header, typeof(*cmd), header); |
---|
2271 | 2000 | |
---|
2272 | | - if (cmd->body.type >= SVGA3D_SHADERTYPE_PREDX_MAX) { |
---|
2273 | | - DRM_ERROR("Illegal shader type %u.\n", |
---|
2274 | | - (unsigned) cmd->body.type); |
---|
| 2001 | + if (!vmw_shadertype_is_valid(VMW_SM_LEGACY, cmd->body.type)) { |
---|
| 2002 | + VMW_DEBUG_USER("Illegal shader type %u.\n", |
---|
| 2003 | + (unsigned int) cmd->body.type); |
---|
2275 | 2004 | return -EINVAL; |
---|
2276 | 2005 | } |
---|
2277 | 2006 | |
---|
2278 | 2007 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, |
---|
2279 | | - user_context_converter, &cmd->body.cid, |
---|
2280 | | - &ctx_node); |
---|
| 2008 | + VMW_RES_DIRTY_SET, user_context_converter, |
---|
| 2009 | + &cmd->body.cid, &ctx); |
---|
2281 | 2010 | if (unlikely(ret != 0)) |
---|
2282 | 2011 | return ret; |
---|
2283 | 2012 | |
---|
.. | .. |
---|
2285 | 2014 | return 0; |
---|
2286 | 2015 | |
---|
2287 | 2016 | if (cmd->body.shid != SVGA3D_INVALID_ID) { |
---|
2288 | | - res = vmw_shader_lookup(vmw_context_res_man(ctx_node->res), |
---|
2289 | | - cmd->body.shid, |
---|
2290 | | - cmd->body.type); |
---|
2291 | | - |
---|
| 2017 | + /* |
---|
| 2018 | + * This is the compat shader path - Per device guest-backed |
---|
| 2019 | + * shaders, but user-space thinks it's per context host- |
---|
| 2020 | + * backed shaders. |
---|
| 2021 | + */ |
---|
| 2022 | + res = vmw_shader_lookup(vmw_context_res_man(ctx), |
---|
| 2023 | + cmd->body.shid, cmd->body.type); |
---|
2292 | 2024 | if (!IS_ERR(res)) { |
---|
2293 | | - ret = vmw_cmd_res_reloc_add(dev_priv, sw_context, |
---|
2294 | | - &cmd->body.shid, res, |
---|
2295 | | - &res_node); |
---|
2296 | | - vmw_resource_unreference(&res); |
---|
| 2025 | + ret = vmw_execbuf_res_noctx_val_add(sw_context, res, |
---|
| 2026 | + VMW_RES_DIRTY_NONE); |
---|
| 2027 | + if (unlikely(ret != 0)) |
---|
| 2028 | + return ret; |
---|
| 2029 | + |
---|
| 2030 | + ret = vmw_resource_relocation_add |
---|
| 2031 | + (sw_context, res, |
---|
| 2032 | + vmw_ptr_diff(sw_context->buf_start, |
---|
| 2033 | + &cmd->body.shid), |
---|
| 2034 | + vmw_res_rel_normal); |
---|
2297 | 2035 | if (unlikely(ret != 0)) |
---|
2298 | 2036 | return ret; |
---|
2299 | 2037 | } |
---|
2300 | 2038 | } |
---|
2301 | 2039 | |
---|
2302 | | - if (!res_node) { |
---|
2303 | | - ret = vmw_cmd_res_check(dev_priv, sw_context, |
---|
2304 | | - vmw_res_shader, |
---|
2305 | | - user_shader_converter, |
---|
2306 | | - &cmd->body.shid, &res_node); |
---|
| 2040 | + if (IS_ERR_OR_NULL(res)) { |
---|
| 2041 | + ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_shader, |
---|
| 2042 | + VMW_RES_DIRTY_NONE, |
---|
| 2043 | + user_shader_converter, &cmd->body.shid, |
---|
| 2044 | + &res); |
---|
2307 | 2045 | if (unlikely(ret != 0)) |
---|
2308 | 2046 | return ret; |
---|
2309 | 2047 | } |
---|
2310 | 2048 | |
---|
2311 | | - binding.bi.ctx = ctx_node->res; |
---|
2312 | | - binding.bi.res = res_node ? res_node->res : NULL; |
---|
| 2049 | + ctx_info = vmw_execbuf_info_from_res(sw_context, ctx); |
---|
| 2050 | + if (!ctx_info) |
---|
| 2051 | + return -EINVAL; |
---|
| 2052 | + |
---|
| 2053 | + binding.bi.ctx = ctx; |
---|
| 2054 | + binding.bi.res = res; |
---|
2313 | 2055 | binding.bi.bt = vmw_ctx_binding_shader; |
---|
2314 | 2056 | binding.shader_slot = cmd->body.type - SVGA3D_SHADERTYPE_MIN; |
---|
2315 | | - vmw_binding_add(ctx_node->staged_bindings, &binding.bi, |
---|
2316 | | - binding.shader_slot, 0); |
---|
| 2057 | + vmw_binding_add(ctx_info->staged, &binding.bi, binding.shader_slot, 0); |
---|
| 2058 | + |
---|
2317 | 2059 | return 0; |
---|
2318 | 2060 | } |
---|
2319 | 2061 | |
---|
2320 | 2062 | /** |
---|
2321 | | - * vmw_cmd_set_shader_const - Validate an SVGA_3D_CMD_SET_SHADER_CONST |
---|
2322 | | - * command |
---|
| 2063 | + * vmw_cmd_set_shader_const - Validate SVGA_3D_CMD_SET_SHADER_CONST command |
---|
2323 | 2064 | * |
---|
2324 | 2065 | * @dev_priv: Pointer to a device private struct. |
---|
2325 | 2066 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2329 | 2070 | struct vmw_sw_context *sw_context, |
---|
2330 | 2071 | SVGA3dCmdHeader *header) |
---|
2331 | 2072 | { |
---|
2332 | | - struct vmw_set_shader_const_cmd { |
---|
2333 | | - SVGA3dCmdHeader header; |
---|
2334 | | - SVGA3dCmdSetShaderConst body; |
---|
2335 | | - } *cmd; |
---|
| 2073 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdSetShaderConst); |
---|
2336 | 2074 | int ret; |
---|
2337 | 2075 | |
---|
2338 | | - cmd = container_of(header, struct vmw_set_shader_const_cmd, |
---|
2339 | | - header); |
---|
| 2076 | + cmd = container_of(header, typeof(*cmd), header); |
---|
2340 | 2077 | |
---|
2341 | 2078 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, |
---|
2342 | | - user_context_converter, &cmd->body.cid, |
---|
2343 | | - NULL); |
---|
| 2079 | + VMW_RES_DIRTY_SET, user_context_converter, |
---|
| 2080 | + &cmd->body.cid, NULL); |
---|
2344 | 2081 | if (unlikely(ret != 0)) |
---|
2345 | 2082 | return ret; |
---|
2346 | 2083 | |
---|
.. | .. |
---|
2351 | 2088 | } |
---|
2352 | 2089 | |
---|
2353 | 2090 | /** |
---|
2354 | | - * vmw_cmd_bind_gb_shader - Validate an SVGA_3D_CMD_BIND_GB_SHADER |
---|
2355 | | - * command |
---|
| 2091 | + * vmw_cmd_bind_gb_shader - Validate SVGA_3D_CMD_BIND_GB_SHADER command |
---|
2356 | 2092 | * |
---|
2357 | 2093 | * @dev_priv: Pointer to a device private struct. |
---|
2358 | 2094 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2362 | 2098 | struct vmw_sw_context *sw_context, |
---|
2363 | 2099 | SVGA3dCmdHeader *header) |
---|
2364 | 2100 | { |
---|
2365 | | - struct vmw_bind_gb_shader_cmd { |
---|
2366 | | - SVGA3dCmdHeader header; |
---|
2367 | | - SVGA3dCmdBindGBShader body; |
---|
2368 | | - } *cmd; |
---|
2369 | | - |
---|
2370 | | - cmd = container_of(header, struct vmw_bind_gb_shader_cmd, |
---|
2371 | | - header); |
---|
| 2101 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBindGBShader) = |
---|
| 2102 | + container_of(header, typeof(*cmd), header); |
---|
2372 | 2103 | |
---|
2373 | 2104 | return vmw_cmd_switch_backup(dev_priv, sw_context, vmw_res_shader, |
---|
2374 | | - user_shader_converter, |
---|
2375 | | - &cmd->body.shid, &cmd->body.mobid, |
---|
2376 | | - cmd->body.offsetInBytes); |
---|
| 2105 | + user_shader_converter, &cmd->body.shid, |
---|
| 2106 | + &cmd->body.mobid, cmd->body.offsetInBytes); |
---|
2377 | 2107 | } |
---|
2378 | 2108 | |
---|
2379 | 2109 | /** |
---|
2380 | | - * vmw_cmd_dx_set_single_constant_buffer - Validate an |
---|
| 2110 | + * vmw_cmd_dx_set_single_constant_buffer - Validate |
---|
2381 | 2111 | * SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER command. |
---|
2382 | 2112 | * |
---|
2383 | 2113 | * @dev_priv: Pointer to a device private struct. |
---|
.. | .. |
---|
2389 | 2119 | struct vmw_sw_context *sw_context, |
---|
2390 | 2120 | SVGA3dCmdHeader *header) |
---|
2391 | 2121 | { |
---|
2392 | | - struct { |
---|
2393 | | - SVGA3dCmdHeader header; |
---|
2394 | | - SVGA3dCmdDXSetSingleConstantBuffer body; |
---|
2395 | | - } *cmd; |
---|
2396 | | - struct vmw_resource_val_node *res_node = NULL; |
---|
2397 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
| 2122 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXSetSingleConstantBuffer); |
---|
| 2123 | + |
---|
| 2124 | + struct vmw_resource *res = NULL; |
---|
| 2125 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
2398 | 2126 | struct vmw_ctx_bindinfo_cb binding; |
---|
2399 | 2127 | int ret; |
---|
2400 | 2128 | |
---|
2401 | | - if (unlikely(ctx_node == NULL)) { |
---|
2402 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2129 | + if (!ctx_node) |
---|
2403 | 2130 | return -EINVAL; |
---|
2404 | | - } |
---|
2405 | 2131 | |
---|
2406 | 2132 | cmd = container_of(header, typeof(*cmd), header); |
---|
2407 | 2133 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
2408 | | - user_surface_converter, |
---|
2409 | | - &cmd->body.sid, &res_node); |
---|
| 2134 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
| 2135 | + &cmd->body.sid, &res); |
---|
2410 | 2136 | if (unlikely(ret != 0)) |
---|
2411 | 2137 | return ret; |
---|
2412 | 2138 | |
---|
2413 | | - binding.bi.ctx = ctx_node->res; |
---|
2414 | | - binding.bi.res = res_node ? res_node->res : NULL; |
---|
| 2139 | + if (!vmw_shadertype_is_valid(dev_priv->sm_type, cmd->body.type) || |
---|
| 2140 | + cmd->body.slot >= SVGA3D_DX_MAX_CONSTBUFFERS) { |
---|
| 2141 | + VMW_DEBUG_USER("Illegal const buffer shader %u slot %u.\n", |
---|
| 2142 | + (unsigned int) cmd->body.type, |
---|
| 2143 | + (unsigned int) cmd->body.slot); |
---|
| 2144 | + return -EINVAL; |
---|
| 2145 | + } |
---|
| 2146 | + |
---|
| 2147 | + binding.bi.ctx = ctx_node->ctx; |
---|
| 2148 | + binding.bi.res = res; |
---|
2415 | 2149 | binding.bi.bt = vmw_ctx_binding_cb; |
---|
2416 | 2150 | binding.shader_slot = cmd->body.type - SVGA3D_SHADERTYPE_MIN; |
---|
2417 | 2151 | binding.offset = cmd->body.offsetInBytes; |
---|
2418 | 2152 | binding.size = cmd->body.sizeInBytes; |
---|
2419 | 2153 | binding.slot = cmd->body.slot; |
---|
2420 | 2154 | |
---|
2421 | | - if (binding.shader_slot >= SVGA3D_NUM_SHADERTYPE_DX10 || |
---|
2422 | | - binding.slot >= SVGA3D_DX_MAX_CONSTBUFFERS) { |
---|
2423 | | - DRM_ERROR("Illegal const buffer shader %u slot %u.\n", |
---|
2424 | | - (unsigned) cmd->body.type, |
---|
2425 | | - (unsigned) binding.slot); |
---|
2426 | | - return -EINVAL; |
---|
2427 | | - } |
---|
2428 | | - |
---|
2429 | | - vmw_binding_add(ctx_node->staged_bindings, &binding.bi, |
---|
2430 | | - binding.shader_slot, binding.slot); |
---|
| 2155 | + vmw_binding_add(ctx_node->staged, &binding.bi, binding.shader_slot, |
---|
| 2156 | + binding.slot); |
---|
2431 | 2157 | |
---|
2432 | 2158 | return 0; |
---|
2433 | 2159 | } |
---|
2434 | 2160 | |
---|
2435 | 2161 | /** |
---|
2436 | | - * vmw_cmd_dx_set_shader_res - Validate an |
---|
2437 | | - * SVGA_3D_CMD_DX_SET_SHADER_RESOURCES command |
---|
| 2162 | + * vmw_cmd_dx_set_shader_res - Validate SVGA_3D_CMD_DX_SET_SHADER_RESOURCES |
---|
| 2163 | + * command |
---|
2438 | 2164 | * |
---|
2439 | 2165 | * @dev_priv: Pointer to a device private struct. |
---|
2440 | 2166 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2444 | 2170 | struct vmw_sw_context *sw_context, |
---|
2445 | 2171 | SVGA3dCmdHeader *header) |
---|
2446 | 2172 | { |
---|
2447 | | - struct { |
---|
2448 | | - SVGA3dCmdHeader header; |
---|
2449 | | - SVGA3dCmdDXSetShaderResources body; |
---|
2450 | | - } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2173 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXSetShaderResources) = |
---|
| 2174 | + container_of(header, typeof(*cmd), header); |
---|
| 2175 | + |
---|
2451 | 2176 | u32 num_sr_view = (cmd->header.size - sizeof(cmd->body)) / |
---|
2452 | 2177 | sizeof(SVGA3dShaderResourceViewId); |
---|
2453 | 2178 | |
---|
2454 | 2179 | if ((u64) cmd->body.startView + (u64) num_sr_view > |
---|
2455 | 2180 | (u64) SVGA3D_DX_MAX_SRVIEWS || |
---|
2456 | | - cmd->body.type >= SVGA3D_SHADERTYPE_DX10_MAX) { |
---|
2457 | | - DRM_ERROR("Invalid shader binding.\n"); |
---|
| 2181 | + !vmw_shadertype_is_valid(dev_priv->sm_type, cmd->body.type)) { |
---|
| 2182 | + VMW_DEBUG_USER("Invalid shader binding.\n"); |
---|
2458 | 2183 | return -EINVAL; |
---|
2459 | 2184 | } |
---|
2460 | 2185 | |
---|
.. | .. |
---|
2466 | 2191 | } |
---|
2467 | 2192 | |
---|
2468 | 2193 | /** |
---|
2469 | | - * vmw_cmd_dx_set_shader - Validate an SVGA_3D_CMD_DX_SET_SHADER |
---|
2470 | | - * command |
---|
| 2194 | + * vmw_cmd_dx_set_shader - Validate SVGA_3D_CMD_DX_SET_SHADER command |
---|
2471 | 2195 | * |
---|
2472 | 2196 | * @dev_priv: Pointer to a device private struct. |
---|
2473 | 2197 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2477 | 2201 | struct vmw_sw_context *sw_context, |
---|
2478 | 2202 | SVGA3dCmdHeader *header) |
---|
2479 | 2203 | { |
---|
2480 | | - struct { |
---|
2481 | | - SVGA3dCmdHeader header; |
---|
2482 | | - SVGA3dCmdDXSetShader body; |
---|
2483 | | - } *cmd; |
---|
| 2204 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXSetShader); |
---|
2484 | 2205 | struct vmw_resource *res = NULL; |
---|
2485 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
| 2206 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
2486 | 2207 | struct vmw_ctx_bindinfo_shader binding; |
---|
2487 | 2208 | int ret = 0; |
---|
2488 | 2209 | |
---|
2489 | | - if (unlikely(ctx_node == NULL)) { |
---|
2490 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2210 | + if (!ctx_node) |
---|
2491 | 2211 | return -EINVAL; |
---|
2492 | | - } |
---|
2493 | 2212 | |
---|
2494 | 2213 | cmd = container_of(header, typeof(*cmd), header); |
---|
2495 | 2214 | |
---|
2496 | | - if (cmd->body.type >= SVGA3D_SHADERTYPE_DX10_MAX || |
---|
2497 | | - cmd->body.type < SVGA3D_SHADERTYPE_MIN) { |
---|
2498 | | - DRM_ERROR("Illegal shader type %u.\n", |
---|
2499 | | - (unsigned) cmd->body.type); |
---|
| 2215 | + if (!vmw_shadertype_is_valid(dev_priv->sm_type, cmd->body.type)) { |
---|
| 2216 | + VMW_DEBUG_USER("Illegal shader type %u.\n", |
---|
| 2217 | + (unsigned int) cmd->body.type); |
---|
2500 | 2218 | return -EINVAL; |
---|
2501 | 2219 | } |
---|
2502 | 2220 | |
---|
2503 | 2221 | if (cmd->body.shaderId != SVGA3D_INVALID_ID) { |
---|
2504 | 2222 | res = vmw_shader_lookup(sw_context->man, cmd->body.shaderId, 0); |
---|
2505 | 2223 | if (IS_ERR(res)) { |
---|
2506 | | - DRM_ERROR("Could not find shader for binding.\n"); |
---|
| 2224 | + VMW_DEBUG_USER("Could not find shader for binding.\n"); |
---|
2507 | 2225 | return PTR_ERR(res); |
---|
2508 | 2226 | } |
---|
2509 | 2227 | |
---|
2510 | | - ret = vmw_resource_val_add(sw_context, res, NULL); |
---|
| 2228 | + ret = vmw_execbuf_res_noctx_val_add(sw_context, res, |
---|
| 2229 | + VMW_RES_DIRTY_NONE); |
---|
2511 | 2230 | if (ret) |
---|
2512 | | - goto out_unref; |
---|
| 2231 | + return ret; |
---|
2513 | 2232 | } |
---|
2514 | 2233 | |
---|
2515 | | - binding.bi.ctx = ctx_node->res; |
---|
| 2234 | + binding.bi.ctx = ctx_node->ctx; |
---|
2516 | 2235 | binding.bi.res = res; |
---|
2517 | 2236 | binding.bi.bt = vmw_ctx_binding_dx_shader; |
---|
2518 | 2237 | binding.shader_slot = cmd->body.type - SVGA3D_SHADERTYPE_MIN; |
---|
2519 | 2238 | |
---|
2520 | | - vmw_binding_add(ctx_node->staged_bindings, &binding.bi, |
---|
2521 | | - binding.shader_slot, 0); |
---|
2522 | | -out_unref: |
---|
2523 | | - if (res) |
---|
2524 | | - vmw_resource_unreference(&res); |
---|
| 2239 | + vmw_binding_add(ctx_node->staged, &binding.bi, binding.shader_slot, 0); |
---|
2525 | 2240 | |
---|
2526 | | - return ret; |
---|
| 2241 | + return 0; |
---|
2527 | 2242 | } |
---|
2528 | 2243 | |
---|
2529 | 2244 | /** |
---|
2530 | | - * vmw_cmd_dx_set_vertex_buffers - Validates an |
---|
2531 | | - * SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS command |
---|
| 2245 | + * vmw_cmd_dx_set_vertex_buffers - Validates SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS |
---|
| 2246 | + * command |
---|
2532 | 2247 | * |
---|
2533 | 2248 | * @dev_priv: Pointer to a device private struct. |
---|
2534 | 2249 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2538 | 2253 | struct vmw_sw_context *sw_context, |
---|
2539 | 2254 | SVGA3dCmdHeader *header) |
---|
2540 | 2255 | { |
---|
2541 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
| 2256 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
2542 | 2257 | struct vmw_ctx_bindinfo_vb binding; |
---|
2543 | | - struct vmw_resource_val_node *res_node; |
---|
| 2258 | + struct vmw_resource *res; |
---|
2544 | 2259 | struct { |
---|
2545 | 2260 | SVGA3dCmdHeader header; |
---|
2546 | 2261 | SVGA3dCmdDXSetVertexBuffers body; |
---|
.. | .. |
---|
2548 | 2263 | } *cmd; |
---|
2549 | 2264 | int i, ret, num; |
---|
2550 | 2265 | |
---|
2551 | | - if (unlikely(ctx_node == NULL)) { |
---|
2552 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2266 | + if (!ctx_node) |
---|
2553 | 2267 | return -EINVAL; |
---|
2554 | | - } |
---|
2555 | 2268 | |
---|
2556 | 2269 | cmd = container_of(header, typeof(*cmd), header); |
---|
2557 | 2270 | num = (cmd->header.size - sizeof(cmd->body)) / |
---|
2558 | 2271 | sizeof(SVGA3dVertexBuffer); |
---|
2559 | 2272 | if ((u64)num + (u64)cmd->body.startBuffer > |
---|
2560 | 2273 | (u64)SVGA3D_DX_MAX_VERTEXBUFFERS) { |
---|
2561 | | - DRM_ERROR("Invalid number of vertex buffers.\n"); |
---|
| 2274 | + VMW_DEBUG_USER("Invalid number of vertex buffers.\n"); |
---|
2562 | 2275 | return -EINVAL; |
---|
2563 | 2276 | } |
---|
2564 | 2277 | |
---|
2565 | 2278 | for (i = 0; i < num; i++) { |
---|
2566 | 2279 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
| 2280 | + VMW_RES_DIRTY_NONE, |
---|
2567 | 2281 | user_surface_converter, |
---|
2568 | | - &cmd->buf[i].sid, &res_node); |
---|
| 2282 | + &cmd->buf[i].sid, &res); |
---|
2569 | 2283 | if (unlikely(ret != 0)) |
---|
2570 | 2284 | return ret; |
---|
2571 | 2285 | |
---|
2572 | | - binding.bi.ctx = ctx_node->res; |
---|
| 2286 | + binding.bi.ctx = ctx_node->ctx; |
---|
2573 | 2287 | binding.bi.bt = vmw_ctx_binding_vb; |
---|
2574 | | - binding.bi.res = ((res_node) ? res_node->res : NULL); |
---|
| 2288 | + binding.bi.res = res; |
---|
2575 | 2289 | binding.offset = cmd->buf[i].offset; |
---|
2576 | 2290 | binding.stride = cmd->buf[i].stride; |
---|
2577 | 2291 | binding.slot = i + cmd->body.startBuffer; |
---|
2578 | 2292 | |
---|
2579 | | - vmw_binding_add(ctx_node->staged_bindings, &binding.bi, |
---|
2580 | | - 0, binding.slot); |
---|
| 2293 | + vmw_binding_add(ctx_node->staged, &binding.bi, 0, binding.slot); |
---|
2581 | 2294 | } |
---|
2582 | 2295 | |
---|
2583 | 2296 | return 0; |
---|
2584 | 2297 | } |
---|
2585 | 2298 | |
---|
2586 | 2299 | /** |
---|
2587 | | - * vmw_cmd_dx_ia_set_vertex_buffers - Validate an |
---|
| 2300 | + * vmw_cmd_dx_ia_set_vertex_buffers - Validate |
---|
2588 | 2301 | * SVGA_3D_CMD_DX_IA_SET_INDEX_BUFFER command. |
---|
2589 | 2302 | * |
---|
2590 | 2303 | * @dev_priv: Pointer to a device private struct. |
---|
.. | .. |
---|
2595 | 2308 | struct vmw_sw_context *sw_context, |
---|
2596 | 2309 | SVGA3dCmdHeader *header) |
---|
2597 | 2310 | { |
---|
2598 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
| 2311 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
2599 | 2312 | struct vmw_ctx_bindinfo_ib binding; |
---|
2600 | | - struct vmw_resource_val_node *res_node; |
---|
2601 | | - struct { |
---|
2602 | | - SVGA3dCmdHeader header; |
---|
2603 | | - SVGA3dCmdDXSetIndexBuffer body; |
---|
2604 | | - } *cmd; |
---|
| 2313 | + struct vmw_resource *res; |
---|
| 2314 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXSetIndexBuffer); |
---|
2605 | 2315 | int ret; |
---|
2606 | 2316 | |
---|
2607 | | - if (unlikely(ctx_node == NULL)) { |
---|
2608 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2317 | + if (!ctx_node) |
---|
2609 | 2318 | return -EINVAL; |
---|
2610 | | - } |
---|
2611 | 2319 | |
---|
2612 | 2320 | cmd = container_of(header, typeof(*cmd), header); |
---|
2613 | 2321 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
2614 | | - user_surface_converter, |
---|
2615 | | - &cmd->body.sid, &res_node); |
---|
| 2322 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
| 2323 | + &cmd->body.sid, &res); |
---|
2616 | 2324 | if (unlikely(ret != 0)) |
---|
2617 | 2325 | return ret; |
---|
2618 | 2326 | |
---|
2619 | | - binding.bi.ctx = ctx_node->res; |
---|
2620 | | - binding.bi.res = ((res_node) ? res_node->res : NULL); |
---|
| 2327 | + binding.bi.ctx = ctx_node->ctx; |
---|
| 2328 | + binding.bi.res = res; |
---|
2621 | 2329 | binding.bi.bt = vmw_ctx_binding_ib; |
---|
2622 | 2330 | binding.offset = cmd->body.offset; |
---|
2623 | 2331 | binding.format = cmd->body.format; |
---|
2624 | 2332 | |
---|
2625 | | - vmw_binding_add(ctx_node->staged_bindings, &binding.bi, 0, 0); |
---|
| 2333 | + vmw_binding_add(ctx_node->staged, &binding.bi, 0, 0); |
---|
2626 | 2334 | |
---|
2627 | 2335 | return 0; |
---|
2628 | 2336 | } |
---|
2629 | 2337 | |
---|
2630 | 2338 | /** |
---|
2631 | | - * vmw_cmd_dx_set_rendertarget - Validate an |
---|
2632 | | - * SVGA_3D_CMD_DX_SET_RENDERTARGETS command |
---|
| 2339 | + * vmw_cmd_dx_set_rendertarget - Validate SVGA_3D_CMD_DX_SET_RENDERTARGETS |
---|
| 2340 | + * command |
---|
2633 | 2341 | * |
---|
2634 | 2342 | * @dev_priv: Pointer to a device private struct. |
---|
2635 | 2343 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2639 | 2347 | struct vmw_sw_context *sw_context, |
---|
2640 | 2348 | SVGA3dCmdHeader *header) |
---|
2641 | 2349 | { |
---|
2642 | | - struct { |
---|
2643 | | - SVGA3dCmdHeader header; |
---|
2644 | | - SVGA3dCmdDXSetRenderTargets body; |
---|
2645 | | - } *cmd = container_of(header, typeof(*cmd), header); |
---|
2646 | | - int ret; |
---|
| 2350 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXSetRenderTargets) = |
---|
| 2351 | + container_of(header, typeof(*cmd), header); |
---|
2647 | 2352 | u32 num_rt_view = (cmd->header.size - sizeof(cmd->body)) / |
---|
2648 | 2353 | sizeof(SVGA3dRenderTargetViewId); |
---|
| 2354 | + int ret; |
---|
2649 | 2355 | |
---|
2650 | 2356 | if (num_rt_view > SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS) { |
---|
2651 | | - DRM_ERROR("Invalid DX Rendertarget binding.\n"); |
---|
| 2357 | + VMW_DEBUG_USER("Invalid DX Rendertarget binding.\n"); |
---|
2652 | 2358 | return -EINVAL; |
---|
2653 | 2359 | } |
---|
2654 | 2360 | |
---|
2655 | | - ret = vmw_view_bindings_add(sw_context, vmw_view_ds, |
---|
2656 | | - vmw_ctx_binding_ds, 0, |
---|
2657 | | - &cmd->body.depthStencilViewId, 1, 0); |
---|
| 2361 | + ret = vmw_view_bindings_add(sw_context, vmw_view_ds, vmw_ctx_binding_ds, |
---|
| 2362 | + 0, &cmd->body.depthStencilViewId, 1, 0); |
---|
2658 | 2363 | if (ret) |
---|
2659 | 2364 | return ret; |
---|
2660 | 2365 | |
---|
2661 | 2366 | return vmw_view_bindings_add(sw_context, vmw_view_rt, |
---|
2662 | | - vmw_ctx_binding_dx_rt, 0, |
---|
2663 | | - (void *)&cmd[1], num_rt_view, 0); |
---|
| 2367 | + vmw_ctx_binding_dx_rt, 0, (void *)&cmd[1], |
---|
| 2368 | + num_rt_view, 0); |
---|
2664 | 2369 | } |
---|
2665 | 2370 | |
---|
2666 | 2371 | /** |
---|
2667 | | - * vmw_cmd_dx_clear_rendertarget_view - Validate an |
---|
| 2372 | + * vmw_cmd_dx_clear_rendertarget_view - Validate |
---|
2668 | 2373 | * SVGA_3D_CMD_DX_CLEAR_RENDERTARGET_VIEW command |
---|
2669 | 2374 | * |
---|
2670 | 2375 | * @dev_priv: Pointer to a device private struct. |
---|
.. | .. |
---|
2675 | 2380 | struct vmw_sw_context *sw_context, |
---|
2676 | 2381 | SVGA3dCmdHeader *header) |
---|
2677 | 2382 | { |
---|
2678 | | - struct { |
---|
2679 | | - SVGA3dCmdHeader header; |
---|
2680 | | - SVGA3dCmdDXClearRenderTargetView body; |
---|
2681 | | - } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2383 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXClearRenderTargetView) = |
---|
| 2384 | + container_of(header, typeof(*cmd), header); |
---|
| 2385 | + struct vmw_resource *ret; |
---|
2682 | 2386 | |
---|
2683 | | - return vmw_view_id_val_add(sw_context, vmw_view_rt, |
---|
2684 | | - cmd->body.renderTargetViewId); |
---|
| 2387 | + ret = vmw_view_id_val_add(sw_context, vmw_view_rt, |
---|
| 2388 | + cmd->body.renderTargetViewId); |
---|
| 2389 | + |
---|
| 2390 | + return PTR_ERR_OR_ZERO(ret); |
---|
2685 | 2391 | } |
---|
2686 | 2392 | |
---|
2687 | 2393 | /** |
---|
2688 | | - * vmw_cmd_dx_clear_rendertarget_view - Validate an |
---|
| 2394 | + * vmw_cmd_dx_clear_rendertarget_view - Validate |
---|
2689 | 2395 | * SVGA_3D_CMD_DX_CLEAR_DEPTHSTENCIL_VIEW command |
---|
2690 | 2396 | * |
---|
2691 | 2397 | * @dev_priv: Pointer to a device private struct. |
---|
.. | .. |
---|
2696 | 2402 | struct vmw_sw_context *sw_context, |
---|
2697 | 2403 | SVGA3dCmdHeader *header) |
---|
2698 | 2404 | { |
---|
2699 | | - struct { |
---|
2700 | | - SVGA3dCmdHeader header; |
---|
2701 | | - SVGA3dCmdDXClearDepthStencilView body; |
---|
2702 | | - } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2405 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXClearDepthStencilView) = |
---|
| 2406 | + container_of(header, typeof(*cmd), header); |
---|
| 2407 | + struct vmw_resource *ret; |
---|
2703 | 2408 | |
---|
2704 | | - return vmw_view_id_val_add(sw_context, vmw_view_ds, |
---|
2705 | | - cmd->body.depthStencilViewId); |
---|
| 2409 | + ret = vmw_view_id_val_add(sw_context, vmw_view_ds, |
---|
| 2410 | + cmd->body.depthStencilViewId); |
---|
| 2411 | + |
---|
| 2412 | + return PTR_ERR_OR_ZERO(ret); |
---|
2706 | 2413 | } |
---|
2707 | 2414 | |
---|
2708 | 2415 | static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv, |
---|
2709 | 2416 | struct vmw_sw_context *sw_context, |
---|
2710 | 2417 | SVGA3dCmdHeader *header) |
---|
2711 | 2418 | { |
---|
2712 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
2713 | | - struct vmw_resource_val_node *srf_node; |
---|
| 2419 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
| 2420 | + struct vmw_resource *srf; |
---|
2714 | 2421 | struct vmw_resource *res; |
---|
2715 | 2422 | enum vmw_view_type view_type; |
---|
2716 | 2423 | int ret; |
---|
2717 | 2424 | /* |
---|
2718 | | - * This is based on the fact that all affected define commands have |
---|
2719 | | - * the same initial command body layout. |
---|
| 2425 | + * This is based on the fact that all affected define commands have the |
---|
| 2426 | + * same initial command body layout. |
---|
2720 | 2427 | */ |
---|
2721 | 2428 | struct { |
---|
2722 | 2429 | SVGA3dCmdHeader header; |
---|
.. | .. |
---|
2724 | 2431 | uint32 sid; |
---|
2725 | 2432 | } *cmd; |
---|
2726 | 2433 | |
---|
2727 | | - if (unlikely(ctx_node == NULL)) { |
---|
2728 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2434 | + if (!ctx_node) |
---|
2729 | 2435 | return -EINVAL; |
---|
2730 | | - } |
---|
2731 | 2436 | |
---|
2732 | 2437 | view_type = vmw_view_cmd_to_type(header->id); |
---|
2733 | 2438 | if (view_type == vmw_view_max) |
---|
2734 | 2439 | return -EINVAL; |
---|
| 2440 | + |
---|
2735 | 2441 | cmd = container_of(header, typeof(*cmd), header); |
---|
2736 | 2442 | if (unlikely(cmd->sid == SVGA3D_INVALID_ID)) { |
---|
2737 | | - DRM_ERROR("Invalid surface id.\n"); |
---|
| 2443 | + VMW_DEBUG_USER("Invalid surface id.\n"); |
---|
2738 | 2444 | return -EINVAL; |
---|
2739 | 2445 | } |
---|
2740 | 2446 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
2741 | | - user_surface_converter, |
---|
2742 | | - &cmd->sid, &srf_node); |
---|
| 2447 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
| 2448 | + &cmd->sid, &srf); |
---|
2743 | 2449 | if (unlikely(ret != 0)) |
---|
2744 | 2450 | return ret; |
---|
2745 | 2451 | |
---|
2746 | | - res = vmw_context_cotable(ctx_node->res, vmw_view_cotables[view_type]); |
---|
| 2452 | + res = vmw_context_cotable(ctx_node->ctx, vmw_view_cotables[view_type]); |
---|
2747 | 2453 | ret = vmw_cotable_notify(res, cmd->defined_id); |
---|
2748 | | - vmw_resource_unreference(&res); |
---|
2749 | 2454 | if (unlikely(ret != 0)) |
---|
2750 | 2455 | return ret; |
---|
2751 | 2456 | |
---|
2752 | | - return vmw_view_add(sw_context->man, |
---|
2753 | | - ctx_node->res, |
---|
2754 | | - srf_node->res, |
---|
2755 | | - view_type, |
---|
2756 | | - cmd->defined_id, |
---|
2757 | | - header, |
---|
| 2457 | + return vmw_view_add(sw_context->man, ctx_node->ctx, srf, view_type, |
---|
| 2458 | + cmd->defined_id, header, |
---|
2758 | 2459 | header->size + sizeof(*header), |
---|
2759 | 2460 | &sw_context->staged_cmd_res); |
---|
2760 | 2461 | } |
---|
2761 | 2462 | |
---|
2762 | 2463 | /** |
---|
2763 | | - * vmw_cmd_dx_set_so_targets - Validate an |
---|
2764 | | - * SVGA_3D_CMD_DX_SET_SOTARGETS command. |
---|
| 2464 | + * vmw_cmd_dx_set_so_targets - Validate SVGA_3D_CMD_DX_SET_SOTARGETS command. |
---|
2765 | 2465 | * |
---|
2766 | 2466 | * @dev_priv: Pointer to a device private struct. |
---|
2767 | 2467 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2771 | 2471 | struct vmw_sw_context *sw_context, |
---|
2772 | 2472 | SVGA3dCmdHeader *header) |
---|
2773 | 2473 | { |
---|
2774 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
2775 | | - struct vmw_ctx_bindinfo_so binding; |
---|
2776 | | - struct vmw_resource_val_node *res_node; |
---|
| 2474 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
| 2475 | + struct vmw_ctx_bindinfo_so_target binding; |
---|
| 2476 | + struct vmw_resource *res; |
---|
2777 | 2477 | struct { |
---|
2778 | 2478 | SVGA3dCmdHeader header; |
---|
2779 | 2479 | SVGA3dCmdDXSetSOTargets body; |
---|
.. | .. |
---|
2781 | 2481 | } *cmd; |
---|
2782 | 2482 | int i, ret, num; |
---|
2783 | 2483 | |
---|
2784 | | - if (unlikely(ctx_node == NULL)) { |
---|
2785 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2484 | + if (!ctx_node) |
---|
2786 | 2485 | return -EINVAL; |
---|
2787 | | - } |
---|
2788 | 2486 | |
---|
2789 | 2487 | cmd = container_of(header, typeof(*cmd), header); |
---|
2790 | | - num = (cmd->header.size - sizeof(cmd->body)) / |
---|
2791 | | - sizeof(SVGA3dSoTarget); |
---|
| 2488 | + num = (cmd->header.size - sizeof(cmd->body)) / sizeof(SVGA3dSoTarget); |
---|
2792 | 2489 | |
---|
2793 | 2490 | if (num > SVGA3D_DX_MAX_SOTARGETS) { |
---|
2794 | | - DRM_ERROR("Invalid DX SO binding.\n"); |
---|
| 2491 | + VMW_DEBUG_USER("Invalid DX SO binding.\n"); |
---|
2795 | 2492 | return -EINVAL; |
---|
2796 | 2493 | } |
---|
2797 | 2494 | |
---|
2798 | 2495 | for (i = 0; i < num; i++) { |
---|
2799 | 2496 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
| 2497 | + VMW_RES_DIRTY_SET, |
---|
2800 | 2498 | user_surface_converter, |
---|
2801 | | - &cmd->targets[i].sid, &res_node); |
---|
| 2499 | + &cmd->targets[i].sid, &res); |
---|
2802 | 2500 | if (unlikely(ret != 0)) |
---|
2803 | 2501 | return ret; |
---|
2804 | 2502 | |
---|
2805 | | - binding.bi.ctx = ctx_node->res; |
---|
2806 | | - binding.bi.res = ((res_node) ? res_node->res : NULL); |
---|
2807 | | - binding.bi.bt = vmw_ctx_binding_so, |
---|
| 2503 | + binding.bi.ctx = ctx_node->ctx; |
---|
| 2504 | + binding.bi.res = res; |
---|
| 2505 | + binding.bi.bt = vmw_ctx_binding_so_target, |
---|
2808 | 2506 | binding.offset = cmd->targets[i].offset; |
---|
2809 | 2507 | binding.size = cmd->targets[i].sizeInBytes; |
---|
2810 | 2508 | binding.slot = i; |
---|
2811 | 2509 | |
---|
2812 | | - vmw_binding_add(ctx_node->staged_bindings, &binding.bi, |
---|
2813 | | - 0, binding.slot); |
---|
| 2510 | + vmw_binding_add(ctx_node->staged, &binding.bi, 0, binding.slot); |
---|
2814 | 2511 | } |
---|
2815 | 2512 | |
---|
2816 | 2513 | return 0; |
---|
.. | .. |
---|
2820 | 2517 | struct vmw_sw_context *sw_context, |
---|
2821 | 2518 | SVGA3dCmdHeader *header) |
---|
2822 | 2519 | { |
---|
2823 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
| 2520 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
2824 | 2521 | struct vmw_resource *res; |
---|
2825 | 2522 | /* |
---|
2826 | 2523 | * This is based on the fact that all affected define commands have |
---|
.. | .. |
---|
2833 | 2530 | enum vmw_so_type so_type; |
---|
2834 | 2531 | int ret; |
---|
2835 | 2532 | |
---|
2836 | | - if (unlikely(ctx_node == NULL)) { |
---|
2837 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2533 | + if (!ctx_node) |
---|
2838 | 2534 | return -EINVAL; |
---|
2839 | | - } |
---|
2840 | 2535 | |
---|
2841 | 2536 | so_type = vmw_so_cmd_to_type(header->id); |
---|
2842 | | - res = vmw_context_cotable(ctx_node->res, vmw_so_cotables[so_type]); |
---|
| 2537 | + res = vmw_context_cotable(ctx_node->ctx, vmw_so_cotables[so_type]); |
---|
2843 | 2538 | cmd = container_of(header, typeof(*cmd), header); |
---|
2844 | 2539 | ret = vmw_cotable_notify(res, cmd->defined_id); |
---|
2845 | | - vmw_resource_unreference(&res); |
---|
2846 | 2540 | |
---|
2847 | 2541 | return ret; |
---|
2848 | 2542 | } |
---|
2849 | 2543 | |
---|
2850 | 2544 | /** |
---|
2851 | | - * vmw_cmd_dx_check_subresource - Validate an |
---|
2852 | | - * SVGA_3D_CMD_DX_[X]_SUBRESOURCE command |
---|
| 2545 | + * vmw_cmd_dx_check_subresource - Validate SVGA_3D_CMD_DX_[X]_SUBRESOURCE |
---|
| 2546 | + * command |
---|
2853 | 2547 | * |
---|
2854 | 2548 | * @dev_priv: Pointer to a device private struct. |
---|
2855 | 2549 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2877 | 2571 | offsetof(typeof(*cmd), sid)); |
---|
2878 | 2572 | |
---|
2879 | 2573 | cmd = container_of(header, typeof(*cmd), header); |
---|
2880 | | - |
---|
2881 | 2574 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
2882 | | - user_surface_converter, |
---|
| 2575 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
2883 | 2576 | &cmd->sid, NULL); |
---|
2884 | 2577 | } |
---|
2885 | 2578 | |
---|
.. | .. |
---|
2887 | 2580 | struct vmw_sw_context *sw_context, |
---|
2888 | 2581 | SVGA3dCmdHeader *header) |
---|
2889 | 2582 | { |
---|
2890 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
| 2583 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
2891 | 2584 | |
---|
2892 | | - if (unlikely(ctx_node == NULL)) { |
---|
2893 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2585 | + if (!ctx_node) |
---|
2894 | 2586 | return -EINVAL; |
---|
2895 | | - } |
---|
2896 | 2587 | |
---|
2897 | 2588 | return 0; |
---|
2898 | 2589 | } |
---|
2899 | 2590 | |
---|
2900 | 2591 | /** |
---|
2901 | | - * vmw_cmd_dx_view_remove - validate a view remove command and |
---|
2902 | | - * schedule the view resource for removal. |
---|
| 2592 | + * vmw_cmd_dx_view_remove - validate a view remove command and schedule the view |
---|
| 2593 | + * resource for removal. |
---|
2903 | 2594 | * |
---|
2904 | 2595 | * @dev_priv: Pointer to a device private struct. |
---|
2905 | 2596 | * @sw_context: The software context being used for this batch. |
---|
2906 | 2597 | * @header: Pointer to the command header in the command stream. |
---|
2907 | 2598 | * |
---|
2908 | | - * Check that the view exists, and if it was not created using this |
---|
2909 | | - * command batch, conditionally make this command a NOP. |
---|
| 2599 | + * Check that the view exists, and if it was not created using this command |
---|
| 2600 | + * batch, conditionally make this command a NOP. |
---|
2910 | 2601 | */ |
---|
2911 | 2602 | static int vmw_cmd_dx_view_remove(struct vmw_private *dev_priv, |
---|
2912 | 2603 | struct vmw_sw_context *sw_context, |
---|
2913 | 2604 | SVGA3dCmdHeader *header) |
---|
2914 | 2605 | { |
---|
2915 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
| 2606 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
2916 | 2607 | struct { |
---|
2917 | 2608 | SVGA3dCmdHeader header; |
---|
2918 | 2609 | union vmw_view_destroy body; |
---|
.. | .. |
---|
2921 | 2612 | struct vmw_resource *view; |
---|
2922 | 2613 | int ret; |
---|
2923 | 2614 | |
---|
2924 | | - if (!ctx_node) { |
---|
2925 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2615 | + if (!ctx_node) |
---|
2926 | 2616 | return -EINVAL; |
---|
2927 | | - } |
---|
2928 | 2617 | |
---|
2929 | | - ret = vmw_view_remove(sw_context->man, |
---|
2930 | | - cmd->body.view_id, view_type, |
---|
2931 | | - &sw_context->staged_cmd_res, |
---|
2932 | | - &view); |
---|
| 2618 | + ret = vmw_view_remove(sw_context->man, cmd->body.view_id, view_type, |
---|
| 2619 | + &sw_context->staged_cmd_res, &view); |
---|
2933 | 2620 | if (ret || !view) |
---|
2934 | 2621 | return ret; |
---|
2935 | 2622 | |
---|
.. | .. |
---|
2939 | 2626 | * relocation to conditionally make this command a NOP to avoid |
---|
2940 | 2627 | * device errors. |
---|
2941 | 2628 | */ |
---|
2942 | | - return vmw_resource_relocation_add(&sw_context->res_relocations, |
---|
2943 | | - view, |
---|
| 2629 | + return vmw_resource_relocation_add(sw_context, view, |
---|
2944 | 2630 | vmw_ptr_diff(sw_context->buf_start, |
---|
2945 | 2631 | &cmd->header.id), |
---|
2946 | 2632 | vmw_res_rel_cond_nop); |
---|
2947 | 2633 | } |
---|
2948 | 2634 | |
---|
2949 | 2635 | /** |
---|
2950 | | - * vmw_cmd_dx_define_shader - Validate an SVGA_3D_CMD_DX_DEFINE_SHADER |
---|
2951 | | - * command |
---|
| 2636 | + * vmw_cmd_dx_define_shader - Validate SVGA_3D_CMD_DX_DEFINE_SHADER command |
---|
2952 | 2637 | * |
---|
2953 | 2638 | * @dev_priv: Pointer to a device private struct. |
---|
2954 | 2639 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2958 | 2643 | struct vmw_sw_context *sw_context, |
---|
2959 | 2644 | SVGA3dCmdHeader *header) |
---|
2960 | 2645 | { |
---|
2961 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
| 2646 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
2962 | 2647 | struct vmw_resource *res; |
---|
2963 | | - struct { |
---|
2964 | | - SVGA3dCmdHeader header; |
---|
2965 | | - SVGA3dCmdDXDefineShader body; |
---|
2966 | | - } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2648 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXDefineShader) = |
---|
| 2649 | + container_of(header, typeof(*cmd), header); |
---|
2967 | 2650 | int ret; |
---|
2968 | 2651 | |
---|
2969 | | - if (!ctx_node) { |
---|
2970 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2652 | + if (!ctx_node) |
---|
2971 | 2653 | return -EINVAL; |
---|
2972 | | - } |
---|
2973 | 2654 | |
---|
2974 | | - res = vmw_context_cotable(ctx_node->res, SVGA_COTABLE_DXSHADER); |
---|
| 2655 | + res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXSHADER); |
---|
2975 | 2656 | ret = vmw_cotable_notify(res, cmd->body.shaderId); |
---|
2976 | | - vmw_resource_unreference(&res); |
---|
2977 | 2657 | if (ret) |
---|
2978 | 2658 | return ret; |
---|
2979 | 2659 | |
---|
2980 | | - return vmw_dx_shader_add(sw_context->man, ctx_node->res, |
---|
| 2660 | + return vmw_dx_shader_add(sw_context->man, ctx_node->ctx, |
---|
2981 | 2661 | cmd->body.shaderId, cmd->body.type, |
---|
2982 | 2662 | &sw_context->staged_cmd_res); |
---|
2983 | 2663 | } |
---|
2984 | 2664 | |
---|
2985 | 2665 | /** |
---|
2986 | | - * vmw_cmd_dx_destroy_shader - Validate an SVGA_3D_CMD_DX_DESTROY_SHADER |
---|
2987 | | - * command |
---|
| 2666 | + * vmw_cmd_dx_destroy_shader - Validate SVGA_3D_CMD_DX_DESTROY_SHADER command |
---|
2988 | 2667 | * |
---|
2989 | 2668 | * @dev_priv: Pointer to a device private struct. |
---|
2990 | 2669 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
2994 | 2673 | struct vmw_sw_context *sw_context, |
---|
2995 | 2674 | SVGA3dCmdHeader *header) |
---|
2996 | 2675 | { |
---|
2997 | | - struct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node; |
---|
2998 | | - struct { |
---|
2999 | | - SVGA3dCmdHeader header; |
---|
3000 | | - SVGA3dCmdDXDestroyShader body; |
---|
3001 | | - } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2676 | + struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context); |
---|
| 2677 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXDestroyShader) = |
---|
| 2678 | + container_of(header, typeof(*cmd), header); |
---|
3002 | 2679 | int ret; |
---|
3003 | 2680 | |
---|
3004 | | - if (!ctx_node) { |
---|
3005 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2681 | + if (!ctx_node) |
---|
3006 | 2682 | return -EINVAL; |
---|
3007 | | - } |
---|
3008 | 2683 | |
---|
3009 | 2684 | ret = vmw_shader_remove(sw_context->man, cmd->body.shaderId, 0, |
---|
3010 | 2685 | &sw_context->staged_cmd_res); |
---|
3011 | | - if (ret) |
---|
3012 | | - DRM_ERROR("Could not find shader to remove.\n"); |
---|
3013 | 2686 | |
---|
3014 | 2687 | return ret; |
---|
3015 | 2688 | } |
---|
3016 | 2689 | |
---|
3017 | 2690 | /** |
---|
3018 | | - * vmw_cmd_dx_bind_shader - Validate an SVGA_3D_CMD_DX_BIND_SHADER |
---|
3019 | | - * command |
---|
| 2691 | + * vmw_cmd_dx_bind_shader - Validate SVGA_3D_CMD_DX_BIND_SHADER command |
---|
3020 | 2692 | * |
---|
3021 | 2693 | * @dev_priv: Pointer to a device private struct. |
---|
3022 | 2694 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
3026 | 2698 | struct vmw_sw_context *sw_context, |
---|
3027 | 2699 | SVGA3dCmdHeader *header) |
---|
3028 | 2700 | { |
---|
3029 | | - struct vmw_resource_val_node *ctx_node; |
---|
3030 | | - struct vmw_resource_val_node *res_node; |
---|
| 2701 | + struct vmw_resource *ctx; |
---|
3031 | 2702 | struct vmw_resource *res; |
---|
3032 | | - struct { |
---|
3033 | | - SVGA3dCmdHeader header; |
---|
3034 | | - SVGA3dCmdDXBindShader body; |
---|
3035 | | - } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2703 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXBindShader) = |
---|
| 2704 | + container_of(header, typeof(*cmd), header); |
---|
3036 | 2705 | int ret; |
---|
3037 | 2706 | |
---|
3038 | 2707 | if (cmd->body.cid != SVGA3D_INVALID_ID) { |
---|
3039 | 2708 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, |
---|
3040 | | - user_context_converter, |
---|
3041 | | - &cmd->body.cid, &ctx_node); |
---|
| 2709 | + VMW_RES_DIRTY_SET, |
---|
| 2710 | + user_context_converter, &cmd->body.cid, |
---|
| 2711 | + &ctx); |
---|
3042 | 2712 | if (ret) |
---|
3043 | 2713 | return ret; |
---|
3044 | 2714 | } else { |
---|
3045 | | - ctx_node = sw_context->dx_ctx_node; |
---|
3046 | | - if (!ctx_node) { |
---|
3047 | | - DRM_ERROR("DX Context not set.\n"); |
---|
| 2715 | + struct vmw_ctx_validation_info *ctx_node = |
---|
| 2716 | + VMW_GET_CTX_NODE(sw_context); |
---|
| 2717 | + |
---|
| 2718 | + if (!ctx_node) |
---|
3048 | 2719 | return -EINVAL; |
---|
3049 | | - } |
---|
| 2720 | + |
---|
| 2721 | + ctx = ctx_node->ctx; |
---|
3050 | 2722 | } |
---|
3051 | 2723 | |
---|
3052 | | - res = vmw_shader_lookup(vmw_context_res_man(ctx_node->res), |
---|
3053 | | - cmd->body.shid, 0); |
---|
| 2724 | + res = vmw_shader_lookup(vmw_context_res_man(ctx), cmd->body.shid, 0); |
---|
3054 | 2725 | if (IS_ERR(res)) { |
---|
3055 | | - DRM_ERROR("Could not find shader to bind.\n"); |
---|
| 2726 | + VMW_DEBUG_USER("Could not find shader to bind.\n"); |
---|
3056 | 2727 | return PTR_ERR(res); |
---|
3057 | 2728 | } |
---|
3058 | 2729 | |
---|
3059 | | - ret = vmw_resource_val_add(sw_context, res, &res_node); |
---|
| 2730 | + ret = vmw_execbuf_res_noctx_val_add(sw_context, res, |
---|
| 2731 | + VMW_RES_DIRTY_NONE); |
---|
3060 | 2732 | if (ret) { |
---|
3061 | | - DRM_ERROR("Error creating resource validation node.\n"); |
---|
3062 | | - goto out_unref; |
---|
| 2733 | + VMW_DEBUG_USER("Error creating resource validation node.\n"); |
---|
| 2734 | + return ret; |
---|
3063 | 2735 | } |
---|
3064 | 2736 | |
---|
3065 | | - |
---|
3066 | | - ret = vmw_cmd_res_switch_backup(dev_priv, sw_context, res_node, |
---|
3067 | | - &cmd->body.mobid, |
---|
3068 | | - cmd->body.offsetInBytes); |
---|
3069 | | -out_unref: |
---|
3070 | | - vmw_resource_unreference(&res); |
---|
3071 | | - |
---|
3072 | | - return ret; |
---|
| 2737 | + return vmw_cmd_res_switch_backup(dev_priv, sw_context, res, |
---|
| 2738 | + &cmd->body.mobid, |
---|
| 2739 | + cmd->body.offsetInBytes); |
---|
3073 | 2740 | } |
---|
3074 | 2741 | |
---|
3075 | 2742 | /** |
---|
3076 | | - * vmw_cmd_dx_genmips - Validate an SVGA_3D_CMD_DX_GENMIPS command |
---|
| 2743 | + * vmw_cmd_dx_genmips - Validate SVGA_3D_CMD_DX_GENMIPS command |
---|
3077 | 2744 | * |
---|
3078 | 2745 | * @dev_priv: Pointer to a device private struct. |
---|
3079 | 2746 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
3083 | 2750 | struct vmw_sw_context *sw_context, |
---|
3084 | 2751 | SVGA3dCmdHeader *header) |
---|
3085 | 2752 | { |
---|
3086 | | - struct { |
---|
3087 | | - SVGA3dCmdHeader header; |
---|
3088 | | - SVGA3dCmdDXGenMips body; |
---|
3089 | | - } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2753 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXGenMips) = |
---|
| 2754 | + container_of(header, typeof(*cmd), header); |
---|
| 2755 | + struct vmw_resource *view; |
---|
| 2756 | + struct vmw_res_cache_entry *rcache; |
---|
3090 | 2757 | |
---|
3091 | | - return vmw_view_id_val_add(sw_context, vmw_view_sr, |
---|
| 2758 | + view = vmw_view_id_val_add(sw_context, vmw_view_sr, |
---|
3092 | 2759 | cmd->body.shaderResourceViewId); |
---|
| 2760 | + if (IS_ERR(view)) |
---|
| 2761 | + return PTR_ERR(view); |
---|
| 2762 | + |
---|
| 2763 | + /* |
---|
| 2764 | + * Normally the shader-resource view is not gpu-dirtying, but for |
---|
| 2765 | + * this particular command it is... |
---|
| 2766 | + * So mark the last looked-up surface, which is the surface |
---|
| 2767 | + * the view points to, gpu-dirty. |
---|
| 2768 | + */ |
---|
| 2769 | + rcache = &sw_context->res_cache[vmw_res_surface]; |
---|
| 2770 | + vmw_validation_res_set_dirty(sw_context->ctx, rcache->private, |
---|
| 2771 | + VMW_RES_DIRTY_SET); |
---|
| 2772 | + return 0; |
---|
3093 | 2773 | } |
---|
3094 | 2774 | |
---|
3095 | 2775 | /** |
---|
3096 | | - * vmw_cmd_dx_transfer_from_buffer - |
---|
3097 | | - * Validate an SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER command |
---|
| 2776 | + * vmw_cmd_dx_transfer_from_buffer - Validate |
---|
| 2777 | + * SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER command |
---|
3098 | 2778 | * |
---|
3099 | 2779 | * @dev_priv: Pointer to a device private struct. |
---|
3100 | 2780 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
3104 | 2784 | struct vmw_sw_context *sw_context, |
---|
3105 | 2785 | SVGA3dCmdHeader *header) |
---|
3106 | 2786 | { |
---|
3107 | | - struct { |
---|
3108 | | - SVGA3dCmdHeader header; |
---|
3109 | | - SVGA3dCmdDXTransferFromBuffer body; |
---|
3110 | | - } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2787 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXTransferFromBuffer) = |
---|
| 2788 | + container_of(header, typeof(*cmd), header); |
---|
3111 | 2789 | int ret; |
---|
3112 | 2790 | |
---|
3113 | 2791 | ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
3114 | | - user_surface_converter, |
---|
| 2792 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
3115 | 2793 | &cmd->body.srcSid, NULL); |
---|
3116 | 2794 | if (ret != 0) |
---|
3117 | 2795 | return ret; |
---|
3118 | 2796 | |
---|
3119 | 2797 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
3120 | | - user_surface_converter, |
---|
| 2798 | + VMW_RES_DIRTY_SET, user_surface_converter, |
---|
3121 | 2799 | &cmd->body.destSid, NULL); |
---|
3122 | 2800 | } |
---|
3123 | 2801 | |
---|
3124 | 2802 | /** |
---|
3125 | | - * vmw_cmd_intra_surface_copy - |
---|
3126 | | - * Validate an SVGA_3D_CMD_INTRA_SURFACE_COPY command |
---|
| 2803 | + * vmw_cmd_intra_surface_copy - Validate SVGA_3D_CMD_INTRA_SURFACE_COPY command |
---|
3127 | 2804 | * |
---|
3128 | 2805 | * @dev_priv: Pointer to a device private struct. |
---|
3129 | 2806 | * @sw_context: The software context being used for this batch. |
---|
.. | .. |
---|
3133 | 2810 | struct vmw_sw_context *sw_context, |
---|
3134 | 2811 | SVGA3dCmdHeader *header) |
---|
3135 | 2812 | { |
---|
3136 | | - struct { |
---|
3137 | | - SVGA3dCmdHeader header; |
---|
3138 | | - SVGA3dCmdIntraSurfaceCopy body; |
---|
3139 | | - } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2813 | + VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdIntraSurfaceCopy) = |
---|
| 2814 | + container_of(header, typeof(*cmd), header); |
---|
3140 | 2815 | |
---|
3141 | 2816 | if (!(dev_priv->capabilities2 & SVGA_CAP2_INTRA_SURFACE_COPY)) |
---|
3142 | 2817 | return -EINVAL; |
---|
3143 | 2818 | |
---|
3144 | 2819 | return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
3145 | | - user_surface_converter, |
---|
3146 | | - &cmd->body.surface.sid, NULL); |
---|
| 2820 | + VMW_RES_DIRTY_SET, user_surface_converter, |
---|
| 2821 | + &cmd->body.surface.sid, NULL); |
---|
3147 | 2822 | } |
---|
3148 | 2823 | |
---|
| 2824 | +static int vmw_cmd_sm5(struct vmw_private *dev_priv, |
---|
| 2825 | + struct vmw_sw_context *sw_context, |
---|
| 2826 | + SVGA3dCmdHeader *header) |
---|
| 2827 | +{ |
---|
| 2828 | + if (!has_sm5_context(dev_priv)) |
---|
| 2829 | + return -EINVAL; |
---|
| 2830 | + |
---|
| 2831 | + return 0; |
---|
| 2832 | +} |
---|
| 2833 | + |
---|
| 2834 | +static int vmw_cmd_sm5_view_define(struct vmw_private *dev_priv, |
---|
| 2835 | + struct vmw_sw_context *sw_context, |
---|
| 2836 | + SVGA3dCmdHeader *header) |
---|
| 2837 | +{ |
---|
| 2838 | + if (!has_sm5_context(dev_priv)) |
---|
| 2839 | + return -EINVAL; |
---|
| 2840 | + |
---|
| 2841 | + return vmw_cmd_dx_view_define(dev_priv, sw_context, header); |
---|
| 2842 | +} |
---|
| 2843 | + |
---|
| 2844 | +static int vmw_cmd_sm5_view_remove(struct vmw_private *dev_priv, |
---|
| 2845 | + struct vmw_sw_context *sw_context, |
---|
| 2846 | + SVGA3dCmdHeader *header) |
---|
| 2847 | +{ |
---|
| 2848 | + if (!has_sm5_context(dev_priv)) |
---|
| 2849 | + return -EINVAL; |
---|
| 2850 | + |
---|
| 2851 | + return vmw_cmd_dx_view_remove(dev_priv, sw_context, header); |
---|
| 2852 | +} |
---|
| 2853 | + |
---|
| 2854 | +static int vmw_cmd_clear_uav_uint(struct vmw_private *dev_priv, |
---|
| 2855 | + struct vmw_sw_context *sw_context, |
---|
| 2856 | + SVGA3dCmdHeader *header) |
---|
| 2857 | +{ |
---|
| 2858 | + struct { |
---|
| 2859 | + SVGA3dCmdHeader header; |
---|
| 2860 | + SVGA3dCmdDXClearUAViewUint body; |
---|
| 2861 | + } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2862 | + struct vmw_resource *ret; |
---|
| 2863 | + |
---|
| 2864 | + if (!has_sm5_context(dev_priv)) |
---|
| 2865 | + return -EINVAL; |
---|
| 2866 | + |
---|
| 2867 | + ret = vmw_view_id_val_add(sw_context, vmw_view_ua, |
---|
| 2868 | + cmd->body.uaViewId); |
---|
| 2869 | + |
---|
| 2870 | + return PTR_ERR_OR_ZERO(ret); |
---|
| 2871 | +} |
---|
| 2872 | + |
---|
| 2873 | +static int vmw_cmd_clear_uav_float(struct vmw_private *dev_priv, |
---|
| 2874 | + struct vmw_sw_context *sw_context, |
---|
| 2875 | + SVGA3dCmdHeader *header) |
---|
| 2876 | +{ |
---|
| 2877 | + struct { |
---|
| 2878 | + SVGA3dCmdHeader header; |
---|
| 2879 | + SVGA3dCmdDXClearUAViewFloat body; |
---|
| 2880 | + } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2881 | + struct vmw_resource *ret; |
---|
| 2882 | + |
---|
| 2883 | + if (!has_sm5_context(dev_priv)) |
---|
| 2884 | + return -EINVAL; |
---|
| 2885 | + |
---|
| 2886 | + ret = vmw_view_id_val_add(sw_context, vmw_view_ua, |
---|
| 2887 | + cmd->body.uaViewId); |
---|
| 2888 | + |
---|
| 2889 | + return PTR_ERR_OR_ZERO(ret); |
---|
| 2890 | +} |
---|
| 2891 | + |
---|
| 2892 | +static int vmw_cmd_set_uav(struct vmw_private *dev_priv, |
---|
| 2893 | + struct vmw_sw_context *sw_context, |
---|
| 2894 | + SVGA3dCmdHeader *header) |
---|
| 2895 | +{ |
---|
| 2896 | + struct { |
---|
| 2897 | + SVGA3dCmdHeader header; |
---|
| 2898 | + SVGA3dCmdDXSetUAViews body; |
---|
| 2899 | + } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2900 | + u32 num_uav = (cmd->header.size - sizeof(cmd->body)) / |
---|
| 2901 | + sizeof(SVGA3dUAViewId); |
---|
| 2902 | + int ret; |
---|
| 2903 | + |
---|
| 2904 | + if (!has_sm5_context(dev_priv)) |
---|
| 2905 | + return -EINVAL; |
---|
| 2906 | + |
---|
| 2907 | + if (num_uav > SVGA3D_MAX_UAVIEWS) { |
---|
| 2908 | + VMW_DEBUG_USER("Invalid UAV binding.\n"); |
---|
| 2909 | + return -EINVAL; |
---|
| 2910 | + } |
---|
| 2911 | + |
---|
| 2912 | + ret = vmw_view_bindings_add(sw_context, vmw_view_ua, |
---|
| 2913 | + vmw_ctx_binding_uav, 0, (void *)&cmd[1], |
---|
| 2914 | + num_uav, 0); |
---|
| 2915 | + if (ret) |
---|
| 2916 | + return ret; |
---|
| 2917 | + |
---|
| 2918 | + vmw_binding_add_uav_index(sw_context->dx_ctx_node->staged, 0, |
---|
| 2919 | + cmd->body.uavSpliceIndex); |
---|
| 2920 | + |
---|
| 2921 | + return ret; |
---|
| 2922 | +} |
---|
| 2923 | + |
---|
| 2924 | +static int vmw_cmd_set_cs_uav(struct vmw_private *dev_priv, |
---|
| 2925 | + struct vmw_sw_context *sw_context, |
---|
| 2926 | + SVGA3dCmdHeader *header) |
---|
| 2927 | +{ |
---|
| 2928 | + struct { |
---|
| 2929 | + SVGA3dCmdHeader header; |
---|
| 2930 | + SVGA3dCmdDXSetCSUAViews body; |
---|
| 2931 | + } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2932 | + u32 num_uav = (cmd->header.size - sizeof(cmd->body)) / |
---|
| 2933 | + sizeof(SVGA3dUAViewId); |
---|
| 2934 | + int ret; |
---|
| 2935 | + |
---|
| 2936 | + if (!has_sm5_context(dev_priv)) |
---|
| 2937 | + return -EINVAL; |
---|
| 2938 | + |
---|
| 2939 | + if (num_uav > SVGA3D_MAX_UAVIEWS) { |
---|
| 2940 | + VMW_DEBUG_USER("Invalid UAV binding.\n"); |
---|
| 2941 | + return -EINVAL; |
---|
| 2942 | + } |
---|
| 2943 | + |
---|
| 2944 | + ret = vmw_view_bindings_add(sw_context, vmw_view_ua, |
---|
| 2945 | + vmw_ctx_binding_cs_uav, 0, (void *)&cmd[1], |
---|
| 2946 | + num_uav, 0); |
---|
| 2947 | + if (ret) |
---|
| 2948 | + return ret; |
---|
| 2949 | + |
---|
| 2950 | + vmw_binding_add_uav_index(sw_context->dx_ctx_node->staged, 1, |
---|
| 2951 | + cmd->body.startIndex); |
---|
| 2952 | + |
---|
| 2953 | + return ret; |
---|
| 2954 | +} |
---|
| 2955 | + |
---|
| 2956 | +static int vmw_cmd_dx_define_streamoutput(struct vmw_private *dev_priv, |
---|
| 2957 | + struct vmw_sw_context *sw_context, |
---|
| 2958 | + SVGA3dCmdHeader *header) |
---|
| 2959 | +{ |
---|
| 2960 | + struct vmw_ctx_validation_info *ctx_node = sw_context->dx_ctx_node; |
---|
| 2961 | + struct vmw_resource *res; |
---|
| 2962 | + struct { |
---|
| 2963 | + SVGA3dCmdHeader header; |
---|
| 2964 | + SVGA3dCmdDXDefineStreamOutputWithMob body; |
---|
| 2965 | + } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2966 | + int ret; |
---|
| 2967 | + |
---|
| 2968 | + if (!has_sm5_context(dev_priv)) |
---|
| 2969 | + return -EINVAL; |
---|
| 2970 | + |
---|
| 2971 | + if (!ctx_node) { |
---|
| 2972 | + DRM_ERROR("DX Context not set.\n"); |
---|
| 2973 | + return -EINVAL; |
---|
| 2974 | + } |
---|
| 2975 | + |
---|
| 2976 | + res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_STREAMOUTPUT); |
---|
| 2977 | + ret = vmw_cotable_notify(res, cmd->body.soid); |
---|
| 2978 | + if (ret) |
---|
| 2979 | + return ret; |
---|
| 2980 | + |
---|
| 2981 | + return vmw_dx_streamoutput_add(sw_context->man, ctx_node->ctx, |
---|
| 2982 | + cmd->body.soid, |
---|
| 2983 | + &sw_context->staged_cmd_res); |
---|
| 2984 | +} |
---|
| 2985 | + |
---|
| 2986 | +static int vmw_cmd_dx_destroy_streamoutput(struct vmw_private *dev_priv, |
---|
| 2987 | + struct vmw_sw_context *sw_context, |
---|
| 2988 | + SVGA3dCmdHeader *header) |
---|
| 2989 | +{ |
---|
| 2990 | + struct vmw_ctx_validation_info *ctx_node = sw_context->dx_ctx_node; |
---|
| 2991 | + struct vmw_resource *res; |
---|
| 2992 | + struct { |
---|
| 2993 | + SVGA3dCmdHeader header; |
---|
| 2994 | + SVGA3dCmdDXDestroyStreamOutput body; |
---|
| 2995 | + } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 2996 | + |
---|
| 2997 | + if (!ctx_node) { |
---|
| 2998 | + DRM_ERROR("DX Context not set.\n"); |
---|
| 2999 | + return -EINVAL; |
---|
| 3000 | + } |
---|
| 3001 | + |
---|
| 3002 | + /* |
---|
| 3003 | + * When device does not support SM5 then streamoutput with mob command is |
---|
| 3004 | + * not available to user-space. Simply return in this case. |
---|
| 3005 | + */ |
---|
| 3006 | + if (!has_sm5_context(dev_priv)) |
---|
| 3007 | + return 0; |
---|
| 3008 | + |
---|
| 3009 | + /* |
---|
| 3010 | + * With SM5 capable device if lookup fails then user-space probably used |
---|
| 3011 | + * old streamoutput define command. Return without an error. |
---|
| 3012 | + */ |
---|
| 3013 | + res = vmw_dx_streamoutput_lookup(vmw_context_res_man(ctx_node->ctx), |
---|
| 3014 | + cmd->body.soid); |
---|
| 3015 | + if (IS_ERR(res)) |
---|
| 3016 | + return 0; |
---|
| 3017 | + |
---|
| 3018 | + return vmw_dx_streamoutput_remove(sw_context->man, cmd->body.soid, |
---|
| 3019 | + &sw_context->staged_cmd_res); |
---|
| 3020 | +} |
---|
| 3021 | + |
---|
| 3022 | +static int vmw_cmd_dx_bind_streamoutput(struct vmw_private *dev_priv, |
---|
| 3023 | + struct vmw_sw_context *sw_context, |
---|
| 3024 | + SVGA3dCmdHeader *header) |
---|
| 3025 | +{ |
---|
| 3026 | + struct vmw_ctx_validation_info *ctx_node = sw_context->dx_ctx_node; |
---|
| 3027 | + struct vmw_resource *res; |
---|
| 3028 | + struct { |
---|
| 3029 | + SVGA3dCmdHeader header; |
---|
| 3030 | + SVGA3dCmdDXBindStreamOutput body; |
---|
| 3031 | + } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 3032 | + int ret; |
---|
| 3033 | + |
---|
| 3034 | + if (!has_sm5_context(dev_priv)) |
---|
| 3035 | + return -EINVAL; |
---|
| 3036 | + |
---|
| 3037 | + if (!ctx_node) { |
---|
| 3038 | + DRM_ERROR("DX Context not set.\n"); |
---|
| 3039 | + return -EINVAL; |
---|
| 3040 | + } |
---|
| 3041 | + |
---|
| 3042 | + res = vmw_dx_streamoutput_lookup(vmw_context_res_man(ctx_node->ctx), |
---|
| 3043 | + cmd->body.soid); |
---|
| 3044 | + if (IS_ERR(res)) { |
---|
| 3045 | + DRM_ERROR("Could not find streamoutput to bind.\n"); |
---|
| 3046 | + return PTR_ERR(res); |
---|
| 3047 | + } |
---|
| 3048 | + |
---|
| 3049 | + vmw_dx_streamoutput_set_size(res, cmd->body.sizeInBytes); |
---|
| 3050 | + |
---|
| 3051 | + ret = vmw_execbuf_res_noctx_val_add(sw_context, res, |
---|
| 3052 | + VMW_RES_DIRTY_NONE); |
---|
| 3053 | + if (ret) { |
---|
| 3054 | + DRM_ERROR("Error creating resource validation node.\n"); |
---|
| 3055 | + return ret; |
---|
| 3056 | + } |
---|
| 3057 | + |
---|
| 3058 | + return vmw_cmd_res_switch_backup(dev_priv, sw_context, res, |
---|
| 3059 | + &cmd->body.mobid, |
---|
| 3060 | + cmd->body.offsetInBytes); |
---|
| 3061 | +} |
---|
| 3062 | + |
---|
| 3063 | +static int vmw_cmd_dx_set_streamoutput(struct vmw_private *dev_priv, |
---|
| 3064 | + struct vmw_sw_context *sw_context, |
---|
| 3065 | + SVGA3dCmdHeader *header) |
---|
| 3066 | +{ |
---|
| 3067 | + struct vmw_ctx_validation_info *ctx_node = sw_context->dx_ctx_node; |
---|
| 3068 | + struct vmw_resource *res; |
---|
| 3069 | + struct vmw_ctx_bindinfo_so binding; |
---|
| 3070 | + struct { |
---|
| 3071 | + SVGA3dCmdHeader header; |
---|
| 3072 | + SVGA3dCmdDXSetStreamOutput body; |
---|
| 3073 | + } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 3074 | + int ret; |
---|
| 3075 | + |
---|
| 3076 | + if (!ctx_node) { |
---|
| 3077 | + DRM_ERROR("DX Context not set.\n"); |
---|
| 3078 | + return -EINVAL; |
---|
| 3079 | + } |
---|
| 3080 | + |
---|
| 3081 | + if (cmd->body.soid == SVGA3D_INVALID_ID) |
---|
| 3082 | + return 0; |
---|
| 3083 | + |
---|
| 3084 | + /* |
---|
| 3085 | + * When device does not support SM5 then streamoutput with mob command is |
---|
| 3086 | + * not available to user-space. Simply return in this case. |
---|
| 3087 | + */ |
---|
| 3088 | + if (!has_sm5_context(dev_priv)) |
---|
| 3089 | + return 0; |
---|
| 3090 | + |
---|
| 3091 | + /* |
---|
| 3092 | + * With SM5 capable device if lookup fails then user-space probably used |
---|
| 3093 | + * old streamoutput define command. Return without an error. |
---|
| 3094 | + */ |
---|
| 3095 | + res = vmw_dx_streamoutput_lookup(vmw_context_res_man(ctx_node->ctx), |
---|
| 3096 | + cmd->body.soid); |
---|
| 3097 | + if (IS_ERR(res)) { |
---|
| 3098 | + return 0; |
---|
| 3099 | + } |
---|
| 3100 | + |
---|
| 3101 | + ret = vmw_execbuf_res_noctx_val_add(sw_context, res, |
---|
| 3102 | + VMW_RES_DIRTY_NONE); |
---|
| 3103 | + if (ret) { |
---|
| 3104 | + DRM_ERROR("Error creating resource validation node.\n"); |
---|
| 3105 | + return ret; |
---|
| 3106 | + } |
---|
| 3107 | + |
---|
| 3108 | + binding.bi.ctx = ctx_node->ctx; |
---|
| 3109 | + binding.bi.res = res; |
---|
| 3110 | + binding.bi.bt = vmw_ctx_binding_so; |
---|
| 3111 | + binding.slot = 0; /* Only one SO set to context at a time. */ |
---|
| 3112 | + |
---|
| 3113 | + vmw_binding_add(sw_context->dx_ctx_node->staged, &binding.bi, 0, |
---|
| 3114 | + binding.slot); |
---|
| 3115 | + |
---|
| 3116 | + return ret; |
---|
| 3117 | +} |
---|
| 3118 | + |
---|
| 3119 | +static int vmw_cmd_indexed_instanced_indirect(struct vmw_private *dev_priv, |
---|
| 3120 | + struct vmw_sw_context *sw_context, |
---|
| 3121 | + SVGA3dCmdHeader *header) |
---|
| 3122 | +{ |
---|
| 3123 | + struct vmw_draw_indexed_instanced_indirect_cmd { |
---|
| 3124 | + SVGA3dCmdHeader header; |
---|
| 3125 | + SVGA3dCmdDXDrawIndexedInstancedIndirect body; |
---|
| 3126 | + } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 3127 | + |
---|
| 3128 | + if (!has_sm5_context(dev_priv)) |
---|
| 3129 | + return -EINVAL; |
---|
| 3130 | + |
---|
| 3131 | + return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
| 3132 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
| 3133 | + &cmd->body.argsBufferSid, NULL); |
---|
| 3134 | +} |
---|
| 3135 | + |
---|
| 3136 | +static int vmw_cmd_instanced_indirect(struct vmw_private *dev_priv, |
---|
| 3137 | + struct vmw_sw_context *sw_context, |
---|
| 3138 | + SVGA3dCmdHeader *header) |
---|
| 3139 | +{ |
---|
| 3140 | + struct vmw_draw_instanced_indirect_cmd { |
---|
| 3141 | + SVGA3dCmdHeader header; |
---|
| 3142 | + SVGA3dCmdDXDrawInstancedIndirect body; |
---|
| 3143 | + } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 3144 | + |
---|
| 3145 | + if (!has_sm5_context(dev_priv)) |
---|
| 3146 | + return -EINVAL; |
---|
| 3147 | + |
---|
| 3148 | + return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
| 3149 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
| 3150 | + &cmd->body.argsBufferSid, NULL); |
---|
| 3151 | +} |
---|
| 3152 | + |
---|
| 3153 | +static int vmw_cmd_dispatch_indirect(struct vmw_private *dev_priv, |
---|
| 3154 | + struct vmw_sw_context *sw_context, |
---|
| 3155 | + SVGA3dCmdHeader *header) |
---|
| 3156 | +{ |
---|
| 3157 | + struct vmw_dispatch_indirect_cmd { |
---|
| 3158 | + SVGA3dCmdHeader header; |
---|
| 3159 | + SVGA3dCmdDXDispatchIndirect body; |
---|
| 3160 | + } *cmd = container_of(header, typeof(*cmd), header); |
---|
| 3161 | + |
---|
| 3162 | + if (!has_sm5_context(dev_priv)) |
---|
| 3163 | + return -EINVAL; |
---|
| 3164 | + |
---|
| 3165 | + return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, |
---|
| 3166 | + VMW_RES_DIRTY_NONE, user_surface_converter, |
---|
| 3167 | + &cmd->body.argsBufferSid, NULL); |
---|
| 3168 | +} |
---|
3149 | 3169 | |
---|
3150 | 3170 | static int vmw_cmd_check_not_3d(struct vmw_private *dev_priv, |
---|
3151 | 3171 | struct vmw_sw_context *sw_context, |
---|
.. | .. |
---|
3169 | 3189 | *size = sizeof(uint32_t) + sizeof(SVGAFifoCmdBlitGMRFBToScreen); |
---|
3170 | 3190 | break; |
---|
3171 | 3191 | default: |
---|
3172 | | - DRM_ERROR("Unsupported SVGA command: %u.\n", cmd_id); |
---|
| 3192 | + VMW_DEBUG_USER("Unsupported SVGA command: %u.\n", cmd_id); |
---|
3173 | 3193 | return -EINVAL; |
---|
3174 | 3194 | } |
---|
3175 | 3195 | |
---|
3176 | 3196 | if (*size > size_remaining) { |
---|
3177 | | - DRM_ERROR("Invalid SVGA command (size mismatch):" |
---|
3178 | | - " %u.\n", cmd_id); |
---|
| 3197 | + VMW_DEBUG_USER("Invalid SVGA command (size mismatch): %u.\n", |
---|
| 3198 | + cmd_id); |
---|
3179 | 3199 | return -EINVAL; |
---|
3180 | 3200 | } |
---|
3181 | 3201 | |
---|
3182 | 3202 | if (unlikely(!sw_context->kernel)) { |
---|
3183 | | - DRM_ERROR("Kernel only SVGA command: %u.\n", cmd_id); |
---|
| 3203 | + VMW_DEBUG_USER("Kernel only SVGA command: %u.\n", cmd_id); |
---|
3184 | 3204 | return -EPERM; |
---|
3185 | 3205 | } |
---|
3186 | 3206 | |
---|
.. | .. |
---|
3265 | 3285 | false, false, false), |
---|
3266 | 3286 | VMW_CMD_DEF(SVGA_3D_CMD_DEAD2, &vmw_cmd_invalid, |
---|
3267 | 3287 | false, false, false), |
---|
3268 | | - VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_BITBLT, &vmw_cmd_invalid, |
---|
3269 | | - false, false, false), |
---|
3270 | | - VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_TRANSBLT, &vmw_cmd_invalid, |
---|
3271 | | - false, false, false), |
---|
3272 | | - VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_STRETCHBLT, &vmw_cmd_invalid, |
---|
3273 | | - false, false, false), |
---|
3274 | | - VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_COLORFILL, &vmw_cmd_invalid, |
---|
3275 | | - false, false, false), |
---|
3276 | | - VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_ALPHABLEND, &vmw_cmd_invalid, |
---|
3277 | | - false, false, false), |
---|
3278 | | - VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND, &vmw_cmd_invalid, |
---|
3279 | | - false, false, false), |
---|
| 3288 | + VMW_CMD_DEF(SVGA_3D_CMD_DEAD12, &vmw_cmd_invalid, false, false, false), |
---|
| 3289 | + VMW_CMD_DEF(SVGA_3D_CMD_DEAD13, &vmw_cmd_invalid, false, false, false), |
---|
| 3290 | + VMW_CMD_DEF(SVGA_3D_CMD_DEAD14, &vmw_cmd_invalid, false, false, false), |
---|
| 3291 | + VMW_CMD_DEF(SVGA_3D_CMD_DEAD15, &vmw_cmd_invalid, false, false, false), |
---|
| 3292 | + VMW_CMD_DEF(SVGA_3D_CMD_DEAD16, &vmw_cmd_invalid, false, false, false), |
---|
| 3293 | + VMW_CMD_DEF(SVGA_3D_CMD_DEAD17, &vmw_cmd_invalid, false, false, false), |
---|
3280 | 3294 | VMW_CMD_DEF(SVGA_3D_CMD_SET_OTABLE_BASE, &vmw_cmd_invalid, |
---|
3281 | 3295 | false, false, true), |
---|
3282 | 3296 | VMW_CMD_DEF(SVGA_3D_CMD_READBACK_OTABLE, &vmw_cmd_invalid, |
---|
.. | .. |
---|
3368 | 3382 | VMW_CMD_DEF(SVGA_3D_CMD_DEFINE_GB_SURFACE_V2, &vmw_cmd_invalid, |
---|
3369 | 3383 | false, false, true), |
---|
3370 | 3384 | |
---|
3371 | | - /* |
---|
3372 | | - * DX commands |
---|
3373 | | - */ |
---|
| 3385 | + /* SM commands */ |
---|
3374 | 3386 | VMW_CMD_DEF(SVGA_3D_CMD_DX_DEFINE_CONTEXT, &vmw_cmd_invalid, |
---|
3375 | 3387 | false, false, true), |
---|
3376 | 3388 | VMW_CMD_DEF(SVGA_3D_CMD_DX_DESTROY_CONTEXT, &vmw_cmd_invalid, |
---|
.. | .. |
---|
3486 | 3498 | VMW_CMD_DEF(SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT, |
---|
3487 | 3499 | &vmw_cmd_dx_so_define, true, false, true), |
---|
3488 | 3500 | VMW_CMD_DEF(SVGA_3D_CMD_DX_DESTROY_STREAMOUTPUT, |
---|
3489 | | - &vmw_cmd_dx_cid_check, true, false, true), |
---|
3490 | | - VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_STREAMOUTPUT, &vmw_cmd_dx_cid_check, |
---|
3491 | | - true, false, true), |
---|
| 3501 | + &vmw_cmd_dx_destroy_streamoutput, true, false, true), |
---|
| 3502 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_STREAMOUTPUT, |
---|
| 3503 | + &vmw_cmd_dx_set_streamoutput, true, false, true), |
---|
3492 | 3504 | VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_SOTARGETS, |
---|
3493 | 3505 | &vmw_cmd_dx_set_so_targets, true, false, true), |
---|
3494 | 3506 | VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_INPUT_LAYOUT, |
---|
.. | .. |
---|
3504 | 3516 | true, false, true), |
---|
3505 | 3517 | VMW_CMD_DEF(SVGA_3D_CMD_INTRA_SURFACE_COPY, &vmw_cmd_intra_surface_copy, |
---|
3506 | 3518 | true, false, true), |
---|
| 3519 | + |
---|
| 3520 | + /* |
---|
| 3521 | + * SM5 commands |
---|
| 3522 | + */ |
---|
| 3523 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_DEFINE_UA_VIEW, &vmw_cmd_sm5_view_define, |
---|
| 3524 | + true, false, true), |
---|
| 3525 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_DESTROY_UA_VIEW, &vmw_cmd_sm5_view_remove, |
---|
| 3526 | + true, false, true), |
---|
| 3527 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_CLEAR_UA_VIEW_UINT, &vmw_cmd_clear_uav_uint, |
---|
| 3528 | + true, false, true), |
---|
| 3529 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_CLEAR_UA_VIEW_FLOAT, |
---|
| 3530 | + &vmw_cmd_clear_uav_float, true, false, true), |
---|
| 3531 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_COPY_STRUCTURE_COUNT, &vmw_cmd_invalid, true, |
---|
| 3532 | + false, true), |
---|
| 3533 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_UA_VIEWS, &vmw_cmd_set_uav, true, false, |
---|
| 3534 | + true), |
---|
| 3535 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED_INDIRECT, |
---|
| 3536 | + &vmw_cmd_indexed_instanced_indirect, true, false, true), |
---|
| 3537 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_DRAW_INSTANCED_INDIRECT, |
---|
| 3538 | + &vmw_cmd_instanced_indirect, true, false, true), |
---|
| 3539 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_DISPATCH, &vmw_cmd_sm5, true, false, true), |
---|
| 3540 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_DISPATCH_INDIRECT, |
---|
| 3541 | + &vmw_cmd_dispatch_indirect, true, false, true), |
---|
| 3542 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_CS_UA_VIEWS, &vmw_cmd_set_cs_uav, true, |
---|
| 3543 | + false, true), |
---|
| 3544 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW_V2, |
---|
| 3545 | + &vmw_cmd_sm5_view_define, true, false, true), |
---|
| 3546 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT_WITH_MOB, |
---|
| 3547 | + &vmw_cmd_dx_define_streamoutput, true, false, true), |
---|
| 3548 | + VMW_CMD_DEF(SVGA_3D_CMD_DX_BIND_STREAMOUTPUT, |
---|
| 3549 | + &vmw_cmd_dx_bind_streamoutput, true, false, true), |
---|
3507 | 3550 | }; |
---|
3508 | 3551 | |
---|
3509 | 3552 | bool vmw_cmd_describe(const void *buf, u32 *size, char const **cmd) |
---|
.. | .. |
---|
3552 | 3595 | } |
---|
3553 | 3596 | |
---|
3554 | 3597 | static int vmw_cmd_check(struct vmw_private *dev_priv, |
---|
3555 | | - struct vmw_sw_context *sw_context, |
---|
3556 | | - void *buf, uint32_t *size) |
---|
| 3598 | + struct vmw_sw_context *sw_context, void *buf, |
---|
| 3599 | + uint32_t *size) |
---|
3557 | 3600 | { |
---|
3558 | 3601 | uint32_t cmd_id; |
---|
3559 | 3602 | uint32_t size_remaining = *size; |
---|
.. | .. |
---|
3592 | 3635 | goto out_new; |
---|
3593 | 3636 | |
---|
3594 | 3637 | ret = entry->func(dev_priv, sw_context, header); |
---|
3595 | | - if (unlikely(ret != 0)) |
---|
3596 | | - goto out_invalid; |
---|
| 3638 | + if (unlikely(ret != 0)) { |
---|
| 3639 | + VMW_DEBUG_USER("SVGA3D command: %d failed with error %d\n", |
---|
| 3640 | + cmd_id + SVGA_3D_CMD_BASE, ret); |
---|
| 3641 | + return ret; |
---|
| 3642 | + } |
---|
3597 | 3643 | |
---|
3598 | 3644 | return 0; |
---|
3599 | 3645 | out_invalid: |
---|
3600 | | - DRM_ERROR("Invalid SVGA3D command: %d\n", |
---|
3601 | | - cmd_id + SVGA_3D_CMD_BASE); |
---|
| 3646 | + VMW_DEBUG_USER("Invalid SVGA3D command: %d\n", |
---|
| 3647 | + cmd_id + SVGA_3D_CMD_BASE); |
---|
3602 | 3648 | return -EINVAL; |
---|
3603 | 3649 | out_privileged: |
---|
3604 | | - DRM_ERROR("Privileged SVGA3D command: %d\n", |
---|
3605 | | - cmd_id + SVGA_3D_CMD_BASE); |
---|
| 3650 | + VMW_DEBUG_USER("Privileged SVGA3D command: %d\n", |
---|
| 3651 | + cmd_id + SVGA_3D_CMD_BASE); |
---|
3606 | 3652 | return -EPERM; |
---|
3607 | 3653 | out_old: |
---|
3608 | | - DRM_ERROR("Deprecated (disallowed) SVGA3D command: %d\n", |
---|
3609 | | - cmd_id + SVGA_3D_CMD_BASE); |
---|
| 3654 | + VMW_DEBUG_USER("Deprecated (disallowed) SVGA3D command: %d\n", |
---|
| 3655 | + cmd_id + SVGA_3D_CMD_BASE); |
---|
3610 | 3656 | return -EINVAL; |
---|
3611 | 3657 | out_new: |
---|
3612 | | - DRM_ERROR("SVGA3D command: %d not supported by virtual hardware.\n", |
---|
3613 | | - cmd_id + SVGA_3D_CMD_BASE); |
---|
| 3658 | + VMW_DEBUG_USER("SVGA3D command: %d not supported by virtual device.\n", |
---|
| 3659 | + cmd_id + SVGA_3D_CMD_BASE); |
---|
3614 | 3660 | return -EINVAL; |
---|
3615 | 3661 | } |
---|
3616 | 3662 | |
---|
3617 | 3663 | static int vmw_cmd_check_all(struct vmw_private *dev_priv, |
---|
3618 | | - struct vmw_sw_context *sw_context, |
---|
3619 | | - void *buf, |
---|
| 3664 | + struct vmw_sw_context *sw_context, void *buf, |
---|
3620 | 3665 | uint32_t size) |
---|
3621 | 3666 | { |
---|
3622 | 3667 | int32_t cur_size = size; |
---|
.. | .. |
---|
3634 | 3679 | } |
---|
3635 | 3680 | |
---|
3636 | 3681 | if (unlikely(cur_size != 0)) { |
---|
3637 | | - DRM_ERROR("Command verifier out of sync.\n"); |
---|
| 3682 | + VMW_DEBUG_USER("Command verifier out of sync.\n"); |
---|
3638 | 3683 | return -EINVAL; |
---|
3639 | 3684 | } |
---|
3640 | 3685 | |
---|
.. | .. |
---|
3643 | 3688 | |
---|
3644 | 3689 | static void vmw_free_relocations(struct vmw_sw_context *sw_context) |
---|
3645 | 3690 | { |
---|
3646 | | - sw_context->cur_reloc = 0; |
---|
| 3691 | + /* Memory is validation context memory, so no need to free it */ |
---|
| 3692 | + INIT_LIST_HEAD(&sw_context->bo_relocations); |
---|
3647 | 3693 | } |
---|
3648 | 3694 | |
---|
3649 | 3695 | static void vmw_apply_relocations(struct vmw_sw_context *sw_context) |
---|
3650 | 3696 | { |
---|
3651 | | - uint32_t i; |
---|
3652 | 3697 | struct vmw_relocation *reloc; |
---|
3653 | | - struct ttm_validate_buffer *validate; |
---|
3654 | 3698 | struct ttm_buffer_object *bo; |
---|
3655 | 3699 | |
---|
3656 | | - for (i = 0; i < sw_context->cur_reloc; ++i) { |
---|
3657 | | - reloc = &sw_context->relocs[i]; |
---|
3658 | | - validate = &sw_context->val_bufs[reloc->index].base; |
---|
3659 | | - bo = validate->bo; |
---|
| 3700 | + list_for_each_entry(reloc, &sw_context->bo_relocations, head) { |
---|
| 3701 | + bo = &reloc->vbo->base; |
---|
3660 | 3702 | switch (bo->mem.mem_type) { |
---|
3661 | 3703 | case TTM_PL_VRAM: |
---|
3662 | | - reloc->location->offset += bo->offset; |
---|
| 3704 | + reloc->location->offset += bo->mem.start << PAGE_SHIFT; |
---|
3663 | 3705 | reloc->location->gmrId = SVGA_GMR_FRAMEBUFFER; |
---|
3664 | 3706 | break; |
---|
3665 | 3707 | case VMW_PL_GMR: |
---|
.. | .. |
---|
3673 | 3715 | } |
---|
3674 | 3716 | } |
---|
3675 | 3717 | vmw_free_relocations(sw_context); |
---|
3676 | | -} |
---|
3677 | | - |
---|
3678 | | -/** |
---|
3679 | | - * vmw_resource_list_unrefererence - Free up a resource list and unreference |
---|
3680 | | - * all resources referenced by it. |
---|
3681 | | - * |
---|
3682 | | - * @list: The resource list. |
---|
3683 | | - */ |
---|
3684 | | -static void vmw_resource_list_unreference(struct vmw_sw_context *sw_context, |
---|
3685 | | - struct list_head *list) |
---|
3686 | | -{ |
---|
3687 | | - struct vmw_resource_val_node *val, *val_next; |
---|
3688 | | - |
---|
3689 | | - /* |
---|
3690 | | - * Drop references to resources held during command submission. |
---|
3691 | | - */ |
---|
3692 | | - |
---|
3693 | | - list_for_each_entry_safe(val, val_next, list, head) { |
---|
3694 | | - list_del_init(&val->head); |
---|
3695 | | - vmw_resource_unreference(&val->res); |
---|
3696 | | - |
---|
3697 | | - if (val->staged_bindings) { |
---|
3698 | | - if (val->staged_bindings != sw_context->staged_bindings) |
---|
3699 | | - vmw_binding_state_free(val->staged_bindings); |
---|
3700 | | - else |
---|
3701 | | - sw_context->staged_bindings_inuse = false; |
---|
3702 | | - val->staged_bindings = NULL; |
---|
3703 | | - } |
---|
3704 | | - |
---|
3705 | | - kfree(val); |
---|
3706 | | - } |
---|
3707 | | -} |
---|
3708 | | - |
---|
3709 | | -static void vmw_clear_validations(struct vmw_sw_context *sw_context) |
---|
3710 | | -{ |
---|
3711 | | - struct vmw_validate_buffer *entry, *next; |
---|
3712 | | - struct vmw_resource_val_node *val; |
---|
3713 | | - |
---|
3714 | | - /* |
---|
3715 | | - * Drop references to DMA buffers held during command submission. |
---|
3716 | | - */ |
---|
3717 | | - list_for_each_entry_safe(entry, next, &sw_context->validate_nodes, |
---|
3718 | | - base.head) { |
---|
3719 | | - list_del(&entry->base.head); |
---|
3720 | | - ttm_bo_unref(&entry->base.bo); |
---|
3721 | | - (void) drm_ht_remove_item(&sw_context->res_ht, &entry->hash); |
---|
3722 | | - sw_context->cur_val_buf--; |
---|
3723 | | - } |
---|
3724 | | - BUG_ON(sw_context->cur_val_buf != 0); |
---|
3725 | | - |
---|
3726 | | - list_for_each_entry(val, &sw_context->resource_list, head) |
---|
3727 | | - (void) drm_ht_remove_item(&sw_context->res_ht, &val->hash); |
---|
3728 | | -} |
---|
3729 | | - |
---|
3730 | | -int vmw_validate_single_buffer(struct vmw_private *dev_priv, |
---|
3731 | | - struct ttm_buffer_object *bo, |
---|
3732 | | - bool interruptible, |
---|
3733 | | - bool validate_as_mob) |
---|
3734 | | -{ |
---|
3735 | | - struct vmw_buffer_object *vbo = |
---|
3736 | | - container_of(bo, struct vmw_buffer_object, base); |
---|
3737 | | - struct ttm_operation_ctx ctx = { interruptible, false }; |
---|
3738 | | - int ret; |
---|
3739 | | - |
---|
3740 | | - if (vbo->pin_count > 0) |
---|
3741 | | - return 0; |
---|
3742 | | - |
---|
3743 | | - if (validate_as_mob) |
---|
3744 | | - return ttm_bo_validate(bo, &vmw_mob_placement, &ctx); |
---|
3745 | | - |
---|
3746 | | - /** |
---|
3747 | | - * Put BO in VRAM if there is space, otherwise as a GMR. |
---|
3748 | | - * If there is no space in VRAM and GMR ids are all used up, |
---|
3749 | | - * start evicting GMRs to make room. If the DMA buffer can't be |
---|
3750 | | - * used as a GMR, this will return -ENOMEM. |
---|
3751 | | - */ |
---|
3752 | | - |
---|
3753 | | - ret = ttm_bo_validate(bo, &vmw_vram_gmr_placement, &ctx); |
---|
3754 | | - if (likely(ret == 0 || ret == -ERESTARTSYS)) |
---|
3755 | | - return ret; |
---|
3756 | | - |
---|
3757 | | - /** |
---|
3758 | | - * If that failed, try VRAM again, this time evicting |
---|
3759 | | - * previous contents. |
---|
3760 | | - */ |
---|
3761 | | - |
---|
3762 | | - ret = ttm_bo_validate(bo, &vmw_vram_placement, &ctx); |
---|
3763 | | - return ret; |
---|
3764 | | -} |
---|
3765 | | - |
---|
3766 | | -static int vmw_validate_buffers(struct vmw_private *dev_priv, |
---|
3767 | | - struct vmw_sw_context *sw_context) |
---|
3768 | | -{ |
---|
3769 | | - struct vmw_validate_buffer *entry; |
---|
3770 | | - int ret; |
---|
3771 | | - |
---|
3772 | | - list_for_each_entry(entry, &sw_context->validate_nodes, base.head) { |
---|
3773 | | - ret = vmw_validate_single_buffer(dev_priv, entry->base.bo, |
---|
3774 | | - true, |
---|
3775 | | - entry->validate_as_mob); |
---|
3776 | | - if (unlikely(ret != 0)) |
---|
3777 | | - return ret; |
---|
3778 | | - } |
---|
3779 | | - return 0; |
---|
3780 | 3718 | } |
---|
3781 | 3719 | |
---|
3782 | 3720 | static int vmw_resize_cmd_bounce(struct vmw_sw_context *sw_context, |
---|
.. | .. |
---|
3798 | 3736 | sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size); |
---|
3799 | 3737 | |
---|
3800 | 3738 | if (sw_context->cmd_bounce == NULL) { |
---|
3801 | | - DRM_ERROR("Failed to allocate command bounce buffer.\n"); |
---|
| 3739 | + VMW_DEBUG_USER("Failed to allocate command bounce buffer.\n"); |
---|
3802 | 3740 | sw_context->cmd_bounce_size = 0; |
---|
3803 | 3741 | return -ENOMEM; |
---|
3804 | 3742 | } |
---|
.. | .. |
---|
3813 | 3751 | * If this fails for some reason, We sync the fifo and return NULL. |
---|
3814 | 3752 | * It is then safe to fence buffers with a NULL pointer. |
---|
3815 | 3753 | * |
---|
3816 | | - * If @p_handle is not NULL @file_priv must also not be NULL. Creates |
---|
3817 | | - * a userspace handle if @p_handle is not NULL, otherwise not. |
---|
| 3754 | + * If @p_handle is not NULL @file_priv must also not be NULL. Creates a |
---|
| 3755 | + * userspace handle if @p_handle is not NULL, otherwise not. |
---|
3818 | 3756 | */ |
---|
3819 | 3757 | |
---|
3820 | 3758 | int vmw_execbuf_fence_commands(struct drm_file *file_priv, |
---|
.. | .. |
---|
3831 | 3769 | |
---|
3832 | 3770 | ret = vmw_fifo_send_fence(dev_priv, &sequence); |
---|
3833 | 3771 | if (unlikely(ret != 0)) { |
---|
3834 | | - DRM_ERROR("Fence submission error. Syncing.\n"); |
---|
| 3772 | + VMW_DEBUG_USER("Fence submission error. Syncing.\n"); |
---|
3835 | 3773 | synced = true; |
---|
3836 | 3774 | } |
---|
3837 | 3775 | |
---|
.. | .. |
---|
3842 | 3780 | ret = vmw_fence_create(dev_priv->fman, sequence, p_fence); |
---|
3843 | 3781 | |
---|
3844 | 3782 | if (unlikely(ret != 0 && !synced)) { |
---|
3845 | | - (void) vmw_fallback_wait(dev_priv, false, false, |
---|
3846 | | - sequence, false, |
---|
3847 | | - VMW_FENCE_WAIT_TIMEOUT); |
---|
| 3783 | + (void) vmw_fallback_wait(dev_priv, false, false, sequence, |
---|
| 3784 | + false, VMW_FENCE_WAIT_TIMEOUT); |
---|
3848 | 3785 | *p_fence = NULL; |
---|
3849 | 3786 | } |
---|
3850 | 3787 | |
---|
.. | .. |
---|
3852 | 3789 | } |
---|
3853 | 3790 | |
---|
3854 | 3791 | /** |
---|
3855 | | - * vmw_execbuf_copy_fence_user - copy fence object information to |
---|
3856 | | - * user-space. |
---|
| 3792 | + * vmw_execbuf_copy_fence_user - copy fence object information to user-space. |
---|
3857 | 3793 | * |
---|
3858 | 3794 | * @dev_priv: Pointer to a vmw_private struct. |
---|
3859 | 3795 | * @vmw_fp: Pointer to the struct vmw_fpriv representing the calling file. |
---|
3860 | 3796 | * @ret: Return value from fence object creation. |
---|
3861 | | - * @user_fence_rep: User space address of a struct drm_vmw_fence_rep to |
---|
3862 | | - * which the information should be copied. |
---|
| 3797 | + * @user_fence_rep: User space address of a struct drm_vmw_fence_rep to which |
---|
| 3798 | + * the information should be copied. |
---|
3863 | 3799 | * @fence: Pointer to the fenc object. |
---|
3864 | 3800 | * @fence_handle: User-space fence handle. |
---|
3865 | 3801 | * @out_fence_fd: exported file descriptor for the fence. -1 if not used |
---|
3866 | 3802 | * @sync_file: Only used to clean up in case of an error in this function. |
---|
3867 | 3803 | * |
---|
3868 | | - * This function copies fence information to user-space. If copying fails, |
---|
3869 | | - * The user-space struct drm_vmw_fence_rep::error member is hopefully |
---|
3870 | | - * left untouched, and if it's preloaded with an -EFAULT by user-space, |
---|
3871 | | - * the error will hopefully be detected. |
---|
3872 | | - * Also if copying fails, user-space will be unable to signal the fence |
---|
3873 | | - * object so we wait for it immediately, and then unreference the |
---|
3874 | | - * user-space reference. |
---|
| 3804 | + * This function copies fence information to user-space. If copying fails, the |
---|
| 3805 | + * user-space struct drm_vmw_fence_rep::error member is hopefully left |
---|
| 3806 | + * untouched, and if it's preloaded with an -EFAULT by user-space, the error |
---|
| 3807 | + * will hopefully be detected. |
---|
| 3808 | + * |
---|
| 3809 | + * Also if copying fails, user-space will be unable to signal the fence object |
---|
| 3810 | + * so we wait for it immediately, and then unreference the user-space reference. |
---|
3875 | 3811 | */ |
---|
3876 | 3812 | int |
---|
3877 | 3813 | vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv, |
---|
3878 | | - struct vmw_fpriv *vmw_fp, |
---|
3879 | | - int ret, |
---|
| 3814 | + struct vmw_fpriv *vmw_fp, int ret, |
---|
3880 | 3815 | struct drm_vmw_fence_rep __user *user_fence_rep, |
---|
3881 | | - struct vmw_fence_obj *fence, |
---|
3882 | | - uint32_t fence_handle, |
---|
| 3816 | + struct vmw_fence_obj *fence, uint32_t fence_handle, |
---|
3883 | 3817 | int32_t out_fence_fd) |
---|
3884 | 3818 | { |
---|
3885 | 3819 | struct drm_vmw_fence_rep fence_rep; |
---|
.. | .. |
---|
3901 | 3835 | } |
---|
3902 | 3836 | |
---|
3903 | 3837 | /* |
---|
3904 | | - * copy_to_user errors will be detected by user space not |
---|
3905 | | - * seeing fence_rep::error filled in. Typically |
---|
3906 | | - * user-space would have pre-set that member to -EFAULT. |
---|
| 3838 | + * copy_to_user errors will be detected by user space not seeing |
---|
| 3839 | + * fence_rep::error filled in. Typically user-space would have pre-set |
---|
| 3840 | + * that member to -EFAULT. |
---|
3907 | 3841 | */ |
---|
3908 | 3842 | ret = copy_to_user(user_fence_rep, &fence_rep, |
---|
3909 | 3843 | sizeof(fence_rep)); |
---|
3910 | 3844 | |
---|
3911 | 3845 | /* |
---|
3912 | | - * User-space lost the fence object. We need to sync |
---|
3913 | | - * and unreference the handle. |
---|
| 3846 | + * User-space lost the fence object. We need to sync and unreference the |
---|
| 3847 | + * handle. |
---|
3914 | 3848 | */ |
---|
3915 | 3849 | if (unlikely(ret != 0) && (fence_rep.error == 0)) { |
---|
3916 | | - ttm_ref_object_base_unref(vmw_fp->tfile, |
---|
3917 | | - fence_handle, TTM_REF_USAGE); |
---|
3918 | | - DRM_ERROR("Fence copy error. Syncing.\n"); |
---|
| 3850 | + ttm_ref_object_base_unref(vmw_fp->tfile, fence_handle, |
---|
| 3851 | + TTM_REF_USAGE); |
---|
| 3852 | + VMW_DEBUG_USER("Fence copy error. Syncing.\n"); |
---|
3919 | 3853 | (void) vmw_fence_obj_wait(fence, false, false, |
---|
3920 | 3854 | VMW_FENCE_WAIT_TIMEOUT); |
---|
3921 | 3855 | } |
---|
.. | .. |
---|
3924 | 3858 | } |
---|
3925 | 3859 | |
---|
3926 | 3860 | /** |
---|
3927 | | - * vmw_execbuf_submit_fifo - Patch a command batch and submit it using |
---|
3928 | | - * the fifo. |
---|
| 3861 | + * vmw_execbuf_submit_fifo - Patch a command batch and submit it using the fifo. |
---|
3929 | 3862 | * |
---|
3930 | 3863 | * @dev_priv: Pointer to a device private structure. |
---|
3931 | 3864 | * @kernel_commands: Pointer to the unpatched command batch. |
---|
3932 | 3865 | * @command_size: Size of the unpatched command batch. |
---|
3933 | 3866 | * @sw_context: Structure holding the relocation lists. |
---|
3934 | 3867 | * |
---|
3935 | | - * Side effects: If this function returns 0, then the command batch |
---|
3936 | | - * pointed to by @kernel_commands will have been modified. |
---|
| 3868 | + * Side effects: If this function returns 0, then the command batch pointed to |
---|
| 3869 | + * by @kernel_commands will have been modified. |
---|
3937 | 3870 | */ |
---|
3938 | 3871 | static int vmw_execbuf_submit_fifo(struct vmw_private *dev_priv, |
---|
3939 | | - void *kernel_commands, |
---|
3940 | | - u32 command_size, |
---|
| 3872 | + void *kernel_commands, u32 command_size, |
---|
3941 | 3873 | struct vmw_sw_context *sw_context) |
---|
3942 | 3874 | { |
---|
3943 | 3875 | void *cmd; |
---|
3944 | 3876 | |
---|
3945 | 3877 | if (sw_context->dx_ctx_node) |
---|
3946 | | - cmd = vmw_fifo_reserve_dx(dev_priv, command_size, |
---|
3947 | | - sw_context->dx_ctx_node->res->id); |
---|
| 3878 | + cmd = VMW_FIFO_RESERVE_DX(dev_priv, command_size, |
---|
| 3879 | + sw_context->dx_ctx_node->ctx->id); |
---|
3948 | 3880 | else |
---|
3949 | | - cmd = vmw_fifo_reserve(dev_priv, command_size); |
---|
3950 | | - if (!cmd) { |
---|
3951 | | - DRM_ERROR("Failed reserving fifo space for commands.\n"); |
---|
| 3881 | + cmd = VMW_FIFO_RESERVE(dev_priv, command_size); |
---|
| 3882 | + |
---|
| 3883 | + if (!cmd) |
---|
3952 | 3884 | return -ENOMEM; |
---|
3953 | | - } |
---|
3954 | 3885 | |
---|
3955 | 3886 | vmw_apply_relocations(sw_context); |
---|
3956 | 3887 | memcpy(cmd, kernel_commands, command_size); |
---|
.. | .. |
---|
3962 | 3893 | } |
---|
3963 | 3894 | |
---|
3964 | 3895 | /** |
---|
3965 | | - * vmw_execbuf_submit_cmdbuf - Patch a command batch and submit it using |
---|
3966 | | - * the command buffer manager. |
---|
| 3896 | + * vmw_execbuf_submit_cmdbuf - Patch a command batch and submit it using the |
---|
| 3897 | + * command buffer manager. |
---|
3967 | 3898 | * |
---|
3968 | 3899 | * @dev_priv: Pointer to a device private structure. |
---|
3969 | 3900 | * @header: Opaque handle to the command buffer allocation. |
---|
3970 | 3901 | * @command_size: Size of the unpatched command batch. |
---|
3971 | 3902 | * @sw_context: Structure holding the relocation lists. |
---|
3972 | 3903 | * |
---|
3973 | | - * Side effects: If this function returns 0, then the command buffer |
---|
3974 | | - * represented by @header will have been modified. |
---|
| 3904 | + * Side effects: If this function returns 0, then the command buffer represented |
---|
| 3905 | + * by @header will have been modified. |
---|
3975 | 3906 | */ |
---|
3976 | 3907 | static int vmw_execbuf_submit_cmdbuf(struct vmw_private *dev_priv, |
---|
3977 | 3908 | struct vmw_cmdbuf_header *header, |
---|
3978 | 3909 | u32 command_size, |
---|
3979 | 3910 | struct vmw_sw_context *sw_context) |
---|
3980 | 3911 | { |
---|
3981 | | - u32 id = ((sw_context->dx_ctx_node) ? sw_context->dx_ctx_node->res->id : |
---|
| 3912 | + u32 id = ((sw_context->dx_ctx_node) ? sw_context->dx_ctx_node->ctx->id : |
---|
3982 | 3913 | SVGA3D_INVALID_ID); |
---|
3983 | | - void *cmd = vmw_cmdbuf_reserve(dev_priv->cman, command_size, |
---|
3984 | | - id, false, header); |
---|
| 3914 | + void *cmd = vmw_cmdbuf_reserve(dev_priv->cman, command_size, id, false, |
---|
| 3915 | + header); |
---|
3985 | 3916 | |
---|
3986 | 3917 | vmw_apply_relocations(sw_context); |
---|
3987 | 3918 | vmw_resource_relocations_apply(cmd, &sw_context->res_relocations); |
---|
.. | .. |
---|
4001 | 3932 | * @header: Out parameter returning the opaque pointer to the command buffer. |
---|
4002 | 3933 | * |
---|
4003 | 3934 | * This function checks whether we can use the command buffer manager for |
---|
4004 | | - * submission and if so, creates a command buffer of suitable size and |
---|
4005 | | - * copies the user data into that buffer. |
---|
| 3935 | + * submission and if so, creates a command buffer of suitable size and copies |
---|
| 3936 | + * the user data into that buffer. |
---|
4006 | 3937 | * |
---|
4007 | 3938 | * On successful return, the function returns a pointer to the data in the |
---|
4008 | 3939 | * command buffer and *@header is set to non-NULL. |
---|
4009 | | - * If command buffers could not be used, the function will return the value |
---|
4010 | | - * of @kernel_commands on function call. That value may be NULL. In that case, |
---|
4011 | | - * the value of *@header will be set to NULL. |
---|
| 3940 | + * |
---|
| 3941 | + * If command buffers could not be used, the function will return the value of |
---|
| 3942 | + * @kernel_commands on function call. That value may be NULL. In that case, the |
---|
| 3943 | + * value of *@header will be set to NULL. |
---|
| 3944 | + * |
---|
4012 | 3945 | * If an error is encountered, the function will return a pointer error value. |
---|
4013 | 3946 | * If the function is interrupted by a signal while sleeping, it will return |
---|
4014 | 3947 | * -ERESTARTSYS casted to a pointer error value. |
---|
4015 | 3948 | */ |
---|
4016 | 3949 | static void *vmw_execbuf_cmdbuf(struct vmw_private *dev_priv, |
---|
4017 | 3950 | void __user *user_commands, |
---|
4018 | | - void *kernel_commands, |
---|
4019 | | - u32 command_size, |
---|
| 3951 | + void *kernel_commands, u32 command_size, |
---|
4020 | 3952 | struct vmw_cmdbuf_header **header) |
---|
4021 | 3953 | { |
---|
4022 | 3954 | size_t cmdbuf_size; |
---|
.. | .. |
---|
4024 | 3956 | |
---|
4025 | 3957 | *header = NULL; |
---|
4026 | 3958 | if (command_size > SVGA_CB_MAX_SIZE) { |
---|
4027 | | - DRM_ERROR("Command buffer is too large.\n"); |
---|
| 3959 | + VMW_DEBUG_USER("Command buffer is too large.\n"); |
---|
4028 | 3960 | return ERR_PTR(-EINVAL); |
---|
4029 | 3961 | } |
---|
4030 | 3962 | |
---|
.. | .. |
---|
4034 | 3966 | /* If possible, add a little space for fencing. */ |
---|
4035 | 3967 | cmdbuf_size = command_size + 512; |
---|
4036 | 3968 | cmdbuf_size = min_t(size_t, cmdbuf_size, SVGA_CB_MAX_SIZE); |
---|
4037 | | - kernel_commands = vmw_cmdbuf_alloc(dev_priv->cman, cmdbuf_size, |
---|
4038 | | - true, header); |
---|
| 3969 | + kernel_commands = vmw_cmdbuf_alloc(dev_priv->cman, cmdbuf_size, true, |
---|
| 3970 | + header); |
---|
4039 | 3971 | if (IS_ERR(kernel_commands)) |
---|
4040 | 3972 | return kernel_commands; |
---|
4041 | 3973 | |
---|
4042 | | - ret = copy_from_user(kernel_commands, user_commands, |
---|
4043 | | - command_size); |
---|
| 3974 | + ret = copy_from_user(kernel_commands, user_commands, command_size); |
---|
4044 | 3975 | if (ret) { |
---|
4045 | | - DRM_ERROR("Failed copying commands.\n"); |
---|
| 3976 | + VMW_DEBUG_USER("Failed copying commands.\n"); |
---|
4046 | 3977 | vmw_cmdbuf_header_free(*header); |
---|
4047 | 3978 | *header = NULL; |
---|
4048 | 3979 | return ERR_PTR(-EFAULT); |
---|
.. | .. |
---|
4055 | 3986 | struct vmw_sw_context *sw_context, |
---|
4056 | 3987 | uint32_t handle) |
---|
4057 | 3988 | { |
---|
4058 | | - struct vmw_resource_val_node *ctx_node; |
---|
4059 | 3989 | struct vmw_resource *res; |
---|
4060 | 3990 | int ret; |
---|
| 3991 | + unsigned int size; |
---|
4061 | 3992 | |
---|
4062 | 3993 | if (handle == SVGA3D_INVALID_ID) |
---|
4063 | 3994 | return 0; |
---|
4064 | 3995 | |
---|
4065 | | - ret = vmw_user_resource_lookup_handle(dev_priv, sw_context->fp->tfile, |
---|
4066 | | - handle, user_context_converter, |
---|
4067 | | - &res); |
---|
4068 | | - if (unlikely(ret != 0)) { |
---|
4069 | | - DRM_ERROR("Could not find or user DX context 0x%08x.\n", |
---|
4070 | | - (unsigned) handle); |
---|
| 3996 | + size = vmw_execbuf_res_size(dev_priv, vmw_res_dx_context); |
---|
| 3997 | + ret = vmw_validation_preload_res(sw_context->ctx, size); |
---|
| 3998 | + if (ret) |
---|
4071 | 3999 | return ret; |
---|
| 4000 | + |
---|
| 4001 | + res = vmw_user_resource_noref_lookup_handle |
---|
| 4002 | + (dev_priv, sw_context->fp->tfile, handle, |
---|
| 4003 | + user_context_converter); |
---|
| 4004 | + if (IS_ERR(res)) { |
---|
| 4005 | + VMW_DEBUG_USER("Could not find or user DX context 0x%08x.\n", |
---|
| 4006 | + (unsigned int) handle); |
---|
| 4007 | + return PTR_ERR(res); |
---|
4072 | 4008 | } |
---|
4073 | 4009 | |
---|
4074 | | - ret = vmw_resource_val_add(sw_context, res, &ctx_node); |
---|
| 4010 | + ret = vmw_execbuf_res_noref_val_add(sw_context, res, VMW_RES_DIRTY_SET); |
---|
4075 | 4011 | if (unlikely(ret != 0)) |
---|
4076 | | - goto out_err; |
---|
| 4012 | + return ret; |
---|
4077 | 4013 | |
---|
4078 | | - sw_context->dx_ctx_node = ctx_node; |
---|
| 4014 | + sw_context->dx_ctx_node = vmw_execbuf_info_from_res(sw_context, res); |
---|
4079 | 4015 | sw_context->man = vmw_context_res_man(res); |
---|
4080 | | -out_err: |
---|
4081 | | - vmw_resource_unreference(&res); |
---|
4082 | | - return ret; |
---|
| 4016 | + |
---|
| 4017 | + return 0; |
---|
4083 | 4018 | } |
---|
4084 | 4019 | |
---|
4085 | 4020 | int vmw_execbuf_process(struct drm_file *file_priv, |
---|
4086 | 4021 | struct vmw_private *dev_priv, |
---|
4087 | | - void __user *user_commands, |
---|
4088 | | - void *kernel_commands, |
---|
4089 | | - uint32_t command_size, |
---|
4090 | | - uint64_t throttle_us, |
---|
| 4022 | + void __user *user_commands, void *kernel_commands, |
---|
| 4023 | + uint32_t command_size, uint64_t throttle_us, |
---|
4091 | 4024 | uint32_t dx_context_handle, |
---|
4092 | 4025 | struct drm_vmw_fence_rep __user *user_fence_rep, |
---|
4093 | | - struct vmw_fence_obj **out_fence, |
---|
4094 | | - uint32_t flags) |
---|
| 4026 | + struct vmw_fence_obj **out_fence, uint32_t flags) |
---|
4095 | 4027 | { |
---|
4096 | 4028 | struct vmw_sw_context *sw_context = &dev_priv->ctx; |
---|
4097 | 4029 | struct vmw_fence_obj *fence = NULL; |
---|
4098 | | - struct vmw_resource *error_resource; |
---|
4099 | | - struct list_head resource_list; |
---|
4100 | 4030 | struct vmw_cmdbuf_header *header; |
---|
4101 | | - struct ww_acquire_ctx ticket; |
---|
4102 | | - uint32_t handle; |
---|
| 4031 | + uint32_t handle = 0; |
---|
4103 | 4032 | int ret; |
---|
4104 | 4033 | int32_t out_fence_fd = -1; |
---|
4105 | 4034 | struct sync_file *sync_file = NULL; |
---|
| 4035 | + DECLARE_VAL_CONTEXT(val_ctx, &sw_context->res_ht, 1); |
---|
4106 | 4036 | |
---|
| 4037 | + vmw_validation_set_val_mem(&val_ctx, &dev_priv->vvm); |
---|
4107 | 4038 | |
---|
4108 | 4039 | if (flags & DRM_VMW_EXECBUF_FLAG_EXPORT_FENCE_FD) { |
---|
4109 | 4040 | out_fence_fd = get_unused_fd_flags(O_CLOEXEC); |
---|
4110 | 4041 | if (out_fence_fd < 0) { |
---|
4111 | | - DRM_ERROR("Failed to get a fence file descriptor.\n"); |
---|
| 4042 | + VMW_DEBUG_USER("Failed to get a fence fd.\n"); |
---|
4112 | 4043 | return out_fence_fd; |
---|
4113 | 4044 | } |
---|
4114 | 4045 | } |
---|
.. | .. |
---|
4141 | 4072 | if (unlikely(ret != 0)) |
---|
4142 | 4073 | goto out_unlock; |
---|
4143 | 4074 | |
---|
4144 | | - |
---|
4145 | | - ret = copy_from_user(sw_context->cmd_bounce, |
---|
4146 | | - user_commands, command_size); |
---|
4147 | | - |
---|
| 4075 | + ret = copy_from_user(sw_context->cmd_bounce, user_commands, |
---|
| 4076 | + command_size); |
---|
4148 | 4077 | if (unlikely(ret != 0)) { |
---|
4149 | 4078 | ret = -EFAULT; |
---|
4150 | | - DRM_ERROR("Failed copying commands.\n"); |
---|
| 4079 | + VMW_DEBUG_USER("Failed copying commands.\n"); |
---|
4151 | 4080 | goto out_unlock; |
---|
4152 | 4081 | } |
---|
| 4082 | + |
---|
4153 | 4083 | kernel_commands = sw_context->cmd_bounce; |
---|
4154 | | - } else if (!header) |
---|
| 4084 | + } else if (!header) { |
---|
4155 | 4085 | sw_context->kernel = true; |
---|
| 4086 | + } |
---|
4156 | 4087 | |
---|
4157 | 4088 | sw_context->fp = vmw_fpriv(file_priv); |
---|
4158 | | - sw_context->cur_reloc = 0; |
---|
4159 | | - sw_context->cur_val_buf = 0; |
---|
4160 | | - INIT_LIST_HEAD(&sw_context->resource_list); |
---|
4161 | | - INIT_LIST_HEAD(&sw_context->ctx_resource_list); |
---|
| 4089 | + INIT_LIST_HEAD(&sw_context->ctx_list); |
---|
4162 | 4090 | sw_context->cur_query_bo = dev_priv->pinned_bo; |
---|
4163 | 4091 | sw_context->last_query_ctx = NULL; |
---|
4164 | 4092 | sw_context->needs_post_query_barrier = false; |
---|
.. | .. |
---|
4166 | 4094 | sw_context->dx_query_mob = NULL; |
---|
4167 | 4095 | sw_context->dx_query_ctx = NULL; |
---|
4168 | 4096 | memset(sw_context->res_cache, 0, sizeof(sw_context->res_cache)); |
---|
4169 | | - INIT_LIST_HEAD(&sw_context->validate_nodes); |
---|
4170 | 4097 | INIT_LIST_HEAD(&sw_context->res_relocations); |
---|
| 4098 | + INIT_LIST_HEAD(&sw_context->bo_relocations); |
---|
| 4099 | + |
---|
4171 | 4100 | if (sw_context->staged_bindings) |
---|
4172 | 4101 | vmw_binding_state_reset(sw_context->staged_bindings); |
---|
4173 | 4102 | |
---|
.. | .. |
---|
4175 | 4104 | ret = drm_ht_create(&sw_context->res_ht, VMW_RES_HT_ORDER); |
---|
4176 | 4105 | if (unlikely(ret != 0)) |
---|
4177 | 4106 | goto out_unlock; |
---|
| 4107 | + |
---|
4178 | 4108 | sw_context->res_ht_initialized = true; |
---|
4179 | 4109 | } |
---|
| 4110 | + |
---|
4180 | 4111 | INIT_LIST_HEAD(&sw_context->staged_cmd_res); |
---|
4181 | | - INIT_LIST_HEAD(&resource_list); |
---|
| 4112 | + sw_context->ctx = &val_ctx; |
---|
4182 | 4113 | ret = vmw_execbuf_tie_context(dev_priv, sw_context, dx_context_handle); |
---|
4183 | | - if (unlikely(ret != 0)) { |
---|
4184 | | - list_splice_init(&sw_context->ctx_resource_list, |
---|
4185 | | - &sw_context->resource_list); |
---|
| 4114 | + if (unlikely(ret != 0)) |
---|
4186 | 4115 | goto out_err_nores; |
---|
4187 | | - } |
---|
4188 | 4116 | |
---|
4189 | 4117 | ret = vmw_cmd_check_all(dev_priv, sw_context, kernel_commands, |
---|
4190 | 4118 | command_size); |
---|
4191 | | - /* |
---|
4192 | | - * Merge the resource lists before checking the return status |
---|
4193 | | - * from vmd_cmd_check_all so that all the open hashtabs will |
---|
4194 | | - * be handled properly even if vmw_cmd_check_all fails. |
---|
4195 | | - */ |
---|
4196 | | - list_splice_init(&sw_context->ctx_resource_list, |
---|
4197 | | - &sw_context->resource_list); |
---|
4198 | | - |
---|
4199 | 4119 | if (unlikely(ret != 0)) |
---|
4200 | 4120 | goto out_err_nores; |
---|
4201 | 4121 | |
---|
.. | .. |
---|
4203 | 4123 | if (unlikely(ret != 0)) |
---|
4204 | 4124 | goto out_err_nores; |
---|
4205 | 4125 | |
---|
4206 | | - ret = ttm_eu_reserve_buffers(&ticket, &sw_context->validate_nodes, |
---|
4207 | | - true, NULL); |
---|
| 4126 | + ret = vmw_validation_bo_reserve(&val_ctx, true); |
---|
4208 | 4127 | if (unlikely(ret != 0)) |
---|
4209 | 4128 | goto out_err_nores; |
---|
4210 | 4129 | |
---|
4211 | | - ret = vmw_validate_buffers(dev_priv, sw_context); |
---|
| 4130 | + ret = vmw_validation_bo_validate(&val_ctx, true); |
---|
4212 | 4131 | if (unlikely(ret != 0)) |
---|
4213 | 4132 | goto out_err; |
---|
4214 | 4133 | |
---|
4215 | | - ret = vmw_resources_validate(sw_context); |
---|
| 4134 | + ret = vmw_validation_res_validate(&val_ctx, true); |
---|
4216 | 4135 | if (unlikely(ret != 0)) |
---|
4217 | 4136 | goto out_err; |
---|
| 4137 | + |
---|
| 4138 | + vmw_validation_drop_ht(&val_ctx); |
---|
4218 | 4139 | |
---|
4219 | 4140 | ret = mutex_lock_interruptible(&dev_priv->binding_mutex); |
---|
4220 | 4141 | if (unlikely(ret != 0)) { |
---|
.. | .. |
---|
4241 | 4162 | goto out_err; |
---|
4242 | 4163 | |
---|
4243 | 4164 | vmw_query_bo_switch_commit(dev_priv, sw_context); |
---|
4244 | | - ret = vmw_execbuf_fence_commands(file_priv, dev_priv, |
---|
4245 | | - &fence, |
---|
| 4165 | + ret = vmw_execbuf_fence_commands(file_priv, dev_priv, &fence, |
---|
4246 | 4166 | (user_fence_rep) ? &handle : NULL); |
---|
4247 | 4167 | /* |
---|
4248 | 4168 | * This error is harmless, because if fence submission fails, |
---|
4249 | 4169 | * vmw_fifo_send_fence will sync. The error will be propagated to |
---|
4250 | 4170 | * user-space in @fence_rep |
---|
4251 | 4171 | */ |
---|
4252 | | - |
---|
4253 | 4172 | if (ret != 0) |
---|
4254 | | - DRM_ERROR("Fence submission error. Syncing.\n"); |
---|
| 4173 | + VMW_DEBUG_USER("Fence submission error. Syncing.\n"); |
---|
4255 | 4174 | |
---|
4256 | | - vmw_resources_unreserve(sw_context, false); |
---|
| 4175 | + vmw_execbuf_bindings_commit(sw_context, false); |
---|
| 4176 | + vmw_bind_dx_query_mob(sw_context); |
---|
| 4177 | + vmw_validation_res_unreserve(&val_ctx, false); |
---|
4257 | 4178 | |
---|
4258 | | - ttm_eu_fence_buffer_objects(&ticket, &sw_context->validate_nodes, |
---|
4259 | | - (void *) fence); |
---|
| 4179 | + vmw_validation_bo_fence(sw_context->ctx, fence); |
---|
4260 | 4180 | |
---|
4261 | | - if (unlikely(dev_priv->pinned_bo != NULL && |
---|
4262 | | - !dev_priv->query_cid_valid)) |
---|
| 4181 | + if (unlikely(dev_priv->pinned_bo != NULL && !dev_priv->query_cid_valid)) |
---|
4263 | 4182 | __vmw_execbuf_release_pinned_bo(dev_priv, fence); |
---|
4264 | 4183 | |
---|
4265 | | - vmw_clear_validations(sw_context); |
---|
4266 | | - |
---|
4267 | 4184 | /* |
---|
4268 | | - * If anything fails here, give up trying to export the fence |
---|
4269 | | - * and do a sync since the user mode will not be able to sync |
---|
4270 | | - * the fence itself. This ensures we are still functionally |
---|
4271 | | - * correct. |
---|
| 4185 | + * If anything fails here, give up trying to export the fence and do a |
---|
| 4186 | + * sync since the user mode will not be able to sync the fence itself. |
---|
| 4187 | + * This ensures we are still functionally correct. |
---|
4272 | 4188 | */ |
---|
4273 | 4189 | if (flags & DRM_VMW_EXECBUF_FLAG_EXPORT_FENCE_FD) { |
---|
4274 | 4190 | |
---|
4275 | 4191 | sync_file = sync_file_create(&fence->base); |
---|
4276 | 4192 | if (!sync_file) { |
---|
4277 | | - DRM_ERROR("Unable to create sync file for fence\n"); |
---|
| 4193 | + VMW_DEBUG_USER("Sync file create failed for fence\n"); |
---|
4278 | 4194 | put_unused_fd(out_fence_fd); |
---|
4279 | 4195 | out_fence_fd = -1; |
---|
4280 | 4196 | |
---|
.. | .. |
---|
4305 | 4221 | vmw_fence_obj_unreference(&fence); |
---|
4306 | 4222 | } |
---|
4307 | 4223 | |
---|
4308 | | - list_splice_init(&sw_context->resource_list, &resource_list); |
---|
4309 | 4224 | vmw_cmdbuf_res_commit(&sw_context->staged_cmd_res); |
---|
4310 | 4225 | mutex_unlock(&dev_priv->cmdbuf_mutex); |
---|
4311 | 4226 | |
---|
4312 | 4227 | /* |
---|
4313 | | - * Unreference resources outside of the cmdbuf_mutex to |
---|
4314 | | - * avoid deadlocks in resource destruction paths. |
---|
| 4228 | + * Unreference resources outside of the cmdbuf_mutex to avoid deadlocks |
---|
| 4229 | + * in resource destruction paths. |
---|
4315 | 4230 | */ |
---|
4316 | | - vmw_resource_list_unreference(sw_context, &resource_list); |
---|
| 4231 | + vmw_validation_unref_lists(&val_ctx); |
---|
4317 | 4232 | |
---|
4318 | 4233 | return ret; |
---|
4319 | 4234 | |
---|
4320 | 4235 | out_unlock_binding: |
---|
4321 | 4236 | mutex_unlock(&dev_priv->binding_mutex); |
---|
4322 | 4237 | out_err: |
---|
4323 | | - ttm_eu_backoff_reservation(&ticket, &sw_context->validate_nodes); |
---|
| 4238 | + vmw_validation_bo_backoff(&val_ctx); |
---|
4324 | 4239 | out_err_nores: |
---|
4325 | | - vmw_resources_unreserve(sw_context, true); |
---|
| 4240 | + vmw_execbuf_bindings_commit(sw_context, true); |
---|
| 4241 | + vmw_validation_res_unreserve(&val_ctx, true); |
---|
4326 | 4242 | vmw_resource_relocations_free(&sw_context->res_relocations); |
---|
4327 | 4243 | vmw_free_relocations(sw_context); |
---|
4328 | | - vmw_clear_validations(sw_context); |
---|
4329 | | - if (unlikely(dev_priv->pinned_bo != NULL && |
---|
4330 | | - !dev_priv->query_cid_valid)) |
---|
| 4244 | + if (unlikely(dev_priv->pinned_bo != NULL && !dev_priv->query_cid_valid)) |
---|
4331 | 4245 | __vmw_execbuf_release_pinned_bo(dev_priv, NULL); |
---|
4332 | 4246 | out_unlock: |
---|
4333 | | - list_splice_init(&sw_context->resource_list, &resource_list); |
---|
4334 | | - error_resource = sw_context->error_resource; |
---|
4335 | | - sw_context->error_resource = NULL; |
---|
4336 | 4247 | vmw_cmdbuf_res_revert(&sw_context->staged_cmd_res); |
---|
| 4248 | + vmw_validation_drop_ht(&val_ctx); |
---|
| 4249 | + WARN_ON(!list_empty(&sw_context->ctx_list)); |
---|
4337 | 4250 | mutex_unlock(&dev_priv->cmdbuf_mutex); |
---|
4338 | 4251 | |
---|
4339 | 4252 | /* |
---|
4340 | | - * Unreference resources outside of the cmdbuf_mutex to |
---|
4341 | | - * avoid deadlocks in resource destruction paths. |
---|
| 4253 | + * Unreference resources outside of the cmdbuf_mutex to avoid deadlocks |
---|
| 4254 | + * in resource destruction paths. |
---|
4342 | 4255 | */ |
---|
4343 | | - vmw_resource_list_unreference(sw_context, &resource_list); |
---|
4344 | | - if (unlikely(error_resource != NULL)) |
---|
4345 | | - vmw_resource_unreference(&error_resource); |
---|
| 4256 | + vmw_validation_unref_lists(&val_ctx); |
---|
4346 | 4257 | out_free_header: |
---|
4347 | 4258 | if (header) |
---|
4348 | 4259 | vmw_cmdbuf_header_free(header); |
---|
.. | .. |
---|
4358 | 4269 | * |
---|
4359 | 4270 | * @dev_priv: The device private structure. |
---|
4360 | 4271 | * |
---|
4361 | | - * This function is called to idle the fifo and unpin the query buffer |
---|
4362 | | - * if the normal way to do this hits an error, which should typically be |
---|
4363 | | - * extremely rare. |
---|
| 4272 | + * This function is called to idle the fifo and unpin the query buffer if the |
---|
| 4273 | + * normal way to do this hits an error, which should typically be extremely |
---|
| 4274 | + * rare. |
---|
4364 | 4275 | */ |
---|
4365 | 4276 | static void vmw_execbuf_unpin_panic(struct vmw_private *dev_priv) |
---|
4366 | 4277 | { |
---|
4367 | | - DRM_ERROR("Can't unpin query buffer. Trying to recover.\n"); |
---|
| 4278 | + VMW_DEBUG_USER("Can't unpin query buffer. Trying to recover.\n"); |
---|
4368 | 4279 | |
---|
4369 | 4280 | (void) vmw_fallback_wait(dev_priv, false, true, 0, false, 10*HZ); |
---|
4370 | 4281 | vmw_bo_pin_reserved(dev_priv->pinned_bo, false); |
---|
.. | .. |
---|
4376 | 4287 | |
---|
4377 | 4288 | |
---|
4378 | 4289 | /** |
---|
4379 | | - * __vmw_execbuf_release_pinned_bo - Flush queries and unpin the pinned |
---|
4380 | | - * query bo. |
---|
| 4290 | + * __vmw_execbuf_release_pinned_bo - Flush queries and unpin the pinned query |
---|
| 4291 | + * bo. |
---|
4381 | 4292 | * |
---|
4382 | 4293 | * @dev_priv: The device private structure. |
---|
4383 | | - * @fence: If non-NULL should point to a struct vmw_fence_obj issued |
---|
4384 | | - * _after_ a query barrier that flushes all queries touching the current |
---|
4385 | | - * buffer pointed to by @dev_priv->pinned_bo |
---|
| 4294 | + * @fence: If non-NULL should point to a struct vmw_fence_obj issued _after_ a |
---|
| 4295 | + * query barrier that flushes all queries touching the current buffer pointed to |
---|
| 4296 | + * by @dev_priv->pinned_bo |
---|
4386 | 4297 | * |
---|
4387 | | - * This function should be used to unpin the pinned query bo, or |
---|
4388 | | - * as a query barrier when we need to make sure that all queries have |
---|
4389 | | - * finished before the next fifo command. (For example on hardware |
---|
4390 | | - * context destructions where the hardware may otherwise leak unfinished |
---|
4391 | | - * queries). |
---|
| 4298 | + * This function should be used to unpin the pinned query bo, or as a query |
---|
| 4299 | + * barrier when we need to make sure that all queries have finished before the |
---|
| 4300 | + * next fifo command. (For example on hardware context destructions where the |
---|
| 4301 | + * hardware may otherwise leak unfinished queries). |
---|
4392 | 4302 | * |
---|
4393 | | - * This function does not return any failure codes, but make attempts |
---|
4394 | | - * to do safe unpinning in case of errors. |
---|
| 4303 | + * This function does not return any failure codes, but make attempts to do safe |
---|
| 4304 | + * unpinning in case of errors. |
---|
4395 | 4305 | * |
---|
4396 | | - * The function will synchronize on the previous query barrier, and will |
---|
4397 | | - * thus not finish until that barrier has executed. |
---|
| 4306 | + * The function will synchronize on the previous query barrier, and will thus |
---|
| 4307 | + * not finish until that barrier has executed. |
---|
4398 | 4308 | * |
---|
4399 | | - * the @dev_priv->cmdbuf_mutex needs to be held by the current thread |
---|
4400 | | - * before calling this function. |
---|
| 4309 | + * the @dev_priv->cmdbuf_mutex needs to be held by the current thread before |
---|
| 4310 | + * calling this function. |
---|
4401 | 4311 | */ |
---|
4402 | 4312 | void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv, |
---|
4403 | 4313 | struct vmw_fence_obj *fence) |
---|
4404 | 4314 | { |
---|
4405 | 4315 | int ret = 0; |
---|
4406 | | - struct list_head validate_list; |
---|
4407 | | - struct ttm_validate_buffer pinned_val, query_val; |
---|
4408 | 4316 | struct vmw_fence_obj *lfence = NULL; |
---|
4409 | | - struct ww_acquire_ctx ticket; |
---|
| 4317 | + DECLARE_VAL_CONTEXT(val_ctx, NULL, 0); |
---|
4410 | 4318 | |
---|
4411 | 4319 | if (dev_priv->pinned_bo == NULL) |
---|
4412 | 4320 | goto out_unlock; |
---|
4413 | 4321 | |
---|
4414 | | - INIT_LIST_HEAD(&validate_list); |
---|
4415 | | - |
---|
4416 | | - pinned_val.bo = ttm_bo_reference(&dev_priv->pinned_bo->base); |
---|
4417 | | - pinned_val.shared = false; |
---|
4418 | | - list_add_tail(&pinned_val.head, &validate_list); |
---|
4419 | | - |
---|
4420 | | - query_val.bo = ttm_bo_reference(&dev_priv->dummy_query_bo->base); |
---|
4421 | | - query_val.shared = false; |
---|
4422 | | - list_add_tail(&query_val.head, &validate_list); |
---|
4423 | | - |
---|
4424 | | - ret = ttm_eu_reserve_buffers(&ticket, &validate_list, |
---|
4425 | | - false, NULL); |
---|
4426 | | - if (unlikely(ret != 0)) { |
---|
4427 | | - vmw_execbuf_unpin_panic(dev_priv); |
---|
| 4322 | + ret = vmw_validation_add_bo(&val_ctx, dev_priv->pinned_bo, false, |
---|
| 4323 | + false); |
---|
| 4324 | + if (ret) |
---|
4428 | 4325 | goto out_no_reserve; |
---|
4429 | | - } |
---|
| 4326 | + |
---|
| 4327 | + ret = vmw_validation_add_bo(&val_ctx, dev_priv->dummy_query_bo, false, |
---|
| 4328 | + false); |
---|
| 4329 | + if (ret) |
---|
| 4330 | + goto out_no_reserve; |
---|
| 4331 | + |
---|
| 4332 | + ret = vmw_validation_bo_reserve(&val_ctx, false); |
---|
| 4333 | + if (ret) |
---|
| 4334 | + goto out_no_reserve; |
---|
4430 | 4335 | |
---|
4431 | 4336 | if (dev_priv->query_cid_valid) { |
---|
4432 | 4337 | BUG_ON(fence != NULL); |
---|
4433 | 4338 | ret = vmw_fifo_emit_dummy_query(dev_priv, dev_priv->query_cid); |
---|
4434 | | - if (unlikely(ret != 0)) { |
---|
4435 | | - vmw_execbuf_unpin_panic(dev_priv); |
---|
| 4339 | + if (ret) |
---|
4436 | 4340 | goto out_no_emit; |
---|
4437 | | - } |
---|
4438 | 4341 | dev_priv->query_cid_valid = false; |
---|
4439 | 4342 | } |
---|
4440 | 4343 | |
---|
.. | .. |
---|
4448 | 4351 | NULL); |
---|
4449 | 4352 | fence = lfence; |
---|
4450 | 4353 | } |
---|
4451 | | - ttm_eu_fence_buffer_objects(&ticket, &validate_list, (void *) fence); |
---|
| 4354 | + vmw_validation_bo_fence(&val_ctx, fence); |
---|
4452 | 4355 | if (lfence != NULL) |
---|
4453 | 4356 | vmw_fence_obj_unreference(&lfence); |
---|
4454 | 4357 | |
---|
4455 | | - ttm_bo_unref(&query_val.bo); |
---|
4456 | | - ttm_bo_unref(&pinned_val.bo); |
---|
| 4358 | + vmw_validation_unref_lists(&val_ctx); |
---|
4457 | 4359 | vmw_bo_unreference(&dev_priv->pinned_bo); |
---|
| 4360 | + |
---|
4458 | 4361 | out_unlock: |
---|
4459 | 4362 | return; |
---|
4460 | | - |
---|
4461 | 4363 | out_no_emit: |
---|
4462 | | - ttm_eu_backoff_reservation(&ticket, &validate_list); |
---|
| 4364 | + vmw_validation_bo_backoff(&val_ctx); |
---|
4463 | 4365 | out_no_reserve: |
---|
4464 | | - ttm_bo_unref(&query_val.bo); |
---|
4465 | | - ttm_bo_unref(&pinned_val.bo); |
---|
| 4366 | + vmw_validation_unref_lists(&val_ctx); |
---|
| 4367 | + vmw_execbuf_unpin_panic(dev_priv); |
---|
4466 | 4368 | vmw_bo_unreference(&dev_priv->pinned_bo); |
---|
4467 | 4369 | } |
---|
4468 | 4370 | |
---|
4469 | 4371 | /** |
---|
4470 | | - * vmw_execbuf_release_pinned_bo - Flush queries and unpin the pinned |
---|
4471 | | - * query bo. |
---|
| 4372 | + * vmw_execbuf_release_pinned_bo - Flush queries and unpin the pinned query bo. |
---|
4472 | 4373 | * |
---|
4473 | 4374 | * @dev_priv: The device private structure. |
---|
4474 | 4375 | * |
---|
4475 | | - * This function should be used to unpin the pinned query bo, or |
---|
4476 | | - * as a query barrier when we need to make sure that all queries have |
---|
4477 | | - * finished before the next fifo command. (For example on hardware |
---|
4478 | | - * context destructions where the hardware may otherwise leak unfinished |
---|
4479 | | - * queries). |
---|
| 4376 | + * This function should be used to unpin the pinned query bo, or as a query |
---|
| 4377 | + * barrier when we need to make sure that all queries have finished before the |
---|
| 4378 | + * next fifo command. (For example on hardware context destructions where the |
---|
| 4379 | + * hardware may otherwise leak unfinished queries). |
---|
4480 | 4380 | * |
---|
4481 | | - * This function does not return any failure codes, but make attempts |
---|
4482 | | - * to do safe unpinning in case of errors. |
---|
| 4381 | + * This function does not return any failure codes, but make attempts to do safe |
---|
| 4382 | + * unpinning in case of errors. |
---|
4483 | 4383 | * |
---|
4484 | | - * The function will synchronize on the previous query barrier, and will |
---|
4485 | | - * thus not finish until that barrier has executed. |
---|
| 4384 | + * The function will synchronize on the previous query barrier, and will thus |
---|
| 4385 | + * not finish until that barrier has executed. |
---|
4486 | 4386 | */ |
---|
4487 | 4387 | void vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv) |
---|
4488 | 4388 | { |
---|
.. | .. |
---|
4492 | 4392 | mutex_unlock(&dev_priv->cmdbuf_mutex); |
---|
4493 | 4393 | } |
---|
4494 | 4394 | |
---|
4495 | | -int vmw_execbuf_ioctl(struct drm_device *dev, unsigned long data, |
---|
4496 | | - struct drm_file *file_priv, size_t size) |
---|
| 4395 | +int vmw_execbuf_ioctl(struct drm_device *dev, void *data, |
---|
| 4396 | + struct drm_file *file_priv) |
---|
4497 | 4397 | { |
---|
4498 | 4398 | struct vmw_private *dev_priv = vmw_priv(dev); |
---|
4499 | | - struct drm_vmw_execbuf_arg arg; |
---|
| 4399 | + struct drm_vmw_execbuf_arg *arg = data; |
---|
4500 | 4400 | int ret; |
---|
4501 | | - static const size_t copy_offset[] = { |
---|
4502 | | - offsetof(struct drm_vmw_execbuf_arg, context_handle), |
---|
4503 | | - sizeof(struct drm_vmw_execbuf_arg)}; |
---|
4504 | 4401 | struct dma_fence *in_fence = NULL; |
---|
4505 | 4402 | |
---|
4506 | | - if (unlikely(size < copy_offset[0])) { |
---|
4507 | | - DRM_ERROR("Invalid command size, ioctl %d\n", |
---|
4508 | | - DRM_VMW_EXECBUF); |
---|
4509 | | - return -EINVAL; |
---|
4510 | | - } |
---|
4511 | | - |
---|
4512 | | - if (copy_from_user(&arg, (void __user *) data, copy_offset[0]) != 0) |
---|
4513 | | - return -EFAULT; |
---|
4514 | | - |
---|
4515 | 4403 | /* |
---|
4516 | | - * Extend the ioctl argument while |
---|
4517 | | - * maintaining backwards compatibility: |
---|
4518 | | - * We take different code paths depending on the value of |
---|
4519 | | - * arg.version. |
---|
| 4404 | + * Extend the ioctl argument while maintaining backwards compatibility: |
---|
| 4405 | + * We take different code paths depending on the value of arg->version. |
---|
| 4406 | + * |
---|
| 4407 | + * Note: The ioctl argument is extended and zeropadded by core DRM. |
---|
4520 | 4408 | */ |
---|
4521 | | - |
---|
4522 | | - if (unlikely(arg.version > DRM_VMW_EXECBUF_VERSION || |
---|
4523 | | - arg.version == 0)) { |
---|
4524 | | - DRM_ERROR("Incorrect execbuf version.\n"); |
---|
| 4409 | + if (unlikely(arg->version > DRM_VMW_EXECBUF_VERSION || |
---|
| 4410 | + arg->version == 0)) { |
---|
| 4411 | + VMW_DEBUG_USER("Incorrect execbuf version.\n"); |
---|
4525 | 4412 | return -EINVAL; |
---|
4526 | 4413 | } |
---|
4527 | 4414 | |
---|
4528 | | - if (arg.version > 1 && |
---|
4529 | | - copy_from_user(&arg.context_handle, |
---|
4530 | | - (void __user *) (data + copy_offset[0]), |
---|
4531 | | - copy_offset[arg.version - 1] - |
---|
4532 | | - copy_offset[0]) != 0) |
---|
4533 | | - return -EFAULT; |
---|
4534 | | - |
---|
4535 | | - switch (arg.version) { |
---|
| 4415 | + switch (arg->version) { |
---|
4536 | 4416 | case 1: |
---|
4537 | | - arg.context_handle = (uint32_t) -1; |
---|
| 4417 | + /* For v1 core DRM have extended + zeropadded the data */ |
---|
| 4418 | + arg->context_handle = (uint32_t) -1; |
---|
4538 | 4419 | break; |
---|
4539 | 4420 | case 2: |
---|
4540 | 4421 | default: |
---|
| 4422 | + /* For v2 and later core DRM would have correctly copied it */ |
---|
4541 | 4423 | break; |
---|
4542 | 4424 | } |
---|
4543 | 4425 | |
---|
4544 | | - |
---|
4545 | 4426 | /* If imported a fence FD from elsewhere, then wait on it */ |
---|
4546 | | - if (arg.flags & DRM_VMW_EXECBUF_FLAG_IMPORT_FENCE_FD) { |
---|
4547 | | - in_fence = sync_file_get_fence(arg.imported_fence_fd); |
---|
| 4427 | + if (arg->flags & DRM_VMW_EXECBUF_FLAG_IMPORT_FENCE_FD) { |
---|
| 4428 | + in_fence = sync_file_get_fence(arg->imported_fence_fd); |
---|
4548 | 4429 | |
---|
4549 | 4430 | if (!in_fence) { |
---|
4550 | | - DRM_ERROR("Cannot get imported fence\n"); |
---|
| 4431 | + VMW_DEBUG_USER("Cannot get imported fence\n"); |
---|
4551 | 4432 | return -EINVAL; |
---|
4552 | 4433 | } |
---|
4553 | 4434 | |
---|
.. | .. |
---|
4561 | 4442 | return ret; |
---|
4562 | 4443 | |
---|
4563 | 4444 | ret = vmw_execbuf_process(file_priv, dev_priv, |
---|
4564 | | - (void __user *)(unsigned long)arg.commands, |
---|
4565 | | - NULL, arg.command_size, arg.throttle_us, |
---|
4566 | | - arg.context_handle, |
---|
4567 | | - (void __user *)(unsigned long)arg.fence_rep, |
---|
4568 | | - NULL, |
---|
4569 | | - arg.flags); |
---|
| 4445 | + (void __user *)(unsigned long)arg->commands, |
---|
| 4446 | + NULL, arg->command_size, arg->throttle_us, |
---|
| 4447 | + arg->context_handle, |
---|
| 4448 | + (void __user *)(unsigned long)arg->fence_rep, |
---|
| 4449 | + NULL, arg->flags); |
---|
| 4450 | + |
---|
4570 | 4451 | ttm_read_unlock(&dev_priv->reservation_sem); |
---|
4571 | 4452 | if (unlikely(ret != 0)) |
---|
4572 | 4453 | goto out; |
---|