diff --git a/level_zero/sysman/source/api/memory/linux/sysman_os_memory_imp_prelim.cpp b/level_zero/sysman/source/api/memory/linux/sysman_os_memory_imp_prelim.cpp index 268fbeb2a2..068ebca47f 100644 --- a/level_zero/sysman/source/api/memory/linux/sysman_os_memory_imp_prelim.cpp +++ b/level_zero/sysman/source/api/memory/linux/sysman_os_memory_imp_prelim.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -47,9 +47,9 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) { ze_result_t status = ZE_RESULT_SUCCESS; pState->health = ZES_MEM_HEALTH_UNKNOWN; FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface(); - if (pFwInterface != nullptr) { - pFwInterface->fwGetMemoryHealthIndicator(&pState->health); - } + // get memory health indicator if supported + auto pSysmanProductHelper = pLinuxSysmanImp->getSysmanProductHelper(); + pSysmanProductHelper->getMemoryHealthIndicator(pFwInterface, &pState->health); std::unique_ptr memoryInfo; { diff --git a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h index 5f50575e5d..6521985c77 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h +++ b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h @@ -52,6 +52,7 @@ class SysmanProductHelper { // Memory virtual ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, LinuxSysmanImp *pLinuxSysmanImp, NEO::Drm *pDrm, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subDeviceId, bool isSubdevice) = 0; virtual ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, PlatformMonitoringTech *pPmt, SysmanDeviceImp *pDevice, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subdeviceId) = 0; + virtual void getMemoryHealthIndicator(FirmwareUtil *pFwInterface, zes_mem_health_t *health) = 0; // Performance virtual void getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) = 0; diff --git a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h index f7fa907c72..32dacac059 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h +++ b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h @@ -29,6 +29,7 @@ class SysmanProductHelperHw : public SysmanProductHelper { // Memory ze_result_t getMemoryProperties(zes_mem_properties_t *pProperties, LinuxSysmanImp *pLinuxSysmanImp, NEO::Drm *pDrm, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subDeviceId, bool isSubdevice) override; ze_result_t getMemoryBandwidth(zes_mem_bandwidth_t *pBandwidth, PlatformMonitoringTech *pPmt, SysmanDeviceImp *pDevice, SysmanKmdInterface *pSysmanKmdInterface, uint32_t subdeviceId) override; + void getMemoryHealthIndicator(FirmwareUtil *pFwInterface, zes_mem_health_t *health) override; // Performance void getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) override; diff --git a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl index fe82e8aab6..b4b55c9016 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl +++ b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl @@ -92,6 +92,11 @@ ze_result_t SysmanProductHelperHw::getMemoryBandwidth(zes_mem_bandwi return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } +template +void SysmanProductHelperHw::getMemoryHealthIndicator(FirmwareUtil *pFwInterface, zes_mem_health_t *health) { + *health = ZES_MEM_HEALTH_UNKNOWN; +} + template void SysmanProductHelperHw::getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) { if (performanceFactor > halfOfMaxPerformanceFactor) { diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp b/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp index 5f2c148147..5a09edc9c8 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp +++ b/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp @@ -190,6 +190,14 @@ ze_result_t SysmanProductHelperHw::getMemoryBandwidth(zes_mem_bandwi return getHBMBandwidth(pBandwidth, pPmt, pDevice, pSysmanKmdInterface, subdeviceId); } +template <> +void SysmanProductHelperHw::getMemoryHealthIndicator(FirmwareUtil *pFwInterface, zes_mem_health_t *health) { + *health = ZES_MEM_HEALTH_UNKNOWN; + if (pFwInterface != nullptr) { + pFwInterface->fwGetMemoryHealthIndicator(health); + } +} + template <> void SysmanProductHelperHw::getMediaPerformanceFactorMultiplier(const double performanceFactor, double *pMultiplier) { if (performanceFactor > halfOfMaxPerformanceFactor) { diff --git a/level_zero/sysman/test/unit_tests/sources/memory/linux/test_sysman_memory_prelim.cpp b/level_zero/sysman/test/unit_tests/sources/memory/linux/test_sysman_memory_prelim.cpp index 9cf4d8a357..72c1040774 100644 --- a/level_zero/sysman/test/unit_tests/sources/memory/linux/test_sysman_memory_prelim.cpp +++ b/level_zero/sysman/test/unit_tests/sources/memory/linux/test_sysman_memory_prelim.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -269,7 +269,22 @@ HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZesMemoryG } } -TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceeds) { +HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZesMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsUnknown, IsNotPVC) { + + auto handles = getMemoryHandles(memoryHandleComponentCount); + + for (auto handle : handles) { + ASSERT_NE(nullptr, handle); + zes_mem_state_t state; + ze_result_t result = zesMemoryGetState(handle, &state); + EXPECT_EQ(result, ZE_RESULT_SUCCESS); + EXPECT_EQ(state.health, ZES_MEM_HEALTH_UNKNOWN); + EXPECT_EQ(state.size, NEO::probedSizeRegionOne); + EXPECT_EQ(state.free, NEO::unallocatedSizeRegionOne); + } +} + +HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZesMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsOK, IsPVC) { auto handles = getMemoryHandles(memoryHandleComponentCount); for (auto handle : handles) { @@ -317,7 +332,42 @@ TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemo } } -TEST_F(SysmanDeviceMemoryFixture, GivenSysmanResourcesAreReleasedAndReInitializedWhenCallingZesSysmanMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceeds) { +HWTEST2_F(SysmanDeviceMemoryFixture, GivenSysmanResourcesAreReleasedAndReInitializedWhenCallingZesMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsUnknown, IsNotPVC) { + pLinuxSysmanImp->releaseSysmanDeviceResources(); + EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxSysmanImp->reInitSysmanDeviceResources()); + + VariableBackup> pmtBackup(&pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject); + pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear(); + auto subdeviceId = 0u; + auto subDeviceCount = pLinuxSysmanImp->getSubDeviceCount(); + do { + auto pPmt = new MockMemoryPmt(); + pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(subdeviceId, pPmt); + } while (++subdeviceId < subDeviceCount); + + VariableBackup backup(&pLinuxSysmanImp->pFwUtilInterface); + pLinuxSysmanImp->pFwUtilInterface = new MockFwUtilInterface(); + + auto handles = getMemoryHandles(memoryHandleComponentCount); + + for (auto handle : handles) { + ASSERT_NE(nullptr, handle); + zes_mem_state_t state; + + ze_result_t result = zesMemoryGetState(handle, &state); + + EXPECT_EQ(result, ZE_RESULT_SUCCESS); + EXPECT_EQ(state.health, ZES_MEM_HEALTH_UNKNOWN); + EXPECT_EQ(state.size, NEO::probedSizeRegionOne); + EXPECT_EQ(state.free, NEO::unallocatedSizeRegionOne); + } + + pLinuxSysmanImp->releasePmtObject(); + delete pLinuxSysmanImp->pFwUtilInterface; + pLinuxSysmanImp->pFwUtilInterface = nullptr; +} + +HWTEST2_F(SysmanDeviceMemoryFixture, GivenSysmanResourcesAreReleasedAndReInitializedWhenCallingZesMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsOK, IsPVC) { pLinuxSysmanImp->releaseSysmanDeviceResources(); EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxSysmanImp->reInitSysmanDeviceResources()); @@ -945,7 +995,7 @@ HWTEST2_F(SysmanMultiDeviceMemoryFixture, GivenValidDevicePointerWhenGettingMemo } } -TEST_F(SysmanMultiDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceeds) { +HWTEST2_F(SysmanMultiDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZesMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsOK, IsPVC) { auto handles = getMemoryHandles(pOsSysman->getSubDeviceCount()); zes_mem_state_t state1; ze_result_t result = zesMemoryGetState(handles[0], &state1); @@ -962,6 +1012,23 @@ TEST_F(SysmanMultiDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysma EXPECT_EQ(state2.free, NEO::unallocatedSizeRegionFour); } +HWTEST2_F(SysmanMultiDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZesMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsUnknown, IsNotPVC) { + auto handles = getMemoryHandles(pOsSysman->getSubDeviceCount()); + zes_mem_state_t state1; + ze_result_t result = zesMemoryGetState(handles[0], &state1); + EXPECT_EQ(result, ZE_RESULT_SUCCESS); + EXPECT_EQ(state1.health, ZES_MEM_HEALTH_UNKNOWN); + EXPECT_EQ(state1.size, NEO::probedSizeRegionOne); + EXPECT_EQ(state1.free, NEO::unallocatedSizeRegionOne); + + zes_mem_state_t state2; + result = zesMemoryGetState(handles[1], &state2); + EXPECT_EQ(result, ZE_RESULT_SUCCESS); + EXPECT_EQ(state2.health, ZES_MEM_HEALTH_UNKNOWN); + EXPECT_EQ(state2.size, NEO::probedSizeRegionFour); + EXPECT_EQ(state2.free, NEO::unallocatedSizeRegionFour); +} + } // namespace ult } // namespace Sysman } // namespace L0 diff --git a/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp b/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp index 48750a9f21..8199c07f8a 100644 --- a/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp +++ b/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -351,7 +351,8 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) { ze_result_t status = ZE_RESULT_SUCCESS; pState->health = ZES_MEM_HEALTH_UNKNOWN; FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface(); - if (pFwInterface != nullptr) { + auto productFamily = SysmanDeviceImp::getProductFamily(pDevice); + if ((pFwInterface != nullptr) && (IGFX_PVC == productFamily)) { pFwInterface->fwGetMemoryHealthIndicator(&pState->health); } auto memoryInfo = pDrm->getIoctlHelper()->createMemoryInfo(); diff --git a/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_prelim.cpp b/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_prelim.cpp index bce8ab7fe7..1992d4f345 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_prelim.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_prelim.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -392,7 +392,7 @@ TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemo } } -TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceeds) { +HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZesMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsOK, IsPVC) { setLocalSupportedAndReinit(true); auto handles = getMemoryHandles(memoryHandleComponentCount); @@ -410,6 +410,24 @@ TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemo } } +HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsUnknown, IsNotPVC) { + setLocalSupportedAndReinit(true); + + auto handles = getMemoryHandles(memoryHandleComponentCount); + + for (auto handle : handles) { + ASSERT_NE(nullptr, handle); + zes_mem_state_t state; + + ze_result_t result = zesMemoryGetState(handle, &state); + + EXPECT_EQ(result, ZE_RESULT_SUCCESS); + EXPECT_EQ(state.health, ZES_MEM_HEALTH_UNKNOWN); + EXPECT_EQ(state.size, NEO::probedSizeRegionOne); + EXPECT_EQ(state.free, NEO::unallocatedSizeRegionOne); + } +} + TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemoryGetStateAndIoctlReturnedErrorThenApiReturnsError) { setLocalSupportedAndReinit(true); @@ -448,7 +466,7 @@ TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemo } } -TEST_F(SysmanDeviceMemoryFixture, GivenSysmanResourcesAreReleasedAndReInitializedWhenCallingZesSysmanMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceeds) { +HWTEST2_F(SysmanDeviceMemoryFixture, GivenSysmanResourcesAreReleasedAndReInitializedWhenCallingZesSysmanMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsOK, IsPVC) { pMemoryManager->localMemorySupported[0] = true; pLinuxSysmanImp->releaseSysmanDeviceResources(); @@ -487,6 +505,45 @@ TEST_F(SysmanDeviceMemoryFixture, GivenSysmanResourcesAreReleasedAndReInitialize pLinuxSysmanImp->pFwUtilInterface = nullptr; } +HWTEST2_F(SysmanDeviceMemoryFixture, GivenSysmanResourcesAreReleasedAndReInitializedWhenCallingZesSysmanMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsUnknown, IsNotPVC) { + pMemoryManager->localMemorySupported[0] = true; + + pLinuxSysmanImp->releaseSysmanDeviceResources(); + pLinuxSysmanImp->pDrm = pDrm; + pLinuxSysmanImp->reInitSysmanDeviceResources(); + + VariableBackup> pmtBackup(&pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject); + pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear(); + for (auto &deviceHandle : deviceHandles) { + ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; + Device::fromHandle(deviceHandle)->getProperties(&deviceProperties); + auto pPmt = new MockMemoryPmt(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE, + deviceProperties.subdeviceId); + pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(deviceProperties.subdeviceId, pPmt); + } + + VariableBackup backup(&pLinuxSysmanImp->pFwUtilInterface); + pLinuxSysmanImp->pFwUtilInterface = new MockFwUtilInterface(); + + auto handles = getMemoryHandles(memoryHandleComponentCount); + + for (auto handle : handles) { + ASSERT_NE(nullptr, handle); + zes_mem_state_t state; + + ze_result_t result = zesMemoryGetState(handle, &state); + + EXPECT_EQ(result, ZE_RESULT_SUCCESS); + EXPECT_EQ(state.health, ZES_MEM_HEALTH_UNKNOWN); + EXPECT_EQ(state.size, NEO::probedSizeRegionOne); + EXPECT_EQ(state.free, NEO::unallocatedSizeRegionOne); + } + + pLinuxSysmanImp->releasePmtObject(); + delete pLinuxSysmanImp->pFwUtilInterface; + pLinuxSysmanImp->pFwUtilInterface = nullptr; +} + TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingzesSysmanMemoryGetBandwidthWhenPmtObjectIsNullThenFailureRetuned) { for (auto &subDeviceIdToPmtEntry : pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject) { if (subDeviceIdToPmtEntry.second != nullptr) { @@ -1134,7 +1191,7 @@ TEST_F(SysmanMultiDeviceMemoryFixture, GivenValidDevicePointerWhenGettingMemoryP } } -TEST_F(SysmanMultiDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceeds) { +HWTEST2_F(SysmanMultiDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsOK, IsPVC) { setLocalSupportedAndReinit(true); auto handles = getMemoryHandles(subDeviceCount); @@ -1157,5 +1214,28 @@ TEST_F(SysmanMultiDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysma EXPECT_EQ(state2.free, NEO::unallocatedSizeRegionFour); } +HWTEST2_F(SysmanMultiDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingZetSysmanMemoryGetStateThenVerifySysmanMemoryGetStateCallSucceedsAndHealthIsUnknown, IsNotPVC) { + setLocalSupportedAndReinit(true); + + auto handles = getMemoryHandles(subDeviceCount); + + for (auto handle : handles) { + ASSERT_NE(nullptr, handle); + } + zes_mem_state_t state1; + ze_result_t result = zesMemoryGetState(handles[0], &state1); + EXPECT_EQ(result, ZE_RESULT_SUCCESS); + EXPECT_EQ(state1.health, ZES_MEM_HEALTH_UNKNOWN); + EXPECT_EQ(state1.size, NEO::probedSizeRegionOne); + EXPECT_EQ(state1.free, NEO::unallocatedSizeRegionOne); + + zes_mem_state_t state2; + result = zesMemoryGetState(handles[1], &state2); + EXPECT_EQ(result, ZE_RESULT_SUCCESS); + EXPECT_EQ(state2.health, ZES_MEM_HEALTH_UNKNOWN); + EXPECT_EQ(state2.size, NEO::probedSizeRegionFour); + EXPECT_EQ(state2.free, NEO::unallocatedSizeRegionFour); +} + } // namespace ult } // namespace L0