mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 05:24:02 +08:00
Change return type from unique_ptr to vector
In some of the drm functions there is a pattern to store array in unique_ptr and pass it's length as an argument. This commit simplifies this. Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9be5efe4f7
commit
d9f6757378
@@ -42,7 +42,7 @@ template <>
|
||||
struct Mock<MemoryNeoDrm> : public MemoryNeoDrm {
|
||||
Mock<MemoryNeoDrm>(RootDeviceEnvironment &rootDeviceEnvironment) : MemoryNeoDrm(rootDeviceEnvironment) {}
|
||||
bool queryMemoryInfoMockPositiveTest() {
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = probedSizeRegionZero;
|
||||
regionInfo[0].unallocatedSize = unallocatedSizeRegionZero;
|
||||
@@ -50,7 +50,7 @@ struct Mock<MemoryNeoDrm> : public MemoryNeoDrm {
|
||||
regionInfo[1].probedSize = probedSizeRegionOne;
|
||||
regionInfo[1].unallocatedSize = unallocatedSizeRegionOne;
|
||||
|
||||
this->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
this->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,13 +81,13 @@ TEST(MemoryInfo, givenMemoryRegionQueryWhenQueryingFailsThenMemoryInfoIsNotCreat
|
||||
TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryEnabledWhenGettingMemoryRegionClassAndInstanceThenReturnCorrectValues) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableLocalMemory.set(1);
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probedSize = 16 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 2);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
|
||||
@@ -106,13 +106,13 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryEnabledWhenGettingMemor
|
||||
TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryEnabledWhenAssignRegionsFromDistancesThenRegionsNotChanged) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableLocalMemory.set(1);
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probedSize = 16 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 2);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
memoryInfo->assignRegionsFromDistances(®ionInfo, 2);
|
||||
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
|
||||
@@ -129,10 +129,10 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryEnabledWhenAssignRegion
|
||||
}
|
||||
|
||||
TEST(MemoryInfo, givenMemoryInfoWithoutDeviceRegionWhenGettingDeviceRegionSizeThenReturnCorrectSize) {
|
||||
MemoryRegion regionInfo[1] = {};
|
||||
std::vector<MemoryRegion> regionInfo(1);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = 8 * GB;
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 1);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
|
||||
EXPECT_EQ(0 * GB, regionSize);
|
||||
@@ -141,13 +141,13 @@ TEST(MemoryInfo, givenMemoryInfoWithoutDeviceRegionWhenGettingDeviceRegionSizeTh
|
||||
TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryDisabledWhenGettingMemoryRegionClassAndInstanceThenReturnCorrectValues) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableLocalMemory.set(0);
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probedSize = 16 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 2);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
|
||||
@@ -167,11 +167,11 @@ TEST(MemoryInfo, whenDebugVariablePrintMemoryRegionSizeIsSetAndGetMemoryRegionSi
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.PrintMemoryRegionSizes.set(true);
|
||||
|
||||
MemoryRegion regionInfo[1] = {};
|
||||
std::vector<MemoryRegion> regionInfo(1);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 1};
|
||||
regionInfo[0].probedSize = 16 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 1);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
@@ -186,7 +186,7 @@ TEST(MemoryInfo, whenDebugVariablePrintMemoryRegionSizeIsSetAndGetMemoryRegionSi
|
||||
TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenGettingMemoryRegionClassAndInstanceWhileDebugFlagIsActiveThenReturnCorrectValues) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableLocalMemory.set(1);
|
||||
MemoryRegion regionInfo[3] = {};
|
||||
std::vector<MemoryRegion> regionInfo(3);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
@@ -194,7 +194,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenGettingMemoryRegionClassAndInstan
|
||||
regionInfo[2].region = {I915_MEMORY_CLASS_DEVICE, 1};
|
||||
regionInfo[2].probedSize = 32 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 3);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
DebugManager.flags.OverrideDrmRegion.set(1);
|
||||
@@ -232,7 +232,7 @@ TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenGettingMemoryRegionClassAndInstan
|
||||
using MemoryInfoTest = ::testing::Test;
|
||||
|
||||
HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemWithExtensionsThenReturnCorrectValues, NonDefaultIoctlsSupported) {
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
@@ -241,11 +241,12 @@ HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemWithExtension
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 2);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
uint32_t handle = 0;
|
||||
auto ret = memoryInfo->createGemExt(drm.get(), ®ionInfo, 2, 1024, handle);
|
||||
std::vector<MemoryClassInstance> memClassInstance = {regionInfo[0].region, regionInfo[1].region};
|
||||
auto ret = memoryInfo->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
@@ -255,13 +256,13 @@ HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemWithExtension
|
||||
HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemExtWithSingleRegionThenReturnCorrectValues, NonDefaultIoctlsSupported) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableLocalMemory.set(1);
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probedSize = 16 * GB;
|
||||
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo, 2);
|
||||
auto memoryInfo = std::make_unique<MemoryInfo>(regionInfo);
|
||||
ASSERT_NE(nullptr, memoryInfo);
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
|
||||
@@ -91,11 +91,11 @@ class DrmMemoryManagerLocalMemoryWithCustomMockTest : public ::testing::Test {
|
||||
HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBufferObjectInMemoryRegionIsCalledThenBufferObjectWithAGivenGpuAddressAndSizeIsCreatedAndAllocatedInASpecifiedMemoryRegion, NonDefaultIoctlsSupported) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableLocalMemory.set(1);
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
mock->ioctlCallsCount = 0;
|
||||
|
||||
auto gpuAddress = 0x1234u;
|
||||
@@ -131,11 +131,11 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndMem
|
||||
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
|
||||
auto mock = new DrmTipMock(*executionEnvironment->rootDeviceEnvironments[i]);
|
||||
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
mock->ioctlCallsCount = 0;
|
||||
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
|
||||
@@ -176,11 +176,11 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndMemory
|
||||
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
|
||||
auto mock = new DrmTipMock(*executionEnvironment->rootDeviceEnvironments[i]);
|
||||
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
mock->ioctlCallsCount = 0;
|
||||
mock->fdToHandleRetVal = -1;
|
||||
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
|
||||
@@ -235,11 +235,11 @@ TEST_F(DrmMemoryManagerUsmSharedHandleTest, givenMultiRootDeviceEnvironmentAndMe
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get());
|
||||
auto mock = new DrmTipMock(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]);
|
||||
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
mock->ioctlCallsCount = 0;
|
||||
mock->fdToHandleRetVal = -1;
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
||||
@@ -302,11 +302,11 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoWhenAllocateWithAlignm
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableBOMmapCreate.set(-1);
|
||||
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
mock->ioctlCallsCount = 0;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -327,11 +327,11 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoAndNotUseObjectMmapProper
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableBOMmapCreate.set(0);
|
||||
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
mock->mmapOffsetRetVal = -1;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -350,11 +350,11 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoAndFailedMmapOffsetWhenAl
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableBOMmapCreate.set(-1);
|
||||
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
mock->mmapOffsetRetVal = -1;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -370,11 +370,11 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoAndDisabledMmapBOCreation
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableBOMmapCreate.set(0);
|
||||
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
mock->mmapOffsetRetVal = -1;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -392,11 +392,11 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMemoryInfoAndFailedGemCreateExtWhen
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableBOMmapCreate.set(-1);
|
||||
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
mock->gemCreateExtRetVal = -1;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -936,11 +936,11 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenAlignmentAndSizeWhenMmapReturnsU
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableBOMmapCreate.set(-1);
|
||||
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
mock->ioctlCallsCount = 0;
|
||||
|
||||
AllocationData allocationData;
|
||||
@@ -973,11 +973,11 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenAlignmentAndSizeWhenMmapReturnsA
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableBOMmapCreate.set(-1);
|
||||
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MemoryInfo(regionInfo));
|
||||
mock->ioctlCallsCount = 0;
|
||||
|
||||
AllocationData allocationData;
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
constexpr MemoryRegion memoryRegions[2] = {
|
||||
const std::vector<MemoryRegion> memoryRegions = {
|
||||
{{I915_MEMORY_CLASS_SYSTEM, 0}, 64 * GB, 0},
|
||||
{{I915_MEMORY_CLASS_DEVICE, 0}, 8 * GB, 0}};
|
||||
|
||||
struct MockMemoryInfo : public MemoryInfo {
|
||||
MockMemoryInfo() : MemoryInfo(memoryRegions, 2) {}
|
||||
MockMemoryInfo() : MemoryInfo(memoryRegions) {}
|
||||
~MockMemoryInfo() override{};
|
||||
};
|
||||
|
||||
@@ -29,7 +29,8 @@ TEST(DrmSystemInfoTest, whenQueryingSystemInfoThenSystemInfoIsNotCreatedAndIoctl
|
||||
}
|
||||
|
||||
TEST(DrmSystemInfoTest, givenSystemInfoCreatedWhenQueryingSpecificAtrributesThenReturnZero) {
|
||||
SystemInfo systemInfo(nullptr, 0);
|
||||
std::vector<uint8_t> inputData{};
|
||||
SystemInfo systemInfo(inputData);
|
||||
|
||||
EXPECT_EQ(0u, systemInfo.getL3CacheSizeInKb());
|
||||
EXPECT_EQ(0u, systemInfo.getL3BankCount());
|
||||
@@ -105,7 +106,7 @@ TEST(DrmSystemInfoTest, whenQueryingSystemInfoThenSystemInfoIsCreatedAndReturnsN
|
||||
}
|
||||
|
||||
TEST(DrmSystemInfoTest, givenSystemInfoCreatedFromDeviceBlobWhenQueryingSpecificAtrributesThenReturnCorrectValues) {
|
||||
SystemInfo systemInfo(dummyDeviceBlobData, sizeof(dummyDeviceBlobData));
|
||||
SystemInfo systemInfo(inputBlobData);
|
||||
|
||||
EXPECT_EQ(0x0Au, systemInfo.getMaxMemoryChannels());
|
||||
EXPECT_EQ(0x0Bu, systemInfo.getMemoryType());
|
||||
|
||||
@@ -23,15 +23,10 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WhenCreateGemExtThenReturnCorrectValue) {
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probed_size = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probed_size = 16 * GB;
|
||||
|
||||
auto ioctlHelper = IoctlHelper::get(drm.get());
|
||||
uint32_t handle = 0;
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, handle);
|
||||
@@ -47,15 +42,12 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WithDrmTipWhenCreateGemExtWithDebugFlagTh
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto ioctlHelper = IoctlHelper::get(drm.get());
|
||||
uint32_t handle = 0;
|
||||
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: 0 BO-1 with size: 1024\n");
|
||||
@@ -71,18 +63,15 @@ DG1TEST_F(IoctlHelperTestsDg1, givenDg1WhenCreateGemExtWithDebugFlagThenPrintDeb
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmMockProdDg1>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto ioctlHelper = IoctlHelper::get(drm.get());
|
||||
uint32_t handle = 0;
|
||||
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_SETPARAM has returned: 0 BO-1 with size: 1024\n");
|
||||
std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: -1 BO-0 with size: 1024\nGEM_CREATE_EXT with EXT_SETPARAM has returned: 0 BO-1 with size: 1024\n");
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
EXPECT_EQ(2u, drm->ioctlCallsCount);
|
||||
EXPECT_EQ(0u, ret);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
using namespace NEO;
|
||||
|
||||
extern int handlePrelimRequests(unsigned long request, void *arg, int ioctlRetVal);
|
||||
extern std::unique_ptr<uint8_t[]> getRegionInfo(const MemoryRegion *inputRegions, uint32_t size);
|
||||
extern std::vector<uint8_t> getRegionInfo(const std::vector<MemoryRegion> &inputRegions);
|
||||
|
||||
class DrmPrelimMock : public DrmMock {
|
||||
public:
|
||||
@@ -42,15 +42,10 @@ TEST(IoctlHelperTestsPrelim, givenPrelimsWhenCreateGemExtThenReturnSuccess) {
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmPrelimMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probed_size = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probed_size = 16 * GB;
|
||||
|
||||
auto ioctlHelper = IoctlHelper::get(drm.get());
|
||||
uint32_t handle = 0;
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
EXPECT_EQ(1u, handle);
|
||||
EXPECT_EQ(0u, ret);
|
||||
@@ -65,14 +60,11 @@ TEST(IoctlHelperTestsPrelim, givenPrelimsWhenCreateGemExtWithDebugFlagThenPrintD
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmPrelimMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto ioctlHelper = IoctlHelper::get(drm.get());
|
||||
uint32_t handle = 0;
|
||||
ioctlHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, param: 0x1000000010001, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT has returned: 0 BO-1 with size: 1024\n");
|
||||
@@ -83,7 +75,7 @@ TEST(IoctlHelperTestsPrelim, givenPrelimsWhenTranslateToMemoryRegionsThenReturnS
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmPrelimMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
MemoryRegion expectedMemRegions[2] = {};
|
||||
std::vector<MemoryRegion> expectedMemRegions(2);
|
||||
expectedMemRegions[0].region.memoryClass = I915_MEMORY_CLASS_SYSTEM;
|
||||
expectedMemRegions[0].region.memoryInstance = 0;
|
||||
expectedMemRegions[0].probedSize = 1024;
|
||||
@@ -91,13 +83,12 @@ TEST(IoctlHelperTestsPrelim, givenPrelimsWhenTranslateToMemoryRegionsThenReturnS
|
||||
expectedMemRegions[1].region.memoryInstance = 0;
|
||||
expectedMemRegions[1].probedSize = 1024;
|
||||
|
||||
auto regionInfo = getRegionInfo(expectedMemRegions, 2);
|
||||
auto regionInfo = getRegionInfo(expectedMemRegions);
|
||||
|
||||
auto numRegions = 0u;
|
||||
auto ioctlHelper = IoctlHelper::get(drm.get());
|
||||
auto memRegions = ioctlHelper->translateToMemoryRegions(reinterpret_cast<uint8_t *>(regionInfo.get()), 0, numRegions);
|
||||
EXPECT_EQ(2u, numRegions);
|
||||
for (uint32_t i = 0; i < numRegions; i++) {
|
||||
auto memRegions = ioctlHelper->translateToMemoryRegions(regionInfo);
|
||||
EXPECT_EQ(2u, memRegions.size());
|
||||
for (uint32_t i = 0; i < memRegions.size(); i++) {
|
||||
EXPECT_EQ(expectedMemRegions[i].region.memoryClass, memRegions[i].region.memoryClass);
|
||||
EXPECT_EQ(expectedMemRegions[i].region.memoryInstance, memRegions[i].region.memoryInstance);
|
||||
EXPECT_EQ(expectedMemRegions[i].probedSize, memRegions[i].probedSize);
|
||||
|
||||
@@ -20,15 +20,10 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCreateGemExtThenReturnCorrectVal
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probed_size = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probed_size = 16 * GB;
|
||||
|
||||
auto ioctlHelper = IoctlHelper::get(drm.get());
|
||||
uint32_t handle = 0;
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
auto ret = ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
EXPECT_EQ(0u, ret);
|
||||
EXPECT_EQ(1u, handle);
|
||||
@@ -45,14 +40,11 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenCreateGemExtWithDebugFlagThenPri
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
drm_i915_memory_region_info regionInfo[2] = {};
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto ioctlHelper = IoctlHelper::get(drm.get());
|
||||
uint32_t handle = 0;
|
||||
ioctlHelper->createGemExt(drm.get(), ®ionInfo[1], 1, 1024, handle);
|
||||
std::vector<MemoryClassInstance> memClassInstance = {{I915_MEMORY_CLASS_DEVICE, 0}};
|
||||
ioctlHelper->createGemExt(drm.get(), memClassInstance, 1024, handle);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
std::string expectedOutput("Performing GEM_CREATE_EXT with { size: 1024, memory class: 1, memory instance: 0 }\nGEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: 0 BO-1 with size: 1024\n");
|
||||
|
||||
@@ -49,13 +49,14 @@ int handlePrelimRequests(unsigned long request, void *arg, int ioctlRetVal) {
|
||||
return ioctlRetVal;
|
||||
}
|
||||
|
||||
std::unique_ptr<uint8_t[]> getRegionInfo(const MemoryRegion *inputRegions, uint32_t size) {
|
||||
int length = sizeof(prelim_drm_i915_query_memory_regions) + size * sizeof(prelim_drm_i915_memory_region_info);
|
||||
auto data = std::make_unique<uint8_t[]>(length);
|
||||
auto memoryRegions = reinterpret_cast<prelim_drm_i915_query_memory_regions *>(data.get());
|
||||
memoryRegions->num_regions = size;
|
||||
std::vector<uint8_t> getRegionInfo(const std::vector<MemoryRegion> &inputRegions) {
|
||||
auto inputSize = static_cast<uint32_t>(inputRegions.size());
|
||||
int length = sizeof(prelim_drm_i915_query_memory_regions) + inputSize * sizeof(prelim_drm_i915_memory_region_info);
|
||||
auto data = std::vector<uint8_t>(length);
|
||||
auto memoryRegions = reinterpret_cast<prelim_drm_i915_query_memory_regions *>(data.data());
|
||||
memoryRegions->num_regions = inputSize;
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
for (uint32_t i = 0; i < inputSize; i++) {
|
||||
memoryRegions->regions[i].region.memory_class = inputRegions[i].region.memoryClass;
|
||||
memoryRegions->regions[i].region.memory_instance = inputRegions[i].region.memoryInstance;
|
||||
memoryRegions->regions[i].probed_size = inputRegions[i].probedSize;
|
||||
|
||||
@@ -600,7 +600,7 @@ bool Drm::isi915Version(int fileDescriptor) {
|
||||
return strcmp(name, "i915") == 0;
|
||||
}
|
||||
|
||||
std::unique_ptr<uint8_t[]> Drm::query(uint32_t queryId, uint32_t queryItemFlags, int32_t &length) {
|
||||
std::vector<uint8_t> Drm::query(uint32_t queryId, uint32_t queryItemFlags) {
|
||||
drm_i915_query query{};
|
||||
drm_i915_query_item queryItem{};
|
||||
queryItem.query_id = queryId;
|
||||
@@ -608,23 +608,19 @@ std::unique_ptr<uint8_t[]> Drm::query(uint32_t queryId, uint32_t queryItemFlags,
|
||||
queryItem.flags = queryItemFlags;
|
||||
query.items_ptr = reinterpret_cast<__u64>(&queryItem);
|
||||
query.num_items = 1;
|
||||
length = 0;
|
||||
|
||||
auto ret = this->ioctl(DRM_IOCTL_I915_QUERY, &query);
|
||||
if (ret != 0 || queryItem.length <= 0) {
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
|
||||
auto data = std::make_unique<uint8_t[]>(queryItem.length);
|
||||
memset(data.get(), 0, queryItem.length);
|
||||
queryItem.data_ptr = castToUint64(data.get());
|
||||
auto data = std::vector<uint8_t>(queryItem.length, 0);
|
||||
queryItem.data_ptr = castToUint64(data.data());
|
||||
|
||||
ret = this->ioctl(DRM_IOCTL_I915_QUERY, &query);
|
||||
if (ret != 0 || queryItem.length <= 0) {
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
|
||||
length = queryItem.length;
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -915,16 +911,13 @@ int Drm::waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWi
|
||||
}
|
||||
|
||||
bool Drm::querySystemInfo() {
|
||||
auto length = 0;
|
||||
auto request = IoctlHelper::get(this)->getHwConfigIoctlVal();
|
||||
auto deviceBlobQuery = this->query(request, DrmQueryItemFlags::empty, length);
|
||||
auto deviceBlob = reinterpret_cast<uint32_t *>(deviceBlobQuery.get());
|
||||
if (!deviceBlob) {
|
||||
auto deviceBlobQuery = this->query(request, DrmQueryItemFlags::empty);
|
||||
if (deviceBlobQuery.empty()) {
|
||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stdout, "%s", "INFO: System Info query failed!\n");
|
||||
return false;
|
||||
}
|
||||
this->systemInfo.reset(new SystemInfo(deviceBlob, length));
|
||||
|
||||
this->systemInfo.reset(new SystemInfo(deviceBlobQuery));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ class Drm : public DriverModel {
|
||||
uint32_t getPciDomain() {
|
||||
return pciDomain;
|
||||
}
|
||||
MOCKABLE_VIRTUAL std::unique_ptr<uint8_t[]> getMemoryRegions();
|
||||
MOCKABLE_VIRTUAL std::vector<uint8_t> getMemoryRegions();
|
||||
|
||||
protected:
|
||||
Drm(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment);
|
||||
@@ -260,7 +260,7 @@ class Drm : public DriverModel {
|
||||
std::string generateUUID();
|
||||
std::string generateElfUUID(const void *data);
|
||||
std::string getSysFsPciPath();
|
||||
std::unique_ptr<uint8_t[]> query(uint32_t queryId, uint32_t queryItemFlags, int32_t &length);
|
||||
std::vector<uint8_t> query(uint32_t queryId, uint32_t queryItemFlags);
|
||||
void printIoctlStatistics();
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
@@ -33,27 +33,24 @@ std::string getIoctlParamStringRemaining(int param) {
|
||||
} // namespace IoctlToStringHelper
|
||||
|
||||
bool Drm::queryEngineInfo(bool isSysmanEnabled) {
|
||||
auto length = 0;
|
||||
auto dataQuery = this->query(DRM_I915_QUERY_ENGINE_INFO, DrmQueryItemFlags::empty, length);
|
||||
auto data = reinterpret_cast<drm_i915_query_engine_info *>(dataQuery.get());
|
||||
if (data) {
|
||||
this->engineInfo.reset(new EngineInfoImpl(data->engines, data->num_engines));
|
||||
return true;
|
||||
auto dataQuery = this->query(DRM_I915_QUERY_ENGINE_INFO, DrmQueryItemFlags::empty);
|
||||
if (dataQuery.empty()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
auto data = reinterpret_cast<drm_i915_query_engine_info *>(dataQuery.data());
|
||||
this->engineInfo.reset(new EngineInfoImpl(data->engines, data->num_engines));
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<uint8_t[]> Drm::getMemoryRegions() {
|
||||
return nullptr;
|
||||
std::vector<uint8_t> Drm::getMemoryRegions() {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool Drm::queryMemoryInfo() {
|
||||
auto length = 0;
|
||||
auto dataQuery = this->query(DRM_I915_QUERY_MEMORY_REGIONS, DrmQueryItemFlags::empty, length);
|
||||
if (dataQuery) {
|
||||
auto numRegions = 0u;
|
||||
auto memRegions = IoctlHelper::get(this)->translateToMemoryRegions(dataQuery.get(), length, numRegions);
|
||||
this->memoryInfo.reset(new MemoryInfo(memRegions.get(), numRegions));
|
||||
auto dataQuery = this->query(DRM_I915_QUERY_MEMORY_REGIONS, DrmQueryItemFlags::empty);
|
||||
if (!dataQuery.empty()) {
|
||||
auto memRegions = IoctlHelper::get(this)->translateToMemoryRegions(dataQuery);
|
||||
this->memoryInfo.reset(new MemoryInfo(memRegions));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -77,13 +74,11 @@ int Drm::createDrmVirtualMemory(uint32_t &drmVmId) {
|
||||
}
|
||||
|
||||
bool Drm::queryTopology(const HardwareInfo &hwInfo, QueryTopologyData &topologyData) {
|
||||
int32_t length;
|
||||
auto dataQuery = this->query(DRM_I915_QUERY_TOPOLOGY_INFO, DrmQueryItemFlags::topology, length);
|
||||
auto data = reinterpret_cast<drm_i915_query_topology_info *>(dataQuery.get());
|
||||
|
||||
if (!data) {
|
||||
auto dataQuery = this->query(DRM_I915_QUERY_TOPOLOGY_INFO, DrmQueryItemFlags::topology);
|
||||
if (dataQuery.empty()) {
|
||||
return false;
|
||||
}
|
||||
auto data = reinterpret_cast<drm_i915_query_topology_info *>(dataQuery.data());
|
||||
|
||||
topologyData.maxSliceCount = data->max_slices;
|
||||
topologyData.maxSubSliceCount = data->max_subslices;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
class Drm;
|
||||
@@ -36,8 +37,8 @@ class IoctlHelper {
|
||||
static IoctlHelper *get(Drm *drm);
|
||||
static uint32_t ioctl(Drm *drm, unsigned long request, void *arg);
|
||||
|
||||
virtual uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) = 0;
|
||||
virtual std::unique_ptr<MemoryRegion[]> translateToMemoryRegions(uint8_t *dataQuery, uint32_t length, uint32_t &numRegions) = 0;
|
||||
virtual uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) = 0;
|
||||
virtual std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) = 0;
|
||||
virtual CacheRegion closAlloc(Drm *drm) = 0;
|
||||
virtual uint16_t closAllocWays(Drm *drm, CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) = 0;
|
||||
virtual CacheRegion closFree(Drm *drm, CacheRegion closIndex) = 0;
|
||||
@@ -52,8 +53,8 @@ class IoctlHelper {
|
||||
|
||||
class IoctlHelperUpstream : public IoctlHelper {
|
||||
public:
|
||||
uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override;
|
||||
std::unique_ptr<MemoryRegion[]> translateToMemoryRegions(uint8_t *dataQuery, uint32_t length, uint32_t &numRegions) override;
|
||||
uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) override;
|
||||
std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) override;
|
||||
CacheRegion closAlloc(Drm *drm) override;
|
||||
uint16_t closAllocWays(Drm *drm, CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
|
||||
CacheRegion closFree(Drm *drm, CacheRegion closIndex) override;
|
||||
@@ -73,14 +74,14 @@ class IoctlHelperImpl : public IoctlHelperUpstream {
|
||||
static IoctlHelperImpl<gfxProduct> instance;
|
||||
return &instance;
|
||||
}
|
||||
uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override;
|
||||
std::unique_ptr<MemoryRegion[]> translateToMemoryRegions(uint8_t *dataQuery, uint32_t length, uint32_t &numRegions) override;
|
||||
uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) override;
|
||||
std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) override;
|
||||
};
|
||||
|
||||
class IoctlHelperPrelim20 : public IoctlHelper {
|
||||
public:
|
||||
uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override;
|
||||
std::unique_ptr<MemoryRegion[]> translateToMemoryRegions(uint8_t *dataQuery, uint32_t length, uint32_t &numRegions) override;
|
||||
uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) override;
|
||||
std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) override;
|
||||
CacheRegion closAlloc(Drm *drm) override;
|
||||
uint16_t closAllocWays(Drm *drm, CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
|
||||
CacheRegion closFree(Drm *drm, CacheRegion closIndex) override;
|
||||
|
||||
@@ -18,9 +18,15 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
uint32_t IoctlHelperPrelim20::createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) {
|
||||
uint32_t IoctlHelperPrelim20::createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
uint32_t regionsSize = static_cast<uint32_t>(memClassInstances.size());
|
||||
prelim_drm_i915_gem_memory_class_instance data[regionsSize];
|
||||
for (uint32_t i = 0; i < regionsSize; i++) {
|
||||
data[i].memory_class = memClassInstances[i].memoryClass;
|
||||
data[i].memory_instance = memClassInstances[i].memoryInstance;
|
||||
}
|
||||
prelim_drm_i915_gem_object_param regionParam{};
|
||||
regionParam.size = dataSize;
|
||||
regionParam.size = regionsSize;
|
||||
regionParam.data = reinterpret_cast<uintptr_t>(data);
|
||||
regionParam.param = PRELIM_I915_OBJECT_PARAM | PRELIM_I915_PARAM_MEMORY_REGIONS;
|
||||
|
||||
@@ -36,7 +42,7 @@ uint32_t IoctlHelperPrelim20::createGemExt(Drm *drm, void *data, uint32_t dataSi
|
||||
allocSize, regionParam.param);
|
||||
|
||||
if (DebugManager.flags.PrintBOCreateDestroyResult.get()) {
|
||||
for (uint32_t i = 0; i < dataSize; i++) {
|
||||
for (uint32_t i = 0; i < regionsSize; i++) {
|
||||
auto region = reinterpret_cast<prelim_drm_i915_gem_memory_class_instance *>(data)[i];
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, ", memory class: %d, memory instance: %d",
|
||||
region.memory_class, region.memory_instance);
|
||||
@@ -51,16 +57,15 @@ uint32_t IoctlHelperPrelim20::createGemExt(Drm *drm, void *data, uint32_t dataSi
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::unique_ptr<MemoryRegion[]> IoctlHelperPrelim20::translateToMemoryRegions(uint8_t *dataQuery, uint32_t length, uint32_t &numRegions) {
|
||||
auto *data = reinterpret_cast<prelim_drm_i915_query_memory_regions *>(dataQuery);
|
||||
auto memRegions = std::make_unique<MemoryRegion[]>(data->num_regions);
|
||||
std::vector<MemoryRegion> IoctlHelperPrelim20::translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) {
|
||||
auto *data = reinterpret_cast<const prelim_drm_i915_query_memory_regions *>(regionInfo.data());
|
||||
auto memRegions = std::vector<MemoryRegion>(data->num_regions);
|
||||
for (uint32_t i = 0; i < data->num_regions; i++) {
|
||||
memRegions[i].probedSize = data->regions[i].probed_size;
|
||||
memRegions[i].unallocatedSize = data->regions[i].unallocated_size;
|
||||
memRegions[i].region.memoryClass = data->regions[i].region.memory_class;
|
||||
memRegions[i].region.memoryInstance = data->regions[i].region.memory_instance;
|
||||
}
|
||||
numRegions = data->num_regions;
|
||||
return memRegions;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,15 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
uint32_t IoctlHelperUpstream::createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) {
|
||||
uint32_t IoctlHelperUpstream::createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
uint32_t regionsSize = static_cast<uint32_t>(memClassInstances.size());
|
||||
drm_i915_gem_memory_class_instance data[regionsSize];
|
||||
for (uint32_t i = 0; i < regionsSize; i++) {
|
||||
data[i].memory_class = memClassInstances[i].memoryClass;
|
||||
data[i].memory_instance = memClassInstances[i].memoryInstance;
|
||||
}
|
||||
drm_i915_gem_create_ext_memory_regions memRegions{};
|
||||
memRegions.num_regions = dataSize;
|
||||
memRegions.num_regions = regionsSize;
|
||||
memRegions.regions = reinterpret_cast<uintptr_t>(data);
|
||||
memRegions.base.name = I915_GEM_CREATE_EXT_MEMORY_REGIONS;
|
||||
|
||||
@@ -27,7 +33,7 @@ uint32_t IoctlHelperUpstream::createGemExt(Drm *drm, void *data, uint32_t dataSi
|
||||
allocSize);
|
||||
|
||||
if (DebugManager.flags.PrintBOCreateDestroyResult.get()) {
|
||||
for (uint32_t i = 0; i < dataSize; i++) {
|
||||
for (uint32_t i = 0; i < regionsSize; i++) {
|
||||
auto region = reinterpret_cast<drm_i915_gem_memory_class_instance *>(data)[i];
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, ", memory class: %d, memory instance: %d",
|
||||
region.memory_class, region.memory_instance);
|
||||
@@ -42,16 +48,15 @@ uint32_t IoctlHelperUpstream::createGemExt(Drm *drm, void *data, uint32_t dataSi
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::unique_ptr<MemoryRegion[]> IoctlHelperUpstream::translateToMemoryRegions(uint8_t *dataQuery, uint32_t length, uint32_t &numRegions) {
|
||||
auto *data = reinterpret_cast<drm_i915_query_memory_regions *>(dataQuery);
|
||||
auto memRegions = std::make_unique<MemoryRegion[]>(data->num_regions);
|
||||
std::vector<MemoryRegion> IoctlHelperUpstream::translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) {
|
||||
auto *data = reinterpret_cast<const drm_i915_query_memory_regions *>(regionInfo.data());
|
||||
auto memRegions = std::vector<MemoryRegion>(data->num_regions);
|
||||
for (uint32_t i = 0; i < data->num_regions; i++) {
|
||||
memRegions[i].probedSize = data->regions[i].probed_size;
|
||||
memRegions[i].unallocatedSize = data->regions[i].unallocated_size;
|
||||
memRegions[i].region.memoryClass = data->regions[i].region.memory_class;
|
||||
memRegions[i].region.memoryInstance = data->regions[i].region.memory_instance;
|
||||
}
|
||||
numRegions = data->num_regions;
|
||||
return memRegions;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,26 +13,10 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
uint32_t createGemExtMemoryRegions(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) {
|
||||
drm_i915_gem_create_ext_memory_regions extRegions{};
|
||||
extRegions.base.name = I915_GEM_CREATE_EXT_MEMORY_REGIONS;
|
||||
extRegions.num_regions = dataSize;
|
||||
extRegions.regions = reinterpret_cast<uintptr_t>(data);
|
||||
|
||||
drm_i915_gem_create_ext createExt{};
|
||||
createExt.size = allocSize;
|
||||
createExt.extensions = reinterpret_cast<uintptr_t>(&extRegions);
|
||||
|
||||
auto ret = IoctlHelper::ioctl(drm, DRM_IOCTL_I915_GEM_CREATE_EXT, &createExt);
|
||||
|
||||
handle = createExt.handle;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool isQueryDrmTip(uint8_t *dataQuery, int32_t length) {
|
||||
auto dataOnDrmTip = reinterpret_cast<drm_i915_query_memory_regions *>(dataQuery);
|
||||
auto lengthOnDrmTip = static_cast<int32_t>(sizeof(drm_i915_query_memory_regions) + dataOnDrmTip->num_regions * sizeof(drm_i915_memory_region_info));
|
||||
return length == lengthOnDrmTip;
|
||||
bool isQueryDrmTip(const std::vector<uint8_t> &queryInfo) {
|
||||
auto dataOnDrmTip = reinterpret_cast<const drm_i915_query_memory_regions *>(queryInfo.data());
|
||||
auto lengthOnDrmTip = static_cast<uint32_t>(sizeof(drm_i915_query_memory_regions) + dataOnDrmTip->num_regions * sizeof(drm_i915_memory_region_info));
|
||||
return static_cast<uint32_t>(queryInfo.size()) == lengthOnDrmTip;
|
||||
}
|
||||
|
||||
namespace PROD_DG1 {
|
||||
@@ -41,11 +25,11 @@ namespace PROD_DG1 {
|
||||
#include "third_party/uapi/dg1/drm/i915_drm.h"
|
||||
} // namespace PROD_DG1
|
||||
|
||||
std::unique_ptr<uint8_t[]> translateToDrmTip(uint8_t *dataQuery) {
|
||||
auto dataOnProdDrm = reinterpret_cast<PROD_DG1::drm_i915_query_memory_regions *>(dataQuery);
|
||||
std::vector<uint8_t> translateToDrmTip(const uint8_t *dataQuery) {
|
||||
auto dataOnProdDrm = reinterpret_cast<const PROD_DG1::drm_i915_query_memory_regions *>(dataQuery);
|
||||
auto lengthTranslated = static_cast<int32_t>(sizeof(drm_i915_query_memory_regions) + dataOnProdDrm->num_regions * sizeof(drm_i915_memory_region_info));
|
||||
auto dataQueryTranslated = std::make_unique<uint8_t[]>(lengthTranslated);
|
||||
auto dataTranslated = reinterpret_cast<drm_i915_query_memory_regions *>(dataQueryTranslated.get());
|
||||
auto dataQueryTranslated = std::vector<uint8_t>(lengthTranslated, 0u);
|
||||
auto dataTranslated = reinterpret_cast<drm_i915_query_memory_regions *>(dataQueryTranslated.data());
|
||||
dataTranslated->num_regions = dataOnProdDrm->num_regions;
|
||||
for (uint32_t i = 0; i < dataTranslated->num_regions; i++) {
|
||||
dataTranslated->regions[i].region.memory_class = dataOnProdDrm->regions[i].region.memory_class;
|
||||
|
||||
@@ -14,31 +14,26 @@
|
||||
namespace NEO {
|
||||
constexpr static auto gfxProduct = IGFX_DG1;
|
||||
|
||||
extern uint32_t createGemExtMemoryRegions(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle);
|
||||
extern bool isQueryDrmTip(uint8_t *dataQuery, int32_t length);
|
||||
extern std::unique_ptr<uint8_t[]> translateToDrmTip(uint8_t *dataQuery);
|
||||
extern bool isQueryDrmTip(const std::vector<uint8_t> &queryInfo);
|
||||
extern std::vector<uint8_t> translateToDrmTip(const uint8_t *dataQuery);
|
||||
|
||||
template <>
|
||||
uint32_t IoctlHelperImpl<gfxProduct>::createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) {
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Performing GEM_CREATE_EXT with { size: %lu", allocSize);
|
||||
|
||||
if (DebugManager.flags.PrintBOCreateDestroyResult.get()) {
|
||||
for (uint32_t i = 0; i < dataSize; i++) {
|
||||
auto region = reinterpret_cast<drm_i915_gem_memory_class_instance *>(data)[i];
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, ", memory class: %d, memory instance: %d",
|
||||
region.memory_class, region.memory_instance);
|
||||
}
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "%s", " }\n");
|
||||
}
|
||||
|
||||
if (createGemExtMemoryRegions(drm, data, dataSize, allocSize, handle) == 0) {
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "GEM_CREATE_EXT with EXT_MEMORY_REGIONS has returned: %d BO-%u with size: %lu\n", 0, handle, allocSize);
|
||||
return 0;
|
||||
uint32_t IoctlHelperImpl<gfxProduct>::createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
auto ret = IoctlHelperUpstream::createGemExt(drm, memClassInstances, allocSize, handle);
|
||||
if (ret == 0) {
|
||||
return ret;
|
||||
}
|
||||
//fallback to PROD_DG1 kernel
|
||||
handle = 0u;
|
||||
uint32_t regionsSize = static_cast<uint32_t>(memClassInstances.size());
|
||||
drm_i915_gem_memory_class_instance data[regionsSize];
|
||||
for (auto i = 0u; i < regionsSize; i++) {
|
||||
data[i].memory_class = memClassInstances[i].memoryClass;
|
||||
data[i].memory_instance = memClassInstances[i].memoryInstance;
|
||||
}
|
||||
|
||||
drm_i915_gem_object_param regionParam{};
|
||||
regionParam.size = dataSize;
|
||||
regionParam.size = regionsSize;
|
||||
regionParam.data = reinterpret_cast<uintptr_t>(data);
|
||||
regionParam.param = I915_OBJECT_PARAM | I915_PARAM_MEMORY_REGIONS;
|
||||
|
||||
@@ -50,7 +45,7 @@ uint32_t IoctlHelperImpl<gfxProduct>::createGemExt(Drm *drm, void *data, uint32_
|
||||
createExt.size = allocSize;
|
||||
createExt.extensions = reinterpret_cast<uintptr_t>(&setparamRegion);
|
||||
|
||||
auto ret = IoctlHelper::ioctl(drm, DRM_IOCTL_I915_GEM_CREATE_EXT, &createExt);
|
||||
ret = IoctlHelper::ioctl(drm, DRM_IOCTL_I915_GEM_CREATE_EXT, &createExt);
|
||||
|
||||
handle = createExt.handle;
|
||||
printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "GEM_CREATE_EXT with EXT_SETPARAM has returned: %d BO-%u with size: %lu\n", ret, createExt.handle, createExt.size);
|
||||
@@ -58,12 +53,12 @@ uint32_t IoctlHelperImpl<gfxProduct>::createGemExt(Drm *drm, void *data, uint32_
|
||||
}
|
||||
|
||||
template <>
|
||||
std::unique_ptr<MemoryRegion[]> IoctlHelperImpl<gfxProduct>::translateToMemoryRegions(uint8_t *dataQuery, uint32_t length, uint32_t &numRegions) {
|
||||
if (!isQueryDrmTip(dataQuery, length)) {
|
||||
auto translated = translateToDrmTip(dataQuery);
|
||||
return IoctlHelperUpstream::translateToMemoryRegions(translated.get(), length, numRegions);
|
||||
std::vector<MemoryRegion> IoctlHelperImpl<gfxProduct>::translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) {
|
||||
if (!isQueryDrmTip(regionInfo)) {
|
||||
auto translated = translateToDrmTip(regionInfo.data());
|
||||
return IoctlHelperUpstream::translateToMemoryRegions(translated);
|
||||
}
|
||||
return IoctlHelperUpstream::translateToMemoryRegions(dataQuery, length, numRegions);
|
||||
return IoctlHelperUpstream::translateToMemoryRegions(regionInfo);
|
||||
}
|
||||
|
||||
template class IoctlHelperImpl<gfxProduct>;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
uint32_t MemoryInfo::createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) {
|
||||
return IoctlHelper::get(drm)->createGemExt(drm, data, dataSize, allocSize, handle);
|
||||
uint32_t MemoryInfo::createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) {
|
||||
return IoctlHelper::get(drm)->createGemExt(drm, memClassInstances, allocSize, handle);
|
||||
}
|
||||
|
||||
MemoryClassInstance MemoryInfo::getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo) {
|
||||
@@ -66,7 +66,8 @@ void MemoryInfo::printRegionSizes() {
|
||||
uint32_t MemoryInfo::createGemExtWithSingleRegion(Drm *drm, uint32_t memoryBanks, size_t allocSize, uint32_t &handle) {
|
||||
auto pHwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
|
||||
auto regionClassAndInstance = getMemoryRegionClassAndInstance(memoryBanks, *pHwInfo);
|
||||
auto ret = createGemExt(drm, ®ionClassAndInstance, 1, allocSize, handle);
|
||||
std::vector<MemoryClassInstance> region = {regionClassAndInstance};
|
||||
auto ret = createGemExt(drm, region, allocSize, handle);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ class MemoryInfo {
|
||||
|
||||
virtual ~MemoryInfo(){};
|
||||
|
||||
MemoryInfo(const MemoryRegion *regionInfo, size_t count);
|
||||
MemoryInfo(const RegionContainer ®ionInfo);
|
||||
|
||||
void assignRegionsFromDistances(const void *distanceInfosPtr, size_t size);
|
||||
|
||||
MOCKABLE_VIRTUAL uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle);
|
||||
MOCKABLE_VIRTUAL uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle);
|
||||
|
||||
MemoryClassInstance getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo);
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
MemoryInfo::MemoryInfo(const MemoryRegion *regionInfo, size_t count)
|
||||
: drmQueryRegions(regionInfo, regionInfo + count), systemMemoryRegion(drmQueryRegions[0]) {
|
||||
MemoryInfo::MemoryInfo(const RegionContainer ®ionInfo)
|
||||
: drmQueryRegions(regionInfo), systemMemoryRegion(drmQueryRegions[0]) {
|
||||
UNRECOVERABLE_IF(systemMemoryRegion.region.memoryClass != I915_MEMORY_CLASS_SYSTEM);
|
||||
std::copy_if(drmQueryRegions.begin(), drmQueryRegions.end(), std::back_inserter(localMemoryRegions),
|
||||
[](const MemoryRegion &memoryRegionInfo) {
|
||||
|
||||
@@ -15,14 +15,15 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
SystemInfo::SystemInfo(const uint32_t *blobData, int32_t blobSize) {
|
||||
this->parseDeviceBlob(blobData, blobSize);
|
||||
SystemInfo::SystemInfo(const std::vector<uint8_t> &inputData) {
|
||||
this->parseDeviceBlob(inputData);
|
||||
}
|
||||
|
||||
void SystemInfo::parseDeviceBlob(const uint32_t *data, int32_t size) {
|
||||
|
||||
void SystemInfo::parseDeviceBlob(const std::vector<uint8_t> &inputData) {
|
||||
auto data = reinterpret_cast<const uint32_t *>(inputData.data());
|
||||
auto dataSize = inputData.size() / sizeof(uint32_t);
|
||||
uint32_t i = 0;
|
||||
while (i < (size / sizeof(uint32_t))) {
|
||||
while (i + 2 < dataSize) {
|
||||
DEBUG_BREAK_IF(data[i + 1] < 1);
|
||||
|
||||
/* Attribute IDs range */
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
struct HardwareInfo;
|
||||
|
||||
struct SystemInfo {
|
||||
|
||||
SystemInfo(const uint32_t *blobData, int32_t blobSize);
|
||||
SystemInfo(const std::vector<uint8_t> &inputData);
|
||||
|
||||
~SystemInfo() = default;
|
||||
|
||||
@@ -37,7 +38,7 @@ struct SystemInfo {
|
||||
void checkSysInfoMismatch(HardwareInfo *hwInfo);
|
||||
|
||||
protected:
|
||||
void parseDeviceBlob(const uint32_t *data, int32_t size);
|
||||
void parseDeviceBlob(const std::vector<uint8_t> &inputData);
|
||||
void extendParseDeviceBlob(const uint32_t *data, uint32_t element);
|
||||
|
||||
uint32_t maxSlicesSupported = 0;
|
||||
|
||||
@@ -146,13 +146,13 @@ class DrmMemoryManagerWithLocalMemoryFixture : public DrmMemoryManagerFixture {
|
||||
};
|
||||
|
||||
struct MockedMemoryInfo : public NEO::MemoryInfo {
|
||||
MockedMemoryInfo(const MemoryRegion *regionInfo, size_t count) : MemoryInfo(regionInfo, count) {}
|
||||
MockedMemoryInfo(const std::vector<MemoryRegion> ®ionInfo) : MemoryInfo(regionInfo) {}
|
||||
~MockedMemoryInfo() override{};
|
||||
|
||||
size_t getMemoryRegionSize(uint32_t memoryBank) override {
|
||||
return 1024u;
|
||||
}
|
||||
uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override {
|
||||
uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) override {
|
||||
if (allocSize == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -191,12 +191,12 @@ class DrmMemoryManagerFixtureWithoutQuietIoctlExpectation {
|
||||
i++;
|
||||
}
|
||||
mock = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->getDriverModel()->as<Drm>());
|
||||
MemoryRegion regionInfo[2] = {};
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
|
||||
regionInfo[0].probedSize = 8 * GB;
|
||||
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};
|
||||
regionInfo[1].probedSize = 16 * GB;
|
||||
mock->memoryInfo.reset(new MockedMemoryInfo(regionInfo, 2));
|
||||
mock->memoryInfo.reset(new MockedMemoryInfo(regionInfo));
|
||||
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u);
|
||||
memoryManager.reset(new TestedDrmMemoryManager(enableLocalMem, false, false, *executionEnvironment));
|
||||
|
||||
|
||||
@@ -128,3 +128,6 @@ static constexpr uint32_t dummyDeviceBlobData[] = {
|
||||
1,
|
||||
0x2C,
|
||||
};
|
||||
|
||||
const std::vector<uint8_t> inputBlobData(reinterpret_cast<const uint8_t *>(dummyDeviceBlobData),
|
||||
reinterpret_cast<const uint8_t *>(dummyDeviceBlobData) + sizeof(dummyDeviceBlobData));
|
||||
|
||||
@@ -140,5 +140,5 @@ TEST(DrmQueryTest, givenDrmWhenGettingMemoryRegionsThenReturnNull) {
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
EXPECT_EQ(drm.getMemoryRegions(), nullptr);
|
||||
}
|
||||
EXPECT_TRUE(drm.getMemoryRegions().empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user