From 7eb5d566813e5a72bcb9de8a543fda06a6ca837c Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Fri, 12 Jul 2024 12:33:09 +0000 Subject: [PATCH 1/2] feature: query wmtp capability from xe engine Related-To: NEO-10445 Signed-off-by: Mateusz Jablonski --- .../source/os_interface/linux/engine_info.cpp | 4 ++++ shared/source/os_interface/linux/ioctl_helper.h | 1 + .../os_interface/linux/xe/ioctl_helper_xe.cpp | 4 +++- shared/source/sku_info/sku_info_base.h | 4 ++++ .../linux/xe/ioctl_helper_xe_tests.cpp | 17 +++++++++++++++++ .../linux/xe/ioctl_helper_xe_tests.h | 4 ++-- third_party/uapi/xe/.version | 1 + third_party/uapi/xe/xe_drm.h | 14 +++++++++++--- 8 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 third_party/uapi/xe/.version diff --git a/shared/source/os_interface/linux/engine_info.cpp b/shared/source/os_interface/linux/engine_info.cpp index 522a6ba130fa9..7b83e766889e3 100644 --- a/shared/source/os_interface/linux/engine_info.cpp +++ b/shared/source/os_interface/linux/engine_info.cpp @@ -84,6 +84,10 @@ void EngineInfo::mapEngine(const NEO::IoctlHelper *ioctlHelper, const EngineCapa engineCounters.numComputeEngines++; } if (engineType != aub_stream::EngineType::NUM_ENGINES) { + if (engineInfo.capabilities.wmtpSupport) { + auto &wmtpInfoMask = rootDeviceEnvironment.getMutableHardwareInfo()->featureTable.wmtpInfoMask; + wmtpInfoMask.set(static_cast(engineType)); + } tileToEngineToInstanceMap[tileId][engineType] = engine; } } diff --git a/shared/source/os_interface/linux/ioctl_helper.h b/shared/source/os_interface/linux/ioctl_helper.h index 0fae937baa471..3bab8f9953e65 100644 --- a/shared/source/os_interface/linux/ioctl_helper.h +++ b/shared/source/os_interface/linux/ioctl_helper.h @@ -51,6 +51,7 @@ struct EngineCapabilities { struct Flags { bool copyClassSaturatePCIE; bool copyClassSaturateLink; + bool wmtpSupport; }; Flags capabilities; }; diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp index d3b508d9c28d8..31fa2f6a9837a 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -254,7 +254,9 @@ std::unique_ptr IoctlHelperXe::createEngineInfo(bool isSysmanEnabled if (enginesPerTile.size() <= tile) { enginesPerTile.resize(tile + 1); } - enginesPerTile[tile].push_back({engineClassInstance, {}}); + EngineCapabilities::Flags engineFlags{}; + engineFlags.wmtpSupport = isValueSet(queryEngines->engines[i].capabilities, DRM_XE_ENGINE_CAPABILITY_WMTP); + enginesPerTile[tile].push_back({engineClassInstance, engineFlags}); if (!defaultEngine && engineClassInstance.engineClass == defaultEngineClass) { defaultEngine = std::make_unique(); *defaultEngine = engine; diff --git a/shared/source/sku_info/sku_info_base.h b/shared/source/sku_info/sku_info_base.h index 678e89ac61784..e89926533c9a0 100644 --- a/shared/source/sku_info/sku_info_base.h +++ b/shared/source/sku_info/sku_info_base.h @@ -7,6 +7,8 @@ #pragma once +#include "aubstream/engine_node.h" + #include #include #include @@ -14,6 +16,7 @@ namespace NEO { constexpr size_t bcsInfoMaskSize = 9u; using BcsInfoMask = std::bitset; +using WmtpInfoMask = std::bitset; struct FeatureTableBase { public: @@ -75,6 +78,7 @@ struct FeatureTableBase { }; BcsInfoMask ftrBcsInfo = 1; + WmtpInfoMask wmtpInfoMask{}; union { Flags flags; diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp index 0ac8c503e8d63..af2aa20f2a053 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp @@ -1177,6 +1177,23 @@ TEST(IoctlHelperXeTest, givenMissingSupportedTopologiesWhenGetTopologyDataAndMap EXPECT_FALSE(result); } +TEST(IoctlHelperXeTest, whenCreatingEngineInfoThenWmtpInfoMaskIsProperlySet) { + DebugManagerStateRestore restorer; + auto executionEnvironment = std::make_unique(); + auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]); + auto xeIoctlHelper = static_cast(drm->getIoctlHelper()); + xeIoctlHelper->initialize(); + auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo(); + EXPECT_EQ(0u, hwInfo.featureTable.wmtpInfoMask.to_ulong()); + auto engineInfo = xeIoctlHelper->createEngineInfo(false); + EXPECT_FALSE(hwInfo.featureTable.wmtpInfoMask.test(static_cast(aub_stream::EngineType::ENGINE_CCS))); + EXPECT_TRUE(hwInfo.featureTable.wmtpInfoMask.test(static_cast(aub_stream::EngineType::ENGINE_CCS1))); + EXPECT_FALSE(hwInfo.featureTable.wmtpInfoMask.test(static_cast(aub_stream::EngineType::ENGINE_CCS2))); + EXPECT_FALSE(hwInfo.featureTable.wmtpInfoMask.test(static_cast(aub_stream::EngineType::ENGINE_CCS3))); + EXPECT_FALSE(hwInfo.featureTable.wmtpInfoMask.test(static_cast(aub_stream::EngineType::ENGINE_RCS))); + EXPECT_FALSE(hwInfo.featureTable.wmtpInfoMask.test(static_cast(aub_stream::EngineType::ENGINE_CCCS))); +} + TEST(IoctlHelperXeTest, whenCreatingEngineInfoThenProperEnginesAreDiscovered) { DebugManagerStateRestore restorer; auto executionEnvironment = std::make_unique(); diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h index a4511d8b5c7bc..2abf42d767dc0 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h +++ b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.h @@ -342,9 +342,9 @@ struct DrmMockXe : public DrmMockCustom { xeQueryEngines->engines[1] = {{DRM_XE_ENGINE_CLASS_COPY, 1, 0}, {}}; xeQueryEngines->engines[2] = {{DRM_XE_ENGINE_CLASS_COPY, 2, 0}, {}}; xeQueryEngines->engines[3] = {{DRM_XE_ENGINE_CLASS_COMPUTE, 3, 0}, {}}; - xeQueryEngines->engines[4] = {{DRM_XE_ENGINE_CLASS_COMPUTE, 4, 0}, {}}; + xeQueryEngines->engines[4] = {{DRM_XE_ENGINE_CLASS_COMPUTE, 4, 0}, DRM_XE_ENGINE_CAPABILITY_WMTP}; xeQueryEngines->engines[5] = {{DRM_XE_ENGINE_CLASS_COMPUTE, 5, 1}, {}}; - xeQueryEngines->engines[6] = {{DRM_XE_ENGINE_CLASS_COMPUTE, 6, 1}, {}}; + xeQueryEngines->engines[6] = {{DRM_XE_ENGINE_CLASS_COMPUTE, 6, 1}, DRM_XE_ENGINE_CAPABILITY_WMTP}; xeQueryEngines->engines[7] = {{DRM_XE_ENGINE_CLASS_COMPUTE, 7, 1}, {}}; xeQueryEngines->engines[8] = {{DRM_XE_ENGINE_CLASS_COMPUTE, 8, 1}, {}}; xeQueryEngines->engines[9] = {{DRM_XE_ENGINE_CLASS_VIDEO_DECODE, 9, 1}, {}}; diff --git a/third_party/uapi/xe/.version b/third_party/uapi/xe/.version new file mode 100644 index 0000000000000..82497c537f9b6 --- /dev/null +++ b/third_party/uapi/xe/.version @@ -0,0 +1 @@ +patch: https://patchwork.freedesktop.org/patch/604493/?series=13613 diff --git a/third_party/uapi/xe/xe_drm.h b/third_party/uapi/xe/xe_drm.h index 6c98c3dfa8909..828921af81c66 100644 --- a/third_party/uapi/xe/xe_drm.h +++ b/third_party/uapi/xe/xe_drm.h @@ -243,13 +243,21 @@ struct drm_xe_engine_class_instance { /** * struct drm_xe_engine - describe hardware engine - */ + * + * The @capabilities can be: + * - DRM_XE_ENGINE_CAPABILITY_WMTP - represents a engine's mid-thread + * preemption capability. +*/ struct drm_xe_engine { /** @instance: The @drm_xe_engine_class_instance */ struct drm_xe_engine_class_instance instance; - +#define DRM_XE_ENGINE_CAPABILITY_WMTP 1 + /** @capabilities: Capabilities of this engine. */ + __u32 capabilities; + /** @pad: MBZ */ + __u32 pad; /** @reserved: Reserved */ - __u64 reserved[3]; + __u64 reserved[2]; }; /** From 9f88f99580af47d6fdac540f9c0426cd4e99cfc4 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Tue, 20 Aug 2024 14:13:21 +0200 Subject: [PATCH 2/2] fix: setup ftrWalkerMTP based on wmtpInfoMask Signed-off-by: Mateusz Jablonski --- shared/source/os_interface/linux/engine_info.cpp | 3 +++ .../os_interface/linux/xe/ioctl_helper_xe_tests.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/shared/source/os_interface/linux/engine_info.cpp b/shared/source/os_interface/linux/engine_info.cpp index 7b83e766889e3..acad2983c8f0e 100644 --- a/shared/source/os_interface/linux/engine_info.cpp +++ b/shared/source/os_interface/linux/engine_info.cpp @@ -164,6 +164,9 @@ void EngineInfo::setSupportedEnginesInfo(const RootDeviceEnvironment &rootDevice ccsInfo.NumberOfCCSEnabled = 0; ccsInfo.Instances.CCSEnableMask = 0; } + if (hwInfo->featureTable.wmtpInfoMask.any()) { + hwInfo->featureTable.flags.ftrWalkerMTP = true; + } } uint32_t EngineInfo::getEngineTileIndex(const EngineClassInstance &engine) { diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp index af2aa20f2a053..b960374f374f8 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp @@ -1177,13 +1177,14 @@ TEST(IoctlHelperXeTest, givenMissingSupportedTopologiesWhenGetTopologyDataAndMap EXPECT_FALSE(result); } -TEST(IoctlHelperXeTest, whenCreatingEngineInfoThenWmtpInfoMaskIsProperlySet) { +TEST(IoctlHelperXeTest, whenCreatingEngineInfoThenWmtpFlagAndInfoMaskAreProperlySet) { DebugManagerStateRestore restorer; auto executionEnvironment = std::make_unique(); auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]); auto xeIoctlHelper = static_cast(drm->getIoctlHelper()); xeIoctlHelper->initialize(); - auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo(); + auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); + hwInfo.featureTable.flags.ftrWalkerMTP = 0; EXPECT_EQ(0u, hwInfo.featureTable.wmtpInfoMask.to_ulong()); auto engineInfo = xeIoctlHelper->createEngineInfo(false); EXPECT_FALSE(hwInfo.featureTable.wmtpInfoMask.test(static_cast(aub_stream::EngineType::ENGINE_CCS))); @@ -1192,6 +1193,7 @@ TEST(IoctlHelperXeTest, whenCreatingEngineInfoThenWmtpInfoMaskIsProperlySet) { EXPECT_FALSE(hwInfo.featureTable.wmtpInfoMask.test(static_cast(aub_stream::EngineType::ENGINE_CCS3))); EXPECT_FALSE(hwInfo.featureTable.wmtpInfoMask.test(static_cast(aub_stream::EngineType::ENGINE_RCS))); EXPECT_FALSE(hwInfo.featureTable.wmtpInfoMask.test(static_cast(aub_stream::EngineType::ENGINE_CCCS))); + EXPECT_TRUE(hwInfo.featureTable.flags.ftrWalkerMTP); } TEST(IoctlHelperXeTest, whenCreatingEngineInfoThenProperEnginesAreDiscovered) {