Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	Dominik Grzegorzek <dominik.grzegorzek@intel.com>
Subject: Re: [PATCH] drm/xe: Move and export xe_hw_engine lookup.
Date: Wed, 31 Jul 2024 02:40:07 +0000	[thread overview]
Message-ID: <ZqmkBw4iGEUcMQSP@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20240729130152.100130-1-mika.kuoppala@linux.intel.com>

On Mon, Jul 29, 2024 at 04:01:52PM +0300, Mika Kuoppala wrote:
> From: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
> 
> Move and export xe_hw_engine lookup. This is in preparation
> to use this in eudebug code where we want to find active
> engine.
> 
> v2: s/tile/gt due to uapi changes (Mika)
> 

Applied to drm-xe-next.

Matt

> Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_exec_queue.c | 37 ++++--------------------------
>  drivers/gpu/drm/xe/xe_hw_engine.c  | 31 +++++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_hw_engine.h  |  7 ++++++
>  3 files changed, 42 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c
> index 69867a7b7c77..956dc15b432a 100644
> --- a/drivers/gpu/drm/xe/xe_exec_queue.c
> +++ b/drivers/gpu/drm/xe/xe_exec_queue.c
> @@ -413,34 +413,6 @@ static int exec_queue_user_extensions(struct xe_device *xe, struct xe_exec_queue
>  	return 0;
>  }
>  
> -static const enum xe_engine_class user_to_xe_engine_class[] = {
> -	[DRM_XE_ENGINE_CLASS_RENDER] = XE_ENGINE_CLASS_RENDER,
> -	[DRM_XE_ENGINE_CLASS_COPY] = XE_ENGINE_CLASS_COPY,
> -	[DRM_XE_ENGINE_CLASS_VIDEO_DECODE] = XE_ENGINE_CLASS_VIDEO_DECODE,
> -	[DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE] = XE_ENGINE_CLASS_VIDEO_ENHANCE,
> -	[DRM_XE_ENGINE_CLASS_COMPUTE] = XE_ENGINE_CLASS_COMPUTE,
> -};
> -
> -static struct xe_hw_engine *
> -find_hw_engine(struct xe_device *xe,
> -	       struct drm_xe_engine_class_instance eci)
> -{
> -	u32 idx;
> -
> -	if (eci.engine_class >= ARRAY_SIZE(user_to_xe_engine_class))
> -		return NULL;
> -
> -	if (eci.gt_id >= xe->info.gt_count)
> -		return NULL;
> -
> -	idx = array_index_nospec(eci.engine_class,
> -				 ARRAY_SIZE(user_to_xe_engine_class));
> -
> -	return xe_gt_hw_engine(xe_device_get_gt(xe, eci.gt_id),
> -			       user_to_xe_engine_class[idx],
> -			       eci.engine_instance, true);
> -}
> -
>  static u32 bind_exec_queue_logical_mask(struct xe_device *xe, struct xe_gt *gt,
>  					struct drm_xe_engine_class_instance *eci,
>  					u16 width, u16 num_placements)
> @@ -462,8 +434,7 @@ static u32 bind_exec_queue_logical_mask(struct xe_device *xe, struct xe_gt *gt,
>  		if (xe_hw_engine_is_reserved(hwe))
>  			continue;
>  
> -		if (hwe->class ==
> -		    user_to_xe_engine_class[DRM_XE_ENGINE_CLASS_COPY])
> +		if (hwe->class == XE_ENGINE_CLASS_COPY)
>  			logical_mask |= BIT(hwe->logical_instance);
>  	}
>  
> @@ -492,7 +463,7 @@ static u32 calc_validate_logical_mask(struct xe_device *xe, struct xe_gt *gt,
>  
>  			n = j * width + i;
>  
> -			hwe = find_hw_engine(xe, eci[n]);
> +			hwe = xe_hw_engine_lookup(xe, eci[n]);
>  			if (XE_IOCTL_DBG(xe, !hwe))
>  				return 0;
>  
> @@ -571,7 +542,7 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
>  			if (XE_IOCTL_DBG(xe, !logical_mask))
>  				return -EINVAL;
>  
> -			hwe = find_hw_engine(xe, eci[0]);
> +			hwe = xe_hw_engine_lookup(xe, eci[0]);
>  			if (XE_IOCTL_DBG(xe, !hwe))
>  				return -EINVAL;
>  
> @@ -608,7 +579,7 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
>  		if (XE_IOCTL_DBG(xe, !logical_mask))
>  			return -EINVAL;
>  
> -		hwe = find_hw_engine(xe, eci[0]);
> +		hwe = xe_hw_engine_lookup(xe, eci[0]);
>  		if (XE_IOCTL_DBG(xe, !hwe))
>  			return -EINVAL;
>  
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine.c b/drivers/gpu/drm/xe/xe_hw_engine.c
> index 07ed9fd28f19..00ace5fcc284 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine.c
> +++ b/drivers/gpu/drm/xe/xe_hw_engine.c
> @@ -5,7 +5,10 @@
>  
>  #include "xe_hw_engine.h"
>  
> +#include <linux/nospec.h>
> +
>  #include <drm/drm_managed.h>
> +#include <drm/xe_drm.h>
>  
>  #include "regs/xe_engine_regs.h"
>  #include "regs/xe_gt_regs.h"
> @@ -1135,3 +1138,31 @@ enum xe_force_wake_domains xe_hw_engine_to_fw_domain(struct xe_hw_engine *hwe)
>  {
>  	return engine_infos[hwe->engine_id].domain;
>  }
> +
> +static const enum xe_engine_class user_to_xe_engine_class[] = {
> +	[DRM_XE_ENGINE_CLASS_RENDER] = XE_ENGINE_CLASS_RENDER,
> +	[DRM_XE_ENGINE_CLASS_COPY] = XE_ENGINE_CLASS_COPY,
> +	[DRM_XE_ENGINE_CLASS_VIDEO_DECODE] = XE_ENGINE_CLASS_VIDEO_DECODE,
> +	[DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE] = XE_ENGINE_CLASS_VIDEO_ENHANCE,
> +	[DRM_XE_ENGINE_CLASS_COMPUTE] = XE_ENGINE_CLASS_COMPUTE,
> +};
> +
> +struct xe_hw_engine *
> +xe_hw_engine_lookup(struct xe_device *xe,
> +		    struct drm_xe_engine_class_instance eci)
> +{
> +	unsigned int idx;
> +
> +	if (eci.engine_class > ARRAY_SIZE(user_to_xe_engine_class))
> +		return NULL;
> +
> +	if (eci.gt_id >= xe->info.gt_count)
> +		return NULL;
> +
> +	idx = array_index_nospec(eci.engine_class,
> +				 ARRAY_SIZE(user_to_xe_engine_class));
> +
> +	return xe_gt_hw_engine(xe_device_get_gt(xe, eci.gt_id),
> +			       user_to_xe_engine_class[idx],
> +			       eci.engine_instance, true);
> +}
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine.h b/drivers/gpu/drm/xe/xe_hw_engine.h
> index 900c8c991430..d227ffe557eb 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine.h
> +++ b/drivers/gpu/drm/xe/xe_hw_engine.h
> @@ -9,6 +9,8 @@
>  #include "xe_hw_engine_types.h"
>  
>  struct drm_printer;
> +struct drm_xe_engine_class_instance;
> +struct xe_device;
>  
>  #ifdef CONFIG_DRM_XE_JOB_TIMEOUT_MIN
>  #define XE_HW_ENGINE_JOB_TIMEOUT_MIN CONFIG_DRM_XE_JOB_TIMEOUT_MIN
> @@ -62,6 +64,11 @@ void xe_hw_engine_print(struct xe_hw_engine *hwe, struct drm_printer *p);
>  void xe_hw_engine_setup_default_lrc_state(struct xe_hw_engine *hwe);
>  
>  bool xe_hw_engine_is_reserved(struct xe_hw_engine *hwe);
> +
> +struct xe_hw_engine *
> +xe_hw_engine_lookup(struct xe_device *xe,
> +		    struct drm_xe_engine_class_instance eci);
> +
>  static inline bool xe_hw_engine_is_valid(struct xe_hw_engine *hwe)
>  {
>  	return hwe->name;
> -- 
> 2.34.1
> 

      parent reply	other threads:[~2024-07-31  2:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29 13:01 [PATCH] drm/xe: Move and export xe_hw_engine lookup Mika Kuoppala
2024-07-29 13:45 ` ✓ CI.Patch_applied: success for " Patchwork
2024-07-29 13:45 ` ✓ CI.checkpatch: " Patchwork
2024-07-29 13:46 ` ✓ CI.KUnit: " Patchwork
2024-07-29 13:58 ` ✓ CI.Build: " Patchwork
2024-07-29 14:01 ` ✓ CI.Hooks: " Patchwork
2024-07-29 14:02 ` ✓ CI.checksparse: " Patchwork
2024-07-29 14:23 ` ✗ CI.BAT: failure " Patchwork
2024-07-29 17:49 ` ✗ CI.FULL: " Patchwork
2024-07-31  2:40 ` Matthew Brost [this message]

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=ZqmkBw4iGEUcMQSP@DUT025-TGLU.fm.intel.com \
    --to=matthew.brost@intel.com \
    --cc=dominik.grzegorzek@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=mika.kuoppala@linux.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