aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_syncobj.c
diff options
context:
space:
mode:
authorVille Syrjälä <[email protected]>2017-11-02 20:03:35 +0000
committerVille Syrjälä <[email protected]>2017-11-09 18:34:21 +0000
commit563eaf53317f2511f78217a1f8d785b8c8ed1cad (patch)
treedd5d7a00d93505f93fba632b6f027c7cc2a944c8 /drivers/gpu/drm/drm_syncobj.c
parentdma-buf/fence: Sparse wants __rcu on the object itself (diff)
downloadkernel-563eaf53317f2511f78217a1f8d785b8c8ed1cad.tar.gz
kernel-563eaf53317f2511f78217a1f8d785b8c8ed1cad.zip
drm/syncobj: Use proper methods for accessing rcu protected pointers
Use rcu_dereference_protected() and rcu_assign_pointer() for accessing the rcu protected syncobj->fence pointer. This eliminates several sparse warnings. Cc: Dave Airlie <[email protected]> Cc: Jason Ekstrand <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Alex Deucher <[email protected]> Cc: Christian König <[email protected]> Cc: Sumit Semwal <[email protected]> Cc: Chris Wilson <[email protected]> Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Daniel Vetter <[email protected]> Acked-by: Christian König <[email protected]>
Diffstat (limited to 'drivers/gpu/drm/drm_syncobj.c')
-rw-r--r--drivers/gpu/drm/drm_syncobj.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 7081ae601d6f..7943c215a03c 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -106,7 +106,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj,
* callback when a fence has already been set.
*/
if (syncobj->fence) {
- *fence = dma_fence_get(syncobj->fence);
+ *fence = dma_fence_get(rcu_dereference_protected(syncobj->fence,
+ lockdep_is_held(&syncobj->lock)));
ret = 1;
} else {
*fence = NULL;
@@ -168,8 +169,9 @@ void drm_syncobj_replace_fence(struct drm_syncobj *syncobj,
spin_lock(&syncobj->lock);
- old_fence = syncobj->fence;
- syncobj->fence = fence;
+ old_fence = rcu_dereference_protected(syncobj->fence,
+ lockdep_is_held(&syncobj->lock));
+ rcu_assign_pointer(syncobj->fence, fence);
if (fence != old_fence) {
list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) {
@@ -613,7 +615,8 @@ static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj,
container_of(cb, struct syncobj_wait_entry, syncobj_cb);
/* This happens inside the syncobj lock */
- wait->fence = dma_fence_get(syncobj->fence);
+ wait->fence = dma_fence_get(rcu_dereference_protected(syncobj->fence,
+ lockdep_is_held(&syncobj->lock)));
wake_up_process(wait->task);
}