fix(sysman): Fix sysman APIs taking incorrect path

Related-To: NEO-12291

Signed-off-by: shubham kumar <shubham.kumar@intel.com>
This commit is contained in:
shubham kumar
2024-08-12 13:33:15 +00:00
committed by Compute-Runtime-Automation
parent 32f80e1131
commit 739e781fd8
3 changed files with 29 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Intel Corporation
* Copyright (C) 2023-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -12,6 +12,7 @@
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h"
#include "level_zero/core/source/driver/driver.h"
#include "level_zero/sysman/source/device/sysman_device.h"
#include "level_zero/sysman/source/driver/sysman_driver_handle.h"
#include "level_zero/sysman/source/driver/sysman_driver_handle_imp.h"
@@ -331,6 +332,14 @@ TEST_F(SysmanDriverHandleTest,
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result);
}
TEST(SysmanDriverInit, GivenValidSysmanImpObjectWhenCallingInitWithSysmanInitFromCoreSetAsTrueThenSysmanInitFails) {
L0::sysmanInitFromCore = true;
std::unique_ptr<SysmanDriverImp> pSysmanDriverImp = std::make_unique<SysmanDriverImp>();
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, pSysmanDriverImp->driverInit(0));
EXPECT_FALSE(L0::Sysman::sysmanOnlyInit);
L0::sysmanInitFromCore = false;
}
} // namespace ult
} // namespace Sysman
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -13,6 +13,7 @@
#include "level_zero/core/source/device/device_imp.h"
#include "level_zero/core/source/driver/driver.h"
#include "level_zero/core/source/driver/driver_handle_imp.h"
#include "level_zero/sysman/source/driver/sysman_driver.h"
#include "level_zero/tools/source/sysman/os_sysman_driver.h"
#include "level_zero/tools/source/sysman/sysman_imp.h"
@@ -34,6 +35,12 @@ void DeviceImp::createSysmanHandle(bool isSubDevice) {
}
SysmanDevice *SysmanDeviceHandleContext::init(ze_device_handle_t coreDevice) {
if (L0::Sysman::sysmanOnlyInit) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr,
"%s", "Sysman Initialization already happened via zesInit\n");
return nullptr;
}
SysmanDeviceImp *sysmanDevice = new SysmanDeviceImp(coreDevice);
DEBUG_BREAK_IF(!sysmanDevice);
if (ZE_RESULT_SUCCESS != sysmanDevice->init()) {

View File

@@ -11,6 +11,7 @@
#include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h"
#include "shared/test/common/test_macros/test.h"
#include "level_zero/sysman/source/driver/sysman_driver.h"
#include "level_zero/tools/source/sysman/diagnostics/linux/os_diagnostics_imp.h"
#include "level_zero/tools/source/sysman/events/linux/os_events_imp.h"
#include "level_zero/tools/source/sysman/firmware/linux/os_firmware_imp.h"
@@ -216,6 +217,16 @@ TEST_F(SysmanDeviceFixture, GivenValidDeviceHandleButSysmanInitFailsThenValidNul
EXPECT_EQ(pSysmanDevice, nullptr);
}
TEST_F(SysmanDeviceFixture, GivenValidDeviceHandleWithSysmanOnlyInitSetAsTrueThenSysmanInitFailsAndValidNullptrReceived) {
ze_device_handle_t hSysman = device->toHandle();
L0::Sysman::sysmanOnlyInit = true;
L0::sysmanInitFromCore = false;
auto pSysmanDevice = L0::SysmanDeviceHandleContext::init(hSysman);
EXPECT_EQ(pSysmanDevice, nullptr);
EXPECT_FALSE(L0::sysmanInitFromCore);
L0::Sysman::sysmanOnlyInit = false;
}
TEST_F(SysmanDeviceFixture, GivenSetValidDrmHandleForDeviceWhenDoingOsSysmanDeviceInitThenSameDrmHandleIsRetrieved) {
EXPECT_EQ(&pLinuxSysmanImp->getDrm(), device->getOsInterface().getDriverModel()->as<Drm>());
}