mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Revert "feature(debugger): online page fault event handling"
This reverts commit 0c6444aab7.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d1f096ad14
commit
e61c5af7ec
@@ -756,45 +756,6 @@ TEST(DebugSessionTest, givenStoppedThreadsWhenFillingResumeAndStoppedThreadsFrom
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DebugSessionTest, givenThreadsStoppedWithPageFaultWhenCallingfillResumeAndStoppedThreadsFromNewlyStoppedThenCRIsWritten) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
auto hwInfo = *NEO::defaultHwInfo.get();
|
||||
|
||||
NEO::MockDevice *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
|
||||
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
|
||||
auto sessionMock = std::make_unique<MockDebugSession>(config, &deviceImp);
|
||||
|
||||
EuThread::ThreadId thread = {0, 0, 0, 0, 1};
|
||||
|
||||
sessionMock->newlyStoppedThreads.push_back(thread);
|
||||
sessionMock->onlyForceException = true;
|
||||
|
||||
std::vector<EuThread::ThreadId> resumeThreads;
|
||||
std::vector<EuThread::ThreadId> stoppedThreads;
|
||||
std::vector<EuThread::ThreadId> interruptedThreads;
|
||||
|
||||
sessionMock->allThreads[thread]->stopThread(1u);
|
||||
sessionMock->allThreads[thread]->setPageFault(true);
|
||||
|
||||
sessionMock->fillResumeAndStoppedThreadsFromNewlyStopped(resumeThreads, stoppedThreads, interruptedThreads);
|
||||
EXPECT_EQ(0u, resumeThreads.size());
|
||||
EXPECT_EQ(1u, stoppedThreads.size());
|
||||
EXPECT_EQ(1u, sessionMock->writeRegistersCallCount);
|
||||
EXPECT_EQ(ZET_DEBUG_REGSET_TYPE_CR_INTEL_GPU, sessionMock->writeRegistersReg);
|
||||
EXPECT_EQ(false, sessionMock->allThreads[thread]->getPageFault());
|
||||
|
||||
resumeThreads.clear();
|
||||
stoppedThreads.clear();
|
||||
sessionMock->newlyStoppedThreads.push_back(thread);
|
||||
sessionMock->onlyForceException = true;
|
||||
sessionMock->fillResumeAndStoppedThreadsFromNewlyStopped(resumeThreads, stoppedThreads, interruptedThreads);
|
||||
EXPECT_EQ(1u, resumeThreads.size());
|
||||
EXPECT_EQ(0u, stoppedThreads.size());
|
||||
EXPECT_EQ(1u, sessionMock->writeRegistersCallCount);
|
||||
}
|
||||
|
||||
TEST(DebugSessionTest, givenNoThreadsStoppedWhenCallingfillResumeAndStoppedThreadsFromNewlyStoppedThenReadStateSaveAreaNotCalled) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
@@ -255,17 +255,5 @@ TEST(EuThread, GivenEuThreadWhenGettingLastCounterThenCorrectValueIsReturned) {
|
||||
EXPECT_EQ(9u, euThread.getLastCounter());
|
||||
}
|
||||
|
||||
TEST(EuThread, GivenEuThreadWhenGettingPageFaultThenCorrectValueIsReturned) {
|
||||
ze_device_thread_t devThread = {3, 4, 5, 6};
|
||||
EuThread::ThreadId threadId(0, devThread);
|
||||
EuThread euThread(threadId);
|
||||
|
||||
EXPECT_EQ(false, euThread.getPageFault());
|
||||
euThread.setPageFault(true);
|
||||
EXPECT_EQ(true, euThread.getPageFault());
|
||||
euThread.setPageFault(false);
|
||||
EXPECT_EQ(false, euThread.getPageFault());
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||
#include "level_zero/tools/source/debug/linux/prelim/debug_session.h"
|
||||
#include "level_zero/tools/test/unit_tests/sources/debug/debug_session_common.h"
|
||||
|
||||
#include "common/StateSaveAreaHeader.h"
|
||||
|
||||
@@ -620,61 +619,6 @@ struct DebugApiLinuxFixture : public DeviceFixture {
|
||||
static constexpr uint8_t bufferSize = 16;
|
||||
};
|
||||
|
||||
struct DebugApiPageFaultEventFixture : public DebugApiLinuxFixture {
|
||||
void setUp() {
|
||||
DebugApiLinuxFixture::setUp();
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
sessionMock = std::make_unique<MockDebugSessionLinux>(config, device, 10);
|
||||
ASSERT_NE(nullptr, sessionMock);
|
||||
sessionMock->clientHandle = MockDebugSessionLinux::mockClientHandle;
|
||||
|
||||
auto handler = new MockIoctlHandler;
|
||||
sessionMock->ioctlHandler.reset(handler);
|
||||
SIP::version version = {2, 0, 0};
|
||||
initStateSaveArea(sessionMock->stateSaveAreaHeader, version, device);
|
||||
handler->setPreadMemory(sessionMock->stateSaveAreaHeader.data(), sessionMock->stateSaveAreaHeader.size(), 0x1000);
|
||||
sessionMock->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->contextsCreated[ctxHandle].vm = vmHandle;
|
||||
sessionMock->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->lrcToContextHandle[lrcHandle] = ctxHandle;
|
||||
DebugSessionLinux::BindInfo cssaInfo = {0x1000, sessionMock->stateSaveAreaHeader.size()};
|
||||
sessionMock->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->vmToContextStateSaveAreaBindInfo[vmHandle] = cssaInfo;
|
||||
}
|
||||
|
||||
void tearDown() {
|
||||
DebugApiLinuxFixture::tearDown();
|
||||
}
|
||||
|
||||
void buildPfi915Event() {
|
||||
buildPfi915Event(MockDebugSessionLinux::mockClientHandle);
|
||||
}
|
||||
void buildPfi915Event(uint64_t clientHandle) {
|
||||
prelim_drm_i915_debug_event_page_fault pf = {};
|
||||
pf.base.type = PRELIM_DRM_I915_DEBUG_EVENT_PAGE_FAULT;
|
||||
pf.base.flags = 0;
|
||||
pf.base.size = sizeof(prelim_drm_i915_debug_event_page_fault) + (bitmaskSize * 3u);
|
||||
pf.client_handle = clientHandle;
|
||||
pf.lrc_handle = lrcHandle;
|
||||
pf.flags = 0;
|
||||
pf.ci.engine_class = 0;
|
||||
pf.ci.engine_instance = 0;
|
||||
pf.bitmask_size = static_cast<uint32_t>(bitmaskSize * 3);
|
||||
|
||||
memcpy(data, &pf, sizeof(prelim_drm_i915_debug_event_page_fault));
|
||||
memcpy(ptrOffset(data, offsetof(prelim_drm_i915_debug_event_page_fault, bitmask)), bitmaskBefore.get(), bitmaskSize);
|
||||
memcpy(ptrOffset(data, offsetof(prelim_drm_i915_debug_event_page_fault, bitmask) + bitmaskSize), bitmaskAfter.get(), bitmaskSize);
|
||||
memcpy(ptrOffset(data, offsetof(prelim_drm_i915_debug_event_page_fault, bitmask) + (2 * bitmaskSize)), bitmaskResolved.get(), bitmaskSize);
|
||||
}
|
||||
|
||||
size_t bitmaskSize = 256;
|
||||
uint8_t data[sizeof(prelim_drm_i915_debug_event_page_fault) + (256 * 3)];
|
||||
std::unique_ptr<uint8_t[]> bitmaskBefore, bitmaskAfter, bitmaskResolved;
|
||||
std::unique_ptr<MockDebugSessionLinux> sessionMock;
|
||||
uint64_t ctxHandle = 2;
|
||||
uint64_t vmHandle = 7;
|
||||
uint64_t lrcHandle = 8;
|
||||
};
|
||||
|
||||
struct DebugApiLinuxMultiDeviceFixture : public MultipleDevicesWithCustomHwInfo {
|
||||
void setUp();
|
||||
|
||||
|
||||
@@ -3044,6 +3044,7 @@ TEST_F(DebugApiLinuxTest, GivenDebugSessionWhenClientCreateAndDestroyEventsReadO
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_DEVICE_LOST, result);
|
||||
EXPECT_EQ(eventsCount, static_cast<size_t>(session->getInternalEventCounter.load()));
|
||||
}
|
||||
|
||||
TEST_F(DebugApiLinuxTest, GivenEventWithInvalidFlagsWhenReadingEventThenUnknownErrorIsReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
@@ -3067,7 +3068,7 @@ TEST_F(DebugApiLinuxTest, GivenEventWithInvalidFlagsWhenReadingEventThenUnknownE
|
||||
auto memory = std::make_unique<uint64_t[]>(MockDebugSessionLinux::maxEventSize / sizeof(uint64_t));
|
||||
prelim_drm_i915_debug_event *event = reinterpret_cast<prelim_drm_i915_debug_event *>(memory.get());
|
||||
event->type = PRELIM_DRM_I915_DEBUG_EVENT_READ;
|
||||
event->flags = 0x8000;
|
||||
event->flags = 0;
|
||||
event->size = MockDebugSessionLinux::maxEventSize;
|
||||
|
||||
ze_result_t result = session->readEventImp(event);
|
||||
@@ -3098,6 +3099,33 @@ TEST_F(DebugApiLinuxTest, GivenDebugSessionInitializationWhenNoValidEventsAreRea
|
||||
EXPECT_EQ(ZE_RESULT_NOT_READY, result);
|
||||
}
|
||||
|
||||
TEST_F(DebugApiLinuxTest, GivenInvalidFlagsWhenReadingEventThenUnknownErrorIsReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
auto session = std::make_unique<MockDebugSessionLinux>(config, device, 10);
|
||||
ASSERT_NE(nullptr, session);
|
||||
|
||||
prelim_drm_i915_debug_event_client clientInvalidFlag = {};
|
||||
clientInvalidFlag.base.type = PRELIM_DRM_I915_DEBUG_EVENT_CLIENT;
|
||||
clientInvalidFlag.base.flags = 0x8000;
|
||||
clientInvalidFlag.base.size = sizeof(prelim_drm_i915_debug_event_client);
|
||||
clientInvalidFlag.handle = 1;
|
||||
|
||||
auto handler = new MockIoctlHandler;
|
||||
handler->eventQueue.push({reinterpret_cast<char *>(&clientInvalidFlag), static_cast<uint64_t>(clientInvalidFlag.base.size)});
|
||||
handler->pollRetVal = 1;
|
||||
|
||||
session->ioctlHandler.reset(handler);
|
||||
|
||||
uint64_t data[512];
|
||||
auto drmDebugEvent = reinterpret_cast<prelim_drm_i915_debug_event *>(data);
|
||||
|
||||
ze_result_t result = session->readEventImp(drmDebugEvent);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result);
|
||||
EXPECT_EQ(1u, static_cast<size_t>(handler->ioctlCalled));
|
||||
}
|
||||
|
||||
TEST_F(DebugApiLinuxTest, GivenValidFlagsWhenReadingEventThenEventIsNotProcessed) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
@@ -5843,130 +5871,6 @@ TEST_F(DebugApiLinuxTest, givenTileAttachEnabledWhenDeviceDoesNotHaveTilesThenTi
|
||||
EXPECT_EQ(0u, session->tileSessions.size());
|
||||
}
|
||||
|
||||
using DebugApiLinuxPageFaultEventTest = Test<DebugApiPageFaultEventFixture>;
|
||||
|
||||
TEST_F(DebugApiLinuxPageFaultEventTest, GivenNoPageFaultingThreadWhenHandlingPageFaultEventThenL0ApiEventGenerated) {
|
||||
auto &hwInfo = neoDevice->getHardwareInfo();
|
||||
auto &l0GfxCoreHelper = neoDevice->getRootDeviceEnvironment().getHelper<L0GfxCoreHelper>();
|
||||
|
||||
std::vector<EuThread::ThreadId> threads{
|
||||
{0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 1},
|
||||
{0, 0, 0, 0, 2},
|
||||
{0, 0, 0, 0, 3},
|
||||
{0, 0, 0, 0, 4},
|
||||
{0, 0, 0, 0, 5},
|
||||
{0, 0, 0, 0, 6}};
|
||||
|
||||
for (auto thread : threads) {
|
||||
sessionMock->stoppedThreads[thread.packed] = 1;
|
||||
}
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmaskBefore, bitmaskSize);
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmaskAfter, bitmaskSize);
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmaskResolved, bitmaskSize);
|
||||
|
||||
bitmaskSize = std::min(size_t(128), bitmaskSize);
|
||||
buildPfi915Event();
|
||||
sessionMock->handleEvent(reinterpret_cast<prelim_drm_i915_debug_event *>(data));
|
||||
EXPECT_EQ(threads.size(), sessionMock->newlyStoppedThreads.size());
|
||||
for (auto thread : threads) {
|
||||
EXPECT_FALSE(sessionMock->allThreads[thread]->getPageFault());
|
||||
}
|
||||
ASSERT_EQ(1u, sessionMock->apiEvents.size());
|
||||
auto event = sessionMock->apiEvents.front();
|
||||
ASSERT_EQ(event.type, ZET_DEBUG_EVENT_TYPE_PAGE_FAULT);
|
||||
}
|
||||
|
||||
TEST_F(DebugApiLinuxPageFaultEventTest, GivenPageFaultEventWIthInvalidClientHandleThenNoThreadsReportedStopped) {
|
||||
|
||||
auto &hwInfo = neoDevice->getHardwareInfo();
|
||||
auto &l0GfxCoreHelper = neoDevice->getRootDeviceEnvironment().getHelper<L0GfxCoreHelper>();
|
||||
|
||||
std::vector<EuThread::ThreadId> threads;
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmaskBefore, bitmaskSize);
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmaskAfter, bitmaskSize);
|
||||
|
||||
threads.push_back({0, 0, 0, 0, 0});
|
||||
threads.push_back({0, 0, 0, 0, 2});
|
||||
threads.push_back({0, 0, 0, 0, 3});
|
||||
threads.push_back({0, 0, 0, 0, 4});
|
||||
threads.push_back({0, 0, 0, 0, 6});
|
||||
for (auto thread : threads) {
|
||||
sessionMock->stoppedThreads[thread.packed] = 1;
|
||||
}
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmaskResolved, bitmaskSize);
|
||||
|
||||
bitmaskSize = std::min(size_t(128), bitmaskSize);
|
||||
buildPfi915Event(MockDebugSessionLinux::invalidClientHandle);
|
||||
sessionMock->handleEvent(reinterpret_cast<prelim_drm_i915_debug_event *>(data));
|
||||
|
||||
EXPECT_EQ(0u, sessionMock->newlyStoppedThreads.size());
|
||||
}
|
||||
|
||||
TEST_F(DebugApiLinuxPageFaultEventTest, GivenPageFaultEventWhenHandlingEventThenThreadsReportedStoppedAndPfSet) {
|
||||
|
||||
auto &hwInfo = neoDevice->getHardwareInfo();
|
||||
auto &l0GfxCoreHelper = neoDevice->getRootDeviceEnvironment().getHelper<L0GfxCoreHelper>();
|
||||
|
||||
std::vector<EuThread::ThreadId> threads;
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmaskBefore, bitmaskSize);
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmaskAfter, bitmaskSize);
|
||||
|
||||
threads.push_back({0, 0, 0, 0, 0});
|
||||
threads.push_back({0, 0, 0, 0, 2});
|
||||
threads.push_back({0, 0, 0, 0, 3});
|
||||
threads.push_back({0, 0, 0, 0, 4});
|
||||
threads.push_back({0, 0, 0, 0, 6});
|
||||
for (auto thread : threads) {
|
||||
sessionMock->stoppedThreads[thread.packed] = 1;
|
||||
}
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmaskResolved, bitmaskSize);
|
||||
|
||||
bitmaskSize = std::min(size_t(128), bitmaskSize);
|
||||
buildPfi915Event();
|
||||
sessionMock->handleEvent(reinterpret_cast<prelim_drm_i915_debug_event *>(data));
|
||||
|
||||
EXPECT_EQ(threads.size(), sessionMock->newlyStoppedThreads.size());
|
||||
for (auto thread : threads) {
|
||||
EXPECT_TRUE(sessionMock->allThreads[thread]->getPageFault());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DebugApiLinuxPageFaultEventTest, GivenPageFaultEventWhenHandlingEventThenThreadsNotNewlyResolvedAreNotMarkedAsPf) {
|
||||
|
||||
auto &hwInfo = neoDevice->getHardwareInfo();
|
||||
auto &l0GfxCoreHelper = neoDevice->getRootDeviceEnvironment().getHelper<L0GfxCoreHelper>();
|
||||
|
||||
std::vector<EuThread::ThreadId> threadsBefore, threadsAfter, threadsResolved;
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threadsBefore, hwInfo, bitmaskBefore, bitmaskSize);
|
||||
threadsAfter.push_back({0, 0, 0, 0, 0});
|
||||
threadsAfter.push_back({0, 0, 0, 0, 1});
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threadsAfter, hwInfo, bitmaskAfter, bitmaskSize);
|
||||
threadsResolved.push_back({0, 0, 0, 0, 0});
|
||||
threadsResolved.push_back({0, 0, 0, 0, 1});
|
||||
threadsResolved.push_back({0, 0, 0, 0, 2});
|
||||
threadsResolved.push_back({0, 0, 0, 0, 3});
|
||||
|
||||
for (auto thread : threadsResolved) {
|
||||
sessionMock->stoppedThreads[thread.packed] = 1;
|
||||
}
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads(threadsResolved, hwInfo, bitmaskResolved, bitmaskSize);
|
||||
|
||||
bitmaskSize = std::min(size_t(128), bitmaskSize);
|
||||
buildPfi915Event();
|
||||
sessionMock->handleEvent(reinterpret_cast<prelim_drm_i915_debug_event *>(data));
|
||||
|
||||
EXPECT_EQ(threadsResolved.size(), sessionMock->newlyStoppedThreads.size());
|
||||
|
||||
for (auto thread : threadsResolved) {
|
||||
if (std::find(threadsAfter.begin(), threadsAfter.end(), thread) == threadsAfter.end()) {
|
||||
EXPECT_TRUE(sessionMock->allThreads[thread]->getPageFault());
|
||||
} else {
|
||||
EXPECT_FALSE(sessionMock->allThreads[thread]->getPageFault());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using DebugApiLinuxAttentionTest = Test<DebugApiLinuxFixture>;
|
||||
|
||||
TEST_F(DebugApiLinuxAttentionTest, GivenEuAttentionEventForThreadsWhenHandlingEventThenNewlyStoppedThreadsSaved) {
|
||||
@@ -8629,37 +8533,6 @@ TEST_F(AffinityMaskMultipleSubdevicesTestLinux, GivenEventWithAckFlagAndTileNotW
|
||||
EXPECT_EQ(vmBindIsa->base.seqno, handler->debugEventAcked.seqno);
|
||||
}
|
||||
|
||||
TEST_F(AffinityMaskMultipleSubdevicesTestLinux, GivenPfEventForTileNotWithinBitfieldWhenHandlingEventThenEventIsSkipped) {
|
||||
auto debugSession = std::make_unique<MockDebugSessionLinux>(zet_debug_config_t{1234}, deviceImp, 10);
|
||||
|
||||
uint64_t ctxHandle = 2;
|
||||
uint64_t vmHandle = 7;
|
||||
uint64_t lrcHandle = 8;
|
||||
|
||||
debugSession->clientHandleToConnection[debugSession->clientHandle]->contextsCreated[ctxHandle].vm = vmHandle;
|
||||
debugSession->clientHandleToConnection[debugSession->clientHandle]->lrcToContextHandle[lrcHandle] = ctxHandle;
|
||||
debugSession->clientHandleToConnection[debugSession->clientHandle]->vmToTile[vmHandle] = 2;
|
||||
|
||||
prelim_drm_i915_debug_event_page_fault pf = {};
|
||||
pf.base.type = PRELIM_DRM_I915_DEBUG_EVENT_PAGE_FAULT;
|
||||
pf.base.flags = 0;
|
||||
pf.base.size = sizeof(prelim_drm_i915_debug_event_page_fault);
|
||||
pf.client_handle = MockDebugSessionLinux::mockClientHandle;
|
||||
pf.lrc_handle = lrcHandle;
|
||||
pf.flags = 0;
|
||||
|
||||
auto engineInfo = mockDrm->getEngineInfo();
|
||||
auto ci = engineInfo->getEngineInstance(2, hwInfo.capabilityTable.defaultEngineType);
|
||||
pf.ci.engine_class = ci->engineClass;
|
||||
pf.ci.engine_instance = ci->engineInstance;
|
||||
|
||||
ze_device_thread_t thread = {0, 0, 0, UINT32_MAX};
|
||||
debugSession->pendingInterrupts.push_back(std::pair<ze_device_thread_t, bool>(thread, false));
|
||||
|
||||
debugSession->handleEvent(&pf.base);
|
||||
EXPECT_FALSE(debugSession->triggerEvents);
|
||||
}
|
||||
|
||||
TEST_F(AffinityMaskMultipleSubdevicesTestLinux, GivenAttEventForTileNotWithinBitfieldWhenHandlingEventThenEventIsSkipped) {
|
||||
auto debugSession = std::make_unique<MockDebugSessionLinux>(zet_debug_config_t{1234}, deviceImp, 10);
|
||||
|
||||
|
||||
@@ -819,70 +819,6 @@ TEST_F(TileAttachTest, givenStoppedThreadsWhenHandlingAttentionEventThenStoppedT
|
||||
EXPECT_TRUE(tileSessions[1]->triggerEvents);
|
||||
}
|
||||
|
||||
TEST_F(TileAttachTest, givenStoppedThreadsWhenHandlingPageFaultEventThenStoppedThreadsFromEventAreProcessed) {
|
||||
// debug attach both tiles
|
||||
rootSession->tileSessions[0].second = true;
|
||||
rootSession->tileSessions[1].second = true;
|
||||
|
||||
uint64_t ctxHandle = 2;
|
||||
uint64_t vmHandle = 7;
|
||||
uint64_t lrcHandle = 8;
|
||||
|
||||
rootSession->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->contextsCreated[ctxHandle].vm = vmHandle;
|
||||
rootSession->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->lrcToContextHandle[lrcHandle] = ctxHandle;
|
||||
rootSession->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->vmToTile[vmHandle] = 1;
|
||||
|
||||
SIP::version version = {2, 0, 0};
|
||||
initStateSaveArea(rootSession->stateSaveAreaHeader, version, deviceImp);
|
||||
DebugSessionLinux::BindInfo cssaInfo = {reinterpret_cast<uint64_t>(rootSession->stateSaveAreaHeader.data()), rootSession->stateSaveAreaHeader.size()};
|
||||
rootSession->clientHandleToConnection[MockDebugSessionLinux::mockClientHandle]->vmToContextStateSaveAreaBindInfo[vmHandle] = cssaInfo;
|
||||
|
||||
auto handler = new MockIoctlHandler;
|
||||
rootSession->ioctlHandler.reset(handler);
|
||||
handler->setPreadMemory(rootSession->stateSaveAreaHeader.data(), rootSession->stateSaveAreaHeader.size(), reinterpret_cast<uint64_t>(rootSession->stateSaveAreaHeader.data()));
|
||||
|
||||
uint8_t data[sizeof(prelim_drm_i915_debug_event_page_fault) + 128 * 3];
|
||||
|
||||
auto engineInfo = mockDrm->getEngineInfo();
|
||||
auto engineInstance = engineInfo->getEngineInstance(1, hwInfo.capabilityTable.defaultEngineType);
|
||||
|
||||
EuThread::ThreadId thread = {1, 0, 0, 0, 0};
|
||||
tileSessions[1]->stoppedThreads[thread.packed] = 1;
|
||||
|
||||
std::unique_ptr<uint8_t[]> bitmaskBefore, bitmaskAfter, bitmaskResolved;
|
||||
size_t bitmaskSize = 0;
|
||||
auto &hwInfo = neoDevice->getHardwareInfo();
|
||||
auto &l0GfxCoreHelper = neoDevice->getRootDeviceEnvironment().getHelper<L0GfxCoreHelper>();
|
||||
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads({thread}, hwInfo, bitmaskBefore, bitmaskSize);
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads({thread}, hwInfo, bitmaskAfter, bitmaskSize);
|
||||
l0GfxCoreHelper.getAttentionBitmaskForSingleThreads({thread}, hwInfo, bitmaskResolved, bitmaskSize);
|
||||
|
||||
prelim_drm_i915_debug_event_page_fault pf = {};
|
||||
pf.base.type = PRELIM_DRM_I915_DEBUG_EVENT_PAGE_FAULT;
|
||||
pf.base.flags = PRELIM_DRM_I915_DEBUG_EVENT_STATE_CHANGE;
|
||||
pf.base.size = sizeof(prelim_drm_i915_debug_event_page_fault);
|
||||
pf.base.seqno = 2;
|
||||
pf.client_handle = MockDebugSessionLinux::mockClientHandle;
|
||||
pf.lrc_handle = lrcHandle;
|
||||
pf.flags = 0;
|
||||
pf.ci.engine_class = engineInstance->engineClass;
|
||||
pf.ci.engine_instance = engineInstance->engineInstance;
|
||||
pf.bitmask_size = static_cast<uint32_t>(bitmaskSize * 3u);
|
||||
|
||||
bitmaskSize = std::min(size_t(128), bitmaskSize);
|
||||
memcpy(data, &pf, sizeof(prelim_drm_i915_debug_event_page_fault));
|
||||
memcpy(ptrOffset(data, offsetof(prelim_drm_i915_debug_event_page_fault, bitmask)), bitmaskBefore.get(), bitmaskSize);
|
||||
memcpy(ptrOffset(data, offsetof(prelim_drm_i915_debug_event_page_fault, bitmask) + bitmaskSize), bitmaskAfter.get(), bitmaskSize);
|
||||
memcpy(ptrOffset(data, offsetof(prelim_drm_i915_debug_event_page_fault, bitmask) + (2 * bitmaskSize)), bitmaskResolved.get(), bitmaskSize);
|
||||
|
||||
rootSession->handleEvent(reinterpret_cast<prelim_drm_i915_debug_event *>(data));
|
||||
|
||||
auto expectedThreadsToCheck = hwInfo.capabilityTable.fusedEuEnabled ? 2u : 1u;
|
||||
EXPECT_EQ(expectedThreadsToCheck, tileSessions[1]->newlyStoppedThreads.size());
|
||||
EXPECT_TRUE(tileSessions[1]->triggerEvents);
|
||||
}
|
||||
|
||||
TEST_F(TileAttachTest, GivenBlockingOnCpuDetachedTileAndZebinModulesWithEventsToAckWhenDetachingTileThenNoAckIoctlIsCalled) {
|
||||
auto handler = new MockIoctlHandler;
|
||||
rootSession->ioctlHandler.reset(handler);
|
||||
|
||||
@@ -298,6 +298,7 @@ struct MockDebugSession : public L0::DebugSessionImp {
|
||||
[[maybe_unused]] auto offset = ptrDiff(gpuVa, reinterpret_cast<uint64_t>(stateSaveAreaHeader.data()));
|
||||
memcpy_s(reinterpret_cast<void *>(gpuVa), size, input, size);
|
||||
}
|
||||
|
||||
return writeMemoryResult;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user