@@ -481,6 +481,9 @@ int Drm::setupHardwareInfo(DeviceDescriptor *device, bool setupFeatureTableAndWo
481481 HardwareInfo *hwInfo = const_cast <HardwareInfo *>(device->pHwInfo );
482482 int ret;
483483
484+ const auto productFamily = hwInfo->platform .eProductFamily ;
485+ setupIoctlHelper (productFamily);
486+
484487 Drm::QueryTopologyData topologyData = {};
485488
486489 bool status = queryTopology (*hwInfo, topologyData);
@@ -506,7 +509,6 @@ int Drm::setupHardwareInfo(DeviceDescriptor *device, bool setupFeatureTableAndWo
506509 hwInfo->gtSystemInfo .DualSubSliceCount = static_cast <uint32_t >(topologyData.subSliceCount );
507510 hwInfo->gtSystemInfo .EUCount = static_cast <uint32_t >(topologyData.euCount );
508511 rootDeviceEnvironment.setHwInfo (hwInfo);
509- setupIoctlHelper ();
510512
511513 status = querySystemInfo ();
512514 if (status) {
@@ -1081,11 +1083,82 @@ bool Drm::completionFenceSupport() {
10811083 return completionFenceSupported;
10821084}
10831085
1084- void Drm::setupIoctlHelper () {
1085- auto hwInfo = rootDeviceEnvironment.getHardwareInfo ();
1086+ void Drm::setupIoctlHelper (const PRODUCT_FAMILY productFamily) {
10861087 std::string prelimVersion = " " ;
10871088 getPrelimVersion (prelimVersion);
1088- this ->ioctlHelper .reset (IoctlHelper::get (hwInfo, prelimVersion));
1089+ this ->ioctlHelper .reset (IoctlHelper::get (productFamily, prelimVersion));
1090+ }
1091+
1092+ bool Drm::queryTopology (const HardwareInfo &hwInfo, QueryTopologyData &topologyData) {
1093+ topologyData.sliceCount = 0 ;
1094+ topologyData.subSliceCount = 0 ;
1095+ topologyData.euCount = 0 ;
1096+
1097+ int sliceCount = 0 ;
1098+ int subSliceCount = 0 ;
1099+ int euCount = 0 ;
1100+
1101+ const auto queryComputeSlicesIoctl = ioctlHelper->getComputeSlicesIoctlVal ();
1102+ if (DebugManager.flags .UseNewQueryTopoIoctl .get () && this ->engineInfo && hwInfo.gtSystemInfo .MultiTileArchInfo .TileCount > 0 && queryComputeSlicesIoctl != 0 ) {
1103+ bool success = true ;
1104+
1105+ for (uint32_t i = 0 ; i < hwInfo.gtSystemInfo .MultiTileArchInfo .TileCount ; i++) {
1106+ auto classInstance = this ->engineInfo ->getEngineInstance (i, hwInfo.capabilityTable .defaultEngineType );
1107+ UNRECOVERABLE_IF (!classInstance);
1108+
1109+ uint32_t flags = classInstance->engineClass ;
1110+ flags |= (classInstance->engineInstance << 8 );
1111+
1112+ auto dataQuery = this ->query (queryComputeSlicesIoctl, flags);
1113+ if (dataQuery.empty ()) {
1114+ success = false ;
1115+ break ;
1116+ }
1117+ auto data = reinterpret_cast <drm_i915_query_topology_info *>(dataQuery.data ());
1118+
1119+ QueryTopologyData tileTopologyData = {};
1120+ TopologyMapping mapping;
1121+ if (!translateTopologyInfo (data, tileTopologyData, mapping)) {
1122+ success = false ;
1123+ break ;
1124+ }
1125+
1126+ // pick smallest config
1127+ sliceCount = (sliceCount == 0 ) ? tileTopologyData.sliceCount : std::min (sliceCount, tileTopologyData.sliceCount );
1128+ subSliceCount = (subSliceCount == 0 ) ? tileTopologyData.subSliceCount : std::min (subSliceCount, tileTopologyData.subSliceCount );
1129+ euCount = (euCount == 0 ) ? tileTopologyData.euCount : std::min (euCount, tileTopologyData.euCount );
1130+
1131+ topologyData.maxSliceCount = std::max (topologyData.maxSliceCount , tileTopologyData.maxSliceCount );
1132+ topologyData.maxSubSliceCount = std::max (topologyData.maxSubSliceCount , tileTopologyData.maxSubSliceCount );
1133+ topologyData.maxEuCount = std::max (topologyData.maxEuCount , static_cast <int >(data->max_eus_per_subslice ));
1134+
1135+ this ->topologyMap [i] = mapping;
1136+ }
1137+
1138+ if (success) {
1139+ topologyData.sliceCount = sliceCount;
1140+ topologyData.subSliceCount = subSliceCount;
1141+ topologyData.euCount = euCount;
1142+ return true ;
1143+ }
1144+ }
1145+
1146+ // fallback to DRM_I915_QUERY_TOPOLOGY_INFO
1147+
1148+ auto dataQuery = this ->query (DRM_I915_QUERY_TOPOLOGY_INFO, DrmQueryItemFlags::topology);
1149+ if (dataQuery.empty ()) {
1150+ return false ;
1151+ }
1152+ auto data = reinterpret_cast <drm_i915_query_topology_info *>(dataQuery.data ());
1153+
1154+ TopologyMapping mapping;
1155+ auto retVal = translateTopologyInfo (data, topologyData, mapping);
1156+ topologyData.maxEuCount = data->max_eus_per_subslice ;
1157+
1158+ this ->topologyMap .clear ();
1159+ this ->topologyMap [0 ] = mapping;
1160+
1161+ return retVal;
10891162}
10901163
10911164} // namespace NEO
0 commit comments