author: Chris Wilson <chris@chris-wilson.co.uk> 2018-10-26 09:03:02 +0100
committer: Chris Wilson <chris@chris-wilson.co.uk> 2018-10-26 15:42:11 +0100
commit: a590d0fdbaa56f482ff515e1040b6d9b1b200d63
parent: 4fb2c933c9656435e8300fd6011daa3d4b0128fd
Commit Summary:
Diffstat:
1 file 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();
}