From 25f2504bf524d7ae1cfade5b9f84ae0911110404 Mon Sep 17 00:00:00 2001 From: Jitendra Sharma Date: Tue, 17 Sep 2024 17:01:05 +0000 Subject: [PATCH] fix: set eudebug extension property when debugging enabled In order to debug on XE, XE_EXEC_QUEUE_SET_PROPERTY_EUDEBUG needs to be set up. Related-To: NEO-12691 Signed-off-by: Jitendra Sharma --- shared/source/helpers/gfx_core_helper.h | 3 -- .../source/helpers/gfx_core_helper_base.inl | 5 --- .../os_interface/linux/xe/ioctl_helper_xe.cpp | 5 ++- .../os_interface/linux/xe/ioctl_helper_xe.h | 2 +- .../linux/xe/ioctl_helper_xe_debugger.cpp | 2 +- .../xe/ioctl_helper_xe_debugger_stubs.cpp | 2 +- .../gfx_core_helper_xe2_hpg_core.cpp | 5 --- .../common/mocks/linux/debug_mock_drm_xe.h | 2 +- .../helpers/gfx_core_helper_tests.cpp | 6 ---- .../xe/ioctl_helper_xe_debugger_tests.cpp | 32 +++++-------------- 10 files changed, 14 insertions(+), 50 deletions(-) diff --git a/shared/source/helpers/gfx_core_helper.h b/shared/source/helpers/gfx_core_helper.h index 3d26523a2f..43c0433840 100644 --- a/shared/source/helpers/gfx_core_helper.h +++ b/shared/source/helpers/gfx_core_helper.h @@ -140,7 +140,6 @@ class GfxCoreHelper { virtual size_t getTimestampPacketAllocatorAlignment() const = 0; virtual size_t getSingleTimestampPacketSize() const = 0; virtual void applyAdditionalCompressionSettings(Gmm &gmm, bool isNotCompressed) const = 0; - virtual bool isRunaloneModeRequired(DebuggingMode debuggingMode) const = 0; virtual void applyRenderCompressionFlag(Gmm &gmm, uint32_t isCompressed) const = 0; virtual bool unTypedDataPortCacheFlushRequired() const = 0; virtual bool isEngineTypeRemappingToHwSpecificRequired() const = 0; @@ -377,8 +376,6 @@ class GfxCoreHelperHw : public GfxCoreHelper { void applyAdditionalCompressionSettings(Gmm &gmm, bool isNotCompressed) const override; - bool isRunaloneModeRequired(DebuggingMode debuggingMode) const override; - void applyRenderCompressionFlag(Gmm &gmm, uint32_t isCompressed) const override; bool unTypedDataPortCacheFlushRequired() const override; diff --git a/shared/source/helpers/gfx_core_helper_base.inl b/shared/source/helpers/gfx_core_helper_base.inl index d355e73361..85be97bbb6 100644 --- a/shared/source/helpers/gfx_core_helper_base.inl +++ b/shared/source/helpers/gfx_core_helper_base.inl @@ -581,11 +581,6 @@ size_t GfxCoreHelperHw::getPreemptionAllocationAlignment() const { template void GfxCoreHelperHw::applyAdditionalCompressionSettings(Gmm &gmm, bool isNotCompressed) const {} -template -bool GfxCoreHelperHw::isRunaloneModeRequired(DebuggingMode debuggingMode) const { - return false; -} - template void GfxCoreHelperHw::applyRenderCompressionFlag(Gmm &gmm, uint32_t isCompressed) const { gmm.resourceParams.Flags.Info.RenderCompressed = isCompressed; 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 608b74446d..793ae6df69 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -1563,12 +1563,11 @@ void IoctlHelperXe::setOptionalContextProperties(Drm &drm, void *extProperties, auto &ext = *reinterpret_cast *>(extProperties); - auto &gfxCoreHelper = drm.getRootDeviceEnvironment().getHelper(); if ((contextParamEngine[0].engine_class == DRM_XE_ENGINE_CLASS_RENDER) || (contextParamEngine[0].engine_class == DRM_XE_ENGINE_CLASS_COMPUTE)) { - if (gfxCoreHelper.isRunaloneModeRequired(drm.getRootDeviceEnvironment().executionEnvironment.getDebuggingMode())) { + if (drm.getRootDeviceEnvironment().executionEnvironment.isDebuggingEnabled()) { ext[extIndexInOut].base.next_extension = 0; ext[extIndexInOut].base.name = DRM_XE_EXEC_QUEUE_EXTENSION_SET_PROPERTY; - ext[extIndexInOut].property = getRunaloneExtProperty(); + ext[extIndexInOut].property = getEudebugExtProperty(); ext[extIndexInOut].value = 1; extIndexInOut++; } diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h index c995de7b99..2c8943738a 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h @@ -152,7 +152,7 @@ class IoctlHelperXe : public IoctlHelper { int debuggerOpenIoctl(DrmIoctl request, void *arg); int debuggerMetadataCreateIoctl(DrmIoctl request, void *arg); int debuggerMetadataDestroyIoctl(DrmIoctl request, void *arg); - int getRunaloneExtProperty(); + int getEudebugExtProperty(); virtual bool isExtraEngineClassAllowed(uint16_t engineClass) const { return false; } virtual std::optional getCxlType() { return {}; } virtual uint32_t getNumEngines(uint64_t *enginesData) const; diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe_debugger.cpp b/shared/source/os_interface/linux/xe/ioctl_helper_xe_debugger.cpp index d43353e0f1..2fee02c07b 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe_debugger.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe_debugger.cpp @@ -57,7 +57,7 @@ int IoctlHelperXe::debuggerMetadataDestroyIoctl(DrmIoctl request, void *arg) { return ret; } -int IoctlHelperXe::getRunaloneExtProperty() { +int IoctlHelperXe::getEudebugExtProperty() { return DRM_XE_EXEC_QUEUE_SET_PROPERTY_EUDEBUG; } diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe_debugger_stubs.cpp b/shared/source/os_interface/linux/xe/ioctl_helper_xe_debugger_stubs.cpp index fd5e9e1a0d..5e67edadcc 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe_debugger_stubs.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe_debugger_stubs.cpp @@ -29,7 +29,7 @@ int IoctlHelperXe::debuggerMetadataDestroyIoctl(DrmIoctl request, void *arg) { return 0; } -int IoctlHelperXe::getRunaloneExtProperty() { +int IoctlHelperXe::getEudebugExtProperty() { UNRECOVERABLE_IF(true); return 0; } diff --git a/shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp index 81b11120a4..9ebb23dfd5 100644 --- a/shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp +++ b/shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp @@ -298,11 +298,6 @@ uint32_t GfxCoreHelperHw::overrideMaxWorkGroupSize(uint32_t maxWG) const return std::min(maxWG, 2048u); } -template <> -bool GfxCoreHelperHw::isRunaloneModeRequired(DebuggingMode debuggingMode) const { - return (debuggingMode == DebuggingMode::online); -} - template <> uint32_t GfxCoreHelperHw::calculateNumThreadsPerThreadGroup(uint32_t simd, uint32_t totalWorkItems, uint32_t grfCount, bool isHwLocalIdGeneration, const RootDeviceEnvironment &rootDeviceEnvironment) const { uint32_t numThreadsPerThreadGroup = getThreadsPerWG(simd, totalWorkItems); diff --git a/shared/test/common/mocks/linux/debug_mock_drm_xe.h b/shared/test/common/mocks/linux/debug_mock_drm_xe.h index 80a0ed288f..3d48fc2064 100644 --- a/shared/test/common/mocks/linux/debug_mock_drm_xe.h +++ b/shared/test/common/mocks/linux/debug_mock_drm_xe.h @@ -29,7 +29,7 @@ using namespace NEO; struct MockIoctlHelperXeDebug : IoctlHelperXe { using IoctlHelperXe::bindInfo; - using IoctlHelperXe::getRunaloneExtProperty; + using IoctlHelperXe::getEudebugExtProperty; using IoctlHelperXe::IoctlHelperXe; using IoctlHelperXe::tileIdToGtId; }; diff --git a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp index acf0b189cb..bd1f1d15c3 100644 --- a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp +++ b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp @@ -1710,12 +1710,6 @@ HWTEST2_F(GfxCoreHelperTest, givenParamsWhenCalculateNumThreadsPerThreadGroupThe } } -HWTEST2_F(GfxCoreHelperTest, givenDebugModeWhenCheckingIfRunaloneModeRequiredThenMethodReturnFalseValue, IsAtMostXeHpcCore) { - auto &gfxCoreHelper = getHelper(); - EXPECT_FALSE(gfxCoreHelper.isRunaloneModeRequired(DebuggingMode::offline)); - EXPECT_FALSE(gfxCoreHelper.isRunaloneModeRequired(DebuggingMode::online)); -} - HWTEST_F(GfxCoreHelperTest, givenFlagRemoveRestrictionsOnNumberOfThreadsInGpgpuThreadGroupWhenCalculateNumThreadsPerThreadGroupThenMethodReturnProperValue) { DebugManagerStateRestore dbgRestore; debugManager.flags.RemoveRestrictionsOnNumberOfThreadsInGpgpuThreadGroup.set(1); diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_debugger_tests.cpp b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_debugger_tests.cpp index 4a3aa3626c..48620dba6f 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_debugger_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_debugger_tests.cpp @@ -58,26 +58,20 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetIoctForDebuggerThenCorre verifyIoctlRequestValue(DRM_IOCTL_XE_EUDEBUG_CONNECT, DrmIoctl::debuggerOpen); } -TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetRunaloneExtPropertyThenCorrectValueReturned) { +TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGetEudebugExtPropertyThenCorrectValueReturned) { auto executionEnvironment = std::make_unique(); executionEnvironment->setDebuggingMode(DebuggingMode::offline); auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]); auto xeIoctlHelper = static_cast(drm->ioctlHelper.get()); - EXPECT_EQ(xeIoctlHelper->getRunaloneExtProperty(), DRM_XE_EXEC_QUEUE_SET_PROPERTY_EUDEBUG); + EXPECT_EQ(xeIoctlHelper->getEudebugExtProperty(), DRM_XE_EXEC_QUEUE_SET_PROPERTY_EUDEBUG); } using IoctlHelperXeTestFixture = ::testing::Test; -HWTEST_F(IoctlHelperXeTestFixture, GivenRunaloneModeRequiredReturnFalseWhenCreateDrmContextThenRunAloneContextIsNotRequested) { +HWTEST_F(IoctlHelperXeTestFixture, GivenDebuggingDisabledWhenCreateDrmContextThenEuDebuggableContextIsNotRequested) { DebugManagerStateRestore restorer; - struct MockGfxCoreHelperHw : NEO::GfxCoreHelperHw { - bool isRunaloneModeRequired(DebuggingMode debuggingMode) const override { - return false; - } - }; - auto executionEnvironment = std::make_unique(); + executionEnvironment->setDebuggingMode(DebuggingMode::disabled); auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0]; - auto raiiFactory = RAIIGfxCoreHelperFactory(rootDeviceEnvironment); rootDeviceEnvironment.osInterface = std::make_unique(); rootDeviceEnvironment.osInterface->setDriverModel(std::make_unique(mockFd, rootDeviceEnvironment)); auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]); @@ -124,17 +118,12 @@ HWTEST_F(IoctlHelperXeTestFixture, givenDeviceIndexWhenCreatingContextThenSetCor EXPECT_EQ(expectedGtId, drm->execQueueEngineInstances[0].gt_id); } -HWTEST_F(IoctlHelperXeTestFixture, GivenRunaloneModeRequiredReturnTrueWhenCreateDrmContextThenRunAloneContextIsRequested) { +HWTEST_F(IoctlHelperXeTestFixture, GivenDebuggingEnabledWhenCreateDrmContextThenEuDebuggableContextIsRequested) { DebugManagerStateRestore restorer; - struct MockGfxCoreHelperHw : NEO::GfxCoreHelperHw { - bool isRunaloneModeRequired(DebuggingMode debuggingMode) const override { - return true; - } - }; auto executionEnvironment = std::make_unique(); + executionEnvironment->setDebuggingMode(DebuggingMode::online); auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0]; - auto raiiFactory = RAIIGfxCoreHelperFactory(rootDeviceEnvironment); rootDeviceEnvironment.osInterface = std::make_unique(); rootDeviceEnvironment.osInterface->setDriverModel(std::make_unique(mockFd, rootDeviceEnvironment)); auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]); @@ -154,17 +143,12 @@ HWTEST_F(IoctlHelperXeTestFixture, GivenRunaloneModeRequiredReturnTrueWhenCreate EXPECT_EQ(ext.value, 1ULL); } -HWTEST_F(IoctlHelperXeTestFixture, GivenContextCreatedForCopyEngineWhenCreateDrmContextThenRunAloneContextIsNotRequested) { +HWTEST_F(IoctlHelperXeTestFixture, GivenContextCreatedForCopyEngineWhenCreateDrmContextThenEuDebuggableContextIsNotRequested) { DebugManagerStateRestore restorer; - struct MockGfxCoreHelperHw : NEO::GfxCoreHelperHw { - bool isRunaloneModeRequired(DebuggingMode debuggingMode) const override { - return true; - } - }; auto executionEnvironment = std::make_unique(); + executionEnvironment->setDebuggingMode(DebuggingMode::online); auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0]; - auto raiiFactory = RAIIGfxCoreHelperFactory(rootDeviceEnvironment); rootDeviceEnvironment.osInterface = std::make_unique(); rootDeviceEnvironment.osInterface->setDriverModel(std::make_unique(mockFd, rootDeviceEnvironment)); auto drm = DrmMockXeDebug::create(*executionEnvironment->rootDeviceEnvironments[0]);