diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2018-09-26 16:55:16 +0300 |
---|---|---|
committer | Thomas Hellstrom <thellstrom@vmware.com> | 2018-09-27 17:14:48 +0300 |
commit | e14c02e6b6990e9f6ee18a214a22ac26bae1b25e (patch) | |
tree | 42258a937b40f01e9dcd935b089f68f6f824a0c3 /drivers/gpu/drm/vmwgfx/ttm_object.h | |
parent | c7eae62666ade1c8c9960085911e420227144d5a (diff) | |
download | linux-e14c02e6b6990e9f6ee18a214a22ac26bae1b25e.tar.xz |
drm/vmwgfx: Look up objects without taking a reference
Typically when we look up objects under the rcu lock, we take a reference
to make sure the returned object pointer is valid.
Now provide a function to look up an object and instead of taking a
reference to it, keep the rcu lock held when returning the object pointer.
This means that the object pointer is valid as long as the rcu lock is
held, but the object may be doomed (its refcount may be zero). Any
persistent usage of the object pointer outside of the rcu lock requires
a reference to be taken using kref_get_unless_zero().
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/ttm_object.h')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/ttm_object.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/gpu/drm/vmwgfx/ttm_object.h b/drivers/gpu/drm/vmwgfx/ttm_object.h index 7aa213f5d677..50d26c7ff42d 100644 --- a/drivers/gpu/drm/vmwgfx/ttm_object.h +++ b/drivers/gpu/drm/vmwgfx/ttm_object.h @@ -357,4 +357,19 @@ extern int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, * per idr. */ #define TTM_OBJ_EXTRA_SIZE 128 + +struct ttm_base_object * +ttm_base_object_noref_lookup(struct ttm_object_file *tfile, uint32_t key); + +/** + * ttm_base_object_noref_release - release a base object pointer looked up + * without reference + * + * Releases a base object pointer looked up with ttm_base_object_noref_lookup(). + */ +static inline void ttm_base_object_noref_release(void) +{ + __acquire(RCU); + rcu_read_unlock(); +} #endif |