Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Francois Dugast <francois.dugast@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v8 06/11] drm/xe/exec_queue: Prepare last fence for hw engine group resume context
Date: Fri, 9 Aug 2024 03:37:57 +0000	[thread overview]
Message-ID: <ZrWPFapYEsSC6VTh@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20240808184220.1715625-7-francois.dugast@intel.com>

On Thu, Aug 08, 2024 at 08:40:24PM +0200, Francois Dugast wrote:
> Ensure we can safely take a ref of the exec queue's last fence from the
> context of resuming jobs from the hw engine group. The locking requirements
> differ from the general case, hence the introduction of this new function.
> 
> v2: Add kernel doc, rework the code to prevent code duplication
> 
> v3: Fix kernel doc, remove now unnecessary lockdep variants (Matt Brost)
> 
> v4: Remove new put function (Matt Brost)
> 
> Signed-off-by: Francois Dugast <francois.dugast@intel.com>

Reviewed-by: Matthew Brost <matthew.brost@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_exec_queue.c | 33 ++++++++++++++++++++++++++++--
>  drivers/gpu/drm/xe/xe_exec_queue.h |  2 ++
>  2 files changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c
> index 588cf5836798..abb2dfe7b1fd 100644
> --- a/drivers/gpu/drm/xe/xe_exec_queue.c
> +++ b/drivers/gpu/drm/xe/xe_exec_queue.c
> @@ -819,10 +819,12 @@ 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)
>  {
> -	if (q->flags & EXEC_QUEUE_FLAG_VM)
> +	if (q->flags & EXEC_QUEUE_FLAG_VM) {
>  		lockdep_assert_held(&vm->lock);
> -	else
> +	} else {
>  		xe_vm_assert_held(vm);
> +		lockdep_assert_held(&q->hwe->hw_engine_group->mode_sem);
> +	}
>  }
>  
>  /**
> @@ -876,6 +878,33 @@ struct dma_fence *xe_exec_queue_last_fence_get(struct xe_exec_queue *q,
>  	return fence;
>  }
>  
> +/**
> + * xe_exec_queue_last_fence_get_for_resume() - Get last fence
> + * @q: The exec queue
> + * @vm: The VM the engine does a bind or exec for
> + *
> + * Get last fence, takes a ref. Only safe to be called in the context of
> + * resuming the hw engine group's long-running exec queue, when the group
> + * semaphore is held.
> + *
> + * Returns: last fence if not signaled, dma fence stub if signaled
> + */
> +struct dma_fence *xe_exec_queue_last_fence_get_for_resume(struct xe_exec_queue *q,
> +							  struct xe_vm *vm)
> +{
> +	struct dma_fence *fence;
> +
> +	lockdep_assert_held_write(&q->hwe->hw_engine_group->mode_sem);
> +
> +	if (q->last_fence &&
> +	    test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &q->last_fence->flags))
> +		xe_exec_queue_last_fence_put_unlocked(q);
> +
> +	fence = q->last_fence ? q->last_fence : dma_fence_get_stub();
> +	dma_fence_get(fence);
> +	return fence;
> +}
> +
>  /**
>   * xe_exec_queue_last_fence_set() - Set last fence
>   * @q: The exec queue
> diff --git a/drivers/gpu/drm/xe/xe_exec_queue.h b/drivers/gpu/drm/xe/xe_exec_queue.h
> index ded77b0f3b90..5dcc1a65e5cf 100644
> --- a/drivers/gpu/drm/xe/xe_exec_queue.h
> +++ b/drivers/gpu/drm/xe/xe_exec_queue.h
> @@ -73,6 +73,8 @@ void xe_exec_queue_last_fence_put(struct xe_exec_queue *e, struct xe_vm *vm);
>  void xe_exec_queue_last_fence_put_unlocked(struct xe_exec_queue *e);
>  struct dma_fence *xe_exec_queue_last_fence_get(struct xe_exec_queue *e,
>  					       struct xe_vm *vm);
> +struct dma_fence *xe_exec_queue_last_fence_get_for_resume(struct xe_exec_queue *e,
> +							  struct xe_vm *vm);
>  void xe_exec_queue_last_fence_set(struct xe_exec_queue *e, struct xe_vm *vm,
>  				  struct dma_fence *fence);
>  int xe_exec_queue_last_fence_test_dep(struct xe_exec_queue *q,
> -- 
> 2.43.0
> 

  reply	other threads:[~2024-08-09  3:39 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-08 18:40 [PATCH v8 00/11] Parallel submission of dma fence jobs and LR jobs with shared hardware resources Francois Dugast
2024-08-08 18:40 ` [PATCH v8 01/11] drm/xe/hw_engine_group: Introduce xe_hw_engine_group Francois Dugast
2024-08-08 18:40 ` [PATCH v8 02/11] drm/xe/guc_submit: Make suspend_wait interruptible Francois Dugast
2024-08-08 23:51   ` Matthew Brost
2024-08-08 18:40 ` [PATCH v8 03/11] 'drm/xe/hw_engine_group: Register hw engine group's exec queues Francois Dugast
2024-08-09  3:36   ` Matthew Brost
2024-08-08 18:40 ` [PATCH v8 04/11] drm/xe/hw_engine_group: Add helper to suspend faulting LR jobs Francois Dugast
2024-08-09  3:19   ` Matthew Brost
2024-08-08 18:40 ` [PATCH v8 05/11] drm/xe/exec_queue: Remove duplicated code Francois Dugast
2024-08-08 18:40 ` [PATCH v8 06/11] drm/xe/exec_queue: Prepare last fence for hw engine group resume context Francois Dugast
2024-08-09  3:37   ` Matthew Brost [this message]
2024-08-08 18:40 ` [PATCH v8 07/11] drm/xe/hw_engine_group: Add helper to wait for dma fence jobs Francois Dugast
2024-08-09  3:39   ` Matthew Brost
2024-08-08 18:40 ` [PATCH v8 08/11] drm/xe/hw_engine_group: Ensure safe transition between execution modes Francois Dugast
2024-08-09  3:40   ` Matthew Brost
2024-08-08 18:40 ` [PATCH v8 09/11] drm/xe/exec: Switch hw engine group execution mode upon job submission Francois Dugast
2024-08-09  3:57   ` Matthew Brost
2024-08-08 18:40 ` [PATCH v8 10/11] drm/xe/vm: Remove restriction that all VMs must be faulting if one is Francois Dugast
2024-08-08 18:40 ` [PATCH v8 11/11] drm/xe/device: Remove unused xe_device::usm::num_vm_in_* Francois Dugast
2024-08-08 20:57 ` ✓ CI.Patch_applied: success for Parallel submission of dma fence jobs and LR jobs with shared hardware resources (rev8) Patchwork
2024-08-08 20:58 ` ✗ CI.checkpatch: warning " Patchwork
2024-08-08 20:59 ` ✓ CI.KUnit: success " Patchwork
2024-08-08 21:11 ` ✓ CI.Build: " Patchwork
2024-08-08 21:13 ` ✓ CI.Hooks: " Patchwork
2024-08-08 21:14 ` ✓ CI.checksparse: " Patchwork
2024-08-08 21:35 ` ✗ CI.BAT: failure " Patchwork
2024-08-09  1:29 ` ✗ 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=ZrWPFapYEsSC6VTh@DUT025-TGLU.fm.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