Skip to content

Commit c317cff

Browse files
Make BDF method as default for UUID calculation
This patch makes PCIE BDF as the default method for UUID calculation. Related-To: LOCI-2909 Signed-off-by: Joshua Santosh Ranjan <joshua.santosh.ranjan@intel.com>
1 parent 7daee00 commit c317cff

File tree

5 files changed

+90
-4
lines changed

5 files changed

+90
-4
lines changed

level_zero/core/test/unit_tests/sources/device/linux/test_device_uuid.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -26,6 +26,7 @@ namespace ult {
2626
struct TestDeviceUuid : public ::testing::Test {
2727
void SetUp() override {}
2828
void TearDown() override {}
29+
DebugManagerStateRestore restorer;
2930
};
3031

3132
HWTEST2_F(TestDeviceUuid, GivenCorrectTelemetryNodesAreAvailableWhenRetrievingDeviceAndSubDevicePropertiesThenCorrectUuidIsReceived, IsXEHP) {
@@ -82,7 +83,7 @@ HWTEST2_F(TestDeviceUuid, GivenCorrectTelemetryNodesAreAvailableWhenRetrievingDe
8283

8384
return -1;
8485
});
85-
DebugManagerStateRestore restore;
86+
DebugManager.flags.EnableChipsetUniqueUUID.set(1);
8687
DebugManager.flags.CreateMultipleSubDevices.set(2);
8788

8889
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
@@ -132,5 +133,23 @@ HWTEST2_F(TestDeviceUuid, GivenCorrectTelemetryNodesAreAvailableWhenRetrievingDe
132133
EXPECT_TRUE(0 == std::memcmp(deviceProps.uuid.id, expectedUuid, sizeof(expectedUuid)));
133134
}
134135

136+
TEST_F(TestDeviceUuid, GivenEnableChipsetUniqueUuidIsSetWhenOsInterfaceIsNotSetThenUuidOfFallbackPathIsReceived) {
137+
138+
DebugManager.flags.EnableChipsetUniqueUUID.set(1);
139+
auto neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get());
140+
NEO::DeviceVector devices;
141+
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
142+
auto driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
143+
driverHandle->initialize(std::move(devices));
144+
auto device = driverHandle->devices[0];
145+
146+
ze_device_properties_t deviceProperties, devicePropertiesBefore;
147+
deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
148+
memset(&deviceProperties.uuid, std::numeric_limits<int>::max(), sizeof(deviceProperties.uuid));
149+
devicePropertiesBefore = deviceProperties;
150+
EXPECT_EQ(ZE_RESULT_SUCCESS, device->getProperties(&deviceProperties));
151+
EXPECT_NE(0, memcmp(&deviceProperties.uuid, &devicePropertiesBefore.uuid, sizeof(devicePropertiesBefore.uuid)));
152+
}
153+
135154
} // namespace ult
136155
} // namespace L0

opencl/test/unit_test/test_files/igdrcl.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,5 @@ UseDrmCompletionFenceForAllAllocations = -1
368368
ExperimentalEnableSourceLevelDebugger = 0
369369
Force2dImageAsArray = -1
370370
ForceExtendedBufferSize = -1
371-
MakeIndirectAllocationsResidentAsPack = -1
371+
MakeIndirectAllocationsResidentAsPack = -1
372+
EnableChipsetUniqueUUID = -1

shared/source/debug_settings/debug_variables_base.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideSystolicInComputeWalker, -1, "set SYSTOL
344344
DECLARE_DEBUG_VARIABLE(int32_t, AddStatePrefetchCmdToMemoryPrefetchAPI, -1, "Add STATE_PREFETCH to zeCommandListAppendMemoryPrefetch, -1:default, 0:disable, 1:enable")
345345
DECLARE_DEBUG_VARIABLE(int32_t, EnableDrmCompletionFence, -1, "Enables DRM completion fence, -1:default (disabled), 0:disable, 1:enable")
346346
DECLARE_DEBUG_VARIABLE(int32_t, UseDrmCompletionFenceForAllAllocations, -1, "Uses DRM completion fence for all allocations, -1:default (disabled), 0:disable, 1:enable")
347+
DECLARE_DEBUG_VARIABLE(int32_t, EnableChipsetUniqueUUID, -1, "Enables retrieving chipset unique UUID using telemetry, -1:default (disabled), 0:disable, 1:enable")
347348

348349
/*EXPERIMENTAL TOGGLES*/
349350
DECLARE_DEBUG_VARIABLE(int32_t, ExperimentalSetWalkerPartitionCount, 0, "Experimental implementation: Set number of COMPUTE_WALKERs for a given Partition Type, 0 - do not set the feature.")

shared/source/device/device.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,11 @@ bool Device::createDeviceImpl() {
270270
createBindlessHeapsHelper();
271271
if (!isEngineInstanced()) {
272272
auto hardwareInfo = getRootDeviceEnvironment().getMutableHardwareInfo();
273-
uuid.isValid = HwInfoConfig::get(hardwareInfo->platform.eProductFamily)->getUuid(this, uuid.id);
273+
uuid.isValid = false;
274+
275+
if (DebugManager.flags.EnableChipsetUniqueUUID.get() == 1) {
276+
uuid.isValid = HwInfoConfig::get(hardwareInfo->platform.eProductFamily)->getUuid(this, uuid.id);
277+
}
274278

275279
if (!uuid.isValid && getRootDeviceEnvironment().osInterface != nullptr) {
276280
PhysicalDevicePciBusInfo pciBusInfo = getRootDeviceEnvironment().osInterface->getDriverModel()->getPciBusInfo();

shared/test/unit_test/os_interface/device_uuid_tests.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,65 @@ HWTEST2_F(MultipleDeviceBdfUuidTest, GivenValidBdfWithOneBitEnabledInAffinityMas
170170
expectedUuid[15] = 4;
171171
EXPECT_TRUE(0 == std::memcmp(uuid.data(), expectedUuid, sizeof(expectedUuid)));
172172
}
173+
174+
using DeviceUuidEnablementTest = MultipleDeviceBdfUuidTest;
175+
176+
template <PRODUCT_FAMILY gfxProduct>
177+
class MockHwInfoConfigHwUuidEnablementTest : public HwInfoConfigHw<gfxProduct> {
178+
public:
179+
const bool returnStatus;
180+
MockHwInfoConfigHwUuidEnablementTest(bool returnStatus) : returnStatus(returnStatus) {}
181+
bool getUuid(Device *device, std::array<uint8_t, HwInfoConfig::uuidSize> &uuid) const override {
182+
uuid.fill(255u);
183+
return returnStatus;
184+
}
185+
};
186+
187+
HWTEST2_F(DeviceUuidEnablementTest, GivenEnableChipsetUniqueUUIDIsDefaultWhenDeviceIsCreatedThenChipsetUniqueUuidUsingTelemetryIsNotUsed, MatchAny) {
188+
189+
mockHwInfoConfig.reset(new MockHwInfoConfigHwUuidEnablementTest<productFamily>(true));
190+
VariableBackup<HwInfoConfig *> backupHwInfoConfig(&hwInfoConfigFactory[productFamily], mockHwInfoConfig.get());
191+
std::array<uint8_t, 16> uuid, expectedUuid;
192+
uuid.fill(0u);
193+
expectedUuid.fill(255u);
194+
195+
PhysicalDevicePciBusInfo pciBusInfo(0x00, 0x34, 0xab, 0xcd);
196+
const auto deviceFactory = createDevices(pciBusInfo, 2);
197+
198+
EXPECT_EQ(true, deviceFactory->rootDevices[0]->getUuid(uuid));
199+
EXPECT_FALSE(0 == std::memcmp(uuid.data(), expectedUuid.data(), 16));
200+
}
201+
202+
HWTEST2_F(DeviceUuidEnablementTest, GivenEnableChipsetUniqueUUIDIsEnabledWhenDeviceIsCreatedThenChipsetUniqueUuidUsingTelemetryIsUsed, MatchAny) {
203+
204+
mockHwInfoConfig.reset(new MockHwInfoConfigHwUuidEnablementTest<productFamily>(true));
205+
VariableBackup<HwInfoConfig *> backupHwInfoConfig(&hwInfoConfigFactory[productFamily], mockHwInfoConfig.get());
206+
DebugManager.flags.EnableChipsetUniqueUUID.set(1);
207+
std::array<uint8_t, 16> uuid, expectedUuid;
208+
uuid.fill(0u);
209+
expectedUuid.fill(255u);
210+
211+
PhysicalDevicePciBusInfo pciBusInfo(0x00, 0x34, 0xab, 0xcd);
212+
const auto deviceFactory = createDevices(pciBusInfo, 2);
213+
214+
EXPECT_EQ(true, deviceFactory->rootDevices[0]->getUuid(uuid));
215+
EXPECT_TRUE(0 == std::memcmp(uuid.data(), expectedUuid.data(), 16));
216+
}
217+
218+
HWTEST2_F(DeviceUuidEnablementTest, GivenEnableChipsetUniqueUUIDIsDisabledWhenDeviceIsCreatedThenChipsetUniqueUuidUsingTelemetryIsNotUsed, MatchAny) {
219+
220+
mockHwInfoConfig.reset(new MockHwInfoConfigHwUuidEnablementTest<productFamily>(true));
221+
VariableBackup<HwInfoConfig *> backupHwInfoConfig(&hwInfoConfigFactory[productFamily], mockHwInfoConfig.get());
222+
DebugManager.flags.EnableChipsetUniqueUUID.set(0);
223+
std::array<uint8_t, 16> uuid, expectedUuid;
224+
uuid.fill(0u);
225+
expectedUuid.fill(255u);
226+
227+
PhysicalDevicePciBusInfo pciBusInfo(0x00, 0x34, 0xab, 0xcd);
228+
const auto deviceFactory = createDevices(pciBusInfo, 2);
229+
230+
EXPECT_EQ(true, deviceFactory->rootDevices[0]->getUuid(uuid));
231+
EXPECT_FALSE(0 == std::memcmp(uuid.data(), expectedUuid.data(), 16));
232+
}
233+
173234
} // namespace NEO

0 commit comments

Comments
 (0)