From 322089fa5fe07246f56ef9b27d3b861639f96164 Mon Sep 17 00:00:00 2001 From: Jitendra Sharma Date: Mon, 16 Dec 2024 17:40:50 +0000 Subject: [PATCH] feature: Pass cookie in vmBindExt Provide cookie in vmBindExt, so that information about deviceBitField could be provided to vmBind. This information could be used in debugUMD code to to create grouping of ISA segments on different tiles. Related-To: NEO-11104 Signed-off-by: Jitendra Sharma --- shared/source/os_interface/linux/drm_neo.cpp | 2 +- shared/source/os_interface/linux/ioctl_helper.h | 6 +++--- shared/source/os_interface/linux/ioctl_helper_prelim.cpp | 2 +- shared/source/os_interface/linux/ioctl_helper_upstream.cpp | 2 +- shared/source/os_interface/linux/xe/ioctl_helper_xe.h | 2 +- .../os_interface/linux/xe/ioctl_helper_xe_debugger.cpp | 5 +++-- .../linux/xe/ioctl_helper_xe_debugger_stubs.cpp | 2 +- .../os_interface/linux/ioctl_helper_tests_prelim.cpp | 2 +- .../os_interface/linux/ioctl_helper_tests_upstream.cpp | 2 +- .../linux/xe/ioctl_helper_xe_debugger_tests.cpp | 3 ++- 10 files changed, 15 insertions(+), 13 deletions(-) diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index 23fb5c5f1b..1056febb04 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -1427,7 +1427,7 @@ int changeBufferObjectBinding(Drm *drm, OsContext *osContext, uint32_t vmHandleI if (bind) { bool allowUUIDsForDebug = !osContext->isInternalEngine() && !EngineHelpers::isBcs(osContext->getEngineType()); if (bo->getBindExtHandles().size() > 0 && allowUUIDsForDebug) { - extensions = ioctlHelper->prepareVmBindExt(bo->getBindExtHandles()); + extensions = ioctlHelper->prepareVmBindExt(bo->getBindExtHandles(), vmHandleId); } bool bindCapture = bo->isMarkedForCapture(); bool bindImmediate = bo->isImmediateBindingRequired(); diff --git a/shared/source/os_interface/linux/ioctl_helper.h b/shared/source/os_interface/linux/ioctl_helper.h index 45a588742b..3d2afd78f5 100644 --- a/shared/source/os_interface/linux/ioctl_helper.h +++ b/shared/source/os_interface/linux/ioctl_helper.h @@ -132,7 +132,7 @@ class IoctlHelper { virtual bool setGemTiling(void *setTiling) = 0; virtual bool getGemTiling(void *setTiling) = 0; virtual uint32_t getDirectSubmissionFlag() = 0; - virtual std::unique_ptr prepareVmBindExt(const StackVec &bindExtHandles) = 0; + virtual std::unique_ptr prepareVmBindExt(const StackVec &bindExtHandles, uint32_t vmHandleId) = 0; virtual uint64_t getFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident, bool bindLockedMemory, bool readOnlyResource) = 0; virtual int queryDistances(std::vector &queryItems, std::vector &distanceInfos) = 0; virtual uint16_t getWaitUserFenceSoftFlag() = 0; @@ -300,7 +300,7 @@ class IoctlHelperUpstream : public IoctlHelperI915 { bool setVmBoAdviseForChunking(int32_t handle, uint64_t start, uint64_t length, uint32_t attribute, void *region) override; bool setVmPrefetch(uint64_t start, uint64_t length, uint32_t region, uint32_t vmId) override; uint32_t getDirectSubmissionFlag() override; - std::unique_ptr prepareVmBindExt(const StackVec &bindExtHandles) override; + std::unique_ptr prepareVmBindExt(const StackVec &bindExtHandles, uint32_t vmHandleId) override; uint64_t getFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident, bool bindLockedMemory, bool readOnlyResource) override; int queryDistances(std::vector &queryItems, std::vector &distanceInfos) override; uint16_t getWaitUserFenceSoftFlag() override; @@ -377,7 +377,7 @@ class IoctlHelperPrelim20 : public IoctlHelperI915 { bool setVmBoAdviseForChunking(int32_t handle, uint64_t start, uint64_t length, uint32_t attribute, void *region) override; bool setVmPrefetch(uint64_t start, uint64_t length, uint32_t region, uint32_t vmId) override; uint32_t getDirectSubmissionFlag() override; - std::unique_ptr prepareVmBindExt(const StackVec &bindExtHandles) override; + std::unique_ptr prepareVmBindExt(const StackVec &bindExtHandles, uint32_t vmHandleId) override; uint64_t getFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident, bool bindLockedMemory, bool readOnlyResource) override; int queryDistances(std::vector &queryItems, std::vector &distanceInfos) override; uint16_t getWaitUserFenceSoftFlag() override; diff --git a/shared/source/os_interface/linux/ioctl_helper_prelim.cpp b/shared/source/os_interface/linux/ioctl_helper_prelim.cpp index 305da26095..b325a21c7b 100644 --- a/shared/source/os_interface/linux/ioctl_helper_prelim.cpp +++ b/shared/source/os_interface/linux/ioctl_helper_prelim.cpp @@ -495,7 +495,7 @@ bool IoctlHelperPrelim20::completionFenceExtensionSupported(const bool isVmBindA return isVmBindAvailable; } -std::unique_ptr IoctlHelperPrelim20::prepareVmBindExt(const StackVec &bindExtHandles) { +std::unique_ptr IoctlHelperPrelim20::prepareVmBindExt(const StackVec &bindExtHandles, uint32_t vmHandleId) { static_assert(std::is_trivially_destructible_v, "Storage must be allowed to be reused without calling the destructor!"); diff --git a/shared/source/os_interface/linux/ioctl_helper_upstream.cpp b/shared/source/os_interface/linux/ioctl_helper_upstream.cpp index 20a51a5c54..2e096b22ba 100644 --- a/shared/source/os_interface/linux/ioctl_helper_upstream.cpp +++ b/shared/source/os_interface/linux/ioctl_helper_upstream.cpp @@ -164,7 +164,7 @@ uint32_t IoctlHelperUpstream::getDirectSubmissionFlag() { return 0u; } -std::unique_ptr IoctlHelperUpstream::prepareVmBindExt(const StackVec &bindExtHandles) { +std::unique_ptr IoctlHelperUpstream::prepareVmBindExt(const StackVec &bindExtHandles, uint32_t vmHandleId) { return {}; } 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 a5a26a792c..1923902dc5 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h @@ -62,7 +62,7 @@ class IoctlHelperXe : public IoctlHelper { bool setGemTiling(void *setTiling) override; bool getGemTiling(void *setTiling) override; uint32_t getDirectSubmissionFlag() override; - std::unique_ptr prepareVmBindExt(const StackVec &bindExtHandles) override; + std::unique_ptr prepareVmBindExt(const StackVec &bindExtHandles, uint32_t vmHandleId) override; uint64_t getFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident, bool bindLock, bool readOnlyResource) override; virtual std::string xeGetBindFlagNames(int bindFlags); int queryDistances(std::vector &queryItems, std::vector &distanceInfos) override; 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 541ccdfb54..7758a1c034 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 @@ -104,7 +104,7 @@ void IoctlHelperXe::unregisterResource(uint32_t handle) { PRINT_DEBUGGER_INFO_LOG("DRM_XE_DEBUG_METADATA_DESTROY: id=%llu\n", metadata.metadataId); } -std::unique_ptr IoctlHelperXe::prepareVmBindExt(const StackVec &bindExtHandles) { +std::unique_ptr IoctlHelperXe::prepareVmBindExt(const StackVec &bindExtHandles, uint32_t vmHandleId) { static_assert(std::is_trivially_destructible_v, "Storage must be allowed to be reused without calling the destructor!"); @@ -121,12 +121,13 @@ std::unique_ptr IoctlHelperXe::prepareVmBindExt(const StackVecgetParamValue(EuDebugParam::vmBindOpExtensionsAttachDebug); + extensions[0].cookie = vmHandleId; for (size_t i = 1; i < bindExtHandles.size(); i++) { extensions[i - 1].base.nextExtension = reinterpret_cast(&extensions[i]); extensions[i].metadataId = bindExtHandles[i]; extensions[i].base.name = euDebugInterface->getParamValue(EuDebugParam::vmBindOpExtensionsAttachDebug); - ; + extensions[i].cookie = vmHandleId; } return extensionsBuffer; } 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 5e67edadcc..ef9d265be3 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 @@ -47,7 +47,7 @@ void IoctlHelperXe::unregisterResource(uint32_t handle) { UNRECOVERABLE_IF(true); } -std::unique_ptr IoctlHelperXe::prepareVmBindExt(const StackVec &bindExtHandles) { +std::unique_ptr IoctlHelperXe::prepareVmBindExt(const StackVec &bindExtHandles, uint32_t vmHandleId) { return {}; } diff --git a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp index 8eb9933f0e..04f84220df 100644 --- a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp +++ b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp @@ -303,7 +303,7 @@ TEST_F(IoctlPrelimHelperTests, whenGettingVmBindExtFromHandlesThenProperStructsA bindExtHandles.push_back(1u); bindExtHandles.push_back(2u); bindExtHandles.push_back(3u); - auto retVal = ioctlHelper.prepareVmBindExt(bindExtHandles); + auto retVal = ioctlHelper.prepareVmBindExt(bindExtHandles, 0); auto vmBindExt = reinterpret_cast(retVal.get()); for (size_t i = 0; i < bindExtHandles.size(); i++) { diff --git a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp index c7faad6f55..0645379dcb 100644 --- a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp +++ b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_upstream.cpp @@ -334,7 +334,7 @@ TEST(IoctlHelperUpstreamTest, whenGettingVmBindExtFromHandlesThenNullptrIsReturn bindExtHandles.push_back(1u); bindExtHandles.push_back(2u); bindExtHandles.push_back(3u); - auto retVal = ioctlHelper.prepareVmBindExt(bindExtHandles); + auto retVal = ioctlHelper.prepareVmBindExt(bindExtHandles, 0); EXPECT_EQ(nullptr, retVal); } 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 fdc9cb3307..4f756c548b 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 @@ -267,13 +267,14 @@ TEST(IoctlHelperXeTest, whenGettingVmBindExtFromHandlesThenProperStructsAreRetur bindExtHandles.push_back(1u); bindExtHandles.push_back(2u); bindExtHandles.push_back(3u); - auto retVal = xeIoctlHelper->prepareVmBindExt(bindExtHandles); + auto retVal = xeIoctlHelper->prepareVmBindExt(bindExtHandles, 1); auto vmBindExt = reinterpret_cast(retVal.get()); for (size_t i = 0; i < bindExtHandles.size(); i++) { EXPECT_EQ(bindExtHandles[i], vmBindExt[i].metadataId); EXPECT_EQ(static_cast(EuDebugParam::vmBindOpExtensionsAttachDebug), vmBindExt[i].base.name); + EXPECT_EQ(1u, vmBindExt[i].cookie); } EXPECT_EQ(reinterpret_cast(&vmBindExt[1]), vmBindExt[0].base.nextExtension);