diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2018-09-26 17:32:40 +0300 |
---|---|---|
committer | Thomas Hellstrom <thellstrom@vmware.com> | 2018-09-28 09:57:09 +0300 |
commit | e8c66efbfe3a2e3cbc573f2474a3d51690f1b857 (patch) | |
tree | f6f43b8ada79b82dd0f577686638caf46cb5b45a /drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | |
parent | 1b9a01d62cb1bed2bc98f8b4e31d5b9daf0a446b (diff) | |
download | linux-e8c66efbfe3a2e3cbc573f2474a3d51690f1b857.tar.xz |
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: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_resource.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index cf48d0b157f6..8a029bade32a 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c @@ -231,6 +231,41 @@ out_bad_resource: } /** + * 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. * * The pointer this pointed at by out_surf and out_buf needs to be null. |