[PATCH] drm/nouveau: Skip fence context seqno check if notifies are enabled

Chris Wilson chris at chris-wilson.co.uk
Wed Sep 7 20:21:05 UTC 2016


If the fence context has notifies enabled, each of the fences'
FENCE_FLAG_SIGNALED_BIT will be updated from the interrupt. We can rely
on this status for reporting the current fence_is_signaled() and so
avoid an expensive uncached read.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Ben Skeggs <bskeggs at redhat.com>
Cc: dri-devel at lists.freedesktop.org
Cc: nouveau at lists.freedesktop.org
---
 drivers/gpu/drm/nouveau/nouveau_fence.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 4bb9ab892ae1..7daed5c33043 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -510,6 +510,16 @@ static bool nouveau_fence_is_signaled(struct fence *f)
 	struct nouveau_channel *chan;
 	bool ret = false;
 
+	/* If the notify is already active, we can rely on
+	 * FENCE_FLAG_SIGNALED_BIT being accurate and skip checking the
+	 * current seqno as fctx->read() requires an expensive uncached read.
+	 */
+	if (test_bit(FENCE_FLAG_USER_BITS, &fence->base.flags))
+		return false;
+
+	if (READ_ONCE(fctx->notify_ref))
+		return false;
+
 	rcu_read_lock();
 	chan = rcu_dereference(fence->channel);
 	if (chan)
-- 
2.9.3



More information about the dri-devel mailing list