@@ -1055,138 +1055,140 @@ bool DebugSessionLinux::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bind *v
10551055 if (connection->uuidMap [vmBind->uuids [uuidIter]].classIndex == NEO::DrmResourceClass::L0ZebinModule) {
10561056 uint64_t loadAddress = 0 ;
10571057 auto &module = connection->uuidToModule [vmBind->uuids [uuidIter]];
1058-
1059- if (createEvent) {
1060- module .segmentVmBindCounter [tileIndex]++;
1061-
1062- DEBUG_BREAK_IF (module .loadAddresses [tileIndex].size () > module .segmentCount );
1063- bool canTriggerEvent = module .loadAddresses [tileIndex].size () == (module .segmentCount - 1 );
1064- module .loadAddresses [tileIndex].insert (vmBind->va_start );
1065-
1066- if (!blockOnFenceMode) {
1067- if (canTriggerEvent && module .loadAddresses [tileIndex].size () == module .segmentCount ) {
1068- auto gmmHelper = connectedDevice->getNEODevice ()->getGmmHelper ();
1069- loadAddress = gmmHelper->canonize (*std::min_element (module .loadAddresses [tileIndex].begin (), module .loadAddresses [tileIndex].end ()));
1070- PRINT_DEBUGGER_INFO_LOG (" Zebin module loaded at: %p, with %u isa allocations" , (void *)loadAddress, module .segmentCount );
1071-
1072- zet_debug_event_t debugEvent = {};
1073- debugEvent.type = ZET_DEBUG_EVENT_TYPE_MODULE_LOAD;
1074- debugEvent.info .module .format = ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF;
1075- debugEvent.info .module .load = loadAddress;
1076- debugEvent.info .module .moduleBegin = connection->uuidMap [module .elfUuidHandle ].ptr ;
1077- debugEvent.info .module .moduleEnd = connection->uuidMap [module .elfUuidHandle ].ptr + connection->uuidMap [module .elfUuidHandle ].dataSize ;
1078-
1079- if (!tileSessionsEnabled) {
1080- bool allInstancesEventsReceived = true ;
1081- if (module .deviceBitfield .count () > 1 ) {
1082- allInstancesEventsReceived = checkAllOtherTileModuleSegmentsPresent (tileIndex, module );
1083- }
1084- if (allInstancesEventsReceived) {
1085- if (vmBind->base .flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK) {
1086- debugEvent.flags = ZET_DEBUG_EVENT_FLAG_NEED_ACK;
1087- module .ackEvents [tileIndex].push_back (vmBind->base );
1058+ auto moduleUsedOnTile = module .deviceBitfield .test (tileIndex) || module .deviceBitfield .count () == 0 ;
1059+ if (moduleUsedOnTile) {
1060+ if (createEvent) {
1061+ module .segmentVmBindCounter [tileIndex]++;
1062+
1063+ DEBUG_BREAK_IF (module .loadAddresses [tileIndex].size () > module .segmentCount );
1064+ bool canTriggerEvent = module .loadAddresses [tileIndex].size () == (module .segmentCount - 1 );
1065+ module .loadAddresses [tileIndex].insert (vmBind->va_start );
1066+
1067+ if (!blockOnFenceMode) {
1068+ if (canTriggerEvent && module .loadAddresses [tileIndex].size () == module .segmentCount ) {
1069+ auto gmmHelper = connectedDevice->getNEODevice ()->getGmmHelper ();
1070+ loadAddress = gmmHelper->canonize (*std::min_element (module .loadAddresses [tileIndex].begin (), module .loadAddresses [tileIndex].end ()));
1071+ PRINT_DEBUGGER_INFO_LOG (" Zebin module loaded at: %p, with %u isa allocations" , (void *)loadAddress, module .segmentCount );
1072+
1073+ zet_debug_event_t debugEvent = {};
1074+ debugEvent.type = ZET_DEBUG_EVENT_TYPE_MODULE_LOAD;
1075+ debugEvent.info .module .format = ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF;
1076+ debugEvent.info .module .load = loadAddress;
1077+ debugEvent.info .module .moduleBegin = connection->uuidMap [module .elfUuidHandle ].ptr ;
1078+ debugEvent.info .module .moduleEnd = connection->uuidMap [module .elfUuidHandle ].ptr + connection->uuidMap [module .elfUuidHandle ].dataSize ;
1079+
1080+ if (!tileSessionsEnabled) {
1081+ bool allInstancesEventsReceived = true ;
1082+ if (module .deviceBitfield .count () > 1 ) {
1083+ allInstancesEventsReceived = checkAllOtherTileModuleSegmentsPresent (tileIndex, module );
10881084 }
1089- pushApiEvent (debugEvent, vmBind->uuids [uuidIter]);
1090- shouldAckEvent = false ;
1091- }
1092- } else {
1093- auto tileAttached = static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->insertModule (debugEvent.info .module );
1094-
1095- if (tileAttached) {
1096- if (vmBind->base .flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK) {
1097- debugEvent.flags = ZET_DEBUG_EVENT_FLAG_NEED_ACK;
1098- module .ackEvents [tileIndex].push_back (vmBind->base );
1085+ if (allInstancesEventsReceived) {
1086+ if (vmBind->base .flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK) {
1087+ debugEvent.flags = ZET_DEBUG_EVENT_FLAG_NEED_ACK;
1088+ module .ackEvents [tileIndex].push_back (vmBind->base );
1089+ }
1090+ pushApiEvent (debugEvent, vmBind->uuids [uuidIter]);
1091+ shouldAckEvent = false ;
1092+ }
1093+ } else {
1094+ auto tileAttached = static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->insertModule (debugEvent.info .module );
1095+
1096+ if (tileAttached) {
1097+ if (vmBind->base .flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK) {
1098+ debugEvent.flags = ZET_DEBUG_EVENT_FLAG_NEED_ACK;
1099+ module .ackEvents [tileIndex].push_back (vmBind->base );
1100+ }
1101+ static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->pushApiEvent (debugEvent, vmBind->uuids [uuidIter]);
1102+ shouldAckEvent = false ;
10991103 }
1100- static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->pushApiEvent (debugEvent, vmBind->uuids [uuidIter]);
1101- shouldAckEvent = false ;
11021104 }
11031105 }
1104- }
1105- } else {
1106- PRINT_DEBUGGER_INFO_LOG (" Zebin module = %ull has load addresses = %d" , static_cast <uint64_t >(vmBind->uuids [uuidIter]), static_cast <int >(module .loadAddresses [tileIndex].size ()));
1107-
1108- if (canTriggerEvent && module .loadAddresses [tileIndex].size () == module .segmentCount ) {
1109- auto gmmHelper = connectedDevice->getNEODevice ()->getGmmHelper ();
1110- loadAddress = gmmHelper->canonize (*std::min_element (module .loadAddresses [tileIndex].begin (), module .loadAddresses [tileIndex].end ()));
1111- PRINT_DEBUGGER_INFO_LOG (" Zebin module loaded at: %p, with %u isa allocations" , (void *)loadAddress, module .segmentCount );
1112-
1113- zet_debug_event_t debugEvent = {};
1114- debugEvent.type = ZET_DEBUG_EVENT_TYPE_MODULE_LOAD;
1115- debugEvent.info .module .format = ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF;
1116- debugEvent.info .module .load = loadAddress;
1117- debugEvent.info .module .moduleBegin = connection->uuidMap [module .elfUuidHandle ].ptr ;
1118- debugEvent.info .module .moduleEnd = connection->uuidMap [module .elfUuidHandle ].ptr + connection->uuidMap [module .elfUuidHandle ].dataSize ;
1119- if (vmBind->base .flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK) {
1120- debugEvent.flags = ZET_DEBUG_EVENT_FLAG_NEED_ACK;
1121- }
1122-
1123- if (!tileSessionsEnabled) {
1124- bool allInstancesEventsReceived = true ;
1125- if (module .deviceBitfield .count () > 1 ) {
1126- allInstancesEventsReceived = checkAllOtherTileModuleSegmentsPresent (tileIndex, module );
1106+ } else {
1107+ PRINT_DEBUGGER_INFO_LOG (" Zebin module = %ull has load addresses = %d" , static_cast <uint64_t >(vmBind->uuids [uuidIter]), static_cast <int >(module .loadAddresses [tileIndex].size ()));
1108+
1109+ if (canTriggerEvent && module .loadAddresses [tileIndex].size () == module .segmentCount ) {
1110+ auto gmmHelper = connectedDevice->getNEODevice ()->getGmmHelper ();
1111+ loadAddress = gmmHelper->canonize (*std::min_element (module .loadAddresses [tileIndex].begin (), module .loadAddresses [tileIndex].end ()));
1112+ PRINT_DEBUGGER_INFO_LOG (" Zebin module loaded at: %p, with %u isa allocations" , (void *)loadAddress, module .segmentCount );
1113+
1114+ zet_debug_event_t debugEvent = {};
1115+ debugEvent.type = ZET_DEBUG_EVENT_TYPE_MODULE_LOAD;
1116+ debugEvent.info .module .format = ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF;
1117+ debugEvent.info .module .load = loadAddress;
1118+ debugEvent.info .module .moduleBegin = connection->uuidMap [module .elfUuidHandle ].ptr ;
1119+ debugEvent.info .module .moduleEnd = connection->uuidMap [module .elfUuidHandle ].ptr + connection->uuidMap [module .elfUuidHandle ].dataSize ;
1120+ if (vmBind->base .flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK) {
1121+ debugEvent.flags = ZET_DEBUG_EVENT_FLAG_NEED_ACK;
11271122 }
1128- if (allInstancesEventsReceived) {
1129- pushApiEvent (debugEvent, vmBind->uuids [uuidIter]);
1130- shouldAckEvent = false ;
1123+
1124+ if (!tileSessionsEnabled) {
1125+ bool allInstancesEventsReceived = true ;
1126+ if (module .deviceBitfield .count () > 1 ) {
1127+ allInstancesEventsReceived = checkAllOtherTileModuleSegmentsPresent (tileIndex, module );
1128+ }
1129+ if (allInstancesEventsReceived) {
1130+ pushApiEvent (debugEvent, vmBind->uuids [uuidIter]);
1131+ shouldAckEvent = false ;
1132+ }
1133+ } else {
1134+ auto tileAttached = static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->insertModule (debugEvent.info .module );
1135+ if (tileAttached) {
1136+ static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->pushApiEvent (debugEvent, vmBind->uuids [uuidIter]);
1137+ shouldAckEvent = false ;
1138+ }
11311139 }
1132- } else {
1133- auto tileAttached = static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex]. first )-> insertModule (debugEvent. info . module );
1134- if (tileAttached) {
1135- static_cast <TileDebugSessionLinux *>(tileSessions [tileIndex]. first )-> pushApiEvent (debugEvent, vmBind-> uuids [uuidIter]);
1140+ }
1141+ {
1142+ std::lock_guard<std::mutex> lock (asyncThreadMutex);
1143+ if (! module . moduleLoadEventAcked [tileIndex]) {
11361144 shouldAckEvent = false ;
11371145 }
1138- }
1139- }
1140- {
1141- std::lock_guard<std::mutex> lock (asyncThreadMutex);
1142- if (!module .moduleLoadEventAcked [tileIndex]) {
1143- shouldAckEvent = false ;
1144- }
11451146
1146- if (tileSessionsEnabled && !static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->isAttached ) {
1147- shouldAckEvent = true ;
1148- }
1149- if (!shouldAckEvent && (vmBind->base .flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK)) {
1150- module .ackEvents [tileIndex].push_back (vmBind->base );
1147+ if (tileSessionsEnabled && !static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->isAttached ) {
1148+ shouldAckEvent = true ;
1149+ }
1150+ if (!shouldAckEvent && (vmBind->base .flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK)) {
1151+ module .ackEvents [tileIndex].push_back (vmBind->base );
1152+ }
11511153 }
11521154 }
1153- }
11541155
1155- } else { // destroyEvent
1156+ } else { // destroyEvent
11561157
1157- module .segmentVmBindCounter [tileIndex]--;
1158+ module .segmentVmBindCounter [tileIndex]--;
11581159
1159- if (module .segmentVmBindCounter [tileIndex] == 0 ) {
1160+ if (module .segmentVmBindCounter [tileIndex] == 0 ) {
11601161
1161- zet_debug_event_t debugEvent = {};
1162+ zet_debug_event_t debugEvent = {};
11621163
1163- auto gmmHelper = connectedDevice->getNEODevice ()->getGmmHelper ();
1164- auto loadAddress = gmmHelper->canonize (*std::min_element (module .loadAddresses [tileIndex].begin (), module .loadAddresses [tileIndex].end ()));
1165- debugEvent.type = ZET_DEBUG_EVENT_TYPE_MODULE_UNLOAD;
1166- debugEvent.info .module .format = ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF;
1167- debugEvent.info .module .load = loadAddress;
1168- debugEvent.info .module .moduleBegin = connection->uuidMap [module .elfUuidHandle ].ptr ;
1169- debugEvent.info .module .moduleEnd = connection->uuidMap [module .elfUuidHandle ].ptr + connection->uuidMap [module .elfUuidHandle ].dataSize ;
1164+ auto gmmHelper = connectedDevice->getNEODevice ()->getGmmHelper ();
1165+ auto loadAddress = gmmHelper->canonize (*std::min_element (module .loadAddresses [tileIndex].begin (), module .loadAddresses [tileIndex].end ()));
1166+ debugEvent.type = ZET_DEBUG_EVENT_TYPE_MODULE_UNLOAD;
1167+ debugEvent.info .module .format = ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF;
1168+ debugEvent.info .module .load = loadAddress;
1169+ debugEvent.info .module .moduleBegin = connection->uuidMap [module .elfUuidHandle ].ptr ;
1170+ debugEvent.info .module .moduleEnd = connection->uuidMap [module .elfUuidHandle ].ptr + connection->uuidMap [module .elfUuidHandle ].dataSize ;
11701171
1171- if (tileSessionsEnabled) {
1172+ if (tileSessionsEnabled) {
11721173
1173- auto tileAttached = static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->removeModule (debugEvent.info .module );
1174+ auto tileAttached = static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->removeModule (debugEvent.info .module );
11741175
1175- if (tileAttached) {
1176- static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->pushApiEvent (debugEvent, vmBind->uuids [uuidIter]);
1177- }
1176+ if (tileAttached) {
1177+ static_cast <TileDebugSessionLinux *>(tileSessions[tileIndex].first )->pushApiEvent (debugEvent, vmBind->uuids [uuidIter]);
1178+ }
11781179
1179- } else {
1180- bool notifyEvent = true ;
1181- if (module .deviceBitfield .count () > 1 ) {
1182- notifyEvent = checkAllOtherTileModuleSegmentsRemoved (tileIndex, module );
1183- }
1184- if (notifyEvent) {
1185- pushApiEvent (debugEvent, vmBind->uuids [uuidIter]);
1180+ } else {
1181+ bool notifyEvent = true ;
1182+ if (module .deviceBitfield .count () > 1 ) {
1183+ notifyEvent = checkAllOtherTileModuleSegmentsRemoved (tileIndex, module );
1184+ }
1185+ if (notifyEvent) {
1186+ pushApiEvent (debugEvent, vmBind->uuids [uuidIter]);
1187+ }
11861188 }
1189+ module .loadAddresses [tileIndex].clear ();
1190+ module .moduleLoadEventAcked [tileIndex] = false ;
11871191 }
1188- module .loadAddresses [tileIndex].clear ();
1189- module .moduleLoadEventAcked [tileIndex] = false ;
11901192 }
11911193 }
11921194 break ;
0 commit comments