Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
To: Matthew Brost <matthew.brost@intel.com>,
	<intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v6 12/24] drm/xe: Don't use migrate exec queue for page fault binds
Date: Mon, 21 Sep 2026 18:42:38 +0530	[thread overview]
Message-ID: <32d645f0-472f-4300-aef3-e4988c595a86@intel.com> (raw)
In-Reply-To: <20260904211613.3934307-13-matthew.brost@intel.com>



On 05-09-2026 02:46, Matthew Brost wrote:
> Now that the CPU is always used for binds even in jobs, CPU bind jobs
> can pass GPU jobs in the same exec queue resulting dma-fences signaling
> out-of-order. Use a dedicated exec queue for binds issued from page
> faults to avoid ordering issues and avoid blocking kernel binds on
> unrelated copies / clears.
> 
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> Link: https://patch.msgid.link/20260228013501.106680-13-matthew.brost@intel.com
> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
> ---
>   drivers/gpu/drm/xe/xe_migrate.c | 47 ++++++++++++++++++++++++++++++---
>   drivers/gpu/drm/xe/xe_migrate.h |  1 +
>   drivers/gpu/drm/xe/xe_vm.c      | 17 +++++++-----
>   3 files changed, 55 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> index 53160c2c35a6..ba8e195afcc8 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/xe_migrate.c
> @@ -51,6 +51,8 @@
>   struct xe_migrate {
>   	/** @q: Default exec queue used for migration */
>   	struct xe_exec_queue *q;
> +	/** @bind_q: Default exec queue used for binds */
> +	struct xe_exec_queue *bind_q;
>   	/** @tile: Backpointer to the tile this struct xe_migrate belongs to. */
>   	struct xe_tile *tile;
>   	/** @job_mutex: Timeline mutex for @eng. */
> @@ -115,6 +117,7 @@ static void xe_migrate_fini(void *arg)
>   	mutex_destroy(&m->job_mutex);
>   	xe_vm_close_and_put(m->q->vm);
>   	xe_exec_queue_put(m->q);
> +	xe_exec_queue_put(m->bind_q);
>   }
>   
>   static inline u16 xe_migrate_pat_index(struct xe_device *xe,
> @@ -504,6 +507,15 @@ int xe_migrate_init(struct xe_migrate *m)
>   			goto err_out;
>   		}
>   
> +		m->bind_q = xe_exec_queue_create(xe, vm, logical_mask, 1, hwe0,
> +						 EXEC_QUEUE_FLAG_KERNEL |
> +						 EXEC_QUEUE_FLAG_HIGH_PRIORITY |
> +						 EXEC_QUEUE_FLAG_MIGRATE, 0);
> +		if (IS_ERR(m->bind_q)) {
> +			err = PTR_ERR(m->bind_q);
> +			goto err_out;
> +		}
> +
>   		/*
>   		 * XXX: Currently only reserving 1 (likely slow) BCS instance on
>   		 * PVC, may want to revisit if performance is needed.
> @@ -514,6 +526,15 @@ int xe_migrate_init(struct xe_migrate *m)
>   					    EXEC_QUEUE_FLAG_MIGRATE |
>   					    EXEC_QUEUE_FLAG_LOW_LATENCY, 0);
>   	} else {
> +		m->bind_q = xe_exec_queue_create_class(xe, primary_gt, vm,
> +						       XE_ENGINE_CLASS_COPY,
> +						       EXEC_QUEUE_FLAG_KERNEL |
> +						       EXEC_QUEUE_FLAG_MIGRATE, 0);
> +		if (IS_ERR(m->bind_q)) {
> +			err = PTR_ERR(m->bind_q);
> +			goto err_out;
> +		}
> +
>   		m->q = xe_exec_queue_create_class(xe, primary_gt, vm,
>   						  XE_ENGINE_CLASS_COPY,
>   						  EXEC_QUEUE_FLAG_KERNEL |
> @@ -549,6 +570,8 @@ int xe_migrate_init(struct xe_migrate *m)
>   	return err;
>   
>   err_out:
> +	if (!IS_ERR_OR_NULL(m->bind_q))
> +		xe_exec_queue_put(m->bind_q);
>   	xe_vm_close_and_put(vm);
>   	return err;
>   
> @@ -1505,6 +1528,17 @@ static u32 blt_mem_set_cmd_len(struct xe_device *xe)
>   	return 7;
>   }
>   
> +/**
> + * xe_get_migrate_bind_queue() - Get the bind queue from migrate context.
> + * @migrate: Migrate context.
> + *
> + * Return: Pointer to bind queue on success, error on failure
> + */
> +struct xe_exec_queue *xe_migrate_bind_queue(struct xe_migrate *migrate)
> +{
> +	return migrate->bind_q;
> +}
> +
>   static void emit_clear_link_copy(struct xe_gt *gt, struct xe_bb *bb, u64 src_ofs,
>   				 u32 size, u32 pitch)
>   {
> @@ -1892,6 +1926,11 @@ xe_migrate_update_pgtables_cpu(struct xe_migrate *m,
>   	return dma_fence_get_stub();
>   }
>   
> +static bool is_migrate_queue(struct xe_migrate *m, struct xe_exec_queue *q)
> +{
> +	return m->bind_q == q;
> +}
> +
>   static struct dma_fence *
>   __xe_migrate_update_pgtables(struct xe_migrate *m,
>   			     struct xe_migrate_pt_update *pt_update,
> @@ -1909,7 +1948,7 @@ __xe_migrate_update_pgtables(struct xe_migrate *m,
>   	u32 num_updates = 0, current_update = 0;
>   	u64 addr;
>   	int err = 0;
> -	bool is_migrate = pt_update_ops->q == m->q;
> +	bool is_migrate = is_migrate_queue(m, pt_update_ops->q);
>   	bool usm = is_migrate && xe->info.has_usm;
>   
>   	for (i = 0; i < pt_update_ops->num_ops; ++i) {
> @@ -2631,7 +2670,7 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
>    */
>   void xe_migrate_job_lock(struct xe_migrate *m, struct xe_exec_queue *q)
>   {
> -	bool is_migrate = q == m->q;
> +	bool is_migrate = is_migrate_queue(m, q);
>   
>   	if (is_migrate)
>   		mutex_lock(&m->job_mutex);
> @@ -2649,7 +2688,7 @@ void xe_migrate_job_lock(struct xe_migrate *m, struct xe_exec_queue *q)
>    */
>   void xe_migrate_job_unlock(struct xe_migrate *m, struct xe_exec_queue *q)
>   {
> -	bool is_migrate = q == m->q;
> +	bool is_migrate = is_migrate_queue(m, q);
>   
>   	if (is_migrate)
>   		mutex_unlock(&m->job_mutex);
> @@ -2666,7 +2705,7 @@ void xe_migrate_job_lock_assert(struct xe_exec_queue *q)
>   {
>   	struct xe_migrate *m = gt_to_tile(q->gt)->migrate;
>   
> -	xe_gt_assert(q->gt, q == m->q);
> +	xe_gt_assert(q->gt, q == m->bind_q);
>   	lockdep_assert_held(&m->job_mutex);
>   }
>   #endif
> diff --git a/drivers/gpu/drm/xe/xe_migrate.h b/drivers/gpu/drm/xe/xe_migrate.h
> index 04ef20692b6a..7a824654cb72 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.h
> +++ b/drivers/gpu/drm/xe/xe_migrate.h
> @@ -146,6 +146,7 @@ void xe_migrate_ccs_rw_copy_clear(struct xe_bo *src_bo,
>   
>   struct xe_lrc *xe_migrate_lrc(struct xe_migrate *migrate);
>   struct xe_exec_queue *xe_migrate_exec_queue(struct xe_migrate *migrate);
> +struct xe_exec_queue *xe_migrate_bind_queue(struct xe_migrate *migrate);
>   struct dma_fence *xe_migrate_vram_copy_chunk(struct xe_bo *vram_bo, u64 vram_offset,
>   					     struct xe_bo *sysmem_bo, u64 sysmem_offset,
>   					     u64 size, enum xe_migrate_copy_dir dir);
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index 2737bd25f39a..13e984ac4e4f 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -795,7 +795,9 @@ int xe_vm_rebind(struct xe_vm *vm, bool rebind_worker)
>   	struct xe_vma *vma, *next;
>   	struct xe_vma_ops vops;
>   	struct xe_vma_op *op, *next_op;
> -	int err, i;
> +	struct xe_tile *tile;
> +	u8 id;
> +	int err;
>   
>   	lockdep_assert_held(&vm->lock);
>   	if ((xe_vm_in_lr_mode(vm) && !rebind_worker) ||
> @@ -803,8 +805,11 @@ int xe_vm_rebind(struct xe_vm *vm, bool rebind_worker)
>   		return 0;
>   
>   	xe_vma_ops_init(&vops, vm, NULL, NULL, 0);
> -	for (i = 0; i < XE_MAX_TILES_PER_DEVICE; ++i)
> -		vops.pt_update_ops[i].wait_vm_bookkeep = true;
> +	for_each_tile(tile, vm->xe, id) {
> +		vops.pt_update_ops[id].wait_vm_bookkeep = true;
> +		vops.pt_update_ops[id].q =
> +			xe_migrate_bind_queue(tile->migrate);
> +	}
>   
>   	xe_vm_assert_held(vm);
>   	list_for_each_entry(vma, &vm->rebind_list, combined_links.rebind) {
> @@ -862,7 +867,7 @@ struct dma_fence *xe_vma_rebind(struct xe_vm *vm, struct xe_vma *vma, u8 tile_ma
>   	for_each_tile(tile, vm->xe, id) {
>   		vops.pt_update_ops[id].wait_vm_bookkeep = true;
>   		vops.pt_update_ops[tile->id].q =
> -			xe_migrate_exec_queue(tile->migrate);
> +			xe_migrate_bind_queue(tile->migrate);
>   	}
>   
>   	err = xe_vm_ops_add_rebind(&vops, vma, tile_mask);
> @@ -954,7 +959,7 @@ struct dma_fence *xe_vm_range_rebind(struct xe_vm *vm,
>   	for_each_tile(tile, vm->xe, id) {
>   		vops.pt_update_ops[id].wait_vm_bookkeep = true;
>   		vops.pt_update_ops[tile->id].q =
> -			xe_migrate_exec_queue(tile->migrate);
> +			xe_migrate_bind_queue(tile->migrate);
>   	}
>   
>   	err = xe_vm_ops_add_range_rebind(&vops, vma, range, tile_mask);
> @@ -1038,7 +1043,7 @@ struct dma_fence *xe_vm_range_unbind(struct xe_vm *vm,
>   	for_each_tile(tile, vm->xe, id) {
>   		vops.pt_update_ops[id].wait_vm_bookkeep = true;
>   		vops.pt_update_ops[tile->id].q =
> -			xe_migrate_exec_queue(tile->migrate);
> +			xe_migrate_bind_queue(tile->migrate);
>   	}

LGTM
Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>


>   
>   	err = xe_vm_ops_add_range_unbind(&vops, range);


  reply	other threads:[~2026-09-21 13:12 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 21:15 [PATCH v6 00/24] CPU binds and ULLS on migration queue Matthew Brost
2026-09-04 21:15 ` [PATCH v6 01/24] drm/xe: Drop struct xe_migrate_pt_update argument from populate/clear vfuns Matthew Brost
2026-09-04 21:15 ` [PATCH v6 02/24] drm/xe: Add xe_migrate_update_pgtables_cpu_execute helper Matthew Brost
2026-09-04 21:28   ` sashiko-bot
2026-09-04 21:15 ` [PATCH v6 03/24] drm/xe: Decouple exec queue idle check from LRC Matthew Brost
2026-09-04 21:15 ` [PATCH v6 04/24] drm/xe: Add job count to GuC exec queue snapshot Matthew Brost
2026-09-04 21:23   ` sashiko-bot
2026-09-04 21:15 ` [PATCH v6 05/24] drm/xe: Update xe_bo_put_deferred arguments to include writeback flag Matthew Brost
2026-09-04 21:15 ` [PATCH v6 06/24] drm/xe: Add XE_BO_FLAG_PUT_VM_ASYNC Matthew Brost
2026-09-04 21:33   ` sashiko-bot
2026-09-11 13:10   ` Francois Dugast
2026-09-11 19:54     ` Matthew Brost
2026-09-12  0:27       ` Matthew Brost
2026-09-04 21:15 ` [PATCH v6 07/24] drm/xe: Update scheduler job layer to support PT jobs Matthew Brost
2026-09-04 21:37   ` sashiko-bot
2026-09-11 15:24   ` Francois Dugast
2026-09-11 19:25     ` Matthew Brost
2026-09-04 21:15 ` [PATCH v6 08/24] drm/xe: Add helpers to access PT ops Matthew Brost
2026-09-04 21:15 ` [PATCH v6 09/24] drm/xe: Add struct xe_pt_job_ops Matthew Brost
2026-09-04 21:40   ` sashiko-bot
2026-09-21 11:07   ` Ghimiray, Himal Prasad
2026-09-04 21:15 ` [PATCH v6 10/24] drm/xe: Update GuC submission backend to run PT jobs Matthew Brost
2026-09-04 21:39   ` sashiko-bot
2026-09-21 11:55     ` Ghimiray, Himal Prasad
2026-09-21 17:50       ` Matthew Brost
2026-09-04 21:16 ` [PATCH v6 11/24] drm/xe: Store level in struct xe_vm_pgtable_update Matthew Brost
2026-09-21 12:53   ` Ghimiray, Himal Prasad
2026-09-04 21:16 ` [PATCH v6 12/24] drm/xe: Don't use migrate exec queue for page fault binds Matthew Brost
2026-09-21 13:12   ` Ghimiray, Himal Prasad [this message]
2026-09-04 21:16 ` [PATCH v6 13/24] drm/xe: Enable CPU binds for jobs Matthew Brost
2026-09-04 21:44   ` sashiko-bot
2026-09-21 13:41   ` Ghimiray, Himal Prasad
2026-09-24 22:48     ` Matthew Brost
2026-09-04 21:16 ` [PATCH v6 14/24] drm/xe: Remove unused arguments from xe_migrate_pt_update_ops Matthew Brost
2026-09-19  0:13   ` Lin, Shuicheng
2026-09-04 21:16 ` [PATCH v6 15/24] drm/xe: Make bind queues operate cross-tile Matthew Brost
2026-09-19  3:06   ` Lin, Shuicheng
2026-09-04 21:16 ` [PATCH v6 16/24] drm/xe: Add CPU bind layer Matthew Brost
2026-09-04 21:50   ` sashiko-bot
2026-09-21 16:44   ` Ghimiray, Himal Prasad
2026-09-21 20:20   ` Lin, Shuicheng
2026-09-04 21:16 ` [PATCH v6 17/24] drm/xe: Add device flag to enable PT mirroring across tiles Matthew Brost
2026-09-04 21:40   ` sashiko-bot
2026-09-21 17:03     ` Ghimiray, Himal Prasad
2026-09-25  3:11       ` Matthew Brost
2026-09-21 17:02   ` Ghimiray, Himal Prasad
2026-09-04 21:16 ` [PATCH v6 18/24] drm/xe: Add ULLS support to LRC Matthew Brost
2026-09-23  7:01   ` Ghimiray, Himal Prasad
2026-09-04 21:16 ` [PATCH v6 19/24] drm/xe: Add ULLS migration job support to migration layer Matthew Brost
2026-09-04 21:40   ` sashiko-bot
2026-09-04 21:16 ` [PATCH v6 20/24] drm/xe: Add ULLS migration job support to ring ops Matthew Brost
2026-09-22 23:07   ` Lin, Shuicheng
2026-09-25  3:21     ` Matthew Brost
2026-09-23  8:47   ` Ghimiray, Himal Prasad
2026-09-04 21:16 ` [PATCH v6 21/24] drm/xe: Add ULLS migration job support to GuC submission Matthew Brost
2026-09-22 20:46   ` Lin, Shuicheng
2026-09-23  8:49   ` Ghimiray, Himal Prasad
2026-09-04 21:16 ` [PATCH v6 22/24] drm/xe: Enter ULLS for migration jobs upon page fault or SVM prefetch Matthew Brost
2026-09-22 16:39   ` Lin, Shuicheng
2026-09-23  8:52   ` Ghimiray, Himal Prasad
2026-09-04 21:16 ` [PATCH v6 23/24] drm/xe: Add modparam to enable / disable ULLS on migrate queue Matthew Brost
2026-09-09  8:03   ` Thomas Hellström
2026-09-09 18:11     ` Matthew Brost
2026-09-19  2:13       ` Lin, Shuicheng
2026-09-04 21:16 ` [PATCH v6 24/24] drm/xe: Document ULLS for migration jobs Matthew Brost
2026-09-09  9:01   ` Thomas Hellström
2026-09-09 17:53     ` Matthew Brost
2026-09-04 21:24 ` ✗ CI.checkpatch: warning for CPU binds and ULLS on migration queue (rev8) Patchwork
2026-09-04 21:26 ` ✓ CI.KUnit: success " Patchwork
2026-09-04 22:16 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-05  3:34 ` ✗ Xe.CI.FULL: failure " 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=32d645f0-472f-4300-aef3-e4988c595a86@intel.com \
    --to=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@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