feature: Add NEEDS_RESET property for reset required event

Related-To: NEO-8604

Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
Bellekallu Rajkiran
2023-11-08 13:52:31 +00:00
committed by Compute-Runtime-Automation
parent be76655168
commit 8a50cdf130
4 changed files with 70 additions and 15 deletions

View File

@@ -189,13 +189,21 @@ bool LinuxEventsUtil::isResetRequired(void *dev, zes_event_type_flags_t &pEvent)
return false;
}
std::vector<std::string> properties{"RESET_FAILED", "RESET_REQUIRED"};
std::vector<std::string> properties{"RESET_FAILED", "RESET_REQUIRED", "DEVICE_STATUS"};
for (auto &property : properties) {
const char *propVal = nullptr;
propVal = pUdevLib->getEventPropertyValue(dev, property.c_str());
if (propVal && atoi(propVal) == 1) {
pEvent |= ZES_EVENT_TYPE_FLAG_DEVICE_RESET_REQUIRED;
return true;
if (propVal) {
std::string expectedStr = "NEEDS_RESET";
if (property != "DEVICE_STATUS") {
if (atoi(propVal) == 1) {
pEvent |= ZES_EVENT_TYPE_FLAG_DEVICE_RESET_REQUIRED;
return true;
}
} else if (propVal == expectedStr) {
pEvent |= ZES_EVENT_TYPE_FLAG_DEVICE_RESET_REQUIRED;
return true;
}
}
}

View File

@@ -4,6 +4,12 @@
# SPDX-License-Identifier: MIT
#
set(L0_TESTS_SYSMAN_EVENTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_events.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_events.h
)
if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE

View File

@@ -270,7 +270,7 @@ struct MockEventNeoDrm : public Drm {
mockMemoryType = memory;
}
std::vector<uint8_t> getMemoryRegionsReturnsEmpty() {
std::vector<uint64_t> getMemoryRegionsReturnsEmpty() {
return {};
}
@@ -285,7 +285,7 @@ struct MockEventNeoDrm : public Drm {
}
uint32_t hwBlob[] = {INTEL_HWCONFIG_MAX_MEMORY_CHANNELS, 1, 8, INTEL_HWCONFIG_MEMORY_TYPE, 0, mockMemoryType};
std::vector<uint8_t> inputBlobData(reinterpret_cast<uint8_t *>(hwBlob), reinterpret_cast<uint8_t *>(hwBlob) + sizeof(hwBlob));
std::vector<uint32_t> inputBlobData(reinterpret_cast<uint32_t *>(hwBlob), reinterpret_cast<uint32_t *>(hwBlob) + sizeof(hwBlob));
this->systemInfo.reset(new SystemInfo(inputBlobData));
return returnValue;
}

View File

@@ -10,8 +10,6 @@
#include "level_zero/sysman/test/unit_tests/sources/events/linux/mock_events.h"
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
extern bool sysmanUltsEnable;
namespace L0 {
namespace Sysman {
namespace ult {
@@ -35,9 +33,6 @@ class SysmanEventsFixture : public SysmanDeviceFixture {
L0::Sysman::SysmanDevice *device = nullptr;
void SetUp() override {
if (!sysmanUltsEnable) {
GTEST_SKIP();
}
SysmanDeviceFixture::SetUp();
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
pFsAccess = std::make_unique<MockEventsFsAccess>();
@@ -67,14 +62,10 @@ class SysmanEventsFixture : public SysmanDeviceFixture {
}
pSysmanDeviceImp->pRasHandleContext->handleList.clear();
device = pSysmanDeviceImp;
;
getRasHandles(0);
}
void TearDown() override {
if (!sysmanUltsEnable) {
GTEST_SKIP();
}
if (nullptr != pEventsImp->pOsEvents) {
delete pEventsImp->pOsEvents;
}
@@ -683,6 +674,56 @@ TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForResetRequiredE
delete pMockFwInterface;
}
TEST_F(SysmanEventsFixture, GivenNeedsResetUeventPropertyIsSignalledWhenListeningForResetRequiredEventsThenEventListenAPIReturnsAfterReceivingEventWithinTimeout) {
VariableBackup<FirmwareUtil *> backupFwUtil(&pLinuxSysmanImp->pFwUtilInterface);
auto pMockFwInterface = new MockEventsFwInterface;
pLinuxSysmanImp->pFwUtilInterface = pMockFwInterface;
VariableBackup<decltype(SysCalls::sysCallsPipe)> mockPipe(&SysCalls::sysCallsPipe, [](int pipeFd[2]) -> int {
pipeFd[0] = mockReadPipeFd;
pipeFd[1] = mockWritePipeFd;
return 1;
});
VariableBackup<decltype(SysCalls::sysCallsPoll)> mockPoll(&SysCalls::sysCallsPoll, [](struct pollfd *pollFd, unsigned long int numberOfFds, int timeout) -> int {
for (uint64_t i = 0; i < numberOfFds; i++) {
if (pollFd[i].fd == mockUdevFd) {
pollFd[i].revents = POLLIN;
}
}
return 1;
});
auto pPublicLinuxSysmanDriverImp = new PublicLinuxSysmanDriverImp();
auto pOsSysmanDriverOriginal = driverHandle->pOsSysmanDriver;
driverHandle->pOsSysmanDriver = static_cast<L0::Sysman::OsSysmanDriver *>(pPublicLinuxSysmanDriverImp);
auto pUdevLibLocal = new EventsUdevLibMock();
int a = 0;
void *ptr = &a; // Initialize a void pointer with dummy data
pUdevLibLocal->allocateDeviceToReceiveDataResult = ptr;
pUdevLibLocal->getEventPropertyValueResult = "NEEDS_RESET";
auto pUdevLibOriginal = pPublicLinuxSysmanDriverImp->pUdevLib;
pPublicLinuxSysmanDriverImp->pUdevLib = pUdevLibLocal;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_DEVICE_RESET_REQUIRED));
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
phDevices[0] = device->toHandle();
uint32_t numDeviceEvents = 0;
zes_event_type_flags_t *pDeviceEvents = new zes_event_type_flags_t[1];
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverEventListen(driverHandle->toHandle(), 1u, 1u, phDevices, &numDeviceEvents, pDeviceEvents));
EXPECT_EQ(1u, numDeviceEvents);
EXPECT_EQ(ZES_EVENT_TYPE_FLAG_DEVICE_RESET_REQUIRED, pDeviceEvents[0]);
delete[] phDevices;
delete[] pDeviceEvents;
pPublicLinuxSysmanDriverImp->pUdevLib = pUdevLibOriginal;
driverHandle->pOsSysmanDriver = pOsSysmanDriverOriginal;
delete pPublicLinuxSysmanDriverImp;
delete pUdevLibLocal;
delete pMockFwInterface;
}
TEST_F(SysmanDeviceFixture, GivenValidDeviceHandleWhenEventRegisterIsCalledThenSuccessIsReturned) {
auto pPublicLinuxSysmanDriverImp = new PublicLinuxSysmanDriverImp();
auto pOsSysmanDriverOriginal = driverHandle->pOsSysmanDriver;