summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/dma-buf/reservation.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
index 5fb4fd461908..c1618335ca99 100644
--- a/drivers/dma-buf/reservation.c
+++ b/drivers/dma-buf/reservation.c
@@ -147,16 +147,17 @@ void reservation_object_add_shared_fence(struct reservation_object *obj,
struct dma_fence *fence)
{
struct reservation_object_list *fobj;
- unsigned int i;
+ unsigned int i, count;
dma_fence_get(fence);
fobj = reservation_object_get_list(obj);
+ count = fobj->shared_count;
preempt_disable();
write_seqcount_begin(&obj->seq);
- for (i = 0; i < fobj->shared_count; ++i) {
+ for (i = 0; i < count; ++i) {
struct dma_fence *old_fence;
old_fence = rcu_dereference_protected(fobj->shared[i],
@@ -169,14 +170,13 @@ void reservation_object_add_shared_fence(struct reservation_object *obj,
}
BUG_ON(fobj->shared_count >= fobj->shared_max);
- fobj->shared_count++;
+ count++;
replace:
- /*
- * memory barrier is added by write_seqcount_begin,
- * fobj->shared_count is protected by this lock too
- */
RCU_INIT_POINTER(fobj->shared[i], fence);
+ /* pointer update must be visible before we extend the shared_count */
+ smp_store_mb(fobj->shared_count, count);
+
write_seqcount_end(&obj->seq);
preempt_enable();
}