fix: Reduce code duplicity by reusing closeConnection
Related-To: NEO-11188 Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
This commit is contained in:
parent
8c1f0836ae
commit
c5a76cac3a
|
@ -126,7 +126,6 @@ std::unique_ptr<uint64_t[]> DebugSessionLinux::getInternalEvent() {
|
|||
|
||||
void DebugSessionLinux::closeAsyncThread() {
|
||||
asyncThread.close();
|
||||
internalEventThread.close();
|
||||
}
|
||||
|
||||
bool DebugSessionLinux::checkForceExceptionBit(uint64_t memoryHandle, EuThread::ThreadId threadId, uint32_t *cr0, const SIP::regset_desc *regDesc) {
|
||||
|
@ -918,4 +917,39 @@ ze_result_t DebugSessionLinux::acknowledgeEvent(const zet_debug_event_t *event)
|
|||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
|
||||
bool DebugSessionLinux::closeConnection() {
|
||||
closeAsyncThread();
|
||||
closeInternalEventsThread();
|
||||
|
||||
if (clientHandle != invalidClientHandle) {
|
||||
auto numTiles = std::max(1u, connectedDevice->getNEODevice()->getNumSubDevices());
|
||||
for (uint32_t tileIndex = 0; tileIndex < numTiles; tileIndex++) {
|
||||
for (const auto &eventToAck : eventsToAck) {
|
||||
auto moduleHandle = eventToAck.second;
|
||||
ackModuleEvents(tileIndex, moduleHandle);
|
||||
}
|
||||
cleanRootSessionAfterDetach(tileIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return closeFd();
|
||||
}
|
||||
|
||||
void DebugSessionLinux::cleanRootSessionAfterDetach(uint32_t deviceIndex) {
|
||||
auto connection = getClientConnection(clientHandle).get();
|
||||
|
||||
for (const auto &isa : connection->isaMap[deviceIndex]) {
|
||||
|
||||
// zebin modules do not store ackEvents per ISA
|
||||
UNRECOVERABLE_IF(isa.second->ackEvents.size() > 0 && isa.second->perKernelModule == false);
|
||||
|
||||
for (auto &event : isa.second->ackEvents) {
|
||||
eventAckIoctl(event);
|
||||
}
|
||||
|
||||
isa.second->ackEvents.clear();
|
||||
isa.second->moduleLoadEventAck = true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
|
|
@ -24,6 +24,7 @@ struct DebugSessionLinux : DebugSessionImp {
|
|||
static ze_result_t translateDebuggerOpenErrno(int error);
|
||||
bool closeFd();
|
||||
void closeAsyncThread();
|
||||
bool closeConnection() override;
|
||||
|
||||
int fd = 0;
|
||||
std::atomic<bool> internalThreadHasStarted{false};
|
||||
|
@ -162,6 +163,7 @@ struct DebugSessionLinux : DebugSessionImp {
|
|||
};
|
||||
|
||||
protected:
|
||||
void cleanRootSessionAfterDetach(uint32_t deviceIndex) override;
|
||||
virtual std::shared_ptr<ClientConnection> getClientConnection(uint64_t clientHandle) = 0;
|
||||
|
||||
enum class ThreadControlCmd {
|
||||
|
|
|
@ -277,24 +277,6 @@ void DebugSessionLinuxi915::readInternalEventsAsync() {
|
|||
}
|
||||
}
|
||||
|
||||
bool DebugSessionLinuxi915::closeConnection() {
|
||||
closeAsyncThread();
|
||||
closeInternalEventsThread();
|
||||
|
||||
if (clientHandle != invalidClientHandle) {
|
||||
auto numTiles = std::max(1u, connectedDevice->getNEODevice()->getNumSubDevices());
|
||||
for (uint32_t i = 0; i < numTiles; i++) {
|
||||
for (const auto &eventToAck : eventsToAck) {
|
||||
auto moduleUUID = eventToAck.second;
|
||||
ackModuleEvents(i, moduleUUID);
|
||||
}
|
||||
cleanRootSessionAfterDetach(i);
|
||||
}
|
||||
}
|
||||
|
||||
return closeFd();
|
||||
}
|
||||
|
||||
void DebugSessionLinuxi915::handleEvent(prelim_drm_i915_debug_event *event) {
|
||||
auto type = event->type;
|
||||
|
||||
|
@ -1331,29 +1313,6 @@ int DebugSessionLinuxi915::eventAckIoctl(EventToAck &event) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
void DebugSessionLinuxi915::cleanRootSessionAfterDetach(uint32_t deviceIndex) {
|
||||
auto connection = clientHandleToConnection[clientHandle].get();
|
||||
|
||||
for (const auto &isa : connection->isaMap[deviceIndex]) {
|
||||
|
||||
// zebin modules do not store ackEvents per ISA
|
||||
UNRECOVERABLE_IF(isa.second->ackEvents.size() > 0 && isa.second->perKernelModule == false);
|
||||
|
||||
for (auto &event : isa.second->ackEvents) {
|
||||
prelim_drm_i915_debug_event_ack eventToAck = {};
|
||||
eventToAck.type = event.type;
|
||||
eventToAck.seqno = event.seqno;
|
||||
eventToAck.flags = 0;
|
||||
|
||||
auto ret = ioctl(PRELIM_I915_DEBUG_IOCTL_ACK_EVENT, &eventToAck);
|
||||
PRINT_DEBUGGER_INFO_LOG("PRELIM_I915_DEBUG_IOCTL_ACK_EVENT seqno = %llu, ret = %d errno = %d\n", (uint64_t)event.seqno, ret, ret != 0 ? errno : 0);
|
||||
}
|
||||
|
||||
isa.second->ackEvents.clear();
|
||||
isa.second->moduleLoadEventAck = true;
|
||||
}
|
||||
}
|
||||
|
||||
void TileDebugSessionLinuxi915::readStateSaveAreaHeader() {
|
||||
|
||||
const auto header = rootDebugSession->getStateSaveAreaHeader();
|
||||
|
|
|
@ -41,8 +41,6 @@ struct DebugSessionLinuxi915 : DebugSessionLinux {
|
|||
static DebugSession *createLinuxSession(const zet_debug_config_t &config, Device *device, ze_result_t &result, bool isRootAttach);
|
||||
ze_result_t initialize() override;
|
||||
|
||||
bool closeConnection() override;
|
||||
|
||||
struct IoctlHandleri915 : DebugSessionLinux::IoctlHandler {
|
||||
int ioctl(int fd, unsigned long request, void *arg) override {
|
||||
int ret = 0;
|
||||
|
@ -146,7 +144,6 @@ struct DebugSessionLinuxi915 : DebugSessionLinux {
|
|||
void detachTile() override {
|
||||
UNRECOVERABLE_IF(true);
|
||||
}
|
||||
void cleanRootSessionAfterDetach(uint32_t deviceIndex) override;
|
||||
|
||||
void extractUuidData(uint64_t client, const UuidData &uuidData);
|
||||
uint64_t extractVaFromUuidString(std::string &uuid);
|
||||
|
|
|
@ -180,11 +180,6 @@ ze_result_t DebugSessionLinuxXe::readEventImp(drm_xe_eudebug_event *drmDebugEven
|
|||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
bool DebugSessionLinuxXe::closeConnection() {
|
||||
closeInternalEventsThread();
|
||||
return closeFd();
|
||||
}
|
||||
|
||||
void DebugSessionLinuxXe::handleEvent(drm_xe_eudebug_event *event) {
|
||||
auto type = event->type;
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ struct DebugSessionLinuxXe : DebugSessionLinux {
|
|||
|
||||
ze_result_t initialize() override;
|
||||
|
||||
bool closeConnection() override;
|
||||
|
||||
struct IoctlHandlerXe : DebugSessionLinux::IoctlHandler {
|
||||
int ioctl(int fd, unsigned long request, void *arg) override {
|
||||
int ret = 0;
|
||||
|
@ -85,10 +83,6 @@ struct DebugSessionLinuxXe : DebugSessionLinux {
|
|||
static void *asyncThreadFunction(void *arg);
|
||||
void handleEventsAsync();
|
||||
|
||||
void cleanRootSessionAfterDetach(uint32_t deviceIndex) override {
|
||||
UNRECOVERABLE_IF(true);
|
||||
}
|
||||
|
||||
int openVmFd(uint64_t vmHandle, bool readOnly) override;
|
||||
int flushVmCache(int vmfd) override;
|
||||
|
||||
|
|
|
@ -214,6 +214,7 @@ TEST_F(DebugApiLinuxTestXe, GivenDebugSessionWhenClosingConnectionThenSysCallClo
|
|||
EXPECT_EQ(1u, NEO::SysCalls::closeFuncCalled);
|
||||
EXPECT_EQ(10, NEO::SysCalls::closeFuncArgPassed);
|
||||
EXPECT_FALSE(session->internalEventThread.threadActive);
|
||||
EXPECT_FALSE(session->asyncThread.threadActive);
|
||||
|
||||
NEO::SysCalls::closeFuncCalled = 0;
|
||||
NEO::SysCalls::closeFuncArgPassed = 0;
|
||||
|
|
Loading…
Reference in New Issue