diff options
-rw-r--r-- | drivers/dma-buf/reservation.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index d4881f91c43b..dec3a815455d 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c | |||
@@ -431,12 +431,25 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj, | |||
431 | long ret = timeout ? timeout : 1; | 431 | long ret = timeout ? timeout : 1; |
432 | 432 | ||
433 | retry: | 433 | retry: |
434 | fence = NULL; | ||
435 | shared_count = 0; | 434 | shared_count = 0; |
436 | seq = read_seqcount_begin(&obj->seq); | 435 | seq = read_seqcount_begin(&obj->seq); |
437 | rcu_read_lock(); | 436 | rcu_read_lock(); |
438 | 437 | ||
439 | if (wait_all) { | 438 | fence = rcu_dereference(obj->fence_excl); |
439 | if (fence && !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { | ||
440 | if (!dma_fence_get_rcu(fence)) | ||
441 | goto unlock_retry; | ||
442 | |||
443 | if (dma_fence_is_signaled(fence)) { | ||
444 | dma_fence_put(fence); | ||
445 | fence = NULL; | ||
446 | } | ||
447 | |||
448 | } else { | ||
449 | fence = NULL; | ||
450 | } | ||
451 | |||
452 | if (!fence && wait_all) { | ||
440 | struct reservation_object_list *fobj = | 453 | struct reservation_object_list *fobj = |
441 | rcu_dereference(obj->fence); | 454 | rcu_dereference(obj->fence); |
442 | 455 | ||
@@ -463,22 +476,6 @@ retry: | |||
463 | } | 476 | } |
464 | } | 477 | } |
465 | 478 | ||
466 | if (!shared_count) { | ||
467 | struct dma_fence *fence_excl = rcu_dereference(obj->fence_excl); | ||
468 | |||
469 | if (fence_excl && | ||
470 | !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, | ||
471 | &fence_excl->flags)) { | ||
472 | if (!dma_fence_get_rcu(fence_excl)) | ||
473 | goto unlock_retry; | ||
474 | |||
475 | if (dma_fence_is_signaled(fence_excl)) | ||
476 | dma_fence_put(fence_excl); | ||
477 | else | ||
478 | fence = fence_excl; | ||
479 | } | ||
480 | } | ||
481 | |||
482 | rcu_read_unlock(); | 479 | rcu_read_unlock(); |
483 | if (fence) { | 480 | if (fence) { |
484 | if (read_seqcount_retry(&obj->seq, seq)) { | 481 | if (read_seqcount_retry(&obj->seq, seq)) { |