Skip to content

Commit cfce3b7

Browse files
Jexuintel-mediadev
authored andcommitted
[Decode] Refine sys info query
simplify sys info query
1 parent e4b7ec9 commit cfce3b7

File tree

1 file changed

+35
-70
lines changed

1 file changed

+35
-70
lines changed

media_softlet/linux/common/os/xe/mos_bufmgr_xe.c

+35-70
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ static drmMMListHead bufmgr_list = { &bufmgr_list, &bufmgr_list };
419419
static struct drm_xe_query_gt_list *__mos_query_gt_list_xe(int fd);
420420
static void mos_bo_free_xe(struct mos_linux_bo *bo);
421421
static int mos_query_engines_count_xe(struct mos_bufmgr *bufmgr, unsigned int *nengine);
422-
int mos_query_engines_class_xe(struct mos_bufmgr *bufmgr,
422+
int mos_query_engines_xe(struct mos_bufmgr *bufmgr,
423423
__u16 engine_class,
424424
__u64 caps,
425425
unsigned int *nengine,
@@ -1064,7 +1064,7 @@ __mos_context_restore_xe(struct mos_bufmgr *bufmgr,
10641064
MOS_DRM_CHK_STATUS_MESSAGE_RETURN(ret,
10651065
"query engine count of restore failed, return error(%d)", ret)
10661066
struct drm_xe_engine_class_instance engine_map[nengine];
1067-
ret = mos_query_engines_class_xe(bufmgr,
1067+
ret = mos_query_engines_xe(bufmgr,
10681068
context->engine_class,
10691069
context->engine_caps,
10701070
&nengine,
@@ -2716,11 +2716,7 @@ mos_query_engines_count_xe(struct mos_bufmgr *bufmgr, unsigned int *nengine)
27162716
if (nullptr == bufmgr_gem->engines)
27172717
{
27182718
bufmgr_gem->engines = __mos_query_engines_xe(bufmgr_gem->fd);
2719-
if (nullptr == bufmgr_gem->engines)
2720-
{
2721-
MOS_DRM_ASSERTMESSAGE("__mos_query_engines_xe failed");
2722-
return -ENODEV;
2723-
}
2719+
MOS_DRM_CHK_NULL_RETURN_VALUE(bufmgr_gem->engines, -ENODEV);
27242720
}
27252721

27262722
*nengine = bufmgr_gem->engines->num_engines;
@@ -2729,7 +2725,7 @@ mos_query_engines_count_xe(struct mos_bufmgr *bufmgr, unsigned int *nengine)
27292725
}
27302726

27312727
int
2732-
mos_query_engines_class_xe(struct mos_bufmgr *bufmgr,
2728+
mos_query_engines_xe(struct mos_bufmgr *bufmgr,
27332729
__u16 engine_class,
27342730
__u64 caps,
27352731
unsigned int *nengine,
@@ -2745,10 +2741,7 @@ mos_query_engines_class_xe(struct mos_bufmgr *bufmgr,
27452741
if (nullptr == bufmgr_gem->engines)
27462742
{
27472743
bufmgr_gem->engines = __mos_query_engines_xe(bufmgr_gem->fd);
2748-
if (nullptr == bufmgr_gem->engines)
2749-
{
2750-
return -ENODEV;
2751-
}
2744+
MOS_DRM_CHK_NULL_RETURN_VALUE(bufmgr_gem->engines, -ENODEV);
27522745
}
27532746

27542747
engines = bufmgr_gem->engines;
@@ -2787,81 +2780,53 @@ mos_get_engine_class_size_xe()
27872780
return sizeof(struct drm_xe_engine_class_instance);
27882781
}
27892782

2790-
//Note31: remove this code and restore it to previous version in HwInfoLinux.cpp
27912783
static int
2792-
mos_query_sys_engines_xe(struct mos_bufmgr *bufmgr, MEDIA_SYSTEM_INFO* gfx_info)
2784+
mos_query_sysinfo_xe(struct mos_bufmgr *bufmgr, MEDIA_SYSTEM_INFO* gfx_info)
27932785
{
2786+
MOS_DRM_CHK_NULL_RETURN_VALUE(bufmgr, -EINVAL);
2787+
MOS_DRM_CHK_NULL_RETURN_VALUE(gfx_info, -EINVAL);
2788+
27942789
struct mos_xe_bufmgr_gem *bufmgr_gem = (struct mos_xe_bufmgr_gem *)bufmgr;
27952790
int ret;
27962791

2797-
if (nullptr == gfx_info)
2798-
{
2799-
return -EINVAL;
2800-
}
2801-
28022792
if (nullptr == bufmgr_gem->engines)
28032793
{
28042794
bufmgr_gem->engines = __mos_query_engines_xe(bufmgr_gem->fd);
2805-
if (nullptr == bufmgr_gem->engines)
2806-
{
2807-
MOS_DRM_ASSERTMESSAGE("__mos_query_engines_xe failed");
2808-
return -ENODEV;
2809-
}
2795+
MOS_DRM_CHK_NULL_RETURN_VALUE(bufmgr_gem->engines, -ENODEV);
28102796
}
28112797

2812-
if (0 == gfx_info->VDBoxInfo.NumberOfVDBoxEnabled)
2798+
if (0 == gfx_info->VDBoxInfo.NumberOfVDBoxEnabled
2799+
|| 0 == gfx_info->VEBoxInfo.NumberOfVEBoxEnabled)
28132800
{
2814-
unsigned int nengine = bufmgr_gem->engines->num_engines;
2815-
struct drm_xe_engine_class_instance *uengines = nullptr;
2816-
uengines = (struct drm_xe_engine_class_instance *)MOS_AllocAndZeroMemory(nengine * sizeof(struct drm_xe_engine_class_instance));
2817-
if (nullptr == uengines)
2818-
{
2819-
return -ENOMEM;
2820-
}
2821-
ret = mos_query_engines_class_xe(bufmgr, DRM_XE_ENGINE_CLASS_VIDEO_DECODE, 0, &nengine, (void *)uengines);
2822-
if (ret)
2823-
{
2824-
MOS_DRM_ASSERTMESSAGE("Failed to query vdbox engine");
2825-
MOS_SafeFreeMemory(uengines);
2826-
return -ENODEV;
2827-
}
2828-
else
2829-
{
2830-
MOS_OS_ASSERT(nengine <= bufmgr_gem->engines->num_engines);
2831-
gfx_info->VDBoxInfo.NumberOfVDBoxEnabled = nengine;
2832-
}
2801+
unsigned int num_vd = 0;
2802+
unsigned int num_ve = 0;
28332803

2834-
for (int i=0; i<nengine; i++)
2804+
for (unsigned int i = 0; i < bufmgr_gem->engines->num_engines; i++)
28352805
{
2836-
gfx_info->VDBoxInfo.Instances.VDBoxEnableMask |= 1<<uengines[i].engine_instance;
2837-
}
2838-
2839-
MOS_SafeFreeMemory(uengines);
2840-
}
2806+
if (0 == gfx_info->VDBoxInfo.NumberOfVDBoxEnabled
2807+
&& bufmgr_gem->engines->engines[i].instance.engine_class == DRM_XE_ENGINE_CLASS_VIDEO_DECODE)
2808+
{
2809+
gfx_info->VDBoxInfo.Instances.VDBoxEnableMask |=
2810+
1 << bufmgr_gem->engines->engines[i].instance.engine_instance;
2811+
num_vd++;
2812+
}
28412813

2842-
if (0 == gfx_info->VEBoxInfo.NumberOfVEBoxEnabled)
2843-
{
2844-
unsigned int nengine = bufmgr_gem->engines->num_engines;
2845-
struct drm_xe_engine_class_instance *uengines = nullptr;
2846-
uengines = (struct drm_xe_engine_class_instance *)MOS_AllocAndZeroMemory(nengine * sizeof(struct drm_xe_engine_class_instance));
2847-
if (nullptr == uengines)
2848-
{
2849-
return -ENOMEM;
2814+
if (0 == gfx_info->VEBoxInfo.NumberOfVEBoxEnabled
2815+
&& bufmgr_gem->engines->engines[i].instance.engine_class == DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE)
2816+
{
2817+
num_ve++;
2818+
}
28502819
}
2851-
ret = mos_query_engines_class_xe(bufmgr, DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE, 0, &nengine, (void *)uengines);
2852-
if (ret)
2820+
2821+
if (num_vd > 0)
28532822
{
2854-
MOS_DRM_ASSERTMESSAGE("Failed to query vebox engine");
2855-
MOS_SafeFreeMemory(uengines);
2856-
return -ENODEV;
2823+
gfx_info->VDBoxInfo.NumberOfVDBoxEnabled = num_vd;
28572824
}
2858-
else
2825+
2826+
if (num_vd > 0)
28592827
{
2860-
MOS_OS_ASSERT(nengine <= bufmgr_gem->engines->num_engines);
2861-
gfx_info->VEBoxInfo.NumberOfVEBoxEnabled = nengine;
2828+
gfx_info->VEBoxInfo.NumberOfVEBoxEnabled = num_ve;
28622829
}
2863-
2864-
MOS_SafeFreeMemory(uengines);
28652830
}
28662831

28672832
return 0;
@@ -3524,9 +3489,9 @@ mos_bufmgr_gem_init_xe(int fd, int batch_size)
35243489
bufmgr_gem->bufmgr.bo_export_to_prime = mos_bo_export_to_prime_xe;
35253490
bufmgr_gem->bufmgr.get_devid = mos_get_devid_xe;
35263491
bufmgr_gem->bufmgr.query_engines_count = mos_query_engines_count_xe;
3527-
bufmgr_gem->bufmgr.query_engines = mos_query_engines_class_xe;
3492+
bufmgr_gem->bufmgr.query_engines = mos_query_engines_xe;
35283493
bufmgr_gem->bufmgr.get_engine_class_size = mos_get_engine_class_size_xe;
3529-
bufmgr_gem->bufmgr.query_sys_engines = mos_query_sys_engines_xe;
3494+
bufmgr_gem->bufmgr.query_sys_engines = mos_query_sysinfo_xe;
35303495
bufmgr_gem->bufmgr.select_fixed_engine = mos_select_fixed_engine_xe;
35313496
bufmgr_gem->bufmgr.query_device_blob = mos_query_device_blob_xe;
35323497
bufmgr_gem->bufmgr.get_driver_info = mos_get_driver_info_xe;

0 commit comments

Comments
 (0)