Skip to content

Commit 78feb47

Browse files
Add subdevice support for standby
Change-Id: I4209d11a8305ba524e56cddbee5ad3432b32554f Signed-off-by: mraghuwa <[email protected]>
1 parent ee63b7a commit 78feb47

File tree

12 files changed

+170
-36
lines changed

12 files changed

+170
-36
lines changed

level_zero/tools/source/sysman/standby/linux/os_standby_imp.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ namespace L0 {
1111

1212
const std::string LinuxStandbyImp::standbyModeFile("power/rc6_enable");
1313

14+
ze_result_t LinuxStandbyImp::osStandbyGetProperties(zes_standby_properties_t &properties) {
15+
properties.pNext = nullptr;
16+
properties.type = ZES_STANDBY_TYPE_GLOBAL;
17+
properties.onSubdevice = isSubdevice;
18+
properties.subdeviceId = subdeviceId;
19+
return ZE_RESULT_SUCCESS;
20+
}
21+
1422
bool LinuxStandbyImp::isStandbySupported(void) {
1523
if (ZE_RESULT_SUCCESS == pSysfsAccess->canRead(standbyModeFile)) {
1624
return true;
@@ -47,14 +55,14 @@ ze_result_t LinuxStandbyImp::setMode(zes_standby_promo_mode_t mode) {
4755
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
4856
}
4957

50-
LinuxStandbyImp::LinuxStandbyImp(OsSysman *pOsSysman) {
58+
LinuxStandbyImp::LinuxStandbyImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
5159
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
5260

5361
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
5462
}
5563

56-
OsStandby *OsStandby::create(OsSysman *pOsSysman) {
57-
LinuxStandbyImp *pLinuxStandbyImp = new LinuxStandbyImp(pOsSysman);
64+
OsStandby *OsStandby::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
65+
LinuxStandbyImp *pLinuxStandbyImp = new LinuxStandbyImp(pOsSysman, onSubdevice, subdeviceId);
5866
return static_cast<OsStandby *>(pLinuxStandbyImp);
5967
}
6068

level_zero/tools/source/sysman/standby/linux/os_standby_imp.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ class LinuxStandbyImp : public OsStandby, NEO::NonCopyableOrMovableClass {
1818
public:
1919
ze_result_t getMode(zes_standby_promo_mode_t &mode) override;
2020
ze_result_t setMode(zes_standby_promo_mode_t mode) override;
21+
ze_result_t osStandbyGetProperties(zes_standby_properties_t &properties) override;
2122

2223
bool isStandbySupported(void) override;
2324

2425
LinuxStandbyImp() = default;
25-
LinuxStandbyImp(OsSysman *pOsSysman);
26+
LinuxStandbyImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
2627
~LinuxStandbyImp() override = default;
2728

2829
protected:
@@ -32,6 +33,8 @@ class LinuxStandbyImp : public OsStandby, NEO::NonCopyableOrMovableClass {
3233
static const std::string standbyModeFile;
3334
static const int standbyModeDefault = 1;
3435
static const int standbyModeNever = 0;
36+
bool isSubdevice = false;
37+
uint32_t subdeviceId = 0;
3538
};
3639

3740
} // namespace L0

level_zero/tools/source/sysman/standby/os_standby.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ class OsStandby {
1616
public:
1717
virtual ze_result_t getMode(zes_standby_promo_mode_t &mode) = 0;
1818
virtual ze_result_t setMode(zes_standby_promo_mode_t mode) = 0;
19+
virtual ze_result_t osStandbyGetProperties(zes_standby_properties_t &properties) = 0;
1920

2021
virtual bool isStandbySupported(void) = 0;
2122

22-
static OsStandby *create(OsSysman *pOsSysman);
23+
static OsStandby *create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
2324
virtual ~OsStandby() {}
2425
};
2526

level_zero/tools/source/sysman/standby/standby.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,22 @@ StandbyHandleContext::~StandbyHandleContext() {
1919
}
2020
}
2121

22-
void StandbyHandleContext::init() {
23-
Standby *pStandby = new StandbyImp(pOsSysman);
22+
void StandbyHandleContext::createHandle(ze_device_handle_t deviceHandle) {
23+
Standby *pStandby = new StandbyImp(pOsSysman, deviceHandle);
2424
if (pStandby->isStandbyEnabled == true) {
2525
handleList.push_back(pStandby);
2626
} else {
2727
delete pStandby;
2828
}
2929
}
3030

31+
ze_result_t StandbyHandleContext::init(std::vector<ze_device_handle_t> &deviceHandles) {
32+
for (const auto &deviceHandle : deviceHandles) {
33+
createHandle(deviceHandle);
34+
}
35+
return ZE_RESULT_SUCCESS;
36+
}
37+
3138
ze_result_t StandbyHandleContext::standbyGet(uint32_t *pCount, zes_standby_handle_t *phStandby) {
3239
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
3340
uint32_t numToCopy = std::min(*pCount, handleListSize);

level_zero/tools/source/sysman/standby/standby.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#pragma once
9+
#include "level_zero/core/source/device/device.h"
910
#include <level_zero/zes_api.h>
1011

1112
#include <vector>
@@ -37,12 +38,15 @@ struct StandbyHandleContext {
3738
StandbyHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
3839
~StandbyHandleContext();
3940

40-
void init();
41+
ze_result_t init(std::vector<ze_device_handle_t> &deviceHandles);
4142

4243
ze_result_t standbyGet(uint32_t *pCount, zes_standby_handle_t *phStandby);
4344

4445
OsSysman *pOsSysman;
4546
std::vector<Standby *> handleList = {};
47+
48+
private:
49+
void createHandle(ze_device_handle_t deviceHandle);
4650
};
4751

4852
} // namespace L0

level_zero/tools/source/sysman/standby/standby_imp.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ ze_result_t StandbyImp::standbySetMode(const zes_standby_promo_mode_t mode) {
2727
}
2828

2929
void StandbyImp::init() {
30-
standbyProperties.type = ZES_STANDBY_TYPE_GLOBAL; // Currently the only defined type
31-
standbyProperties.onSubdevice = false;
32-
standbyProperties.subdeviceId = 0;
30+
pOsStandby->osStandbyGetProperties(standbyProperties);
3331
this->isStandbyEnabled = pOsStandby->isStandbySupported();
3432
}
3533

36-
StandbyImp::StandbyImp(OsSysman *pOsSysman) {
37-
pOsStandby = OsStandby::create(pOsSysman);
34+
StandbyImp::StandbyImp(OsSysman *pOsSysman, ze_device_handle_t handle) : deviceHandle(handle) {
35+
ze_device_properties_t deviceProperties = {};
36+
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
37+
pOsStandby = OsStandby::create(pOsSysman, deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE, deviceProperties.subdeviceId);
3838
UNRECOVERABLE_IF(nullptr == pOsStandby);
3939
init();
4040
}

level_zero/tools/source/sysman/standby/standby_imp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ class StandbyImp : public Standby, NEO::NonCopyableOrMovableClass {
2222
ze_result_t standbySetMode(const zes_standby_promo_mode_t mode) override;
2323

2424
StandbyImp() = default;
25-
StandbyImp(OsSysman *pOsSysman);
25+
StandbyImp(OsSysman *pOsSysman, ze_device_handle_t handle);
2626
~StandbyImp() override;
2727
OsStandby *pOsStandby = nullptr;
2828

2929
void init();
3030

3131
private:
3232
zes_standby_properties_t standbyProperties = {};
33+
ze_device_handle_t deviceHandle = nullptr;
3334
};
3435

3536
} // namespace L0

level_zero/tools/source/sysman/standby/windows/os_standby_imp.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class WddmStandbyImp : public OsStandby {
1313
public:
1414
ze_result_t getMode(zes_standby_promo_mode_t &mode) override;
1515
ze_result_t setMode(zes_standby_promo_mode_t mode) override;
16+
ze_result_t osStandbyGetProperties(zes_standby_properties_t &properties) override;
1617
bool isStandbySupported(void) override;
1718
};
1819

@@ -24,11 +25,15 @@ ze_result_t WddmStandbyImp::getMode(zes_standby_promo_mode_t &mode) {
2425
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
2526
}
2627

28+
ze_result_t WddmStandbyImp::osStandbyGetProperties(zes_standby_properties_t &properties) {
29+
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
30+
}
31+
2732
bool WddmStandbyImp::isStandbySupported(void) {
2833
return false;
2934
}
3035

31-
OsStandby *OsStandby::create(OsSysman *pOsSysman) {
36+
OsStandby *OsStandby::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
3237
WddmStandbyImp *pWddmStandbyImp = new WddmStandbyImp();
3338
return static_cast<OsStandby *>(pWddmStandbyImp);
3439
}

level_zero/tools/source/sysman/sysman_imp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void SysmanDeviceImp::init() {
8282
pPci->init();
8383
}
8484
if (pStandbyHandleContext) {
85-
pStandbyHandleContext->init();
85+
pStandbyHandleContext->init(deviceHandles);
8686
}
8787
if (pEngineHandleContext) {
8888
pEngineHandleContext->init();

level_zero/tools/test/unit_tests/sources/sysman/linux/mock_sysman_fixture.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class SysmanMultiDeviceFixture : public MultiDeviceFixture, public ::testing::Te
7979
pSysmanDeviceImp = static_cast<SysmanDeviceImp *>(pSysmanDevice);
8080
pOsSysman = pSysmanDeviceImp->pOsSysman;
8181
pLinuxSysmanImp = static_cast<PublicLinuxSysmanImp *>(pOsSysman);
82+
subDeviceCount = numSubDevices;
8283
}
8384
void TearDown() override {
8485
unsetenv("ZES_ENABLE_SYSMAN");
@@ -91,7 +92,8 @@ class SysmanMultiDeviceFixture : public MultiDeviceFixture, public ::testing::Te
9192
PublicLinuxSysmanImp *pLinuxSysmanImp = nullptr;
9293
NEO::Device *neoDevice = nullptr;
9394
L0::Device *device = nullptr;
95+
uint32_t subDeviceCount = 0u;
9496
};
9597

9698
} // namespace ult
97-
} // namespace L0
99+
} // namespace L0

0 commit comments

Comments
 (0)