feature: fix for zesInit path

Allow zesInit when platform is LNL, BMG
and legacy path of sysman is initialized

Related-To: NEO-13295

Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
Kulkarni, Ashwin Kumar 2024-11-27 09:28:53 +00:00 committed by Compute-Runtime-Automation
parent f86d2cee41
commit db7e023452
17 changed files with 187 additions and 8 deletions

View File

@ -28,12 +28,6 @@ bool sysmanOnlyInit = false;
void SysmanDriverImp::initialize(ze_result_t *result) {
*result = ZE_RESULT_ERROR_UNINITIALIZED;
if (sysmanInitFromCore) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr,
"%s", "Sysman Initialization already happened via zeInit\n");
return;
}
auto executionEnvironment = new NEO::ExecutionEnvironment();
UNRECOVERABLE_IF(nullptr == executionEnvironment);
executionEnvironment->incRefInternal();

View File

@ -95,6 +95,7 @@ class SysmanProductHelper {
// Device
virtual bool isUpstreamPortConnected() = 0;
virtual bool isZesInitSupported() = 0;
// Pci
virtual ze_result_t getPciProperties(zes_pci_properties_t *pProperties) = 0;

View File

@ -70,6 +70,7 @@ class SysmanProductHelperHw : public SysmanProductHelper {
// Device
bool isUpstreamPortConnected() override;
bool isZesInitSupported() override;
// Pci
ze_result_t getPciProperties(zes_pci_properties_t *pProperties) override;

View File

@ -315,5 +315,10 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getPciStats(zes_pci_stats_t *pSta
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
};
template <PRODUCT_FAMILY gfxProduct>
bool SysmanProductHelperHw<gfxProduct>::isZesInitSupported() {
return false;
}
} // namespace Sysman
} // namespace L0

View File

@ -655,6 +655,11 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandwidth(zes_mem_bandwi
return ZE_RESULT_SUCCESS;
}
template <>
bool SysmanProductHelperHw<gfxProduct>::isZesInitSupported() {
return true;
}
template class SysmanProductHelperHw<gfxProduct>;
} // namespace Sysman

View File

@ -24,6 +24,11 @@ RasInterfaceType SysmanProductHelperHw<gfxProduct>::getHbmRasUtilInterface() {
return RasInterfaceType::netlink;
}
template <>
bool SysmanProductHelperHw<gfxProduct>::isZesInitSupported() {
return true;
}
template class SysmanProductHelperHw<gfxProduct>;
} // namespace Sysman

View File

@ -18,6 +18,7 @@
#include "shared/source/os_interface/linux/system_info.h"
#include "shared/source/os_interface/os_interface.h"
#include "level_zero/core/source/driver/driver.h"
#include "level_zero/sysman/source/api/pci/linux/sysman_os_pci_imp.h"
#include "level_zero/sysman/source/api/pci/sysman_pci_utils.h"
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
@ -45,6 +46,16 @@ ze_result_t LinuxSysmanImp::init() {
pSysmanProductHelper = SysmanProductHelper::create(getProductFamily());
DEBUG_BREAK_IF(nullptr == pSysmanProductHelper);
if (sysmanInitFromCore) {
if (pSysmanProductHelper->isZesInitSupported()) {
sysmanInitFromCore = false;
} else {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr,
"%s", "Sysman Initialization already happened via zeInit\n");
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
}
pSysmanKmdInterface = SysmanKmdInterface::create(*getDrm(), pSysmanProductHelper.get());
auto result = pSysmanKmdInterface->initFsAccessInterface(*getDrm());
if (result != ZE_RESULT_SUCCESS) {

View File

@ -64,6 +64,9 @@ class SysmanProductHelper {
// Pmt
virtual std::map<unsigned long, std::map<std::string, uint32_t>> *getGuidToKeyOffsetMap() = 0;
// init
virtual bool isZesInitSupported() = 0;
protected:
SysmanProductHelper() = default;
};

View File

@ -44,6 +44,9 @@ class SysmanProductHelperHw : public SysmanProductHelper {
// Pmt
std::map<unsigned long, std::map<std::string, uint32_t>> *getGuidToKeyOffsetMap() override;
// init
bool isZesInitSupported() override;
protected:
SysmanProductHelperHw() = default;
};

View File

@ -301,5 +301,10 @@ std::map<unsigned long, std::map<std::string, uint32_t>> *SysmanProductHelperHw<
return nullptr;
}
template <PRODUCT_FAMILY gfxProduct>
bool SysmanProductHelperHw<gfxProduct>::isZesInitSupported() {
return false;
}
} // namespace Sysman
} // namespace L0

View File

@ -1089,6 +1089,11 @@ std::map<unsigned long, std::map<std::string, uint32_t>> *SysmanProductHelperHw<
return &guidToKeyOffsetMap;
}
template <>
bool SysmanProductHelperHw<gfxProduct>::isZesInitSupported() {
return true;
}
template class SysmanProductHelperHw<gfxProduct>;
} // namespace Sysman

View File

@ -12,6 +12,11 @@ namespace L0 {
namespace Sysman {
constexpr static auto gfxProduct = IGFX_LUNARLAKE;
template <>
bool SysmanProductHelperHw<gfxProduct>::isZesInitSupported() {
return true;
}
template class SysmanProductHelperHw<gfxProduct>;
} // namespace Sysman

View File

@ -11,6 +11,7 @@
#include "shared/source/os_interface/driver_info.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
#include "level_zero/core/source/driver/driver.h"
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util.h"
#include "level_zero/sysman/source/shared/windows/pmt/sysman_pmt.h"
#include "level_zero/sysman/source/shared/windows/product_helper/sysman_product_helper.h"
@ -41,6 +42,16 @@ ze_result_t WddmSysmanImp::init() {
pSysmanProductHelper = SysmanProductHelper::create(getProductFamily());
DEBUG_BREAK_IF(nullptr == pSysmanProductHelper);
if (sysmanInitFromCore) {
if (pSysmanProductHelper->isZesInitSupported()) {
sysmanInitFromCore = false;
} else {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr,
"%s", "Sysman Initialization already happened via zeInit\n");
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
}
pPmt = PlatformMonitoringTech::create(pSysmanProductHelper.get());
return ZE_RESULT_SUCCESS;

View File

@ -17,6 +17,7 @@ if(UNIX)
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_pmt_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_device_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_pci_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_init_tests.cpp
)
endif()
add_subdirectories()
add_subdirectories()

View File

@ -0,0 +1,88 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/mocks/mock_driver_model.h"
#include "shared/test/common/test_macros/hw_test.h"
#include "level_zero/core/source/driver/driver.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
namespace L0 {
namespace Sysman {
namespace ult {
using HasZesInitSupport = IsAnyProducts<IGFX_LUNARLAKE,
IGFX_BMG>;
using SysmanProductHelperSysmanInitTest = SysmanDeviceFixture;
HWTEST2_F(SysmanProductHelperSysmanInitTest, GivenValidProductHelperHandleWhenQueryingForZesInitSupportThenTrueIsReturned, IsLNL) {
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
EXPECT_TRUE(pSysmanProductHelper->isZesInitSupported());
}
HWTEST2_F(SysmanProductHelperSysmanInitTest, GivenValidProductHelperHandleWhenQueryingForZesInitSupportThenTrueIsReturned, IsBMG) {
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
EXPECT_TRUE(pSysmanProductHelper->isZesInitSupported());
}
HWTEST2_F(SysmanProductHelperSysmanInitTest, GivenValidProductHelperHandleWhenQueryingForZesInitSupportThenFalseIsReturned, IsPVC) {
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
EXPECT_FALSE(pSysmanProductHelper->isZesInitSupported());
}
class SysmanNewPlatformInitTest : public ::testing::Test {
public:
void SetUp() override{};
void TearDown() override{};
};
HWTEST2_F(SysmanNewPlatformInitTest, GivenLegacySysmanVariableSetWhenSysmanInitOnLinuxIsCalledThenUnSupportedErrorIsReturned, IsPVC) {
L0::sysmanInitFromCore = true;
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
hwInfo.capabilityTable.levelZeroSupported = true;
auto execEnv = new NEO::ExecutionEnvironment();
execEnv->prepareRootDeviceEnvironments(1);
execEnv->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(NEO::defaultHwInfo.get());
execEnv->rootDeviceEnvironments[0]->osInterface = std::make_unique<NEO::OSInterface>();
execEnv->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::make_unique<NEO::MockDriverModelDRM>());
auto pSysmanDeviceImp = std::make_unique<L0::Sysman::SysmanDeviceImp>(execEnv, 0);
auto pLinuxSysmanImp = static_cast<PublicLinuxSysmanImp *>(pSysmanDeviceImp->pOsSysman);
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxSysmanImp->init());
L0::sysmanInitFromCore = false;
}
HWTEST2_F(SysmanNewPlatformInitTest, GivenLegacySysmanVariableSetWhenSysmanInitOnLinuxIsCalledThenSuccessIsReturned, IsBMG) {
VariableBackup<decltype(NEO::SysCalls::sysCallsRealpath)> mockRealPath(&NEO::SysCalls::sysCallsRealpath, [](const char *path, char *buf) -> char * {
constexpr size_t sizeofPath = sizeof("/sys/devices/pci0000:00/0000:00:02.0");
strcpy_s(buf, sizeofPath, "/sys/devices/pci0000:00/0000:00:02.0");
return buf;
});
VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::string str = "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128";
std::memcpy(buf, str.c_str(), str.size());
return static_cast<int>(str.size());
});
L0::sysmanInitFromCore = true;
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
hwInfo.capabilityTable.levelZeroSupported = true;
auto execEnv = new NEO::ExecutionEnvironment();
execEnv->prepareRootDeviceEnvironments(1);
execEnv->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(NEO::defaultHwInfo.get());
execEnv->rootDeviceEnvironments[0]->osInterface = std::make_unique<NEO::OSInterface>();
execEnv->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::make_unique<SysmanMockDrm>(*execEnv->rootDeviceEnvironments[0]));
auto pSysmanDeviceImp = std::make_unique<L0::Sysman::SysmanDeviceImp>(execEnv, 0);
auto pLinuxSysmanImp = static_cast<PublicLinuxSysmanImp *>(pSysmanDeviceImp->pOsSysman);
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxSysmanImp->init());
EXPECT_FALSE(L0::sysmanInitFromCore);
}
} // namespace ult
} // namespace Sysman
} // namespace L0

View File

@ -11,6 +11,7 @@ if(WIN32)
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_temperature_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_memory_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_power_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_init_tests.cpp
)
endif()
add_subdirectories()
add_subdirectories()

View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/test_macros/hw_test.h"
#include "level_zero/sysman/source/shared/windows/product_helper/sysman_product_helper.h"
#include "level_zero/sysman/test/unit_tests/sources/windows/mock_sysman_fixture.h"
namespace L0 {
namespace Sysman {
namespace ult {
using SysmanProductHelperSysmanInitTest = SysmanDeviceFixture;
HWTEST2_F(SysmanProductHelperSysmanInitTest, GivenValidProductHelperHandleWhenQueryingForZesInitSupportThenTrueIsReturned, IsLNL) {
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
EXPECT_TRUE(pSysmanProductHelper->isZesInitSupported());
}
HWTEST2_F(SysmanProductHelperSysmanInitTest, GivenValidProductHelperHandleWhenQueryingForZesInitSupportThenTrueIsReturned, IsBMG) {
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
EXPECT_TRUE(pSysmanProductHelper->isZesInitSupported());
}
HWTEST2_F(SysmanProductHelperSysmanInitTest, GivenValidProductHelperHandleWhenQueryingForZesInitSupportThenFalseIsReturned, IsPVC) {
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
EXPECT_FALSE(pSysmanProductHelper->isZesInitSupported());
}
} // namespace ult
} // namespace Sysman
} // namespace L0