diff options
author | Christian König <ckoenig.leichtzumerken@gmail.com> | 2018-01-22 15:00:03 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-01-23 10:46:39 -0500 |
commit | 5bffee867df7494ecd32c1e6ec4e8fc934c521b7 (patch) | |
tree | a1f67f409659ef5dc2057553614ef7d944e6013f | |
parent | 341a0ffceaa44660c43d219a3b2569ebbd7d3ad1 (diff) |
dma-buf: fix reservation_object_wait_timeout_rcu once more v2
We need to set shared_count even if we already have a fence to wait for.
v2: init i to -1 as well
Signed-off-by: Christian König <christian.koenig@amd.com>
Cc: stable@vger.kernel.org
Tested-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180122200003.6665-1-christian.koenig@amd.com
-rw-r--r-- | drivers/dma-buf/reservation.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index b759a569b7b8..04ebe2204c12 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c | |||
@@ -471,13 +471,15 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, | |||
471 | unsigned long timeout) | 471 | unsigned long timeout) |
472 | { | 472 | { |
473 | struct dma_fence *fence; | 473 | struct dma_fence *fence; |
474 | unsigned seq, shared_count, i = 0; | 474 | unsigned seq, shared_count; |
475 | long ret = timeout ? timeout : 1; | 475 | long ret = timeout ? timeout : 1; |
476 | int i; | ||
476 | 477 | ||
477 | retry: | 478 | retry: |
478 | shared_count = 0; | 479 | shared_count = 0; |
479 | seq = read_seqcount_begin(&obj->seq); | 480 | seq = read_seqcount_begin(&obj->seq); |
480 | rcu_read_lock(); | 481 | rcu_read_lock(); |
482 | i = -1; | ||
481 | 483 | ||
482 | fence = rcu_dereference(obj->fence_excl); | 484 | fence = rcu_dereference(obj->fence_excl); |
483 | if (fence && !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { | 485 | if (fence && !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { |
@@ -493,14 +495,14 @@ retry: | |||
493 | fence = NULL; | 495 | fence = NULL; |
494 | } | 496 | } |
495 | 497 | ||
496 | if (!fence && wait_all) { | 498 | if (wait_all) { |
497 | struct reservation_object_list *fobj = | 499 | struct reservation_object_list *fobj = |
498 | rcu_dereference(obj->fence); | 500 | rcu_dereference(obj->fence); |
499 | 501 | ||
500 | if (fobj) | 502 | if (fobj) |
501 | shared_count = fobj->shared_count; | 503 | shared_count = fobj->shared_count; |
502 | 504 | ||
503 | for (i = 0; i < shared_count; ++i) { | 505 | for (i = 0; !fence && i < shared_count; ++i) { |
504 | struct dma_fence *lfence = rcu_dereference(fobj->shared[i]); | 506 | struct dma_fence *lfence = rcu_dereference(fobj->shared[i]); |
505 | 507 | ||
506 | if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, | 508 | if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, |