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 v7 09/13] drm/xe/exec: Switch hw engine group execution mode upon job submission
Date: Thu, 8 Aug 2024 03:33:15 +0000	[thread overview]
Message-ID: <ZrQ8e3kPZf6PCbi9@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20240807162416.1307061-10-francois.dugast@intel.com>

On Wed, Aug 07, 2024 at 06:23:38PM +0200, Francois Dugast wrote:
> If the job about to be submitted is a dma-fence job, update the current
> execution mode of the hw engine group. This triggers the required
> operations to ensure mutual exclusion of executions modes in this hw
> engine group.
> 
> v2: Change execution mode in exec IOCTL only when submitted job is
>     dma-fence (Matt Brost)
> 
> Signed-off-by: Francois Dugast <francois.dugast@intel.com>

A little pedantic but I'd restructure the series so patch #10 is before
this patch and then this patch and #11 are combined. The reason being
the common code path of exec IOCTL is fully updated (and feature
complete) in a single patch. e.g. At this point the exec IOCTL is kinda
broken. I think we are likely fine as the restriction removing mixed VMs
is not lifted until later but it is good practice that no single patch
breaks any functionality. Also when looking back via git blame, having
this patch and #11 combined makes things a bit more clear.

The changes in this patch LGTM though.

Matt

> ---
>  drivers/gpu/drm/xe/xe_exec.c            | 17 ++++++++++++++++-
>  drivers/gpu/drm/xe/xe_hw_engine_group.c | 13 +++++++++++++
>  drivers/gpu/drm/xe/xe_hw_engine_group.h |  3 +++
>  3 files changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_exec.c b/drivers/gpu/drm/xe/xe_exec.c
> index f36980aa26e6..2169fbf766d3 100644
> --- a/drivers/gpu/drm/xe/xe_exec.c
> +++ b/drivers/gpu/drm/xe/xe_exec.c
> @@ -14,6 +14,7 @@
>  #include "xe_bo.h"
>  #include "xe_device.h"
>  #include "xe_exec_queue.h"
> +#include "xe_hw_engine_group.h"
>  #include "xe_macros.h"
>  #include "xe_ring_ops_types.h"
>  #include "xe_sched_job.h"
> @@ -124,6 +125,8 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
>  	bool write_locked, skip_retry = false;
>  	ktime_t end = 0;
>  	int err = 0;
> +	struct xe_hw_engine_group *group;
> +	enum xe_hw_engine_group_execution_mode mode, previous_mode;
>  
>  	if (XE_IOCTL_DBG(xe, args->extensions) ||
>  	    XE_IOCTL_DBG(xe, args->pad[0] || args->pad[1] || args->pad[2]) ||
> @@ -182,6 +185,15 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
>  		}
>  	}
>  
> +	group = q->hwe->hw_engine_group;
> +	mode = xe_hw_engine_group_find_exec_mode(q);
> +
> +	if (mode == EXEC_MODE_DMA_FENCE) {
> +		err = xe_hw_engine_group_get_mode(group, mode, &previous_mode);
> +		if (err)
> +			goto err_syncs;
> +	}
> +
>  retry:
>  	if (!xe_vm_in_lr_mode(vm) && xe_vm_userptr_check_repin(vm)) {
>  		err = down_write_killable(&vm->lock);
> @@ -199,7 +211,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
>  		downgrade_write(&vm->lock);
>  		write_locked = false;
>  		if (err)
> -			goto err_unlock_list;
> +			goto err_hw_exec_mode;
>  	}
>  
>  	if (!args->num_batch_buffer) {
> @@ -324,6 +336,9 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
>  	up_read(&vm->lock);
>  	if (err == -EAGAIN && !skip_retry)
>  		goto retry;
> +err_hw_exec_mode:
> +	if (mode == EXEC_MODE_DMA_FENCE)
> +		xe_hw_engine_group_put(group);
>  err_syncs:
>  	while (num_syncs--)
>  		xe_sync_entry_cleanup(&syncs[num_syncs]);
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine_group.c b/drivers/gpu/drm/xe/xe_hw_engine_group.c
> index 75c82d24cedd..4781d6d606aa 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine_group.c
> +++ b/drivers/gpu/drm/xe/xe_hw_engine_group.c
> @@ -288,3 +288,16 @@ __releases(&group->mode_sem)
>  {
>  	up_read(&group->mode_sem);
>  }
> +
> +/**
> + * xe_hw_engine_group_find_exec_mode() - Find the execution mode for this exec queue
> + * @q: The exec_queue
> + */
> +enum xe_hw_engine_group_execution_mode
> +xe_hw_engine_group_find_exec_mode(struct xe_exec_queue *q)
> +{
> +	if (xe_vm_in_lr_mode(q->vm))
> +		return EXEC_MODE_LR;
> +	else
> +		return EXEC_MODE_DMA_FENCE;
> +}
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine_group.h b/drivers/gpu/drm/xe/xe_hw_engine_group.h
> index e0deb7c7bb5b..0f196c0ad98d 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine_group.h
> +++ b/drivers/gpu/drm/xe/xe_hw_engine_group.h
> @@ -22,4 +22,7 @@ int xe_hw_engine_group_get_mode(struct xe_hw_engine_group *group,
>  				enum xe_hw_engine_group_execution_mode *previous_mode);
>  void xe_hw_engine_group_put(struct xe_hw_engine_group *group);
>  
> +enum xe_hw_engine_group_execution_mode
> +xe_hw_engine_group_find_exec_mode(struct xe_exec_queue *q);
> +
>  #endif
> -- 
> 2.43.0
> 

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

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07 16:23 [PATCH v7 00/13] Parallel submission of dma fence jobs and LR jobs with shared hardware resources Francois Dugast
2024-08-07 16:23 ` [PATCH v7 01/13] drm/xe/hw_engine_group: Introduce xe_hw_engine_group Francois Dugast
2024-08-08  2:56   ` Matthew Brost
2024-08-07 16:23 ` [PATCH v7 02/13] drm/xe/guc_submit: Make suspend_wait interruptible Francois Dugast
2024-08-08  3:13   ` Matthew Brost
2024-08-07 16:23 ` [PATCH v7 03/13] drm/xe/hw_engine_group: Register hw engine group's exec queues Francois Dugast
2024-08-08  3:22   ` Matthew Brost
2024-08-07 16:23 ` [PATCH v7 04/13] drm/xe/hw_engine_group: Add helper to suspend faulting LR jobs Francois Dugast
2024-08-08  3:10   ` Matthew Brost
2024-08-07 16:23 ` [PATCH v7 05/13] drm/xe/exec_queue: Remove duplicated code Francois Dugast
2024-08-08  3:50   ` Matthew Brost
2024-08-07 16:23 ` [PATCH v7 06/13] drm/xe/exec_queue: Prepare last fence for hw engine group resume context Francois Dugast
2024-08-08  3:24   ` Matthew Brost
2024-08-07 16:23 ` [PATCH v7 07/13] drm/xe/hw_engine_group: Add helper to wait for dma fence jobs Francois Dugast
2024-08-08  3:05   ` Matthew Brost
2024-08-08 16:51     ` Francois Dugast
2024-08-07 16:23 ` [PATCH v7 08/13] drm/xe/hw_engine_group: Ensure safe transition between execution modes Francois Dugast
2024-08-08  3:26   ` Matthew Brost
2024-08-07 16:23 ` [PATCH v7 09/13] drm/xe/exec: Switch hw engine group execution mode upon job submission Francois Dugast
2024-08-08  3:33   ` Matthew Brost [this message]
2024-08-07 16:23 ` [PATCH v7 10/13] drm/xe/guc_submit: Allow calling guc_exec_queue_resume with pending resume Francois Dugast
2024-08-07 16:23 ` [PATCH v7 11/13] drm/xe/hw_engine_group: Resume exec queues suspended by dma fence jobs Francois Dugast
2024-08-08  3:48   ` Matthew Brost
2024-08-07 16:23 ` [PATCH v7 12/13] drm/xe/vm: Remove restriction that all VMs must be faulting if one is Francois Dugast
2024-08-08  3:45   ` Matthew Brost
2024-08-07 16:23 ` [PATCH v7 13/13] drm/xe/device: Remove unused xe_device::usm::num_vm_in_* Francois Dugast
2024-08-08  3:45   ` Matthew Brost
2024-08-07 16:30 ` ✓ CI.Patch_applied: success for Parallel submission of dma fence jobs and LR jobs with shared hardware resources (rev7) Patchwork
2024-08-07 16:30 ` ✗ CI.checkpatch: warning " Patchwork
2024-08-07 16:31 ` ✓ CI.KUnit: success " Patchwork
2024-08-07 16:43 ` ✓ CI.Build: " Patchwork
2024-08-07 16:45 ` ✓ CI.Hooks: " Patchwork
2024-08-07 16:46 ` ✓ CI.checksparse: " Patchwork
2024-08-07 17:18 ` ✓ CI.BAT: " Patchwork
2024-08-07 19:04 ` ✗ 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=ZrQ8e3kPZf6PCbi9@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