Commit 40298cb4 authored by Christian König's avatar Christian König

drm/nouveau: use the new iterator in nouveau_fence_sync

Simplifying the code a bit.

The new implementation unifies the handling between drivers and so
results in waiting for all shared fernces in all cases.
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/20211005113742.1101-26-christian.koenig@amd.com
parent dd66f56c
...@@ -339,14 +339,15 @@ nouveau_fence_wait(struct nouveau_fence *fence, bool lazy, bool intr) ...@@ -339,14 +339,15 @@ nouveau_fence_wait(struct nouveau_fence *fence, bool lazy, bool intr)
} }
int int
nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool exclusive, bool intr) nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan,
bool exclusive, bool intr)
{ {
struct nouveau_fence_chan *fctx = chan->fence; struct nouveau_fence_chan *fctx = chan->fence;
struct dma_fence *fence;
struct dma_resv *resv = nvbo->bo.base.resv; struct dma_resv *resv = nvbo->bo.base.resv;
struct dma_resv_list *fobj; struct dma_resv_iter cursor;
struct dma_fence *fence;
struct nouveau_fence *f; struct nouveau_fence *f;
int ret = 0, i; int ret;
if (!exclusive) { if (!exclusive) {
ret = dma_resv_reserve_shared(resv, 1); ret = dma_resv_reserve_shared(resv, 1);
...@@ -355,10 +356,7 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e ...@@ -355,10 +356,7 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e
return ret; return ret;
} }
fobj = dma_resv_shared_list(resv); dma_resv_for_each_fence(&cursor, resv, exclusive, fence) {
fence = dma_resv_excl_fence(resv);
if (fence) {
struct nouveau_channel *prev = NULL; struct nouveau_channel *prev = NULL;
bool must_wait = true; bool must_wait = true;
...@@ -366,41 +364,19 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e ...@@ -366,41 +364,19 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e
if (f) { if (f) {
rcu_read_lock(); rcu_read_lock();
prev = rcu_dereference(f->channel); prev = rcu_dereference(f->channel);
if (prev && (prev == chan || fctx->sync(f, prev, chan) == 0)) if (prev && (prev == chan ||
fctx->sync(f, prev, chan) == 0))
must_wait = false; must_wait = false;
rcu_read_unlock(); rcu_read_unlock();
} }
if (must_wait) if (must_wait) {
ret = dma_fence_wait(fence, intr); ret = dma_fence_wait(fence, intr);
if (ret)
return ret; return ret;
}
if (!exclusive || !fobj)
return ret;
for (i = 0; i < fobj->shared_count && !ret; ++i) {
struct nouveau_channel *prev = NULL;
bool must_wait = true;
fence = rcu_dereference_protected(fobj->shared[i],
dma_resv_held(resv));
f = nouveau_local_fence(fence, chan->drm);
if (f) {
rcu_read_lock();
prev = rcu_dereference(f->channel);
if (prev && (prev == chan || fctx->sync(f, prev, chan) == 0))
must_wait = false;
rcu_read_unlock();
} }
if (must_wait)
ret = dma_fence_wait(fence, intr);
} }
return 0;
return ret;
} }
void void
......
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