Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: francois.dugast@intel.com
Subject: [PATCH 1/5] drm/xe: Add xe_sched_msg_lock/unlock helper
Date: Fri,  9 Aug 2024 12:19:25 -0700	[thread overview]
Message-ID: <20240809191929.3138956-2-matthew.brost@intel.com> (raw)
In-Reply-To: <20240809191929.3138956-1-matthew.brost@intel.com>

Will help callers to own locking when adding messages to scheduler.

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_gpu_scheduler.c | 12 ++++++------
 drivers/gpu/drm/xe/xe_gpu_scheduler.h | 10 ++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gpu_scheduler.c b/drivers/gpu/drm/xe/xe_gpu_scheduler.c
index e4ad1d6ce1d5..eea71c67cf2a 100644
--- a/drivers/gpu/drm/xe/xe_gpu_scheduler.c
+++ b/drivers/gpu/drm/xe/xe_gpu_scheduler.c
@@ -15,11 +15,11 @@ static void xe_sched_process_msg_queue_if_ready(struct xe_gpu_scheduler *sched)
 {
 	struct xe_sched_msg *msg;
 
-	spin_lock(&sched->base.job_list_lock);
+	xe_sched_msg_lock(sched);
 	msg = list_first_entry_or_null(&sched->msgs, struct xe_sched_msg, link);
 	if (msg)
 		xe_sched_process_msg_queue(sched);
-	spin_unlock(&sched->base.job_list_lock);
+	xe_sched_msg_unlock(sched);
 }
 
 static struct xe_sched_msg *
@@ -27,12 +27,12 @@ xe_sched_get_msg(struct xe_gpu_scheduler *sched)
 {
 	struct xe_sched_msg *msg;
 
-	spin_lock(&sched->base.job_list_lock);
+	xe_sched_msg_lock(sched);
 	msg = list_first_entry_or_null(&sched->msgs,
 				       struct xe_sched_msg, link);
 	if (msg)
 		list_del(&msg->link);
-	spin_unlock(&sched->base.job_list_lock);
+	xe_sched_msg_unlock(sched);
 
 	return msg;
 }
@@ -93,9 +93,9 @@ void xe_sched_submission_stop(struct xe_gpu_scheduler *sched)
 void xe_sched_add_msg(struct xe_gpu_scheduler *sched,
 		      struct xe_sched_msg *msg)
 {
-	spin_lock(&sched->base.job_list_lock);
+	xe_sched_msg_lock(sched);
 	list_add_tail(&msg->link, &sched->msgs);
-	spin_unlock(&sched->base.job_list_lock);
+	xe_sched_msg_unlock(sched);
 
 	xe_sched_process_msg_queue(sched);
 }
diff --git a/drivers/gpu/drm/xe/xe_gpu_scheduler.h b/drivers/gpu/drm/xe/xe_gpu_scheduler.h
index 10c6bb9c9386..a54038fb3094 100644
--- a/drivers/gpu/drm/xe/xe_gpu_scheduler.h
+++ b/drivers/gpu/drm/xe/xe_gpu_scheduler.h
@@ -25,6 +25,16 @@ void xe_sched_submission_stop(struct xe_gpu_scheduler *sched);
 void xe_sched_add_msg(struct xe_gpu_scheduler *sched,
 		      struct xe_sched_msg *msg);
 
+static inline void xe_sched_msg_lock(struct xe_gpu_scheduler *sched)
+{
+	spin_lock(&sched->base.job_list_lock);
+}
+
+static inline void xe_sched_msg_unlock(struct xe_gpu_scheduler *sched)
+{
+	spin_unlock(&sched->base.job_list_lock);
+}
+
 static inline void xe_sched_stop(struct xe_gpu_scheduler *sched)
 {
 	drm_sched_stop(&sched->base, NULL);
-- 
2.34.1


  reply	other threads:[~2024-08-09 19:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09 19:19 [PATCH 0/5] Allow exec queue backend ops which issue message to be called multiple times Matthew Brost
2024-08-09 19:19 ` Matthew Brost [this message]
2024-08-09 20:43   ` [PATCH 1/5] drm/xe: Add xe_sched_msg_lock/unlock helper Cavitt, Jonathan
2024-08-09 19:19 ` [PATCH 2/5] drm/xe: Reinit msg link when processing a message Matthew Brost
2024-08-09 20:44   ` Cavitt, Jonathan
2024-08-09 19:19 ` [PATCH 3/5] drm/xe: Add xe_sched_add_msg_locked helper Matthew Brost
2024-08-09 20:47   ` Cavitt, Jonathan
2024-08-09 19:19 ` [PATCH 4/5] drm/xe: Only enable scheduling upon resume if needed Matthew Brost
2024-08-09 20:48   ` Cavitt, Jonathan
2024-08-09 19:19 ` [PATCH 5/5] drm/xe: Allow suspend / resume to be safely called multiple times Matthew Brost
2024-08-09 21:02   ` Cavitt, Jonathan
2024-08-09 19:23 ` ✓ CI.Patch_applied: success for Allow exec queue backend ops which issue message to be " Patchwork
2024-08-09 19:23 ` ✓ CI.checkpatch: " Patchwork
2024-08-09 19:25 ` ✓ CI.KUnit: " Patchwork
2024-08-09 19:36 ` ✓ CI.Build: " Patchwork
2024-08-09 19:39 ` ✓ CI.Hooks: " Patchwork
2024-08-09 19:40 ` ✓ CI.checksparse: " Patchwork
2024-08-09 20:00 ` ✗ CI.BAT: failure " Patchwork
2024-08-09 23:40 ` ✗ CI.FULL: " 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=20240809191929.3138956-2-matthew.brost@intel.com \
    --to=matthew.brost@intel.com \
    --cc=francois.dugast@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /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