mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 01:35:20 +08:00
Sysman: cleanup execution env referrals
convert the present system of calling Inc/Dec of execution environment to a more elegant solution Resolves: LOCI-3165 Signed-off-by: Vilvaraj, T J Vivek <t.j.vivek.vilvaraj@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
81899c4477
commit
973bcb9dbc
@@ -118,6 +118,7 @@ ze_result_t LinuxDiagnosticsImp::osRunDiagTestsinFW(zes_diag_result_t *pResult)
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (*pResult == ZES_DIAG_RESULT_REBOOT_FOR_REPAIR) {
|
||||
result = pLinuxSysmanImp->osColdReset();
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
|
||||
@@ -118,7 +118,7 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) {
|
||||
|
||||
result = pProcfsAccess->listProcesses(processes);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
executionEnvironment->decRefInternal();
|
||||
|
||||
return result;
|
||||
}
|
||||
for (auto &&pid : processes) {
|
||||
@@ -134,7 +134,7 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) {
|
||||
} else {
|
||||
// Device is in use by another process.
|
||||
// Don't reset while in use.
|
||||
executionEnvironment->decRefInternal();
|
||||
|
||||
return ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE;
|
||||
}
|
||||
}
|
||||
@@ -146,14 +146,14 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) {
|
||||
if (!(deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_INTEGRATED)) {
|
||||
result = pSysfsAccess->unbindDevice(resetName);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
executionEnvironment->decRefInternal();
|
||||
|
||||
return result;
|
||||
}
|
||||
result = pLinuxSysmanImp->osWarmReset();
|
||||
if (ZE_RESULT_SUCCESS == result) {
|
||||
return pLinuxSysmanImp->initDevice();
|
||||
}
|
||||
executionEnvironment->decRefInternal();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) {
|
||||
// Unbind the device from the kernel driver.
|
||||
result = pSysfsAccess->unbindDevice(resetName);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
executionEnvironment->decRefInternal();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) {
|
||||
// after we check, kill them here.
|
||||
result = pProcfsAccess->listProcesses(processes);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
executionEnvironment->decRefInternal();
|
||||
|
||||
return result;
|
||||
}
|
||||
std::vector<::pid_t> deviceUsingPids;
|
||||
@@ -204,7 +204,7 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) {
|
||||
for (auto &&pid : deviceUsingPids) {
|
||||
while (pProcfsAccess->isAlive(pid)) {
|
||||
if (std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() > resetTimeout) {
|
||||
executionEnvironment->decRefInternal();
|
||||
|
||||
return ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE;
|
||||
}
|
||||
|
||||
@@ -217,14 +217,14 @@ ze_result_t LinuxGlobalOperationsImp::reset(ze_bool_t force) {
|
||||
// Reset the device.
|
||||
result = pFsAccess->write(resetPath, "1");
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
executionEnvironment->decRefInternal();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Rebind the device to the kernel driver.
|
||||
result = pSysfsAccess->bindDevice(resetName);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
executionEnvironment->decRefInternal();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -409,7 +409,6 @@ LinuxGlobalOperationsImp::LinuxGlobalOperationsImp(OsSysman *pOsSysman) {
|
||||
pDevice = pLinuxSysmanImp->getDeviceHandle();
|
||||
auto device = static_cast<DeviceImp *>(pDevice);
|
||||
devicePciBdf = device->getNEODevice()->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>()->getPciPath();
|
||||
executionEnvironment = device->getNEODevice()->getExecutionEnvironment();
|
||||
rootDeviceIndex = device->getNEODevice()->getRootDeviceIndex();
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ void LinuxSysmanImp::releaseDeviceResources() {
|
||||
devicePciBdf = devicePtr->getNEODevice()->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>()->getPciPath();
|
||||
rootDeviceIndex = devicePtr->getNEODevice()->getRootDeviceIndex();
|
||||
|
||||
executionEnvironment->incRefInternal();
|
||||
restorer = std::make_unique<ExecutionEnvironmentRefCountRestore>(executionEnvironment);
|
||||
releaseSysmanDeviceResources();
|
||||
auto device = static_cast<DeviceImp *>(getDeviceHandle());
|
||||
executionEnvironment = device->getNEODevice()->getExecutionEnvironment();
|
||||
@@ -302,7 +302,6 @@ ze_result_t LinuxSysmanImp::initDevice() {
|
||||
|
||||
auto neoDevice = NEO::DeviceFactory::createDevice(*executionEnvironment, devicePciBdf, rootDeviceIndex);
|
||||
if (neoDevice == nullptr) {
|
||||
executionEnvironment->decRefInternal();
|
||||
return ZE_RESULT_ERROR_DEVICE_LOST;
|
||||
}
|
||||
static_cast<L0::DriverHandleImp *>(device->getDriverHandle())->updateRootDeviceBitFields(neoDevice);
|
||||
@@ -310,8 +309,6 @@ ze_result_t LinuxSysmanImp::initDevice() {
|
||||
Device::deviceReinit(device->getDriverHandle(), device, neoDevice, &result);
|
||||
reInitSysmanDeviceResources();
|
||||
|
||||
executionEnvironment->decRefInternal();
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,19 @@ namespace L0 {
|
||||
|
||||
class PmuInterface;
|
||||
|
||||
class ExecutionEnvironmentRefCountRestore {
|
||||
public:
|
||||
ExecutionEnvironmentRefCountRestore() = delete;
|
||||
ExecutionEnvironmentRefCountRestore(NEO::ExecutionEnvironment *executionEnvironmentRecevied) {
|
||||
executionEnvironment = executionEnvironmentRecevied;
|
||||
executionEnvironment->incRefInternal();
|
||||
}
|
||||
~ExecutionEnvironmentRefCountRestore() {
|
||||
executionEnvironment->decRefInternal();
|
||||
}
|
||||
NEO::ExecutionEnvironment *executionEnvironment = nullptr;
|
||||
};
|
||||
|
||||
class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
LinuxSysmanImp(SysmanDeviceImp *pParentSysmanDeviceImp);
|
||||
@@ -66,6 +79,7 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
|
||||
uint32_t rootDeviceIndex = 0u;
|
||||
NEO::ExecutionEnvironment *executionEnvironment = nullptr;
|
||||
bool diagnosticsReset = false;
|
||||
std::unique_ptr<ExecutionEnvironmentRefCountRestore> restorer;
|
||||
|
||||
protected:
|
||||
FsAccess *pFsAccess = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user