drm/xe: Move and export xe_hw_engine lookup.
BugLink: https://bugs.launchpad.net/bugs/2097301 [ Upstream commit 6f20fc09936e786a4ba18f5514fe185e0451ada9 ] 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) 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> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240729130152.100130-1-mika.kuoppala@linux.intel.com Stable-dep-of: 852856e3b6f6 ("drm/xe: Use reserved copy engine for user binds on faulting devices") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
941843ba47
commit
b1c236414e
@@ -391,34 +391,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)
|
||||
@@ -440,8 +412,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);
|
||||
}
|
||||
|
||||
@@ -470,7 +441,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;
|
||||
|
||||
@@ -548,7 +519,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;
|
||||
|
||||
@@ -587,7 +558,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;
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -881,3 +884,31 @@ bool xe_hw_engine_is_reserved(struct xe_hw_engine *hwe)
|
||||
return xe->info.has_usm && hwe->class == XE_ENGINE_CLASS_COPY &&
|
||||
hwe->instance == gt->usm.reserved_bcs_instance;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user