Skip to content

Commit 2ed2cb4

Browse files
fix: Read fifo_head from state save area header correctly
Currently we are reading fifo_head from local copy of saved stateSaveAreaHeader. However, during fifo read dbgUMD is reading FIFO entries and accordingly SIP would also update fifo_head. Hence while accessing fifo_head, ensure that we always read fifo_head from latest in memory state save area header. Related-To: NEO-12787 Signed-off-by: Jitendra Sharma <[email protected]>
1 parent 468e309 commit 2ed2cb4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

level_zero/tools/source/debug/debug_session_imp.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,11 @@ ze_result_t DebugSessionImp::readFifo(uint64_t vmHandle, std::vector<EuThread::T
17391739
fifoTailIndex = 0;
17401740
}
17411741
}
1742-
lastHead = stateSaveAreaHeader->regHeaderV3.fifo_head;
1742+
retVal = readGpuMemory(vmHandle, reinterpret_cast<char *>(&lastHead), sizeof(uint32_t), gpuVa + offsetHead);
1743+
if (retVal != ZE_RESULT_SUCCESS) {
1744+
PRINT_DEBUGGER_ERROR_LOG("Reading fifo_head failed, error = %d\n", retVal);
1745+
return retVal;
1746+
}
17431747
NEO::sleep(std::chrono::milliseconds(failsafeTimeoutWait));
17441748
}
17451749
return ZE_RESULT_SUCCESS;

level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,14 @@ TEST_F(DebugSessionTestSwFifoFixture, GivenSwFifoWhenReadGpuMemoryFailsDuringFif
19421942
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, session->readFifo(0, threadsWithAttention));
19431943
}
19441944

1945+
TEST_F(DebugSessionTestSwFifoFixture, GivenSwFifoWhenReadGpuMemoryFailsDuringUpdateOfLastHeadThenErrorReturned) {
1946+
1947+
EXPECT_FALSE(session->stateSaveAreaHeader.empty());
1948+
session->forcereadGpuMemoryFailOnCount = 4;
1949+
std::vector<EuThread::ThreadId> threadsWithAttention;
1950+
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, session->readFifo(0, threadsWithAttention));
1951+
}
1952+
19451953
TEST(DebugSessionTest, GivenSwFifoWhenStateSaveAreaVersionIsLessThanThreeDuringFifoReadThenFifoIsNotReadAndSuccessIsReturned) {
19461954
auto stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2);
19471955

0 commit comments

Comments
 (0)