Skip to content

Commit 67f7430

Browse files
drm/nouveau: wait for the exclusive fence after the shared ones v2
Always waiting for the exclusive fence resulted on some performance regressions. So try to wait for the shared fences first, then the exclusive fence should always be signaled already. v2: fix incorrectly placed "(", add some comment why we do this. Signed-off-by: Christian König <[email protected]> Tested-by: Stefan Fritsch <[email protected]> Tested-by: Dan Moulding <[email protected]> Acked-by: Ben Skeggs <[email protected]> Signed-off-by: Christian König <[email protected]> Cc: <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent fc74881 commit 67f7430

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

drivers/gpu/drm/nouveau/nouveau_fence.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,22 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e
353353

354354
if (ret)
355355
return ret;
356-
}
357356

358-
fobj = dma_resv_shared_list(resv);
359-
fence = dma_resv_excl_fence(resv);
357+
fobj = NULL;
358+
} else {
359+
fobj = dma_resv_shared_list(resv);
360+
}
360361

361-
if (fence) {
362+
/* Waiting for the exclusive fence first causes performance regressions
363+
* under some circumstances. So manually wait for the shared ones first.
364+
*/
365+
for (i = 0; i < (fobj ? fobj->shared_count : 0) && !ret; ++i) {
362366
struct nouveau_channel *prev = NULL;
363367
bool must_wait = true;
364368

369+
fence = rcu_dereference_protected(fobj->shared[i],
370+
dma_resv_held(resv));
371+
365372
f = nouveau_local_fence(fence, chan->drm);
366373
if (f) {
367374
rcu_read_lock();
@@ -373,20 +380,13 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e
373380

374381
if (must_wait)
375382
ret = dma_fence_wait(fence, intr);
376-
377-
return ret;
378383
}
379384

380-
if (!exclusive || !fobj)
381-
return ret;
382-
383-
for (i = 0; i < fobj->shared_count && !ret; ++i) {
385+
fence = dma_resv_excl_fence(resv);
386+
if (fence) {
384387
struct nouveau_channel *prev = NULL;
385388
bool must_wait = true;
386389

387-
fence = rcu_dereference_protected(fobj->shared[i],
388-
dma_resv_held(resv));
389-
390390
f = nouveau_local_fence(fence, chan->drm);
391391
if (f) {
392392
rcu_read_lock();
@@ -398,6 +398,8 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e
398398

399399
if (must_wait)
400400
ret = dma_fence_wait(fence, intr);
401+
402+
return ret;
401403
}
402404

403405
return ret;

0 commit comments

Comments
 (0)