lkml.org 
[lkml]   [2025]   [Apr]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [PATCH 1/3] drm/nouveau: Prevent signaled fences in pending list
From
From 165df36b603b37f6f1785ce359f7cd184db62196 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
Date: Thu, 10 Apr 2025 10:18:29 +0200
Subject: [PATCH] drm/nouveau: fix and cleanup fence handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The fence was not removed from the pending list when signaled from the
.signaled callback. Fix that and also remove the superflous
.enable_signaling callback.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/nouveau/nouveau_fence.c | 31 +++++++------------------
1 file changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 7cc84472cece..53c70ddef964 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -485,32 +485,18 @@ static bool nouveau_fence_is_signaled(struct dma_fence *f)
ret = (int)(fctx->read(chan) - fence->base.seqno) >= 0;
rcu_read_unlock();

- return ret;
-}
-
-static bool nouveau_fence_no_signaling(struct dma_fence *f)
-{
- struct nouveau_fence *fence = from_fence(f);
-
- /*
- * caller should have a reference on the fence,
- * else fence could get freed here
- */
- WARN_ON(kref_read(&fence->base.refcount) <= 1);
+ if (ret) {
+ /*
+ * caller should have a reference on the fence,
+ * else fence could get freed here
+ */
+ WARN_ON(kref_read(&fence->base.refcount) <= 1);

- /*
- * This needs uevents to work correctly, but dma_fence_add_callback relies on
- * being able to enable signaling. It will still get signaled eventually,
- * just not right away.
- */
- if (nouveau_fence_is_signaled(f)) {
list_del(&fence->head);
-
dma_fence_put(&fence->base);
- return false;
}

- return true;
+ return ret;
}

static void nouveau_fence_release(struct dma_fence *f)
@@ -525,7 +511,6 @@ static void nouveau_fence_release(struct dma_fence *f)
static const struct dma_fence_ops nouveau_fence_ops_legacy = {
.get_driver_name = nouveau_fence_get_get_driver_name,
.get_timeline_name = nouveau_fence_get_timeline_name,
- .enable_signaling = nouveau_fence_no_signaling,
.signaled = nouveau_fence_is_signaled,
.wait = nouveau_fence_wait_legacy,
.release = nouveau_fence_release
@@ -540,7 +525,7 @@ static bool nouveau_fence_enable_signaling(struct dma_fence *f)
if (!fctx->notify_ref++)
nvif_event_allow(&fctx->event);

- ret = nouveau_fence_no_signaling(f);
+ ret = nouveau_fence_is_signaled(f);
if (ret)
set_bit(DMA_FENCE_FLAG_USER_BITS, &fence->base.flags);
else if (!--fctx->notify_ref)
--
2.34.1
\
 
 \ /
  Last update: 2025-04-10 15:22    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog