Skip to content

Commit c645f84

Browse files
feature(sysman): Update Power Module to replace CARD domain with PACKAGE domain
Related-To: NEO-13985 Signed-off-by: Anvesh Bakwad <anvesh.bakwad@intel.com>
1 parent 05977f6 commit c645f84

File tree

10 files changed

+31
-39
lines changed

10 files changed

+31
-39
lines changed

level_zero/sysman/source/api/power/linux/sysman_os_power_imp.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ze_result_t LinuxPowerImp::getDefaultLimit(int32_t &defaultLimit) {
5757
}
5858

5959
ze_result_t LinuxPowerImp::getPropertiesExt(zes_power_ext_properties_t *pExtPoperties) {
60-
pExtPoperties->domain = isSubdevice ? ZES_POWER_DOMAIN_PACKAGE : powerDomain;
60+
pExtPoperties->domain = powerDomain;
6161
if (pExtPoperties->defaultLimit) {
6262
if (!isSubdevice) {
6363
uint64_t val = 0;
@@ -184,6 +184,7 @@ ze_result_t LinuxPowerImp::setLimits(const zes_power_sustained_limit_t *pSustain
184184
}
185185
return result;
186186
}
187+
187188
ze_result_t LinuxPowerImp::getEnergyThreshold(zes_energy_threshold_t *pThreshold) {
188189
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s() returning UNSUPPORTED_FEATURE \n", __FUNCTION__);
189190
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
@@ -340,8 +341,8 @@ LinuxPowerImp::LinuxPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_
340341
pSysmanProductHelper = pLinuxSysmanImp->getSysmanProductHelper();
341342
}
342343

343-
std::vector<zes_power_domain_t> OsPower::getNumberOfPowerDomainsSupported(OsSysman *pOsSysman) {
344-
std::vector<zes_power_domain_t> powerDomains = {ZES_POWER_DOMAIN_CARD};
344+
std::vector<zes_power_domain_t> OsPower::getSupportedPowerDomains(OsSysman *pOsSysman) {
345+
std::vector<zes_power_domain_t> powerDomains = {ZES_POWER_DOMAIN_PACKAGE};
345346
return powerDomains;
346347
}
347348

level_zero/sysman/source/api/power/linux/sysman_os_power_imp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
5656
bool isSubdevice = false;
5757
uint32_t subdeviceId = 0;
5858
uint32_t powerLimitCount = 0;
59-
zes_power_domain_t powerDomain = ZES_POWER_DOMAIN_CARD;
59+
zes_power_domain_t powerDomain = ZES_POWER_DOMAIN_UNKNOWN;
6060

6161
ze_result_t getErrorCode(ze_result_t result) {
6262
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {

level_zero/sysman/source/api/power/sysman_os_power.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class OsPower {
2929

3030
virtual bool isPowerModuleSupported() = 0;
3131
static OsPower *create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId, zes_power_domain_t powerDomain);
32-
static std::vector<zes_power_domain_t> getNumberOfPowerDomainsSupported(OsSysman *pOsSysman);
32+
static std::vector<zes_power_domain_t> getSupportedPowerDomains(OsSysman *pOsSysman);
3333

3434
virtual ~OsPower() = default;
3535
};

level_zero/sysman/source/api/power/sysman_power.cpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,15 @@ void PowerHandleContext::createHandle(ze_bool_t isSubDevice, uint32_t subDeviceI
3535
delete pPower;
3636
}
3737
}
38-
ze_result_t PowerHandleContext::init(uint32_t subDeviceCount) {
39-
40-
auto totalDomains = OsPower::getNumberOfPowerDomainsSupported(pOsSysman);
4138

39+
void PowerHandleContext::init(uint32_t subDeviceCount) {
40+
auto totalDomains = OsPower::getSupportedPowerDomains(pOsSysman);
4241
for (auto &powerDomain : totalDomains) {
4342
createHandle(false, 0, powerDomain);
44-
}
45-
46-
for (uint32_t subDeviceId = 0; subDeviceId < subDeviceCount; subDeviceId++) {
47-
for (auto &powerDomain : totalDomains) {
43+
for (uint32_t subDeviceId = 0; subDeviceId < subDeviceCount; subDeviceId++) {
4844
createHandle(true, subDeviceId, powerDomain);
4945
}
5046
}
51-
52-
return ZE_RESULT_SUCCESS;
5347
}
5448

5549
void PowerHandleContext::initPower() {

level_zero/sysman/source/api/power/sysman_power.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct PowerHandleContext {
3838
PowerHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
3939
~PowerHandleContext();
4040

41-
ze_result_t init(uint32_t subDeviceCount);
41+
void init(uint32_t subDeviceCount);
4242
ze_result_t powerGet(uint32_t *pCount, zes_pwr_handle_t *phPower);
4343
ze_result_t powerGetCardDomain(zes_pwr_handle_t *phPower);
4444

level_zero/sysman/source/api/power/sysman_power_imp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ PowerImp::PowerImp(OsSysman *pOsSysman, ze_bool_t isSubDevice, uint32_t subDevic
6868

6969
pOsPower = OsPower::create(pOsSysman, isSubDevice, subDeviceId, powerDomain);
7070
UNRECOVERABLE_IF(nullptr == pOsPower);
71-
this->isCardPower = isSubDevice ? false : true;
71+
this->isCardPower = (powerDomain == ZES_POWER_DOMAIN_CARD);
7272
init();
7373
}
7474

level_zero/sysman/source/api/power/windows/sysman_os_power_imp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ WddmPowerImp::WddmPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t
611611
isPowerHandleEnergyCounterOnly();
612612
}
613613

614-
std::vector<zes_power_domain_t> OsPower::getNumberOfPowerDomainsSupported(OsSysman *pOsSysman) {
614+
std::vector<zes_power_domain_t> OsPower::getSupportedPowerDomains(OsSysman *pOsSysman) {
615615
WddmSysmanImp *pWddmSysmanImp = static_cast<WddmSysmanImp *>(pOsSysman);
616616
KmdSysManager *pKmdSysManager = &pWddmSysmanImp->getKmdSysManager();
617617
KmdSysman::RequestProperty request;

level_zero/sysman/test/unit_tests/sources/power/linux/test_zes_power.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,22 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenComponentCountZeroWhenEnumeratingPower
4242
}
4343
}
4444

45-
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerPointerWhenGettingCardPowerDomainWhenhwmonInterfaceExistsAndThenCallSucceeds) {
45+
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerPointerWhenGetCardPowerDomainIsCalledThenFailureIsReturned) {
4646
zes_pwr_handle_t phPower = {};
47-
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_SUCCESS);
47+
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
4848
}
4949

50-
TEST_F(SysmanDevicePowerFixtureI915, GivenInvalidPowerPointerWhenGettingCardPowerDomainAndThenReturnsFailure) {
50+
TEST_F(SysmanDevicePowerFixtureI915, GivenInvalidPowerPointerWhenGetCardPowerDomainIsCalledThenFailureIsReturned) {
5151
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), nullptr), ZE_RESULT_ERROR_INVALID_NULL_POINTER);
5252
}
5353

54-
TEST_F(SysmanDevicePowerFixtureI915, GivenUninitializedPowerHandlesAndWhenGettingCardPowerDomainThenReturnsFailure) {
55-
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
56-
delete handle;
57-
}
58-
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
54+
TEST_F(SysmanDevicePowerFixtureI915, GivenPowerHandlesListContainsCardDomainHandleWhenGetCardPowerDomainIsCalledThenCallSucceeds) {
55+
Power *pPower = new PowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_CARD);
56+
57+
pSysmanDeviceImp->pPowerHandleContext->handleList.push_back(pPower);
5958

6059
zes_pwr_handle_t phPower = {};
61-
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
60+
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_SUCCESS);
6261
}
6362

6463
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesWhenhwmonInterfaceExistsThenCallSucceeds) {
@@ -118,7 +117,7 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerProper
118117
EXPECT_EQ(properties.defaultLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
119118
EXPECT_EQ(properties.maxLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
120119
EXPECT_EQ(properties.minLimit, -1);
121-
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_CARD);
120+
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_PACKAGE);
122121
EXPECT_TRUE(defaultLimit.limitValueLocked);
123122
EXPECT_TRUE(defaultLimit.enabledStateLocked);
124123
EXPECT_TRUE(defaultLimit.intervalValueLocked);
@@ -180,7 +179,7 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleAndPowerSetLimitSuppor
180179
}
181180

182181
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesAndSysfsReadFailsThenFailureIsReturned) {
183-
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_CARD));
182+
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_PACKAGE));
184183
EXPECT_TRUE(pLinuxPowerImp->isPowerModuleSupported());
185184
pSysfsAccess->mockReadValUnsignedLongResult.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
186185
zes_power_properties_t properties{};

level_zero/sysman/test/unit_tests/sources/power/linux/test_zes_power_helper.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidDeviceHandlesAndHwmo
3232
uint32_t subdeviceId = 0;
3333
do {
3434
ze_bool_t onSubdevice = (subDeviceCount == 0) ? false : true;
35-
PublicLinuxPowerImp *pPowerImp = new PublicLinuxPowerImp(pOsSysman, onSubdevice, subdeviceId, ZES_POWER_DOMAIN_CARD);
35+
PublicLinuxPowerImp *pPowerImp = new PublicLinuxPowerImp(pOsSysman, onSubdevice, subdeviceId, ZES_POWER_DOMAIN_PACKAGE);
3636
EXPECT_TRUE(pPowerImp->isPowerModuleSupported());
3737
delete pPowerImp;
3838

@@ -49,9 +49,9 @@ TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenInvalidComponentCountWhen
4949
EXPECT_EQ(count, powerHandleComponentCountMultiDevice);
5050
}
5151

52-
TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerPointerWhenGettingCardPowerDomainWhenhwmonInterfaceExistsAndThenCallSucceeds) {
52+
TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerPointerWhenGettingCardPowerDomainThenFailureIsReturned) {
5353
zes_pwr_handle_t phPower = {};
54-
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_SUCCESS);
54+
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
5555
}
5656

5757
TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerHandleWhenGettingPowerPropertiesThenCallSucceeds) {
@@ -102,13 +102,12 @@ TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerHandleWhenGetti
102102
EXPECT_EQ(defaultLimit.level, ZES_POWER_LEVEL_UNKNOWN);
103103
EXPECT_EQ(defaultLimit.source, ZES_POWER_SOURCE_ANY);
104104
EXPECT_EQ(defaultLimit.limitUnit, ZES_LIMIT_UNIT_POWER);
105+
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_PACKAGE);
105106
if (properties.onSubdevice) {
106107
EXPECT_FALSE(properties.canControl);
107-
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_PACKAGE);
108108
EXPECT_EQ(defaultLimit.limit, -1);
109109
} else {
110110
EXPECT_TRUE(properties.canControl);
111-
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_CARD);
112111
EXPECT_EQ(defaultLimit.limit, static_cast<int32_t>(mockDefaultPowerLimitVal / milliFactor));
113112
EXPECT_EQ(properties.defaultLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
114113
EXPECT_EQ(properties.maxLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
@@ -133,15 +132,14 @@ TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerHandleAndExtPro
133132
properties.pNext = &extProperties;
134133
extProperties.stype = ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES;
135134
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetProperties(handle, &properties));
135+
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_PACKAGE);
136136
if (properties.onSubdevice) {
137137
EXPECT_FALSE(properties.canControl);
138-
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_PACKAGE);
139138
EXPECT_EQ(properties.maxLimit, -1);
140139
EXPECT_EQ(properties.minLimit, -1);
141140
EXPECT_EQ(properties.defaultLimit, -1);
142141
} else {
143142
EXPECT_TRUE(properties.canControl);
144-
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_CARD);
145143
EXPECT_EQ(properties.defaultLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
146144
EXPECT_EQ(properties.maxLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
147145
EXPECT_EQ(properties.minLimit, -1);

level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_power_tests.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ HWTEST2_F(SysmanProductHelperPowerTest, GivenSysfsReadFailsAndKeyOffsetMapNotAva
156156
return count;
157157
});
158158

159-
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_CARD));
159+
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_PACKAGE));
160160
pLinuxPowerImp->isTelemetrySupportAvailable = true;
161161
zes_power_energy_counter_t energyCounter = {};
162162
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, pLinuxPowerImp->getEnergyCounter(&energyCounter));
@@ -188,7 +188,7 @@ HWTEST2_F(SysmanProductHelperPowerTest, GivenSysfsReadFailsAndPmtReadValueFailsW
188188
return count;
189189
});
190190

191-
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_CARD));
191+
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_PACKAGE));
192192
pLinuxPowerImp->isTelemetrySupportAvailable = true;
193193
zes_power_energy_counter_t energyCounter = {};
194194
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pLinuxPowerImp->getEnergyCounter(&energyCounter));
@@ -200,7 +200,7 @@ HWTEST2_F(SysmanProductHelperPowerTest, GivenSysfsReadFailsWhenGettingPowerEnerg
200200
VariableBackup<decltype(NEO::SysCalls::sysCallsOpen)> mockOpen(&NEO::SysCalls::sysCallsOpen, &mockOpenSuccess);
201201
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, &mockReadSuccess);
202202

203-
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_CARD));
203+
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_PACKAGE));
204204
pLinuxPowerImp->isTelemetrySupportAvailable = true;
205205
zes_power_energy_counter_t energyCounter = {};
206206
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getEnergyCounter(&energyCounter));
@@ -240,7 +240,7 @@ HWTEST2_F(SysmanProductHelperPowerTest, GivenScanDirectoriesFailAndTelemetrySupp
240240
pSysmanDeviceImp->pPowerHandleContext->init(subDeviceCount);
241241
ze_bool_t onSubdevice = (subDeviceCount == 0) ? false : true;
242242
uint32_t subdeviceId = 0;
243-
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, onSubdevice, subdeviceId, ZES_POWER_DOMAIN_CARD));
243+
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, onSubdevice, subdeviceId, ZES_POWER_DOMAIN_PACKAGE));
244244
EXPECT_TRUE(pLinuxPowerImp->isPowerModuleSupported());
245245
}
246246

0 commit comments

Comments
 (0)