I really wonder what's wrong with my mail client, but it looks like this
patch never made it at least to dri-devel.
Forwarding manually now,
Christian.
Am 04.09.2017 um 15:16 schrieb Christian König:
From: Christian König <christian.koenig@xxxxxxx>
The logic is buggy and unnecessary complex. When dma_fence_get_rcu() fails to
acquire a reference it doesn't necessary mean that there is no fence at all.
It usually mean that the fence was replaced by a new one and in this situation
we certainly want to have the new one as result and *NOT* NULL.
Signed-off-by: Christian König <christian.koenig@xxxxxxx>
Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Cc: Daniel Vetter <daniel.vetter@xxxxxxxx>
Cc: Sumit Semwal <sumit.semwal@xxxxxxxxxx>
Cc: linux-media@xxxxxxxxxxxxxxx
Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx
Cc: linaro-mm-sig@xxxxxxxxxxxxxxxx
---
include/linux/dma-fence.h | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index a5195a7..37f3d67 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -246,27 +246,8 @@ dma_fence_get_rcu_safe(struct dma_fence * __rcu *fencep)
struct dma_fence *fence;
fence = rcu_dereference(*fencep);
- if (!fence || !dma_fence_get_rcu(fence))
- return NULL;
-
- /* The atomic_inc_not_zero() inside dma_fence_get_rcu()
- * provides a full memory barrier upon success (such as now).
- * This is paired with the write barrier from assigning
- * to the __rcu protected fence pointer so that if that
- * pointer still matches the current fence, we know we
- * have successfully acquire a reference to it. If it no
- * longer matches, we are holding a reference to some other
- * reallocated pointer. This is possible if the allocator
- * is using a freelist like SLAB_TYPESAFE_BY_RCU where the
- * fence remains valid for the RCU grace period, but it
- * may be reallocated. When using such allocators, we are
- * responsible for ensuring the reference we get is to
- * the right fence, as below.
- */
- if (fence == rcu_access_pointer(*fencep))
- return rcu_pointer_handoff(fence);
-
- dma_fence_put(fence);
+ if (!fence || dma_fence_get_rcu(fence))
+ return fence;
} while (1);
}