Commit 9d38814d authored by Christian König's avatar Christian König

dma-buf: fix dma_resv_test_signaled test_all handling v2

As the name implies if testing all fences is requested we
should indeed test all fences and not skip the exclusive
one because we see shared ones.

v2: fix logic once more
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210702111642.17259-3-christian.koenig@amd.com
parent a0356899
...@@ -615,25 +615,21 @@ static inline int dma_resv_test_signaled_single(struct dma_fence *passed_fence) ...@@ -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) 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; int ret;
rcu_read_lock(); rcu_read_lock();
retry: retry:
ret = true; ret = true;
shared_count = 0;
seq = read_seqcount_begin(&obj->seq); seq = read_seqcount_begin(&obj->seq);
if (test_all) { if (test_all) {
struct dma_resv_list *fobj = dma_resv_shared_list(obj); struct dma_resv_list *fobj = dma_resv_shared_list(obj);
unsigned int i; unsigned int i, shared_count;
if (fobj)
shared_count = fobj->shared_count;
shared_count = fobj ? fobj->shared_count : 0;
for (i = 0; i < shared_count; ++i) { for (i = 0; i < shared_count; ++i) {
struct dma_fence *fence;
fence = rcu_dereference(fobj->shared[i]); fence = rcu_dereference(fobj->shared[i]);
ret = dma_resv_test_signaled_single(fence); ret = dma_resv_test_signaled_single(fence);
if (ret < 0) if (ret < 0)
...@@ -641,23 +637,18 @@ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) ...@@ -641,23 +637,18 @@ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all)
else if (!ret) else if (!ret)
break; break;
} }
if (read_seqcount_retry(&obj->seq, seq))
goto retry;
} }
if (!shared_count) { fence = dma_resv_excl_fence(obj);
struct dma_fence *fence_excl = dma_resv_excl_fence(obj); if (ret && fence) {
ret = dma_resv_test_signaled_single(fence);
if (fence_excl) {
ret = dma_resv_test_signaled_single(fence_excl);
if (ret < 0) if (ret < 0)
goto retry; goto retry;
}
if (read_seqcount_retry(&obj->seq, seq)) if (read_seqcount_retry(&obj->seq, seq))
goto retry; goto retry;
}
}
rcu_read_unlock(); rcu_read_unlock();
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment