From 4467b1e8de3262eb982f69043ce5796437b2f24f Mon Sep 17 00:00:00 2001 From: Maciej Bielski Date: Wed, 4 Dec 2024 15:54:56 +0000 Subject: [PATCH] feature: specify cache level when reserving a region Related-To: NEO-12837 Signed-off-by: Maciej Bielski --- shared/source/os_interface/linux/clos_cache.cpp | 6 +++--- shared/source/os_interface/linux/clos_cache.h | 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.cpp | 2 +- shared/source/os_interface/linux/xe/ioctl_helper_xe.h | 2 +- .../unit_test/os_interface/linux/drm_with_prelim_tests.cpp | 4 ++-- .../os_interface/linux/ioctl_helper_tests_upstream.cpp | 2 +- .../os_interface/linux/xe/ioctl_helper_xe_tests.cpp | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/shared/source/os_interface/linux/clos_cache.cpp b/shared/source/os_interface/linux/clos_cache.cpp index aa9057f115..ba23f840a4 100644 --- a/shared/source/os_interface/linux/clos_cache.cpp +++ b/shared/source/os_interface/linux/clos_cache.cpp @@ -16,7 +16,7 @@ namespace NEO { CacheRegion ClosCacheReservation::reserveCache(CacheLevel cacheLevel, uint16_t numWays) { - auto closIndex = allocEntry(); + auto closIndex = allocEntry(cacheLevel); if (closIndex == CacheRegion::none) { return CacheRegion::none; } @@ -36,8 +36,8 @@ CacheRegion ClosCacheReservation::freeCache(CacheLevel cacheLevel, CacheRegion c return freeEntry(closIndex); } -CacheRegion ClosCacheReservation::allocEntry() { - return ioctlHelper.closAlloc(); +CacheRegion ClosCacheReservation::allocEntry(CacheLevel cacheLevel) { + return ioctlHelper.closAlloc(cacheLevel); } CacheRegion ClosCacheReservation::freeEntry(CacheRegion closIndex) { diff --git a/shared/source/os_interface/linux/clos_cache.h b/shared/source/os_interface/linux/clos_cache.h index 5dab09bec3..58b3d6d734 100644 --- a/shared/source/os_interface/linux/clos_cache.h +++ b/shared/source/os_interface/linux/clos_cache.h @@ -24,7 +24,7 @@ class ClosCacheReservation { CacheRegion freeCache(CacheLevel cacheLevel, CacheRegion closIndex); protected: - CacheRegion allocEntry(); + CacheRegion allocEntry(CacheLevel cacheLevel); CacheRegion freeEntry(CacheRegion closIndex); uint16_t allocCacheWay(CacheRegion closIndex, CacheLevel cacheLevel, uint16_t numWays); diff --git a/shared/source/os_interface/linux/ioctl_helper.h b/shared/source/os_interface/linux/ioctl_helper.h index 1f080719fb..d30df35780 100644 --- a/shared/source/os_interface/linux/ioctl_helper.h +++ b/shared/source/os_interface/linux/ioctl_helper.h @@ -116,7 +116,7 @@ class IoctlHelper { virtual bool isVmBindAvailable() = 0; virtual int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) = 0; virtual uint32_t createGem(uint64_t size, uint32_t memoryBanks, std::optional isCoherent) = 0; - virtual CacheRegion closAlloc() = 0; + virtual CacheRegion closAlloc(CacheLevel cacheLevel) = 0; virtual uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) = 0; virtual CacheRegion closFree(CacheRegion closIndex) = 0; virtual int waitUserFence(uint32_t ctxId, uint64_t address, @@ -286,7 +286,7 @@ class IoctlHelperUpstream : public IoctlHelperI915 { bool isChunkingAvailable() override; bool isVmBindAvailable() override; int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) override; - CacheRegion closAlloc() override; + CacheRegion closAlloc(CacheLevel cacheLevel) override; uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override; CacheRegion closFree(CacheRegion closIndex) override; int waitUserFence(uint32_t ctxId, uint64_t address, @@ -363,7 +363,7 @@ class IoctlHelperPrelim20 : public IoctlHelperI915 { bool isChunkingAvailable() override; bool isVmBindAvailable() override; int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) override; - CacheRegion closAlloc() override; + CacheRegion closAlloc(CacheLevel cacheLevel) override; uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override; CacheRegion closFree(CacheRegion closIndex) override; int waitUserFence(uint32_t ctxId, uint64_t address, diff --git a/shared/source/os_interface/linux/ioctl_helper_prelim.cpp b/shared/source/os_interface/linux/ioctl_helper_prelim.cpp index 6583d055c9..305da26095 100644 --- a/shared/source/os_interface/linux/ioctl_helper_prelim.cpp +++ b/shared/source/os_interface/linux/ioctl_helper_prelim.cpp @@ -262,7 +262,7 @@ int IoctlHelperPrelim20::createGemExt(const MemRegionsVec &memClassInstances, si return ret; } -CacheRegion IoctlHelperPrelim20::closAlloc() { +CacheRegion IoctlHelperPrelim20::closAlloc(CacheLevel cacheLevel) { struct prelim_drm_i915_gem_clos_reserve clos = {}; int ret = IoctlHelper::ioctl(DrmIoctl::gemClosReserve, &clos); diff --git a/shared/source/os_interface/linux/ioctl_helper_upstream.cpp b/shared/source/os_interface/linux/ioctl_helper_upstream.cpp index 0edc44f89f..20a51a5c54 100644 --- a/shared/source/os_interface/linux/ioctl_helper_upstream.cpp +++ b/shared/source/os_interface/linux/ioctl_helper_upstream.cpp @@ -115,7 +115,7 @@ void IoctlHelperUpstream::detectExtSetPatSupport() { this->isSetPatSupported ? "enabled" : "disabled"); } -CacheRegion IoctlHelperUpstream::closAlloc() { +CacheRegion IoctlHelperUpstream::closAlloc(CacheLevel cacheLevel) { return CacheRegion::none; } 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 383f26a0ba..1418aaa3a4 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -698,7 +698,7 @@ uint32_t IoctlHelperXe::createGem(uint64_t size, uint32_t memoryBanks, std::opti return create.handle; } -CacheRegion IoctlHelperXe::closAlloc() { +CacheRegion IoctlHelperXe::closAlloc(CacheLevel cacheLevel) { xeLog(" -> IoctlHelperXe::%s\n", __FUNCTION__); return CacheRegion::none; } 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 553e479030..929238fc3f 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h @@ -47,7 +47,7 @@ class IoctlHelperXe : public IoctlHelper { bool isVmBindAvailable() override; int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional memPolicyMode, std::optional> memPolicyNodemask, std::optional isCoherent) override; uint32_t createGem(uint64_t size, uint32_t memoryBanks, std::optional isCoherent) override; - CacheRegion closAlloc() override; + CacheRegion closAlloc(CacheLevel cacheLevel) override; uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override; CacheRegion closFree(CacheRegion closIndex) override; int waitUserFence(uint32_t ctxId, uint64_t address, diff --git a/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp index 1d89ffafe2..fa70d51e5c 100644 --- a/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp @@ -240,7 +240,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCallIoctlThenProperIoctlRegiste TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenClosAllocThenReturnCorrectRegion) { drm->ioctlCallsCount = 0; auto ioctlHelper = drm->getIoctlHelper(); - auto cacheRegion = ioctlHelper->closAlloc(); + auto cacheRegion = ioctlHelper->closAlloc(NEO::CacheLevel::level3); EXPECT_EQ(CacheRegion::region1, cacheRegion); EXPECT_EQ(1u, drm->ioctlCallsCount); @@ -250,7 +250,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsAndInvalidIoctlReturnValWhenClosAll drm->ioctlRetVal = -1; drm->ioctlCallsCount = 0; auto ioctlHelper = drm->getIoctlHelper(); - auto cacheRegion = ioctlHelper->closAlloc(); + auto cacheRegion = ioctlHelper->closAlloc(NEO::CacheLevel::level3); EXPECT_EQ(CacheRegion::none, cacheRegion); EXPECT_EQ(1u, drm->ioctlCallsCount); 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 d706dcb116..c7faad6f55 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 @@ -468,7 +468,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenClosAllocThenReturnNoneRegion) { auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); auto ioctlHelper = drm->getIoctlHelper(); - auto cacheRegion = ioctlHelper->closAlloc(); + auto cacheRegion = ioctlHelper->closAlloc(NEO::CacheLevel::level3); EXPECT_EQ(CacheRegion::none, cacheRegion); } 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 12d3838e05..7df0bbddfd 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 @@ -304,7 +304,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe EXPECT_FALSE(xeIoctlHelper->isSetPairAvailable()); - EXPECT_EQ(CacheRegion::none, xeIoctlHelper->closAlloc()); + EXPECT_EQ(CacheRegion::none, xeIoctlHelper->closAlloc(NEO::CacheLevel::level3)); EXPECT_EQ(0u, xeIoctlHelper->closAllocWays(CacheRegion::none, 0u, 0u));