From: 2564278112@qq.com
To: alexander.deucher@amd.com
Cc: christian.koenig@amd.com, airlied@gmail.com, simona@ffwll.ch,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, 2564278112@qq.com,
Wang Jiang <jiangwang@kylinos.cn>
Subject: [PATCH v2] drm/radeon: restore hardware polling in fence_is_signaled to fix performance regression
Date: Thu, 30 Jul 2026 09:56:47 +0800 [thread overview]
Message-ID: <tencent_38CA3044B54F14EC7314032134C531AFA807@qq.com> (raw)
From: Wang Jiang <jiangwang@kylinos.cn>
Commit 9eb00b5f5697b ("drm/radeon: delete radeon_fence_process in
is_signaled, no deadlock") removed the hardware status check from
radeon_fence_is_signaled() to fix a self-deadlock caused by
wake_up_all(&rdev->fence_queue) being called with the fence queue
lock held.
However, removing the hardware poll entirely causes significant
performance regression (e.g. glxgears FPS drop) because the signaled
check becomes purely passive — it only reads the cached last_seq
without probing the GPU, so completed GPU work is not detected in
time, causing unnecessary CPU stalls in sync-heavy workloads.
Fix this by calling radeon_fence_read() directly in
radeon_fence_is_signaled() to poll the hardware fence counter
without updating last_seq or calling wake_up_all(). This restores
timely fence detection while avoiding the original deadlock, since
last_seq update and waiter wakeup remain solely in the interrupt
handler's responsibility.
Fixes: 9eb00b5f5697b ("drm/radeon: delete radeon_fence_process in is_signaled, no deadlock")
Signed-off-by: Wang Jiang <jiangwang@kylinos.cn>
---
drivers/gpu/drm/radeon/radeon_fence.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index 02a40e4750c7..047ec5a1d194 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -360,6 +360,18 @@ static bool radeon_fence_is_signaled(struct dma_fence *f)
if (atomic64_read(&rdev->fence_drv[ring].last_seq) >= seq)
return true;
+ /*
+ * Poll hardware directly without updating last_seq.
+ * This allows immediate detection of signaled fences (performance)
+ * while leaving last_seq update and wake_up_all() to the interrupt
+ * handler, avoiding:
+ * 1. Deadlock from calling wake_up_all() with fence lock held
+ * 2. Wake event stealing by advancing last_seq without waking waiters
+ * 3. rw_semaphore usage in atomic/irq context (unsafe on PREEMPT_RT)
+ */
+ if (radeon_fence_read(rdev, ring) >= (u32)seq)
+ return true;
+
return false;
}
--
2.25.1
next reply other threads:[~2026-07-30 1:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 1:56 2564278112 [this message]
2026-08-05 11:43 ` Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_38CA3044B54F14EC7314032134C531AFA807@qq.com \
--to=2564278112@qq.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jiangwang@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=simona@ffwll.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®