Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nirmoy Das <nirmoy.das@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Nirmoy Das <nirmoy.das@intel.com>, Matthew Auld <matthew.auld@intel.com>
Subject: [PATCH v3] drm/xe/ufence: Signal ufence immediately when possible
Date: Fri, 18 Oct 2024 14:47:10 +0200	[thread overview]
Message-ID: <20241018124710.1536948-1-nirmoy.das@intel.com> (raw)

If the backing fence is signaled then signal ufence immediately.
This should reduce load from the xe ordered_wq and also won't block
signaling a ufence which doesn't require any serialization.

v2: fix system_wq typo
v3: signal immediately instead of queuing in system_wq (Matt B)

Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/1630
Cc: Matthew Auld <matthew.auld@intel.com>
gc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
---
 drivers/gpu/drm/xe/xe_sync.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c
index c6cf227ead40..069c1e4ebea5 100644
--- a/drivers/gpu/drm/xe/xe_sync.c
+++ b/drivers/gpu/drm/xe/xe_sync.c
@@ -72,10 +72,8 @@ static struct xe_user_fence *user_fence_create(struct xe_device *xe, u64 addr,
 	return ufence;
 }
 
-static void user_fence_worker(struct work_struct *w)
+static void signal_user_fence(struct xe_user_fence *ufence)
 {
-	struct xe_user_fence *ufence = container_of(w, struct xe_user_fence, worker);
-
 	if (mmget_not_zero(ufence->mm)) {
 		kthread_use_mm(ufence->mm);
 		if (copy_to_user(ufence->addr, &ufence->value, sizeof(ufence->value)))
@@ -89,6 +87,14 @@ static void user_fence_worker(struct work_struct *w)
 	user_fence_put(ufence);
 }
 
+static void user_fence_worker(struct work_struct *w)
+{
+	struct xe_user_fence *ufence = container_of(w, struct xe_user_fence,
+						    worker);
+
+	signal_user_fence(ufence);
+}
+
 static void kick_ufence(struct xe_user_fence *ufence, struct dma_fence *fence)
 {
 	INIT_WORK(&ufence->worker, user_fence_worker);
@@ -236,7 +242,8 @@ void xe_sync_entry_signal(struct xe_sync_entry *sync, struct dma_fence *fence)
 		err = dma_fence_add_callback(fence, &sync->ufence->cb,
 					     user_fence_cb);
 		if (err == -ENOENT) {
-			kick_ufence(sync->ufence, fence);
+			/* signal the ufence immediately if fence is already signalled */
+			signal_user_fence(sync->ufence);
 		} else if (err) {
 			XE_WARN_ON("failed to add user fence");
 			user_fence_put(sync->ufence);
-- 
2.46.0


             reply	other threads:[~2024-10-18 13:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18 12:47 Nirmoy Das [this message]
2024-10-18 13:34 ` ✓ CI.Patch_applied: success for drm/xe/ufence: Signal ufence immediately when possible Patchwork
2024-10-18 13:34 ` ✓ CI.checkpatch: " Patchwork
2024-10-18 13:35 ` ✓ CI.KUnit: " Patchwork
2024-10-18 13:47 ` ✓ CI.Build: " Patchwork
2024-10-18 13:49 ` ✓ CI.Hooks: " Patchwork
2024-10-18 13:51 ` ✓ CI.checksparse: " Patchwork
2024-10-18 14:16 ` ✗ CI.BAT: failure " Patchwork
2024-10-18 14:23 ` [PATCH v3] " Matthew Auld
2024-10-18 14:40   ` Nirmoy Das
2024-10-18 14:53     ` Matthew Auld
2024-10-18 15:29       ` Nirmoy Das
2024-10-18 16:16         ` Matthew Brost
2024-10-19  8:30           ` Nirmoy Das
2024-10-19  4:55 ` ✗ CI.FULL: failure for " Patchwork

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=20241018124710.1536948-1-nirmoy.das@intel.com \
    --to=nirmoy.das@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    /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