fix: Remove appropriate device on warm reset

Related-To: NEO-11926

Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
Bellekallu Rajkiran
2024-07-30 06:22:17 +00:00
committed by Compute-Runtime-Automation
parent afc1664fce
commit eadb7b5a66
12 changed files with 86 additions and 9 deletions

View File

@@ -135,6 +135,11 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryProperties(zes_mem_prope
return ZE_RESULT_SUCCESS;
}
template <>
bool SysmanProductHelperHw<gfxProduct>::isUpstreamPortConnected() {
return true;
}
template class SysmanProductHelperHw<gfxProduct>;
} // namespace Sysman

View File

@@ -96,6 +96,9 @@ class SysmanProductHelper {
// Ecc
virtual bool isEccConfigurationSupported() = 0;
// Device
virtual bool isUpstreamPortConnected() = 0;
virtual ~SysmanProductHelper() = default;
virtual const std::map<std::string, std::map<std::string, uint64_t>> *getGuidToKeyOffsetMap() = 0;

View File

@@ -71,6 +71,9 @@ class SysmanProductHelperHw : public SysmanProductHelper {
// Ecc
bool isEccConfigurationSupported() override;
// Device
bool isUpstreamPortConnected() override;
~SysmanProductHelperHw() override = default;
const std::map<std::string, std::map<std::string, uint64_t>> *getGuidToKeyOffsetMap() override;

View File

@@ -265,5 +265,10 @@ bool SysmanProductHelperHw<gfxProduct>::isEccConfigurationSupported() {
return false;
}
template <PRODUCT_FAMILY gfxProduct>
bool SysmanProductHelperHw<gfxProduct>::isUpstreamPortConnected() {
return false;
}
} // namespace Sysman
} // namespace L0

View File

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

View File

@@ -430,6 +430,11 @@ bool SysmanProductHelperHw<gfxProduct>::isDiagnosticsSupported() {
return true;
}
template <>
bool SysmanProductHelperHw<gfxProduct>::isUpstreamPortConnected() {
return true;
}
template class SysmanProductHelperHw<gfxProduct>;
} // namespace Sysman

View File

@@ -203,6 +203,11 @@ bool SysmanProductHelperHw<gfxProduct>::isEccConfigurationSupported() {
return true;
}
template <>
bool SysmanProductHelperHw<gfxProduct>::isUpstreamPortConnected() {
return true;
}
template class SysmanProductHelperHw<gfxProduct>;
} // namespace Sysman

View File

@@ -421,8 +421,14 @@ ze_result_t LinuxSysmanImp::osWarmReset() {
return ZE_RESULT_ERROR_UNKNOWN;
}
std::string cardBusPath = getPciCardBusDirectoryPath(gtDevicePath);
ze_result_t result = pFsAccess->write(cardBusPath + '/' + "remove", "1");
std::string devicePath = {};
if (pSysmanProductHelper->isUpstreamPortConnected()) {
devicePath = getPciCardBusDirectoryPath(gtDevicePath);
} else {
devicePath = gtDevicePath;
}
ze_result_t result = pFsAccess->write(devicePath + '/' + "remove", "1");
if (ZE_RESULT_SUCCESS != result) {
return result;
}
@@ -469,7 +475,7 @@ ze_result_t LinuxSysmanImp::osWarmReset() {
return result;
}
result = pFsAccess->write(cardBusPath + '/' + "remove", "1");
result = pFsAccess->write(devicePath + '/' + "remove", "1");
if (ZE_RESULT_SUCCESS != result) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stdout,
"Card Bus remove after resizing VF bar failed\n");
@@ -495,11 +501,11 @@ std::string LinuxSysmanImp::getAddressFromPath(std::string &rootPortPath) {
}
ze_result_t LinuxSysmanImp::osColdReset() {
const std::string slotPath("/sys/bus/pci/slots/"); // holds the directories matching to the number of slots in the PC
std::string cardBusPath; // will hold the PCIe Root port directory path (the address of the PCIe slot).
// will hold the absolute real path (not symlink) to the selected Device
cardBusPath = getPciCardBusDirectoryPath(gtDevicePath); // e.g cardBusPath=/sys/devices/pci0000:89/0000:89:02.0/
std::string rootAddress = getAddressFromPath(cardBusPath); // e.g rootAddress = 0000:8a:00.0
const std::string slotPath("/sys/bus/pci/slots/"); // holds the directories matching to the number of slots in the PC
std::string cardBusPath; // will hold the PCIe upstream port path (the address of the PCIe slot).
// will hold the absolute real path (not symlink) to the selected Device
cardBusPath = getPciCardBusDirectoryPath(gtDevicePath); // e.g cardBusPath=/sys/devices/pci0000:89/0000:89:02.0/
std::string uspAddress = getAddressFromPath(cardBusPath); // e.g upstreamPortAddress = 0000:8a:00.0
std::vector<std::string> dir;
ze_result_t result = pFsAccess->listDirectory(slotPath, dir); // get list of slot directories from /sys/bus/pci/slots/
@@ -512,7 +518,7 @@ ze_result_t LinuxSysmanImp::osColdReset() {
if (ZE_RESULT_SUCCESS != result) {
return result;
}
if (slotAddress.compare(rootAddress) == 0) { // compare slot address to root port address
if (slotAddress.compare(uspAddress) == 0) { // compare slot address to upstream port address
result = pFsAccess->write((slotPath + slot + "/power"), "0"); // turn off power
if (ZE_RESULT_SUCCESS != result) {
return result;

View File

@@ -15,6 +15,7 @@
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
#include "level_zero/sysman/test/unit_tests/sources/global_operations/linux/mock_global_operations.h"
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
#include "level_zero/sysman/test/unit_tests/sources/linux/mocks/mock_sysman_product_helper.h"
#include "level_zero/sysman/test/unit_tests/sources/shared/linux/kmd_interface/mock_sysman_kmd_interface_i915.h"
#include <fcntl.h>
@@ -838,6 +839,10 @@ TEST_F(SysmanGlobalOperationsFixture, GivenGemCreateIoctlFailsWithEINVALWhenCall
TEST_F(SysmanGlobalOperationsFixture, GivenDeviceInUseWhenCallingzesDeviceResetExtThenResetExtCallReturnSuccess) {
init(true);
std::unique_ptr<SysmanProductHelper> pSysmanProductHelper = std::make_unique<MockSysmanProductHelper>();
std::swap(pLinuxSysmanImp->pSysmanProductHelper, pSysmanProductHelper);
DebugManagerStateRestore dbgRestore;
debugManager.flags.VfBarResourceAllocationWa.set(false);
zes_reset_properties_t pProperties = {.stype = ZES_STRUCTURE_TYPE_RESET_PROPERTIES, .pNext = nullptr, .force = true, .resetType = ZES_RESET_TYPE_WARM};

View File

@@ -27,6 +27,7 @@ struct MockSysmanProductHelper : public L0::Sysman::SysmanProductHelperHw<IGFX_U
std::map<std::string, std::map<std::string, uint64_t>> *getGuidToKeyOffsetMap() override { return &mockGuidToKeyOffsetMap; }
ADDMETHOD_NOBASE(isFrequencySetRangeSupported, bool, false, ());
ADDMETHOD_NOBASE(isPowerSetLimitSupported, bool, false, ());
ADDMETHOD_NOBASE(isUpstreamPortConnected, bool, true, ());
};
} // namespace ult

View File

@@ -15,6 +15,7 @@ if(UNIX)
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_ras_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_power_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_pmt_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_device_tests.cpp
)
endif()
add_subdirectories()

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#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 HasUpstreamPort = IsAnyProducts<IGFX_PVC,
IGFX_BMG,
IGFX_DG1,
IGFX_DG2>;
using SysmanProductHelperDeviceTest = SysmanDeviceFixture;
HWTEST2_F(SysmanProductHelperDeviceTest, GivenValidProductHelperHandleWhenQueryingForUpstreamPortConnectivityThenVerifyUpstreamPortIsConnected, HasUpstreamPort) {
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
EXPECT_TRUE(pSysmanProductHelper->isUpstreamPortConnected());
}
HWTEST2_F(SysmanProductHelperDeviceTest, GivenValidProductHelperHandleWhenQueryingForUpstreamPortConnectivityThenVerifyUpstreamPortIsNotConnected, IsMTL) {
auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily);
EXPECT_FALSE(pSysmanProductHelper->isUpstreamPortConnected());
}
} // namespace ult
} // namespace Sysman
} // namespace L0