mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 13:33:02 +08:00
fix(sysman): Changes in the Sysman Engine
The engine module returns error if incorrect fds are fetched Related-To: NEO-10657 Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f673a255f7
commit
22e94c3a8c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -44,6 +44,9 @@ ze_result_t OsEngine::getNumEngineTypeAndInstances(std::set<std::pair<zes_engine
|
||||
bool status = false;
|
||||
{
|
||||
auto hwDeviceId = pLinuxSysmanImp->getSysmanHwDeviceIdInstance();
|
||||
if (hwDeviceId.getFileDescriptor() < 0) {
|
||||
return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
|
||||
}
|
||||
status = pDrm->sysmanQueryEngineInfo();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -43,6 +43,9 @@ ze_result_t OsEngine::getNumEngineTypeAndInstances(std::set<std::pair<zes_engine
|
||||
bool status = false;
|
||||
{
|
||||
auto hwDeviceId = pLinuxSysmanImp->getSysmanHwDeviceIdInstance();
|
||||
if (hwDeviceId.getFileDescriptor() < 0) {
|
||||
return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
|
||||
}
|
||||
status = pDrm->sysmanQueryEngineInfo();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -33,7 +33,12 @@ void EngineHandleContext::createHandle(zes_engine_group_t engineType, uint32_t e
|
||||
|
||||
void EngineHandleContext::init(uint32_t subDeviceCount) {
|
||||
std::set<std::pair<zes_engine_group_t, EngineInstanceSubDeviceId>> engineGroupInstance = {}; // set contains pair of engine group and struct containing engine instance and subdeviceId
|
||||
OsEngine::getNumEngineTypeAndInstances(engineGroupInstance, pOsSysman);
|
||||
deviceEngineInitStatus = OsEngine::getNumEngineTypeAndInstances(engineGroupInstance, pOsSysman);
|
||||
|
||||
if (deviceEngineInitStatus != ZE_RESULT_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto itr = engineGroupInstance.begin(); itr != engineGroupInstance.end(); ++itr) {
|
||||
for (uint32_t subDeviceId = 0; subDeviceId <= subDeviceCount; subDeviceId++) {
|
||||
if (subDeviceId == itr->second.second) {
|
||||
@@ -53,6 +58,11 @@ ze_result_t EngineHandleContext::engineGet(uint32_t *pCount, zes_engine_handle_t
|
||||
this->init(pOsSysman->getSubDeviceCount());
|
||||
this->engineInitDone = true;
|
||||
});
|
||||
|
||||
if (deviceEngineInitStatus != ZE_RESULT_SUCCESS) {
|
||||
return deviceEngineInitStatus;
|
||||
}
|
||||
|
||||
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
|
||||
uint32_t numToCopy = std::min(*pCount, handleListSize);
|
||||
if (0 == *pCount || *pCount > handleListSize) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -50,6 +50,7 @@ struct EngineHandleContext {
|
||||
void createHandle(zes_engine_group_t engineType, uint32_t engineInstance, uint32_t subDeviceId, ze_bool_t onSubdevice);
|
||||
std::once_flag initEngineOnce;
|
||||
bool engineInitDone = false;
|
||||
ze_result_t deviceEngineInitStatus = ZE_RESULT_SUCCESS;
|
||||
};
|
||||
|
||||
} // namespace Sysman
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -17,9 +17,7 @@ class SysmanHwDeviceIdDrm : public NEO::HwDeviceIdDrm {
|
||||
using NEO::HwDeviceIdDrm::HwDeviceIdDrm;
|
||||
class SingleInstance {
|
||||
public:
|
||||
SingleInstance(SysmanHwDeviceIdDrm &input) : instance(input), fileDescriptor(input.openFileDescriptor()) {
|
||||
UNRECOVERABLE_IF(fileDescriptor < 0);
|
||||
}
|
||||
SingleInstance(SysmanHwDeviceIdDrm &input) : instance(input), fileDescriptor(input.openFileDescriptor()) {}
|
||||
~SingleInstance() { instance.closeFileDescriptor(); }
|
||||
int getFileDescriptor() const { return fileDescriptor; }
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -23,11 +23,27 @@ namespace L0 {
|
||||
namespace Sysman {
|
||||
namespace ult {
|
||||
|
||||
class MockEngineSysmanHwDeviceIdDrm : public MockSysmanHwDeviceIdDrm {
|
||||
public:
|
||||
using L0::Sysman::ult::MockSysmanHwDeviceIdDrm::MockSysmanHwDeviceIdDrm;
|
||||
int returnOpenFileDescriptor = -1;
|
||||
int returnCloseFileDescriptor = 0;
|
||||
|
||||
int openFileDescriptor() override {
|
||||
return returnOpenFileDescriptor;
|
||||
}
|
||||
|
||||
int closeFileDescriptor() override {
|
||||
return returnCloseFileDescriptor;
|
||||
}
|
||||
};
|
||||
|
||||
struct MockEngineNeoDrm : public Drm {
|
||||
using Drm::getEngineInfo;
|
||||
using Drm::setupIoctlHelper;
|
||||
const int mockFd = 0;
|
||||
MockEngineNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<MockSysmanHwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {}
|
||||
MockEngineNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment, int mockFileDescriptor) : Drm(std::make_unique<MockEngineSysmanHwDeviceIdDrm>(mockFileDescriptor, ""), rootDeviceEnvironment) {}
|
||||
|
||||
bool mockSysmanQueryEngineInfoReturnFalse = true;
|
||||
bool sysmanQueryEngineInfo() override {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -33,11 +33,27 @@ constexpr uint32_t numberOfMockedEnginesForSingleTileDevice = 7u;
|
||||
constexpr uint32_t numberOfTiles = 2u;
|
||||
constexpr uint32_t numberOfMockedEnginesForMultiTileDevice = 2u;
|
||||
|
||||
class MockEngineSysmanHwDeviceIdDrm : public MockSysmanHwDeviceIdDrm {
|
||||
public:
|
||||
using L0::Sysman::ult::MockSysmanHwDeviceIdDrm::MockSysmanHwDeviceIdDrm;
|
||||
int returnOpenFileDescriptor = -1;
|
||||
int returnCloseFileDescriptor = 0;
|
||||
|
||||
int openFileDescriptor() override {
|
||||
return returnOpenFileDescriptor;
|
||||
}
|
||||
|
||||
int closeFileDescriptor() override {
|
||||
return returnCloseFileDescriptor;
|
||||
}
|
||||
};
|
||||
|
||||
struct MockEngineNeoDrm : public Drm {
|
||||
using Drm::engineInfo;
|
||||
using Drm::setupIoctlHelper;
|
||||
const int mockFd = 0;
|
||||
MockEngineNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<MockSysmanHwDeviceIdDrm>(mockFd, ""), rootDeviceEnvironment) {}
|
||||
MockEngineNeoDrm(RootDeviceEnvironment &rootDeviceEnvironment, int mockFileDescriptor) : Drm(std::make_unique<MockEngineSysmanHwDeviceIdDrm>(mockFileDescriptor, ""), rootDeviceEnvironment) {}
|
||||
|
||||
bool mockReadSysmanQueryEngineInfo = false;
|
||||
bool mockReadSysmanQueryEngineInfoMultiDevice = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -69,6 +69,23 @@ class ZesEngineFixtureI915 : public ZesEngineFixture {
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenComponentCountZeroAndOpenCallFailsWhenCallingZesDeviceEnumEngineGroupsThenErrorIsReturned) {
|
||||
|
||||
MockEngineNeoDrm *pDrm = nullptr;
|
||||
int mockFd = -1;
|
||||
pDrm = new MockEngineNeoDrm(const_cast<NEO::RootDeviceEnvironment &>(pSysmanDeviceImp->getRootDeviceEnvironment()), mockFd);
|
||||
pDrm->setupIoctlHelper(pSysmanDeviceImp->getRootDeviceEnvironment().getHardwareInfo()->platform.eProductFamily);
|
||||
auto &osInterface = pSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
|
||||
osInterface->setDriverModel(std::unique_ptr<MockEngineNeoDrm>(pDrm));
|
||||
|
||||
pSysmanDeviceImp->pEngineHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = true;
|
||||
L0::Sysman::SysmanDevice *device = pSysmanDevice;
|
||||
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, zesDeviceEnumEngineGroups(device->toHandle(), &count, NULL));
|
||||
}
|
||||
|
||||
TEST_F(ZesEngineFixtureI915, GivenComponentCountZeroWhenCallingzesDeviceEnumEngineGroupsThenNonZeroCountIsReturnedAndVerifyCallSucceeds) {
|
||||
|
||||
uint32_t count = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -80,6 +80,23 @@ class ZesEngineFixture : public SysmanDeviceFixture {
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenComponentCountZeroAndOpenCallFailsWhenCallingZesDeviceEnumEngineGroupsThenErrorIsReturned) {
|
||||
|
||||
MockEngineNeoDrm *pDrm = nullptr;
|
||||
int mockFd = -1;
|
||||
pDrm = new MockEngineNeoDrm(const_cast<NEO::RootDeviceEnvironment &>(pSysmanDeviceImp->getRootDeviceEnvironment()), mockFd);
|
||||
pDrm->setupIoctlHelper(pSysmanDeviceImp->getRootDeviceEnvironment().getHardwareInfo()->platform.eProductFamily);
|
||||
auto &osInterface = pSysmanDeviceImp->getRootDeviceEnvironment().osInterface;
|
||||
osInterface->setDriverModel(std::unique_ptr<MockEngineNeoDrm>(pDrm));
|
||||
|
||||
pSysmanDeviceImp->pEngineHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = true;
|
||||
L0::Sysman::SysmanDevice *device = pSysmanDevice;
|
||||
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE, zesDeviceEnumEngineGroups(device->toHandle(), &count, NULL));
|
||||
}
|
||||
|
||||
TEST_F(ZesEngineFixture, GivenComponentCountZeroWhenCallingzesDeviceEnumEngineGroupsThenNonZeroCountIsReturnedAndVerifyCallSucceeds) {
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEnumEngineGroups(device->toHandle(), &count, NULL));
|
||||
@@ -94,6 +111,7 @@ TEST_F(ZesEngineFixture, GivenComponentCountZeroWhenCallingzesDeviceEnumEngineGr
|
||||
EXPECT_EQ(zesDeviceEnumEngineGroups(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, handleComponentCount);
|
||||
}
|
||||
|
||||
TEST_F(ZesEngineFixture, GivenValidEngineHandlesWhenCallingZesEngineGetPropertiesThenVerifyCallSucceeds) {
|
||||
zes_engine_properties_t properties;
|
||||
auto handles = getEngineHandles(handleComponentCount);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -68,11 +68,11 @@ TEST_F(SysmanDeviceEngineFixture, GivenComponentCountZeroWhenEnumeratingEngineGr
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceEngineFixture, GivenComponentCountZeroWhenEnumeratingEngineGroupsAndRequestMultipleFailsThenZeroHandlesAreReturned) {
|
||||
TEST_F(SysmanDeviceEngineFixture, GivenComponentCountZeroWhenEnumeratingEngineGroupsAndRequestMultipleFailsThenErrorAndZeroHandlesAreReturned) {
|
||||
pKmdSysManager->mockRequestMultiple = true;
|
||||
pKmdSysManager->mockRequestMultipleResult = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(zesDeviceEnumEngineGroups(pSysmanDevice->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(zesDeviceEnumEngineGroups(pSysmanDevice->toHandle(), &count, nullptr), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
EXPECT_EQ(count, 0u);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user