Commit e8c66efb authored by Thomas Hellstrom's avatar Thomas Hellstrom

drm/vmwgfx: Make user resource lookups reference-free during validation

Make the process of looking up a user resource and adding it to the
validation list reference-free unless when it's actually added to the
validation list where a single reference is taken.
This saves two locked atomic operations per command stream buffer object
handle lookup, unless there is a lookup cache hit.
Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: default avatarSinclair Yeh <syeh@vmware.com>
parent 1b9a01d6
...@@ -337,8 +337,6 @@ struct vmw_ctx_validation_info; ...@@ -337,8 +337,6 @@ struct vmw_ctx_validation_info;
* @last_query_ctx: Last context that submitted a query * @last_query_ctx: Last context that submitted a query
* @needs_post_query_barrier: Whether a query barrier is needed after * @needs_post_query_barrier: Whether a query barrier is needed after
* command submission * command submission
* @error_resource: Pointer to hold a reference to the resource causing
* an error
* @staged_bindings: Cached per-context binding tracker * @staged_bindings: Cached per-context binding tracker
* @staged_bindings_inuse: Whether the cached per-context binding tracker * @staged_bindings_inuse: Whether the cached per-context binding tracker
* is in use * is in use
...@@ -365,7 +363,6 @@ struct vmw_sw_context{ ...@@ -365,7 +363,6 @@ struct vmw_sw_context{
struct vmw_res_cache_entry res_cache[vmw_res_max]; struct vmw_res_cache_entry res_cache[vmw_res_max];
struct vmw_resource *last_query_ctx; struct vmw_resource *last_query_ctx;
bool needs_post_query_barrier; bool needs_post_query_barrier;
struct vmw_resource *error_resource;
struct vmw_ctx_binding_state *staged_bindings; struct vmw_ctx_binding_state *staged_bindings;
bool staged_bindings_inuse; bool staged_bindings_inuse;
struct list_head staged_cmd_res; struct list_head staged_cmd_res;
...@@ -698,6 +695,12 @@ extern int vmw_user_resource_lookup_handle( ...@@ -698,6 +695,12 @@ extern int vmw_user_resource_lookup_handle(
uint32_t handle, uint32_t handle,
const struct vmw_user_resource_conv *converter, const struct vmw_user_resource_conv *converter,
struct vmw_resource **p_res); struct vmw_resource **p_res);
extern struct vmw_resource *
vmw_user_resource_noref_lookup_handle(struct vmw_private *dev_priv,
struct ttm_object_file *tfile,
uint32_t handle,
const struct vmw_user_resource_conv *
converter);
extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data, extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv); struct drm_file *file_priv);
extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data, extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data,
...@@ -716,6 +719,15 @@ extern int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob); ...@@ -716,6 +719,15 @@ extern int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob);
extern void vmw_resource_evict_all(struct vmw_private *dev_priv); extern void vmw_resource_evict_all(struct vmw_private *dev_priv);
extern void vmw_resource_unbind_list(struct vmw_buffer_object *vbo); extern void vmw_resource_unbind_list(struct vmw_buffer_object *vbo);
/**
* vmw_user_resource_noref_release - release a user resource pointer looked up
* without reference
*/
static inline void vmw_user_resource_noref_release(void)
{
ttm_base_object_noref_release();
}
/** /**
* Buffer object helper functions - vmwgfx_bo.c * Buffer object helper functions - vmwgfx_bo.c
*/ */
......
This diff is collapsed.
...@@ -230,6 +230,41 @@ int vmw_user_resource_lookup_handle(struct vmw_private *dev_priv, ...@@ -230,6 +230,41 @@ int vmw_user_resource_lookup_handle(struct vmw_private *dev_priv,
return ret; return ret;
} }
/**
* vmw_user_resource_lookup_handle - lookup a struct resource from a
* TTM user-space handle and perform basic type checks
*
* @dev_priv: Pointer to a device private struct
* @tfile: Pointer to a struct ttm_object_file identifying the caller
* @handle: The TTM user-space handle
* @converter: Pointer to an object describing the resource type
* @p_res: On successful return the location pointed to will contain
* a pointer to a refcounted struct vmw_resource.
*
* If the handle can't be found or is associated with an incorrect resource
* type, -EINVAL will be returned.
*/
struct vmw_resource *
vmw_user_resource_noref_lookup_handle(struct vmw_private *dev_priv,
struct ttm_object_file *tfile,
uint32_t handle,
const struct vmw_user_resource_conv
*converter)
{
struct ttm_base_object *base;
base = ttm_base_object_noref_lookup(tfile, handle);
if (!base)
return ERR_PTR(-ESRCH);
if (unlikely(ttm_base_object_type(base) != converter->object_type)) {
ttm_base_object_noref_release();
return ERR_PTR(-EINVAL);
}
return converter->base_obj_to_res(base);
}
/** /**
* Helper function that looks either a surface or bo. * Helper function that looks either a surface or bo.
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment