Merge tag 'dt-5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-microblaze.git] / drivers / dma-buf / dma-resv.c
index f26c717..e744fd8 100644 (file)
@@ -615,25 +615,21 @@ static inline int dma_resv_test_signaled_single(struct dma_fence *passed_fence)
  */
 bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all)
 {
-       unsigned int seq, shared_count;
+       struct dma_fence *fence;
+       unsigned int seq;
        int ret;
 
        rcu_read_lock();
 retry:
        ret = true;
-       shared_count = 0;
        seq = read_seqcount_begin(&obj->seq);
 
        if (test_all) {
                struct dma_resv_list *fobj = dma_resv_shared_list(obj);
-               unsigned int i;
-
-               if (fobj)
-                       shared_count = fobj->shared_count;
+               unsigned int i, shared_count;
 
+               shared_count = fobj ? fobj->shared_count : 0;
                for (i = 0; i < shared_count; ++i) {
-                       struct dma_fence *fence;
-
                        fence = rcu_dereference(fobj->shared[i]);
                        ret = dma_resv_test_signaled_single(fence);
                        if (ret < 0)
@@ -641,24 +637,19 @@ retry:
                        else if (!ret)
                                break;
                }
-
-               if (read_seqcount_retry(&obj->seq, seq))
-                       goto retry;
        }
 
-       if (!shared_count) {
-               struct dma_fence *fence_excl = dma_resv_excl_fence(obj);
-
-               if (fence_excl) {
-                       ret = dma_resv_test_signaled_single(fence_excl);
-                       if (ret < 0)
-                               goto retry;
+       fence = dma_resv_excl_fence(obj);
+       if (ret && fence) {
+               ret = dma_resv_test_signaled_single(fence);
+               if (ret < 0)
+                       goto retry;
 
-                       if (read_seqcount_retry(&obj->seq, seq))
-                               goto retry;
-               }
        }
 
+       if (read_seqcount_retry(&obj->seq, seq))
+               goto retry;
+
        rcu_read_unlock();
        return ret;
 }