From e190e1b8ec8a668190f2ce4bc53ad71d745972cd Mon Sep 17 00:00:00 2001 From: Radoslaw Jablonski Date: Tue, 5 Aug 2025 21:42:01 +0000 Subject: [PATCH] fix: use relative subslice mapping indices in Xe DRM This aligns behavior with i915 and L0 spec. Signed-off-by: Radoslaw Jablonski --- .../os_interface/linux/xe/ioctl_helper_xe.cpp | 3 +- .../linux/xe/ioctl_helper_xe_tests.cpp | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) 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 f910b9f2c8..dd01675015 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -596,8 +596,9 @@ bool IoctlHelperXe::getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTo auto byte = subSliceId / 8; auto bit = subSliceId & 0b111; int sliceId = static_cast(subSliceId / topologyData.maxSubSlicesPerSlice); + int subSliceIdRelative = static_cast(subSliceId % topologyData.maxSubSlicesPerSlice); if (subSliceInfo[byte].test(bit)) { - subSliceIndices.push_back(subSliceId); + subSliceIndices.push_back(subSliceIdRelative); subSliceCountPerTile++; if (sliceId != previouslyEnabledSlice) { previouslyEnabledSlice = sliceId; 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 6927b2d539..e44d88bfd2 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 @@ -1486,6 +1486,52 @@ TEST_F(IoctlHelperXeTest, givenMissingEuPerDssInTopologyWhenGetTopologyDataAndMa EXPECT_EQ(8, topologyData.maxEusPerSubSlice); } +TEST_F(IoctlHelperXeTest, givenSliceWithIdxGreaterThanZeroWhenGetTopologyDataAndMapThenSubSliceIndicesAreRelativeToTheSlice) { + auto executionEnvironment = std::make_unique(); + auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]); + auto xeIoctlHelper = static_cast(drm->getIoctlHelper()); + auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); + xeIoctlHelper->initialize(); + + const auto &tileIdToGtId = xeIoctlHelper->tileIdToGtId; + auto numTiles = tileIdToGtId.size(); + + for (auto &dssConfigType : {DRM_XE_TOPO_DSS_GEOMETRY, DRM_XE_TOPO_DSS_COMPUTE}) { + drm->queryTopology.clear(); + + DrmQueryTopologyData topologyData{}; + TopologyMap topologyMap{}; + + for (auto tileId = 0u; tileId < numTiles; tileId++) { + drm->addMockedQueryTopologyData(tileIdToGtId[tileId], dssConfigType, 8, {0, 0b1100'0011, 0, 0, 0, 0, 0, 0}); + drm->addMockedQueryTopologyData(tileIdToGtId[tileId], DRM_XE_TOPO_EU_PER_DSS, 4, {0b1111'1111, 0, 0, 0}); + } + hwInfo.gtSystemInfo.MaxSlicesSupported = 2; + hwInfo.gtSystemInfo.MaxSubSlicesSupported = 16; + hwInfo.gtSystemInfo.MaxEuPerSubSlice = 8; + auto result = xeIoctlHelper->getTopologyDataAndMap(hwInfo, topologyData, topologyMap); + EXPECT_TRUE(result); + + EXPECT_EQ(1, topologyData.sliceCount); + EXPECT_EQ(2, topologyData.maxSlices); + + EXPECT_EQ(4, topologyData.subSliceCount); + EXPECT_EQ(8, topologyData.maxSubSlicesPerSlice); + + EXPECT_EQ(32, topologyData.euCount); + EXPECT_EQ(8, topologyData.maxEusPerSubSlice); + + for (auto tileId = 0u; tileId < numTiles; tileId++) { + std::vector expectedSubSliceIndices{0, 1, 6, 7}; + + ASSERT_EQ(topologyMap[tileId].subsliceIndices.size(), expectedSubSliceIndices.size()); + for (auto i = 0u; i < topologyMap[tileId].subsliceIndices.size(); ++i) { + EXPECT_EQ(topologyMap[tileId].subsliceIndices[i], expectedSubSliceIndices[i]); + } + } + } +} + TEST_F(IoctlHelperXeTest, whenCreatingEngineInfoThenProperEnginesAreDiscovered) { DebugManagerStateRestore restorer; auto executionEnvironment = std::make_unique();