mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-27 07:44:16 +08:00
This patch does the following: - Fixes a bug in FsAccess::listDirectory that could return ZE_RESULT_UNKNOWN_ERROR when no error has occurred. - Fixes a bug in zesDeviceReset that would reset the device if force was set to false, even if the device was in use. - Fixes a bug in zesDeviceReset that would reset the device if force was set to false without closing the file descriptor. - Added a releaseResources method method to Device object. This method does the same thing as the DeviceImp destructor except it does not free the DeviceImp object and it does not free the SysmanDeviceImp object. - Added the releaseResources methods to Mock<Device> object. - Moved the reset of the debugger out of DriverHandleImp destructor and into DeviceImp releaseResources. - Added a releaseEngine method to the EngineHandleContext. This method frees all the Engine handles. - On reset, I call the Devcie->releaseResources and EngineHandleContext->releaseEngines before resetting the device. - Added a -r (--reset) option to zello_sysman so I could easily test resets. With these patches, the L0 Sysman CTS for zesDeviceReset both pass. Change-Id: I31fad1b27bc5cc6befe31cd6f9319748e2683424
63 lines
1.8 KiB
C++
63 lines
1.8 KiB
C++
/*
|
|
* Copyright (C) 2020 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "level_zero/tools/source/sysman/engine/engine.h"
|
|
|
|
#include "shared/source/helpers/basic_math.h"
|
|
#include "shared/source/helpers/debug_helpers.h"
|
|
|
|
#include "level_zero/tools/source/sysman/engine/engine_imp.h"
|
|
class OsEngine;
|
|
namespace L0 {
|
|
|
|
EngineHandleContext::EngineHandleContext(OsSysman *pOsSysman) {
|
|
this->pOsSysman = pOsSysman;
|
|
}
|
|
|
|
EngineHandleContext::~EngineHandleContext() {
|
|
releaseEngines();
|
|
}
|
|
|
|
void EngineHandleContext::createHandle(zes_engine_group_t engineType, uint32_t engineInstance) {
|
|
Engine *pEngine = new EngineImp(pOsSysman, engineType, engineInstance);
|
|
handleList.push_back(pEngine);
|
|
}
|
|
|
|
void EngineHandleContext::init() {
|
|
std::multimap<zes_engine_group_t, uint32_t> engineGroupInstance = {};
|
|
ze_result_t status = OsEngine::getNumEngineTypeAndInstances(engineGroupInstance, pOsSysman);
|
|
if (status != ZE_RESULT_SUCCESS) {
|
|
return;
|
|
}
|
|
for (auto itr = engineGroupInstance.begin(); itr != engineGroupInstance.end(); ++itr) {
|
|
createHandle(itr->first, itr->second);
|
|
}
|
|
}
|
|
|
|
void EngineHandleContext::releaseEngines() {
|
|
for (Engine *pEngine : handleList) {
|
|
delete pEngine;
|
|
}
|
|
handleList.clear();
|
|
}
|
|
|
|
ze_result_t EngineHandleContext::engineGet(uint32_t *pCount, zes_engine_handle_t *phEngine) {
|
|
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
|
|
uint32_t numToCopy = std::min(*pCount, handleListSize);
|
|
if (0 == *pCount || *pCount > handleListSize) {
|
|
*pCount = handleListSize;
|
|
}
|
|
if (nullptr != phEngine) {
|
|
for (uint32_t i = 0; i < numToCopy; i++) {
|
|
phEngine[i] = handleList[i]->toHandle();
|
|
}
|
|
}
|
|
return ZE_RESULT_SUCCESS;
|
|
}
|
|
|
|
} // namespace L0
|