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>
Subject: [Intel-xe] [RFC PATCH 4/7] drm/xe: Allow num_batch_buffer == 0 in exec IOCTL
Date: Wed,  6 Dec 2023 21:57:26 -0800	[thread overview]
Message-ID: <20231207055729.438642-5-matthew.brost@intel.com> (raw)
In-Reply-To: <20231207055729.438642-1-matthew.brost@intel.com>

The idea being out-syncs can signal indicating all previous operations
on the exec queue are complete. An example use case of this would be
support for implementing vkQueueWaitIdle easily.

v2: Don't add last_fence for VM's that do not support dma fences
v3: Use a flags field instead of severval bools in sync parse (Thomas)
v4: s/vkQueueWaitForIdle/vkQueueWaitIdle
v5: Fix inverted lr_mode checks

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_exec.c             | 17 ++++++++++++++++-
 drivers/gpu/drm/xe/xe_exec_queue.c       |  5 ++++-
 drivers/gpu/drm/xe/xe_exec_queue_types.h |  5 +++--
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_exec.c b/drivers/gpu/drm/xe/xe_exec.c
index a8a025495b14..96d7506a4c72 100644
--- a/drivers/gpu/drm/xe/xe_exec.c
+++ b/drivers/gpu/drm/xe/xe_exec.c
@@ -161,7 +161,8 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 	if (XE_IOCTL_DBG(xe, q->flags & EXEC_QUEUE_FLAG_VM))
 		return -EINVAL;
 
-	if (XE_IOCTL_DBG(xe, q->width != args->num_batch_buffer))
+	if (XE_IOCTL_DBG(xe, args->num_batch_buffer &&
+			 q->width != args->num_batch_buffer))
 		return -EINVAL;
 
 	if (XE_IOCTL_DBG(xe, q->flags & EXEC_QUEUE_FLAG_BANNED)) {
@@ -235,6 +236,18 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 		goto err_exec;
 	}
 
+	if (!args->num_batch_buffer) {
+		if (!xe_vm_in_lr_mode(vm)) {
+			struct dma_fence *fence =
+				xe_exec_queue_last_fence_get(q, vm);
+
+			for (i = 0; i < num_syncs; i++)
+				xe_sync_entry_signal(&syncs[i], NULL, fence);
+		}
+
+		goto err_exec;
+	}
+
 	if (xe_exec_queue_is_lr(q) && xe_exec_queue_ring_full(q)) {
 		err = -EWOULDBLOCK;
 		goto err_exec;
@@ -328,6 +341,8 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 
 	if (xe_exec_queue_is_lr(q))
 		q->ring_ops->emit_job(job);
+	if (!xe_vm_in_lr_mode(vm))
+		xe_exec_queue_last_fence_set(q, vm, &job->drm.s_fence->finished);
 	xe_sched_job_push(job);
 	xe_vm_reactivate_rebind(vm);
 
diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c
index cb284c4ad049..67e3fd9dfc5f 100644
--- a/drivers/gpu/drm/xe/xe_exec_queue.c
+++ b/drivers/gpu/drm/xe/xe_exec_queue.c
@@ -886,7 +886,10 @@ int xe_exec_queue_destroy_ioctl(struct drm_device *dev, void *data,
 static void xe_exec_queue_last_fence_lockdep_assert(struct xe_exec_queue *q,
 						    struct xe_vm *vm)
 {
-	lockdep_assert_held_write(&vm->lock);
+	if (q->flags & EXEC_QUEUE_FLAG_VM)
+		lockdep_assert_held_write(&vm->lock);
+	else
+		xe_vm_assert_held(vm);
 }
 
 /**
diff --git a/drivers/gpu/drm/xe/xe_exec_queue_types.h b/drivers/gpu/drm/xe/xe_exec_queue_types.h
index 5ba47a5cfdbd..52f0927d0d9b 100644
--- a/drivers/gpu/drm/xe/xe_exec_queue_types.h
+++ b/drivers/gpu/drm/xe/xe_exec_queue_types.h
@@ -56,8 +56,9 @@ struct xe_exec_queue {
 	struct xe_hw_fence_irq *fence_irq;
 
 	/**
-	 * @last_fence: last fence on engine, protected by vm->lock in write
-	 * mode if bind engine
+	 * @last_fence: last fence on exec queue, protected by vm->lock in write
+	 * mode if bind exec queue, protected by dma resv lock if non-bind exec
+	 * queue
 	 */
 	struct dma_fence *last_fence;
 
-- 
2.34.1


  parent reply	other threads:[~2023-12-07  5:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07  5:57 [Intel-xe] [RFC PATCH 0/7] Syncs vs async exec/bind uAPI change Matthew Brost
2023-12-07  5:57 ` [Intel-xe] [RFC PATCH 1/7] drm/xe: Use a flags field instead of bools for VMA create Matthew Brost
2023-12-07  5:57 ` [Intel-xe] [RFC PATCH 2/7] drm/xe: Use a flags field instead of bools for sync parse Matthew Brost
2023-12-07  5:57 ` [Intel-xe] [RFC PATCH 3/7] drm/xe: Allow num_binds == 0 in VM bind IOCTL Matthew Brost
2023-12-07  5:57 ` Matthew Brost [this message]
2023-12-07  5:57 ` [Intel-xe] [RFC PATCH 5/7] drm/xe: Take in-syncs into account when num_execs or num_binds == 0 Matthew Brost
2023-12-08 15:04   ` Thomas Hellström
2023-12-12 17:18     ` Matthew Brost
2023-12-07  5:57 ` [Intel-xe] [RFC PATCH 6/7] drm/xe: Add last fence as dependency for jobs on user exec queues Matthew Brost
2023-12-07  5:57 ` [Intel-xe] [RFC PATCH 7/7] drm/xe/uapi: Uniform async vs sync handling Matthew Brost
2023-12-07 19:51   ` Rodrigo Vivi
2023-12-08 15:00   ` Thomas Hellström
2023-12-08  9:45     ` Matthew Brost
2023-12-11 15:43       ` Thomas Hellström
2023-12-11 16:49         ` Matthew Brost
2023-12-11 18:11           ` Thomas Hellström
2023-12-11 21:11             ` Matthew Brost
2023-12-12  8:43               ` Thomas Hellström
2023-12-08 12:24     ` Matthew Brost
2023-12-11 15:34       ` Thomas Hellström
2023-12-11 16:50         ` Matthew Brost
2023-12-07  7:38 ` [Intel-xe] ✗ CI.Patch_applied: failure for Syncs vs async exec/bind uAPI change 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=20231207055729.438642-5-matthew.brost@intel.com \
    --to=matthew.brost@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