Skip to content

Commit f474285

Browse files
Update zesDevicePciGetBars API to report correct count of bars
This change does the following: - As per latest spec, update zesDevicePciGetBars API to report correct number of bars. - Cleanup to remove environment variable check while creating temperature handles. Change-Id: I4f86210093e3d142183a01bef89417ef9d9fde9b Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
1 parent 8785f5a commit f474285

File tree

4 files changed

+11
-32
lines changed

4 files changed

+11
-32
lines changed

level_zero/tools/source/sysman/pci/pci_imp.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ ze_result_t PciImp::pciStaticProperties(zes_pci_properties_t *pProperties) {
4848
}
4949

5050
ze_result_t PciImp::pciGetInitializedBars(uint32_t *pCount, zes_pci_bar_properties_t *pProperties) {
51-
if (pProperties == nullptr) {
52-
*pCount = static_cast<uint32_t>(pciBarProperties.size());
53-
return ZE_RESULT_SUCCESS;
54-
} else {
55-
*pCount = std::min(*pCount, static_cast<uint32_t>(pciBarProperties.size()));
56-
for (uint32_t i = 0; i < *pCount; i++) {
51+
uint32_t pciBarPropertiesSize = static_cast<uint32_t>(pciBarProperties.size());
52+
uint32_t numToCopy = std::min(*pCount, pciBarPropertiesSize);
53+
if (0 == *pCount || *pCount > pciBarPropertiesSize) {
54+
*pCount = pciBarPropertiesSize;
55+
}
56+
if (nullptr != pProperties) {
57+
for (uint32_t i = 0; i < numToCopy; i++) {
5758
pProperties[i] = *pciBarProperties[i];
5859
}
5960
}

level_zero/tools/source/sysman/temperature/temperature.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ void TemperatureHandleContext::createHandle(zes_temp_sensors_t type) {
2727
}
2828

2929
void TemperatureHandleContext::init() {
30-
auto isSysmanEnabled = getenv("ZES_ENABLE_SYSMAN");
31-
if (isSysmanEnabled != nullptr) {
32-
auto isSysmanEnabledAsInt = atoi(isSysmanEnabled);
33-
if (isSysmanEnabledAsInt == 1) {
34-
createHandle(ZES_TEMP_SENSORS_GLOBAL);
35-
createHandle(ZES_TEMP_SENSORS_GPU);
36-
}
37-
return;
38-
}
3930
createHandle(ZES_TEMP_SENSORS_GLOBAL);
4031
createHandle(ZES_TEMP_SENSORS_GPU);
4132
}

level_zero/tools/test/unit_tests/sources/sysman/pci/linux/test_zes_pci.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetBarsThenVe
194194
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
195195
EXPECT_GT(count, 0u);
196196

197+
uint32_t testCount = count + 1;
198+
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDevicePciGetBars(device, &testCount, nullptr));
199+
EXPECT_EQ(count, testCount);
200+
197201
std::vector<zes_pci_bar_properties_t> pciBarProps(count);
198202
result = zesDevicePciGetBars(device, &count, pciBarProps.data());
199203
EXPECT_EQ(ZE_RESULT_SUCCESS, result);

level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/test_zes_temperature.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,6 @@ TEST_F(SysmanDeviceTemperatureFixture, GivenPmtSupportAvailableWhenCheckingForTe
108108
}
109109
}
110110

111-
TEST_F(SysmanDeviceTemperatureFixture, GivenSysmanEnvironmentVariableSetToZeroWhenCreatingTemperatureHandlesThenHandlesNotCreated) {
112-
setenv("ZES_ENABLE_SYSMAN", "0", 1);
113-
auto pTempHandleContextTest = std::make_unique<TemperatureHandleContext>(pOsSysman);
114-
pTempHandleContextTest->init();
115-
uint32_t count = 0;
116-
std::vector<zes_temp_handle_t> handles(count, nullptr);
117-
EXPECT_EQ(ZE_RESULT_SUCCESS, pTempHandleContextTest->temperatureGet(&count, handles.data()));
118-
EXPECT_EQ(count, 0u);
119-
}
120-
121-
TEST_F(SysmanDeviceTemperatureFixture, GivenSysmanEnvironmentVariableNotSetWhenCreatingTemperatureHandlesThenZetHandlesCreated) {
122-
unsetenv("ZES_ENABLE_SYSMAN");
123-
auto pTempHandleContextTestWithoutEnvSet = std::make_unique<TemperatureHandleContext>(pOsSysman);
124-
pTempHandleContextTestWithoutEnvSet->init();
125-
EXPECT_EQ(handleComponentCount, static_cast<uint32_t>(pTempHandleContextTestWithoutEnvSet->handleList.size()));
126-
}
127-
128111
TEST_F(SysmanDeviceTemperatureFixture, GivenValidTempHandleWhenGettingTemperaturePropertiesThenUnsupportedIsReturned) {
129112
auto handles = get_temp_handles(handleComponentCount);
130113
for (auto handle : handles) {

0 commit comments

Comments
 (0)