Skip to content

Commit 9c079b8

Browse files
committed
drm/vmwgfx: Adapt execbuf to the new validation api
Strip the old execbuf validation functionality and use the new API instead. Also use the new API for a now removed execbuf function that was called from the kms code. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Sinclair Yeh <syeh@vmware.com>
1 parent 84e1bf0 commit 9c079b8

File tree

3 files changed

+360
-594
lines changed

3 files changed

+360
-594
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_drv.h

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#ifndef _VMWGFX_DRV_H_
2929
#define _VMWGFX_DRV_H_
3030

31+
#include "vmwgfx_validation.h"
3132
#include "vmwgfx_reg.h"
3233
#include <drm/drmP.h>
3334
#include <drm/vmwgfx_drm.h>
@@ -207,26 +208,27 @@ struct vmw_fifo_state {
207208
struct vmw_relocation {
208209
SVGAMobId *mob_loc;
209210
SVGAGuestPtr *location;
210-
uint32_t index;
211+
struct vmw_buffer_object *vbo;
211212
};
212213

213214
/**
214215
* struct vmw_res_cache_entry - resource information cache entry
215-
*
216+
* @handle: User-space handle of a resource.
217+
* @res: Non-ref-counted pointer to the resource.
218+
* @valid_handle: Whether the @handle member is valid.
216219
* @valid: Whether the entry is valid, which also implies that the execbuf
217220
* code holds a reference to the resource, and it's placed on the
218221
* validation list.
219-
* @handle: User-space handle of a resource.
220-
* @res: Non-ref-counted pointer to the resource.
221222
*
222223
* Used to avoid frequent repeated user-space handle lookups of the
223224
* same resource.
224225
*/
225226
struct vmw_res_cache_entry {
226-
bool valid;
227227
uint32_t handle;
228228
struct vmw_resource *res;
229-
struct vmw_resource_val_node *node;
229+
void *private;
230+
unsigned short valid_handle;
231+
unsigned short valid;
230232
};
231233

232234
/**
@@ -291,21 +293,52 @@ enum vmw_display_unit_type {
291293
vmw_du_screen_target
292294
};
293295

296+
struct vmw_validation_context;
297+
struct vmw_ctx_validation_info;
294298

299+
/**
300+
* struct vmw_sw_context - Command submission context
301+
* @res_ht: Pointer hash table used to find validation duplicates
302+
* @kernel: Whether the command buffer originates from kernel code rather
303+
* than from user-space
304+
* @fp: If @kernel is false, points to the file of the client. Otherwise
305+
* NULL
306+
* @relocs: Array of buffer object relocations
307+
* @cur_reloc: Cursor pointing to the current relocation
308+
* @cmd_bounce: Command bounce buffer used for command validation before
309+
* copying to fifo space
310+
* @cmd_bounce_size: Current command bounce buffer size
311+
* @cur_query_bo: Current buffer object used as query result buffer
312+
* @res_relocations: List of resource relocations
313+
* @buf_start: Pointer to start of memory where command validation takes
314+
* place
315+
* @res_cache: Cache of recently looked up resources
316+
* @last_query_ctx: Last context that submitted a query
317+
* @needs_post_query_barrier: Whether a query barrier is needed after
318+
* command submission
319+
* @error_resource: Pointer to hold a reference to the resource causing
320+
* an error
321+
* @staged_bindings: Cached per-context binding tracker
322+
* @staged_bindings_inuse: Whether the cached per-context binding tracker
323+
* is in use
324+
* @staged_cmd_res: List of staged command buffer managed resources in this
325+
* command buffer
326+
* @ctx_list: List of context resources referenced in this command buffer
327+
* @dx_ctx_node: Validation metadata of the current DX context
328+
* @dx_query_mob: The MOB used for DX queries
329+
* @dx_query_ctx: The DX context used for the last DX query
330+
* @man: Pointer to the command buffer managed resource manager
331+
* @ctx: The validation context
332+
*/
295333
struct vmw_sw_context{
296334
struct drm_open_hash res_ht;
297335
bool res_ht_initialized;
298-
bool kernel; /**< is the called made from the kernel */
336+
bool kernel;
299337
struct vmw_fpriv *fp;
300-
struct list_head validate_nodes;
301338
struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS];
302339
uint32_t cur_reloc;
303-
struct vmw_validate_buffer val_bufs[VMWGFX_MAX_VALIDATIONS];
304-
uint32_t cur_val_buf;
305340
uint32_t *cmd_bounce;
306341
uint32_t cmd_bounce_size;
307-
struct list_head resource_list;
308-
struct list_head ctx_resource_list; /* For contexts and cotables */
309342
struct vmw_buffer_object *cur_query_bo;
310343
struct list_head res_relocations;
311344
uint32_t *buf_start;
@@ -316,10 +349,12 @@ struct vmw_sw_context{
316349
struct vmw_ctx_binding_state *staged_bindings;
317350
bool staged_bindings_inuse;
318351
struct list_head staged_cmd_res;
319-
struct vmw_resource_val_node *dx_ctx_node;
352+
struct list_head ctx_list;
353+
struct vmw_ctx_validation_info *dx_ctx_node;
320354
struct vmw_buffer_object *dx_query_mob;
321355
struct vmw_resource *dx_query_ctx;
322356
struct vmw_cmdbuf_res_manager *man;
357+
struct vmw_validation_context *ctx;
323358
};
324359

325360
struct vmw_legacy_display;
@@ -864,10 +899,6 @@ extern void vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
864899
uint32_t fence_handle,
865900
int32_t out_fence_fd,
866901
struct sync_file *sync_file);
867-
extern int vmw_validate_single_buffer(struct vmw_private *dev_priv,
868-
struct ttm_buffer_object *bo,
869-
bool interruptible,
870-
bool validate_as_mob);
871902
bool vmw_cmd_describe(const void *buf, u32 *size, char const **cmd);
872903

873904
/**

0 commit comments

Comments
 (0)