File tree Expand file tree Collapse file tree 4 files changed +13
-6
lines changed
test/unit_tests/sources/sysman/standby/linux Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (C) 2020-2021 Intel Corporation
2+ * Copyright (C) 2020-2022 Intel Corporation
33 *
44 * SPDX-License-Identifier: MIT
55 *
@@ -36,6 +36,9 @@ ze_result_t StandbyHandleContext::init(std::vector<ze_device_handle_t> &deviceHa
3636}
3737
3838ze_result_t StandbyHandleContext::standbyGet (uint32_t *pCount, zes_standby_handle_t *phStandby) {
39+ std::call_once (initStandbyOnce, [this ]() {
40+ this ->init (pOsSysman->getDeviceHandles ());
41+ });
3942 uint32_t handleListSize = static_cast <uint32_t >(handleList.size ());
4043 uint32_t numToCopy = std::min (*pCount, handleListSize);
4144 if (0 == *pCount || *pCount > handleListSize) {
Original file line number Diff line number Diff line change 99#include " level_zero/core/source/device/device.h"
1010#include < level_zero/zes_api.h>
1111
12+ #include < mutex>
1213#include < vector>
1314
1415struct _zes_standby_handle_t {
@@ -47,6 +48,7 @@ struct StandbyHandleContext {
4748
4849 private:
4950 void createHandle (ze_device_handle_t deviceHandle);
51+ std::once_flag initStandbyOnce;
5052};
5153
5254} // namespace L0
Original file line number Diff line number Diff line change @@ -106,9 +106,6 @@ ze_result_t SysmanDeviceImp::init() {
106106 if (pPci) {
107107 pPci->init ();
108108 }
109- if (pStandbyHandleContext) {
110- pStandbyHandleContext->init (deviceHandles);
111- }
112109 if (pEngineHandleContext) {
113110 pEngineHandleContext->init ();
114111 }
Original file line number Diff line number Diff line change @@ -51,7 +51,6 @@ class ZesStandbyFixture : public SysmanDeviceFixture {
5151 deviceHandles.resize (subDeviceCount, nullptr );
5252 Device::fromHandle (device->toHandle ())->getSubDevices (&subDeviceCount, deviceHandles.data ());
5353 }
54- pSysmanDeviceImp->pStandbyHandleContext ->init (deviceHandles);
5554 }
5655 void TearDown () override {
5756 if (!sysmanUltsEnable) {
@@ -68,6 +67,13 @@ class ZesStandbyFixture : public SysmanDeviceFixture {
6867 }
6968};
7069
70+ TEST_F (ZesStandbyFixture, GivenStandbyModeFilesNotAvailableWhenCallingEnumerateThenSuccessResultAndZeroCountIsReturned) {
71+ uint32_t count = 0 ;
72+ ptestSysfsAccess->isStandbyModeFileAvailable = false ;
73+ ze_result_t result = zesDeviceEnumStandbyDomains (device, &count, nullptr );
74+ EXPECT_EQ (ZE_RESULT_SUCCESS, result);
75+ EXPECT_EQ (count, 0u );
76+ }
7177TEST_F (ZesStandbyFixture, GivenComponentCountZeroWhenCallingzesStandbyGetThenNonZeroCountIsReturnedAndVerifyzesStandbyGetCallSucceeds) {
7278 std::vector<zes_standby_handle_t > standbyHandle = {};
7379 uint32_t count = 0 ;
@@ -326,7 +332,6 @@ class ZesStandbyMultiDeviceFixture : public SysmanMultiDeviceFixture {
326332 deviceHandles.resize (subDeviceCount, nullptr );
327333 Device::fromHandle (device->toHandle ())->getSubDevices (&subDeviceCount, deviceHandles.data ());
328334 }
329- pSysmanDeviceImp->pStandbyHandleContext ->init (deviceHandles);
330335 }
331336 void TearDown () override {
332337 if (!sysmanUltsEnable) {
You can’t perform that action at this time.
0 commit comments