[PATCH 15/15] drm/nouveau: Skip fence context seqno check if notifies are enabled
Chris Wilson
chris at chris-wilson.co.uk
Tue Sep 13 09:32:51 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.
v2: Keep the uncached read after first enabling the notify.
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 | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 4bb9ab892ae1..e4d6e478cc44 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)
@@ -566,18 +576,19 @@ static bool nouveau_fence_enable_signaling(struct fence *f)
{
struct nouveau_fence *fence = from_fence(f);
struct nouveau_fence_chan *fctx = nouveau_fctx(fence);
- bool ret;
- if (!fctx->notify_ref++)
+ if (!fctx->notify_ref) {
nvif_notify_get(&fctx->notify);
+ /* Check for a missed signal when installing the interrupt */
+ if (!nouveau_fence_no_signaling(f)) {
+ nvif_notify_put(&fctx->notify);
+ return false;
+ }
+ }
- ret = nouveau_fence_no_signaling(f);
- if (ret)
- set_bit(FENCE_FLAG_USER_BITS, &fence->base.flags);
- else if (!--fctx->notify_ref)
- nvif_notify_put(&fctx->notify);
-
- return ret;
+ fctx->notify_ref++;
+ set_bit(FENCE_FLAG_USER_BITS, &fence->base.flags);
+ return true;
}
static const struct fence_ops nouveau_fence_ops_uevent = {
--
2.9.3
More information about the Intel-gfx-trybot
mailing list