Skip to content

Commit c4bb209

Browse files
Move query hwconfig table and engine info to DrmParam enum
Related-To: NEO-6852, NEO-6999 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 1cffe92 commit c4bb209

File tree

13 files changed

+93
-100
lines changed

13 files changed

+93
-100
lines changed

opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5842,38 +5842,6 @@ TEST_F(DrmMemoryManagerTest, whenCallPaddedAllocationWithMmapPtrAndFailedMmapCal
58425842
mock->ioctl_res = 0;
58435843
}
58445844

5845-
TEST(DistanceInfoTest, givenDistanceInfosWhenAssignRegionsFromDistancesThenCorrectRegionsSet) {
5846-
std::vector<MemoryRegion> memRegions(4);
5847-
memRegions[0] = {{I915_MEMORY_CLASS_SYSTEM, 0}, 1024, 0};
5848-
memRegions[1] = {{I915_MEMORY_CLASS_DEVICE, 0}, 1024, 0};
5849-
memRegions[2] = {{I915_MEMORY_CLASS_DEVICE, 1}, 1024, 0};
5850-
memRegions[3] = {{I915_MEMORY_CLASS_DEVICE, 2}, 1024, 0};
5851-
auto memoryInfo = std::make_unique<MemoryInfo>(memRegions);
5852-
5853-
std::vector<EngineClassInstance> engines(3);
5854-
engines[0] = {I915_ENGINE_CLASS_RENDER, 0};
5855-
engines[1] = {I915_ENGINE_CLASS_COPY, 0};
5856-
engines[2] = {I915_ENGINE_CLASS_COPY, 2};
5857-
5858-
auto distances = std::vector<DistanceInfo>();
5859-
for (const auto &region : memRegions) {
5860-
if (region.region.memoryClass == I915_MEMORY_CLASS_SYSTEM) {
5861-
continue;
5862-
}
5863-
for (const auto &engine : engines) {
5864-
DistanceInfo dist{};
5865-
dist.engine = engine;
5866-
dist.region = {region.region.memoryClass, region.region.memoryInstance};
5867-
dist.distance = (region.region.memoryInstance == engine.engineInstance) ? 0 : 100;
5868-
distances.push_back(dist);
5869-
}
5870-
}
5871-
memoryInfo->assignRegionsFromDistances(distances);
5872-
EXPECT_EQ(1024u, memoryInfo->getMemoryRegionSize(1));
5873-
EXPECT_EQ(1024u, memoryInfo->getMemoryRegionSize(2));
5874-
EXPECT_EQ(0u, memoryInfo->getMemoryRegionSize(4));
5875-
}
5876-
58775845
TEST_F(DrmMemoryManagerTest, GivenEligbleAllocationTypeWhenCheckingAllocationEligbleForCompletionFenceThenReturnTrue) {
58785846
AllocationType validAllocations[] = {
58795847
AllocationType::COMMAND_BUFFER,

shared/source/os_interface/linux/drm_neo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ int Drm::waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWi
966966
}
967967

968968
bool Drm::querySystemInfo() {
969-
auto request = ioctlHelper->getHwConfigIoctlVal();
969+
auto request = ioctlHelper->getDrmParamValue(DrmParam::QueryHwconfigTable);
970970
auto deviceBlobQuery = this->query(request, 0);
971971
if (deviceBlobQuery.empty()) {
972972
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stdout, "%s", "INFO: System Info query failed!\n");
@@ -991,7 +991,8 @@ bool Drm::queryMemoryInfo() {
991991
}
992992

993993
bool Drm::queryEngineInfo(bool isSysmanEnabled) {
994-
auto enginesQuery = this->query(ioctlHelper->getEngineInfoIoctlVal(), 0);
994+
auto request = ioctlHelper->getDrmParamValue(DrmParam::QueryEngineInfo);
995+
auto enginesQuery = this->query(request, 0);
995996
if (enginesQuery.empty()) {
996997
return false;
997998
}

shared/source/os_interface/linux/drm_wrappers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ enum class DrmParam {
244244
EngineClassVideoEnhance,
245245
EngineClassInvalid,
246246
EngineClassInvalidNone,
247+
QueryEngineInfo,
248+
QueryHwconfigTable,
247249
};
248250

249251
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest, IoctlHelper *ioctlHelper);

shared/source/os_interface/linux/ioctl_helper.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,12 @@ class IoctlHelper {
7878
virtual CacheRegion closFree(Drm *drm, CacheRegion closIndex) = 0;
7979
virtual int waitUserFence(Drm *drm, uint32_t ctxId, uint64_t address,
8080
uint64_t value, uint32_t dataWidth, int64_t timeout, uint16_t flags) = 0;
81-
virtual uint32_t getHwConfigIoctlVal() = 0;
8281
virtual uint32_t getAtomicAdvise(bool isNonAtomic) = 0;
8382
virtual uint32_t getPreferredLocationAdvise() = 0;
8483
virtual bool setVmBoAdvise(Drm *drm, int32_t handle, uint32_t attribute, void *region) = 0;
8584
virtual bool setVmPrefetch(Drm *drm, uint64_t start, uint64_t length, uint32_t region) = 0;
8685
virtual uint32_t getDirectSubmissionFlag() = 0;
8786
virtual int32_t getMemRegionsIoctlVal() = 0;
88-
virtual int32_t getEngineInfoIoctlVal() = 0;
8987
virtual uint32_t getComputeSlicesIoctlVal() = 0;
9088
virtual std::unique_ptr<uint8_t[]> prepareVmBindExt(const StackVec<uint32_t, 2> &bindExtHandles) = 0;
9189
virtual uint64_t getFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident) = 0;
@@ -139,14 +137,12 @@ class IoctlHelperUpstream : public IoctlHelper {
139137
CacheRegion closFree(Drm *drm, CacheRegion closIndex) override;
140138
int waitUserFence(Drm *drm, uint32_t ctxId, uint64_t address,
141139
uint64_t value, uint32_t dataWidth, int64_t timeout, uint16_t flags) override;
142-
uint32_t getHwConfigIoctlVal() override;
143140
uint32_t getAtomicAdvise(bool isNonAtomic) override;
144141
uint32_t getPreferredLocationAdvise() override;
145142
bool setVmBoAdvise(Drm *drm, int32_t handle, uint32_t attribute, void *region) override;
146143
bool setVmPrefetch(Drm *drm, uint64_t start, uint64_t length, uint32_t region) override;
147144
uint32_t getDirectSubmissionFlag() override;
148145
int32_t getMemRegionsIoctlVal() override;
149-
int32_t getEngineInfoIoctlVal() override;
150146
uint32_t getComputeSlicesIoctlVal() override;
151147
std::unique_ptr<uint8_t[]> prepareVmBindExt(const StackVec<uint32_t, 2> &bindExtHandles) override;
152148
uint64_t getFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident) override;
@@ -205,14 +201,12 @@ class IoctlHelperPrelim20 : public IoctlHelper {
205201
CacheRegion closFree(Drm *drm, CacheRegion closIndex) override;
206202
int waitUserFence(Drm *drm, uint32_t ctxId, uint64_t address,
207203
uint64_t value, uint32_t dataWidth, int64_t timeout, uint16_t flags) override;
208-
uint32_t getHwConfigIoctlVal() override;
209204
uint32_t getAtomicAdvise(bool isNonAtomic) override;
210205
uint32_t getPreferredLocationAdvise() override;
211206
bool setVmBoAdvise(Drm *drm, int32_t handle, uint32_t attribute, void *region) override;
212207
bool setVmPrefetch(Drm *drm, uint64_t start, uint64_t length, uint32_t region) override;
213208
uint32_t getDirectSubmissionFlag() override;
214209
int32_t getMemRegionsIoctlVal() override;
215-
int32_t getEngineInfoIoctlVal() override;
216210
uint32_t getComputeSlicesIoctlVal() override;
217211
std::unique_ptr<uint8_t[]> prepareVmBindExt(const StackVec<uint32_t, 2> &bindExtHandles) override;
218212
uint64_t getFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident) override;

shared/source/os_interface/linux/ioctl_helper_prelim.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,6 @@ int IoctlHelperPrelim20::waitUserFence(Drm *drm, uint32_t ctxId, uint64_t addres
175175
return IoctlHelper::ioctl(drm, DrmIoctl::GemWaitUserFence, &wait);
176176
}
177177

178-
uint32_t IoctlHelperPrelim20::getHwConfigIoctlVal() {
179-
return PRELIM_DRM_I915_QUERY_HWCONFIG_TABLE;
180-
}
181-
182178
uint32_t IoctlHelperPrelim20::getAtomicAdvise(bool isNonAtomic) {
183179
return isNonAtomic ? PRELIM_I915_VM_ADVISE_ATOMIC_NONE : PRELIM_I915_VM_ADVISE_ATOMIC_SYSTEM;
184180
}
@@ -231,10 +227,6 @@ int32_t IoctlHelperPrelim20::getMemRegionsIoctlVal() {
231227
return PRELIM_DRM_I915_QUERY_MEMORY_REGIONS;
232228
}
233229

234-
int32_t IoctlHelperPrelim20::getEngineInfoIoctlVal() {
235-
return PRELIM_DRM_I915_QUERY_ENGINE_INFO;
236-
}
237-
238230
uint32_t IoctlHelperPrelim20::getComputeSlicesIoctlVal() {
239231
return PRELIM_DRM_I915_QUERY_COMPUTE_SLICES;
240232
}
@@ -636,6 +628,10 @@ int IoctlHelperPrelim20::getDrmParamValue(DrmParam drmParam) const {
636628
switch (drmParam) {
637629
case DrmParam::EngineClassCompute:
638630
return PRELIM_I915_ENGINE_CLASS_COMPUTE;
631+
case DrmParam::QueryEngineInfo:
632+
return PRELIM_DRM_I915_QUERY_ENGINE_INFO;
633+
case DrmParam::QueryHwconfigTable:
634+
return PRELIM_DRM_I915_QUERY_HWCONFIG_TABLE;
639635
default:
640636
return getDrmParamValueBase(drmParam);
641637
}

shared/source/os_interface/linux/ioctl_helper_upstream.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ int IoctlHelperUpstream::waitUserFence(Drm *drm, uint32_t ctxId, uint64_t addres
8787
return 0;
8888
}
8989

90-
uint32_t IoctlHelperUpstream::getHwConfigIoctlVal() {
91-
return DRM_I915_QUERY_HWCONFIG_TABLE;
92-
}
93-
9490
uint32_t IoctlHelperUpstream::getAtomicAdvise(bool isNonAtomic) {
9591
return 0;
9692
}
@@ -115,10 +111,6 @@ int32_t IoctlHelperUpstream::getMemRegionsIoctlVal() {
115111
return DRM_I915_QUERY_MEMORY_REGIONS;
116112
}
117113

118-
int32_t IoctlHelperUpstream::getEngineInfoIoctlVal() {
119-
return DRM_I915_QUERY_ENGINE_INFO;
120-
}
121-
122114
uint32_t IoctlHelperUpstream::getComputeSlicesIoctlVal() {
123115
return 0;
124116
}
@@ -296,6 +288,10 @@ int IoctlHelperUpstream::getDrmParamValue(DrmParam drmParam) const {
296288
switch (drmParam) {
297289
case DrmParam::EngineClassCompute:
298290
return 4;
291+
case DrmParam::QueryEngineInfo:
292+
return DRM_I915_QUERY_ENGINE_INFO;
293+
case DrmParam::QueryHwconfigTable:
294+
return DRM_I915_QUERY_HWCONFIG_TABLE;
299295
default:
300296
return getDrmParamValueBase(drmParam);
301297
}

shared/test/common/libult/linux/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if(UNIX)
99
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
1010
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock.cpp
1111
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock.h
12-
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_mock_engine.cpp
12+
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_engine.cpp
1313
)
1414

1515
if(NEO_ENABLE_i915_PRELIM_DETECTION)

shared/test/common/libult/linux/drm_mock_engine.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
#include "gtest/gtest.h"
1212

1313
void DrmMockEngine::handleQueryItem(QueryItem *queryItem) {
14-
switch (queryItem->queryId) {
15-
case DRM_I915_QUERY_ENGINE_INFO:
14+
if (queryItem->queryId == static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::QueryEngineInfo))) {
1615
if (queryEngineInfoSuccessCount == 0) {
1716
queryItem->length = -EINVAL;
1817
} else {
@@ -26,14 +25,13 @@ void DrmMockEngine::handleQueryItem(QueryItem *queryItem) {
2625
auto queryEnginenInfo = reinterpret_cast<drm_i915_query_engine_info *>(queryItem->dataPtr);
2726
EXPECT_EQ(0u, queryEnginenInfo->num_engines);
2827
queryEnginenInfo->num_engines = numberOfEngines;
29-
queryEnginenInfo->engines[0].engine.engine_class = I915_ENGINE_CLASS_RENDER;
28+
queryEnginenInfo->engines[0].engine.engine_class = static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender));
3029
queryEnginenInfo->engines[0].engine.engine_instance = 1;
31-
queryEnginenInfo->engines[1].engine.engine_class = I915_ENGINE_CLASS_COPY;
30+
queryEnginenInfo->engines[1].engine.engine_class = static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy));
3231
queryEnginenInfo->engines[1].engine.engine_instance = 1;
3332
}
3433
}
35-
break;
36-
case DRM_I915_QUERY_HWCONFIG_TABLE: {
34+
} else if (queryItem->queryId == static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::QueryHwconfigTable))) {
3735
if (failQueryDeviceBlob) {
3836
queryItem->length = -EINVAL;
3937
} else {
@@ -46,6 +44,5 @@ void DrmMockEngine::handleQueryItem(QueryItem *queryItem) {
4644
memcpy(deviceBlobData, &dummyDeviceBlobData, deviceBlobSize);
4745
}
4846
}
49-
} break;
5047
}
5148
}

shared/test/unit_test/os_interface/linux/drm_engine_info_tests.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ TEST(EngineInfoTest, whenCreateEngineInfoWithRcsThenCorrectHwInfoSet) {
5656
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
5757
executionEnvironment->prepareRootDeviceEnvironments(1);
5858
auto drm = std::make_unique<DrmMockEngine>(*executionEnvironment->rootDeviceEnvironments[0]);
59+
auto ioctlHelper = drm->getIoctlHelper();
5960

6061
auto hwInfo = *defaultHwInfo.get();
6162
std::vector<EngineCapabilities> engines(2);
62-
engines[0].engine = {I915_ENGINE_CLASS_RENDER, 0};
63+
engines[0].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 0};
6364
engines[0].capabilities = 0;
64-
engines[1].engine = {I915_ENGINE_CLASS_COPY, 0};
65+
engines[1].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)), 0};
6566
engines[1].capabilities = 0;
6667
auto engineInfo = std::make_unique<EngineInfo>(drm.get(), &hwInfo, engines);
6768

@@ -76,13 +77,14 @@ TEST(EngineInfoTest, whenCreateEngineInfoWithCcsThenCorrectHwInfoSet) {
7677
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
7778
executionEnvironment->prepareRootDeviceEnvironments(1);
7879
auto drm = std::make_unique<DrmMockEngine>(*executionEnvironment->rootDeviceEnvironments[0]);
80+
auto ioctlHelper = drm->getIoctlHelper();
7981

8082
auto hwInfo = *defaultHwInfo.get();
8183
std::vector<EngineCapabilities> engines(2);
82-
uint16_t ccsClass = drm->getIoctlHelper()->getDrmParamValue(DrmParam::EngineClassCompute);
84+
uint16_t ccsClass = ioctlHelper->getDrmParamValue(DrmParam::EngineClassCompute);
8385
engines[0].engine = {ccsClass, 0};
8486
engines[0].capabilities = 0;
85-
engines[1].engine = {I915_ENGINE_CLASS_COPY, 0};
87+
engines[1].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)), 0};
8688
engines[1].capabilities = 0;
8789
auto engineInfo = std::make_unique<EngineInfo>(drm.get(), &hwInfo, engines);
8890

@@ -97,16 +99,17 @@ TEST(EngineInfoTest, whenGetEngineInstanceAndTileThenCorrectValuesReturned) {
9799
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
98100
executionEnvironment->prepareRootDeviceEnvironments(1);
99101
auto drm = std::make_unique<DrmMockEngine>(*executionEnvironment->rootDeviceEnvironments[0]);
102+
auto ioctlHelper = drm->getIoctlHelper();
100103

101104
auto hwInfo = *defaultHwInfo.get();
102105
std::vector<EngineCapabilities> engines(4);
103-
engines[0].engine = {I915_ENGINE_CLASS_RENDER, 0};
106+
engines[0].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 0};
104107
engines[0].capabilities = 0;
105-
engines[1].engine = {I915_ENGINE_CLASS_COPY, 0};
108+
engines[1].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)), 0};
106109
engines[1].capabilities = 0;
107-
engines[2].engine = {I915_ENGINE_CLASS_RENDER, 1};
110+
engines[2].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 1};
108111
engines[2].capabilities = 0;
109-
engines[3].engine = {I915_ENGINE_CLASS_COPY, 1};
112+
engines[3].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)), 1};
110113
engines[3].capabilities = 0;
111114

112115
std::vector<DistanceInfo> distances(4);
@@ -140,23 +143,24 @@ TEST(EngineInfoTest, whenGetEngineInstanceAndTileThenCorrectValuesReturned) {
140143
EXPECT_EQ(0u, engineInfo->getEngineTileIndex(engines[0].engine));
141144
EXPECT_EQ(1u, engineInfo->getEngineTileIndex(engines[2].engine));
142145

143-
EXPECT_EQ(0u, engineInfo->getEngineTileIndex({I915_ENGINE_CLASS_RENDER, 2}));
146+
EXPECT_EQ(0u, engineInfo->getEngineTileIndex({static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 2}));
144147
}
145148

146149
TEST(EngineInfoTest, whenCreateEngineInfoAndInvalidQueryThenNoEnginesSet) {
147150
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
148151
executionEnvironment->prepareRootDeviceEnvironments(1);
149152
auto drm = std::make_unique<DrmMockEngine>(*executionEnvironment->rootDeviceEnvironments[0]);
153+
auto ioctlHelper = drm->getIoctlHelper();
150154

151155
auto hwInfo = *defaultHwInfo.get();
152156
std::vector<EngineCapabilities> engines(4);
153-
engines[0].engine = {I915_ENGINE_CLASS_RENDER, 0};
157+
engines[0].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 0};
154158
engines[0].capabilities = 0;
155-
engines[1].engine = {I915_ENGINE_CLASS_COPY, 0};
159+
engines[1].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)), 0};
156160
engines[1].capabilities = 0;
157-
engines[2].engine = {I915_ENGINE_CLASS_RENDER, 1};
161+
engines[2].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 1};
158162
engines[2].capabilities = 0;
159-
engines[3].engine = {I915_ENGINE_CLASS_COPY, 1};
163+
engines[3].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)), 1};
160164
engines[3].capabilities = 0;
161165

162166
std::vector<DistanceInfo> distances(4);
@@ -181,12 +185,13 @@ TEST(EngineInfoTest, whenEmptyEngineInfoCreatedThen0TileReturned) {
181185
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
182186
executionEnvironment->prepareRootDeviceEnvironments(1);
183187
auto drm = std::make_unique<DrmMockEngine>(*executionEnvironment->rootDeviceEnvironments[0]);
188+
auto ioctlHelper = drm->getIoctlHelper();
184189

185190
auto hwInfo = *defaultHwInfo.get();
186191
std::vector<DistanceInfo> distances;
187192
std::vector<EngineCapabilities> engines;
188193
std::vector<QueryItem> queryItems;
189194

190195
auto engineInfo = std::make_unique<EngineInfo>(drm.get(), &hwInfo, 0, distances, queryItems, engines);
191-
EXPECT_EQ(0u, engineInfo->getEngineTileIndex({I915_ENGINE_CLASS_RENDER, 1}));
196+
EXPECT_EQ(0u, engineInfo->getEngineTileIndex({static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 1}));
192197
}

shared/test/unit_test/os_interface/linux/drm_tests.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,3 +1238,39 @@ TEST(IoctlHelperTest, whenGettingDrmParamValueThenProperValueIsReturned) {
12381238

12391239
EXPECT_THROW(ioctlHelper->getDrmParamValueBase(DrmParam::EngineClassCompute), std::runtime_error);
12401240
}
1241+
1242+
TEST(DistanceInfoTest, givenDistanceInfosWhenAssignRegionsFromDistancesThenCorrectRegionsSet) {
1243+
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
1244+
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
1245+
auto ioctlHelper = drm.getIoctlHelper();
1246+
1247+
std::vector<MemoryRegion> memRegions(4);
1248+
memRegions[0] = {{I915_MEMORY_CLASS_SYSTEM, 0}, 1024, 0};
1249+
memRegions[1] = {{I915_MEMORY_CLASS_DEVICE, 0}, 1024, 0};
1250+
memRegions[2] = {{I915_MEMORY_CLASS_DEVICE, 1}, 1024, 0};
1251+
memRegions[3] = {{I915_MEMORY_CLASS_DEVICE, 2}, 1024, 0};
1252+
auto memoryInfo = std::make_unique<MemoryInfo>(memRegions);
1253+
1254+
std::vector<EngineClassInstance> engines(3);
1255+
engines[0] = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 0};
1256+
engines[1] = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)), 0};
1257+
engines[2] = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)), 2};
1258+
1259+
auto distances = std::vector<DistanceInfo>();
1260+
for (const auto &region : memRegions) {
1261+
if (region.region.memoryClass == I915_MEMORY_CLASS_SYSTEM) {
1262+
continue;
1263+
}
1264+
for (const auto &engine : engines) {
1265+
DistanceInfo dist{};
1266+
dist.engine = engine;
1267+
dist.region = {region.region.memoryClass, region.region.memoryInstance};
1268+
dist.distance = (region.region.memoryInstance == engine.engineInstance) ? 0 : 100;
1269+
distances.push_back(dist);
1270+
}
1271+
}
1272+
memoryInfo->assignRegionsFromDistances(distances);
1273+
EXPECT_EQ(1024u, memoryInfo->getMemoryRegionSize(1));
1274+
EXPECT_EQ(1024u, memoryInfo->getMemoryRegionSize(2));
1275+
EXPECT_EQ(0u, memoryInfo->getMemoryRegionSize(4));
1276+
}

shared/test/unit_test/os_interface/linux/drm_with_prelim_tests.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,16 @@ TEST_F(IoctlHelperPrelimFixture, givenVariousDirectSubmissionFlagSettingWhenCrea
307307
}
308308

309309
TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenQueryDistancesThenCorrectDistanceSet) {
310+
auto ioctlHelper = drm->getIoctlHelper();
310311
std::vector<DistanceInfo> distances(3);
311-
distances[0].engine = {I915_ENGINE_CLASS_RENDER, 0};
312+
distances[0].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 0};
312313
distances[0].region = {I915_MEMORY_CLASS_DEVICE, 0};
313-
distances[1].engine = {I915_ENGINE_CLASS_RENDER, 1};
314+
distances[1].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 1};
314315
distances[1].region = {I915_MEMORY_CLASS_DEVICE, 1};
315-
distances[2].engine = {I915_ENGINE_CLASS_COPY, 4};
316+
distances[2].engine = {static_cast<uint16_t>(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)), 4};
316317
distances[2].region = {I915_MEMORY_CLASS_DEVICE, 2};
317318
std::vector<QueryItem> queryItems(distances.size());
318-
auto ret = drm->getIoctlHelper()->queryDistances(drm.get(), queryItems, distances);
319+
auto ret = ioctlHelper->queryDistances(drm.get(), queryItems, distances);
319320
EXPECT_EQ(0u, ret);
320321
EXPECT_EQ(0, distances[0].distance);
321322
EXPECT_EQ(0, distances[1].distance);

0 commit comments

Comments
 (0)