Use drm tip kernel headers as default 2/2

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2021-10-27 12:43:46 +00:00
committed by Compute-Runtime-Automation
parent 75a5aed81d
commit 3cf2e2e395
31 changed files with 2952 additions and 7832 deletions

View File

@@ -450,18 +450,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Get available platfroms # Get available platfroms
include(platforms.cmake) include(platforms.cmake)
if(SUPPORT_XE_HP_SDV AND "${BRANCH_TYPE}" STREQUAL "") get_filename_component(I915_INCLUDES_DIR "${NEO_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}uapi" ABSOLUTE)
set(I915_LOCAL_MEM_EXP TRUE)
endif()
if(SUPPORT_DG1 AND "${BRANCH_TYPE}" STREQUAL "")
set(I915_LOCAL_MEM_EXP TRUE)
endif()
if(I915_LOCAL_MEM_EXP)
get_filename_component(I915_INCLUDES_DIR "${NEO_SOURCE_DIR}/third_party/uapi/drm_tip" ABSOLUTE)
else()
get_filename_component(I915_INCLUDES_DIR "${NEO_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}uapi" ABSOLUTE)
endif()
message(STATUS "i915 includes dir: ${I915_INCLUDES_DIR}") message(STATUS "i915 includes dir: ${I915_INCLUDES_DIR}")
# Enable/Disable BuiltIns compilation during build # Enable/Disable BuiltIns compilation during build

View File

@@ -23,6 +23,8 @@ set(IGDRCL_SRCS_tests_os_interface_linux
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_mapper_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_mapper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_engine_info_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_engine_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_manager_localmem_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_os_memory_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_os_memory_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_residency_handler_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_residency_handler_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_system_info_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_system_info_tests.cpp
@@ -32,7 +34,7 @@ set(IGDRCL_SRCS_tests_os_interface_linux
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_linux_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_linux_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_linux_tests.h ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_linux_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/linux_create_command_queue_with_properties_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/linux_create_command_queue_with_properties_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_helper_default_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}local_memory_helper_default_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_time_linux.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_os_time_linux.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_performance_counters_linux.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mock_performance_counters_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_performance_counters_linux.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_performance_counters_linux.h
@@ -42,17 +44,7 @@ set(IGDRCL_SRCS_tests_os_interface_linux
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_linux_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_linux_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/self_lib_lin.cpp ${CMAKE_CURRENT_SOURCE_DIR}/self_lib_lin.cpp
) )
if(I915_LOCAL_MEM_EXP)
list(APPEND IGDRCL_SRCS_tests_os_interface_linux
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_info_tests_exp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_localmem_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_helper_default_tests_exp.cpp
)
else()
list(APPEND IGDRCL_SRCS_tests_os_interface_linux
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_info_tests.cpp
)
endif()
if(NEO__LIBVA_FOUND) if(NEO__LIBVA_FOUND)
list(APPEND IGDRCL_SRCS_tests_os_interface_linux list(APPEND IGDRCL_SRCS_tests_os_interface_linux
${CMAKE_CURRENT_SOURCE_DIR}/drm_va_sharing_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_va_sharing_tests.cpp

View File

@@ -8,11 +8,11 @@
#pragma once #pragma once
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h" #include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
class DrmMockCustomExp : public DrmMockCustom { class DrmMockCustomImpl : public DrmMockCustom {
public: public:
using Drm::memoryInfo; using Drm::memoryInfo;
class IoctlsExp { class Ioctls {
public: public:
void reset() { void reset() {
gemCreateExt = 0; gemCreateExt = 0;
@@ -22,13 +22,13 @@ class DrmMockCustomExp : public DrmMockCustom {
std::atomic<int32_t> gemMmapOffset; std::atomic<int32_t> gemMmapOffset;
}; };
IoctlsExp ioctlExp_cnt; Ioctls ioctlImpl_cnt;
IoctlsExp ioctlExp_expected; Ioctls ioctlImpl_expected;
void testIoctlsExp() { void testIoctls() {
#define NEO_IOCTL_EXPECT_EQ(PARAM) \ #define NEO_IOCTL_EXPECT_EQ(PARAM) \
if (this->ioctlExp_expected.PARAM >= 0) { \ if (this->ioctlImpl_expected.PARAM >= 0) { \
EXPECT_EQ(this->ioctlExp_expected.PARAM, this->ioctlExp_cnt.PARAM); \ EXPECT_EQ(this->ioctlImpl_expected.PARAM, this->ioctlImpl_cnt.PARAM); \
} }
NEO_IOCTL_EXPECT_EQ(gemMmapOffset); NEO_IOCTL_EXPECT_EQ(gemMmapOffset);
#undef NEO_IOCTL_EXPECT_EQ #undef NEO_IOCTL_EXPECT_EQ
@@ -54,7 +54,7 @@ class DrmMockCustomExp : public DrmMockCustom {
createExtSize = createExtParams->size; createExtSize = createExtParams->size;
createExtHandle = createExtParams->handle; createExtHandle = createExtParams->handle;
createExtExtensions = createExtParams->extensions; createExtExtensions = createExtParams->extensions;
ioctlExp_cnt.gemCreateExt++; ioctlImpl_cnt.gemCreateExt++;
} break; } break;
case DRM_IOCTL_I915_GEM_MMAP_OFFSET: { case DRM_IOCTL_I915_GEM_MMAP_OFFSET: {
auto mmapOffsetParams = reinterpret_cast<drm_i915_gem_mmap_offset *>(arg); auto mmapOffsetParams = reinterpret_cast<drm_i915_gem_mmap_offset *>(arg);
@@ -62,7 +62,7 @@ class DrmMockCustomExp : public DrmMockCustom {
mmapOffsetPad = mmapOffsetParams->pad; mmapOffsetPad = mmapOffsetParams->pad;
mmapOffsetOffset = mmapOffsetParams->offset; mmapOffsetOffset = mmapOffsetParams->offset;
mmapOffsetFlags = mmapOffsetParams->flags; mmapOffsetFlags = mmapOffsetParams->flags;
ioctlExp_cnt.gemMmapOffset++; ioctlImpl_cnt.gemMmapOffset++;
if (failOnMmapOffset == true) { if (failOnMmapOffset == true) {
return -1; return -1;
} }
@@ -75,8 +75,8 @@ class DrmMockCustomExp : public DrmMockCustom {
return 0; return 0;
} }
DrmMockCustomExp(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockCustom(rootDeviceEnvironment) { DrmMockCustomImpl(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockCustom(rootDeviceEnvironment) {
ioctlExp_cnt.reset(); ioctlImpl_cnt.reset();
ioctlExp_expected.reset(); ioctlImpl_expected.reset();
} }
}; };

View File

@@ -242,4 +242,4 @@ class DrmCommandStreamEnhancedWithFailingExecTemplate : public ::testing::Test {
} }
}; };
using DrmCommandStreamEnhancedWithFailingExec = DrmCommandStreamEnhancedWithFailingExecTemplate<DrmMockCustom>; using DrmCommandStreamEnhancedWithFailingExec = DrmCommandStreamEnhancedWithFailingExecTemplate<DrmMockCustom>;

View File

@@ -5,50 +5,290 @@
* *
*/ */
#include "shared/source/os_interface/linux/memory_info.h" #include "shared/source/execution_environment/execution_environment.h"
#include "shared/test/common/libult/linux/drm_mock.h" #include "shared/source/memory_manager/memory_banks.h"
#include "shared/source/os_interface/linux/memory_info_impl.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock_impl.h"
#include "test.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
using namespace NEO; using namespace NEO;
struct MemoryInfoImpl : public NEO::MemoryInfo { TEST(MemoryInfo, givenNotSupportedLocalMemoryQueryingMemoryInfoThenMemoryInfoIsNotCreated) {
MemoryInfoImpl() {} DebugManagerStateRestore restorer;
~MemoryInfoImpl() override{}; DebugManager.flags.EnableLocalMemory.set(0);
size_t getMemoryRegionSize(uint32_t memoryBank) override {
return 0u;
}
uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override {
return 0u;
}
uint32_t createGemExtWithSingleRegion(Drm *drm, uint32_t memoryBanks, size_t allocSize, uint32_t &handle) override {
return 0u;
}
};
TEST(DrmTest, whenQueryingMemoryInfoThenMemoryInfoIsNotCreatedAndNoIoctlsAreCalled) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
std::unique_ptr<DrmMock> drm = std::make_unique<DrmMock>(*executionEnvironment->rootDeviceEnvironments[0]);
EXPECT_NE(nullptr, drm);
EXPECT_TRUE(drm->queryMemoryInfo()); auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
auto ret = drm->queryMemoryInfo();
auto memoryInfo = drm->getMemoryInfo();
EXPECT_EQ(nullptr, drm->memoryInfo.get());
EXPECT_EQ(0u, drm->ioctlCallsCount); EXPECT_EQ(0u, drm->ioctlCallsCount);
EXPECT_TRUE(ret);
EXPECT_EQ(nullptr, memoryInfo);
} }
TEST(DrmTest, givenMemoryInfoWhenGetMemoryInfoIsCalledThenValidPtrIsReturned) { TEST(MemoryInfo, givenMemoryRegionQuerySupportedWhenQueryingMemoryInfoThenMemoryInfoIsCreatedWithRegions) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
std::unique_ptr<DrmMock> drm = std::make_unique<DrmMock>(*executionEnvironment->rootDeviceEnvironments[0]);
EXPECT_NE(nullptr, drm);
drm->memoryInfo.reset(new MemoryInfoImpl); auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
EXPECT_EQ(drm->memoryInfo.get(), drm->getMemoryInfo()); drm->queryMemoryInfo();
EXPECT_EQ(2u, drm->ioctlCallsCount);
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
ASSERT_NE(nullptr, memoryInfo);
EXPECT_EQ(2u, memoryInfo->getDrmRegionInfos().size());
} }
TEST(MemoryInfo, givenMemoryInfoImplementationWhenDestructingThenDestructorIsCalled) { TEST(MemoryInfo, givenMemoryRegionQueryNotSupportedWhenQueryingMemoryInfoThenMemoryInfoIsNotCreated) {
MemoryInfoImpl memoryInfoImpl; DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
drm->i915QuerySuccessCount = 0;
drm->queryMemoryInfo();
EXPECT_EQ(nullptr, drm->getMemoryInfo());
EXPECT_EQ(1u, drm->ioctlCallsCount);
}
TEST(MemoryInfo, givenMemoryRegionQueryWhenQueryingFailsThenMemoryInfoIsNotCreated) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
drm->queryMemoryRegionInfoSuccessCount = 0;
drm->queryMemoryInfo();
EXPECT_EQ(nullptr, drm->getMemoryInfo());
EXPECT_EQ(1u, drm->ioctlCallsCount);
drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
drm->i915QuerySuccessCount = 1;
drm->queryMemoryInfo();
EXPECT_EQ(nullptr, drm->getMemoryInfo());
EXPECT_EQ(2u, drm->ioctlCallsCount);
drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
drm->queryMemoryRegionInfoSuccessCount = 1;
drm->queryMemoryInfo();
EXPECT_EQ(nullptr, drm->getMemoryInfo());
EXPECT_EQ(2u, drm->ioctlCallsCount);
}
TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryEnabledWhenGettingMemoryRegionClassAndInstanceThenReturnCorrectValues) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
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 memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
ASSERT_NE(nullptr, memoryInfo);
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
EXPECT_EQ(regionInfo[0].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[0].region.memory_instance, regionClassAndInstance.memory_instance);
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::MainBank);
EXPECT_EQ(8 * GB, regionSize);
regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(0), *defaultHwInfo);
EXPECT_EQ(regionInfo[1].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[1].region.memory_instance, regionClassAndInstance.memory_instance);
regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
EXPECT_EQ(16 * GB, regionSize);
}
TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryEnabledWhenAssignRegionsFromDistancesThenRegionsNotChanged) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
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 memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
ASSERT_NE(nullptr, memoryInfo);
memoryInfo->assignRegionsFromDistances(&regionInfo, 2);
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
EXPECT_EQ(regionInfo[0].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[0].region.memory_instance, regionClassAndInstance.memory_instance);
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::MainBank);
EXPECT_EQ(8 * GB, regionSize);
regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(0), *defaultHwInfo);
EXPECT_EQ(regionInfo[1].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[1].region.memory_instance, regionClassAndInstance.memory_instance);
regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
EXPECT_EQ(16 * GB, regionSize);
}
TEST(MemoryInfo, givenMemoryInfoWithoutDeviceRegionWhenGettingDeviceRegionSizeThenReturnCorrectSize) {
drm_i915_memory_region_info regionInfo[1] = {};
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
regionInfo[0].probed_size = 8 * GB;
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 1);
ASSERT_NE(nullptr, memoryInfo);
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
EXPECT_EQ(0 * GB, regionSize);
}
TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryDisabledWhenGettingMemoryRegionClassAndInstanceThenReturnCorrectValues) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(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 memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
ASSERT_NE(nullptr, memoryInfo);
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
EXPECT_EQ(regionInfo[0].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[0].region.memory_instance, regionClassAndInstance.memory_instance);
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::MainBank);
EXPECT_EQ(8 * GB, regionSize);
regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(0), *defaultHwInfo);
EXPECT_EQ(regionInfo[0].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[0].region.memory_instance, regionClassAndInstance.memory_instance);
regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
EXPECT_EQ(16 * GB, regionSize);
}
TEST(MemoryInfo, whenDebugVariablePrintMemoryRegionSizeIsSetAndGetMemoryRegionSizeIsCalledThenMessagePrintedToStdOutput) {
DebugManagerStateRestore restore;
DebugManager.flags.PrintMemoryRegionSizes.set(true);
drm_i915_memory_region_info regionInfo[1] = {};
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 1};
regionInfo[0].probed_size = 16 * GB;
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 1);
ASSERT_NE(nullptr, memoryInfo);
testing::internal::CaptureStdout();
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::MainBank);
EXPECT_EQ(16 * GB, regionSize);
std::string output = testing::internal::GetCapturedStdout();
std::string expectedOutput("Memory type: 0, memory instance: 1, region size: 17179869184\n");
EXPECT_EQ(expectedOutput, output);
}
TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenGettingMemoryRegionClassAndInstanceWhileDebugFlagIsActiveThenReturnCorrectValues) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
drm_i915_memory_region_info regionInfo[3] = {};
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;
regionInfo[2].region = {I915_MEMORY_CLASS_DEVICE, 1};
regionInfo[2].probed_size = 32 * GB;
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 3);
ASSERT_NE(nullptr, memoryInfo);
DebugManager.flags.OverrideDrmRegion.set(1);
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(0), *defaultHwInfo);
EXPECT_EQ(regionInfo[2].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[2].region.memory_instance, regionClassAndInstance.memory_instance);
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
EXPECT_EQ(16 * GB, regionSize);
DebugManager.flags.OverrideDrmRegion.set(0);
regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(1), *defaultHwInfo);
EXPECT_EQ(regionInfo[1].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[1].region.memory_instance, regionClassAndInstance.memory_instance);
regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(1));
EXPECT_EQ(32 * GB, regionSize);
DebugManager.flags.OverrideDrmRegion.set(-1);
DebugManager.flags.ForceMemoryBankIndexOverride.set(1);
auto &helper = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily);
regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(1), *defaultHwInfo);
if (helper.isBankOverrideRequired(*defaultHwInfo)) {
EXPECT_EQ(regionInfo[1].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[1].region.memory_instance, regionClassAndInstance.memory_instance);
} else {
EXPECT_EQ(regionInfo[2].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[2].region.memory_instance, regionClassAndInstance.memory_instance);
}
regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(1));
EXPECT_EQ(32 * GB, regionSize);
}
using MemoryInfoTest = ::testing::Test;
HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemWithExtensionsThenReturnCorrectValues, NonDefaultIoctlsSupported) {
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 executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
ASSERT_NE(nullptr, memoryInfo);
uint32_t handle = 0;
auto ret = memoryInfo->createGemExt(drm.get(), &regionInfo, 2, 1024, handle);
EXPECT_EQ(1u, handle);
EXPECT_EQ(0u, ret);
EXPECT_EQ(1u, drm->ioctlCallsCount);
EXPECT_EQ(1024u, drm->createExt.size);
}
HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemExtWithSingleRegionThenReturnCorrectValues, NonDefaultIoctlsSupported) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
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 memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
ASSERT_NE(nullptr, memoryInfo);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
uint32_t handle = 0;
auto ret = memoryInfo->createGemExtWithSingleRegion(drm.get(), 1, 1024, handle);
EXPECT_EQ(1u, handle);
EXPECT_EQ(0u, ret);
EXPECT_EQ(1u, drm->ioctlCallsCount);
EXPECT_EQ(I915_MEMORY_CLASS_DEVICE, drm->memRegions.memory_class);
EXPECT_EQ(1024u, drm->createExt.size);
} }

View File

@@ -1,277 +0,0 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/memory_manager/memory_banks.h"
#include "shared/source/os_interface/linux/memory_info_impl.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock_exp.h"
#include "test.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(MemoryInfo, givenMemoryRegionQuerySupportedWhenQueryingMemoryInfoThenMemoryInfoIsCreatedWithRegions) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
drm->queryMemoryInfo();
EXPECT_EQ(2u, drm->ioctlCallsCount);
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
ASSERT_NE(nullptr, memoryInfo);
EXPECT_EQ(2u, memoryInfo->getDrmRegionInfos().size());
}
TEST(MemoryInfo, givenMemoryRegionQueryNotSupportedWhenQueryingMemoryInfoThenMemoryInfoIsNotCreated) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
drm->i915QuerySuccessCount = 0;
drm->queryMemoryInfo();
EXPECT_EQ(nullptr, drm->getMemoryInfo());
EXPECT_EQ(1u, drm->ioctlCallsCount);
}
TEST(MemoryInfo, givenMemoryRegionQueryWhenQueryingFailsThenMemoryInfoIsNotCreated) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
drm->queryMemoryRegionInfoSuccessCount = 0;
drm->queryMemoryInfo();
EXPECT_EQ(nullptr, drm->getMemoryInfo());
EXPECT_EQ(1u, drm->ioctlCallsCount);
drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
drm->i915QuerySuccessCount = 1;
drm->queryMemoryInfo();
EXPECT_EQ(nullptr, drm->getMemoryInfo());
EXPECT_EQ(2u, drm->ioctlCallsCount);
drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
drm->queryMemoryRegionInfoSuccessCount = 1;
drm->queryMemoryInfo();
EXPECT_EQ(nullptr, drm->getMemoryInfo());
EXPECT_EQ(2u, drm->ioctlCallsCount);
}
TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryEnabledWhenGettingMemoryRegionClassAndInstanceThenReturnCorrectValues) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
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 memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
ASSERT_NE(nullptr, memoryInfo);
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
EXPECT_EQ(regionInfo[0].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[0].region.memory_instance, regionClassAndInstance.memory_instance);
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::MainBank);
EXPECT_EQ(8 * GB, regionSize);
regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(0), *defaultHwInfo);
EXPECT_EQ(regionInfo[1].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[1].region.memory_instance, regionClassAndInstance.memory_instance);
regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
EXPECT_EQ(16 * GB, regionSize);
}
TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryEnabledWhenAssignRegionsFromDistancesThenRegionsNotChanged) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
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 memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
ASSERT_NE(nullptr, memoryInfo);
memoryInfo->assignRegionsFromDistances(&regionInfo, 2);
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
EXPECT_EQ(regionInfo[0].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[0].region.memory_instance, regionClassAndInstance.memory_instance);
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::MainBank);
EXPECT_EQ(8 * GB, regionSize);
regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(0), *defaultHwInfo);
EXPECT_EQ(regionInfo[1].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[1].region.memory_instance, regionClassAndInstance.memory_instance);
regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
EXPECT_EQ(16 * GB, regionSize);
}
TEST(MemoryInfo, givenMemoryInfoWithoutDeviceRegionWhenGettingDeviceRegionSizeThenReturnCorrectSize) {
drm_i915_memory_region_info regionInfo[1] = {};
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
regionInfo[0].probed_size = 8 * GB;
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 1);
ASSERT_NE(nullptr, memoryInfo);
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
EXPECT_EQ(0 * GB, regionSize);
}
TEST(MemoryInfo, givenMemoryInfoWithRegionsAndLocalMemoryDisabledWhenGettingMemoryRegionClassAndInstanceThenReturnCorrectValues) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(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 memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
ASSERT_NE(nullptr, memoryInfo);
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::MainBank, *defaultHwInfo);
EXPECT_EQ(regionInfo[0].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[0].region.memory_instance, regionClassAndInstance.memory_instance);
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::MainBank);
EXPECT_EQ(8 * GB, regionSize);
regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(0), *defaultHwInfo);
EXPECT_EQ(regionInfo[0].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[0].region.memory_instance, regionClassAndInstance.memory_instance);
regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
EXPECT_EQ(16 * GB, regionSize);
}
TEST(MemoryInfo, whenDebugVariablePrintMemoryRegionSizeIsSetAndGetMemoryRegionSizeIsCalledThenMessagePrintedToStdOutput) {
DebugManagerStateRestore restore;
DebugManager.flags.PrintMemoryRegionSizes.set(true);
drm_i915_memory_region_info regionInfo[1] = {};
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 1};
regionInfo[0].probed_size = 16 * GB;
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 1);
ASSERT_NE(nullptr, memoryInfo);
testing::internal::CaptureStdout();
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::MainBank);
EXPECT_EQ(16 * GB, regionSize);
std::string output = testing::internal::GetCapturedStdout();
std::string expectedOutput("Memory type: 0, memory instance: 1, region size: 17179869184\n");
EXPECT_EQ(expectedOutput, output);
}
TEST(MemoryInfo, givenMemoryInfoWithRegionsWhenGettingMemoryRegionClassAndInstanceWhileDebugFlagIsActiveThenReturnCorrectValues) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
drm_i915_memory_region_info regionInfo[3] = {};
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;
regionInfo[2].region = {I915_MEMORY_CLASS_DEVICE, 1};
regionInfo[2].probed_size = 32 * GB;
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 3);
ASSERT_NE(nullptr, memoryInfo);
DebugManager.flags.OverrideDrmRegion.set(1);
auto regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(0), *defaultHwInfo);
EXPECT_EQ(regionInfo[2].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[2].region.memory_instance, regionClassAndInstance.memory_instance);
auto regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0));
EXPECT_EQ(16 * GB, regionSize);
DebugManager.flags.OverrideDrmRegion.set(0);
regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(1), *defaultHwInfo);
EXPECT_EQ(regionInfo[1].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[1].region.memory_instance, regionClassAndInstance.memory_instance);
regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(1));
EXPECT_EQ(32 * GB, regionSize);
DebugManager.flags.OverrideDrmRegion.set(-1);
DebugManager.flags.ForceMemoryBankIndexOverride.set(1);
auto &helper = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily);
regionClassAndInstance = memoryInfo->getMemoryRegionClassAndInstance(MemoryBanks::getBankForLocalMemory(1), *defaultHwInfo);
if (helper.isBankOverrideRequired(*defaultHwInfo)) {
EXPECT_EQ(regionInfo[1].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[1].region.memory_instance, regionClassAndInstance.memory_instance);
} else {
EXPECT_EQ(regionInfo[2].region.memory_class, regionClassAndInstance.memory_class);
EXPECT_EQ(regionInfo[2].region.memory_instance, regionClassAndInstance.memory_instance);
}
regionSize = memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(1));
EXPECT_EQ(32 * GB, regionSize);
}
using MemoryInfoTest = ::testing::Test;
HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemWithExtensionsThenReturnCorrectValues, NonDefaultIoctlsSupported) {
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 executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
auto memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
ASSERT_NE(nullptr, memoryInfo);
uint32_t handle = 0;
auto ret = memoryInfo->createGemExt(drm.get(), &regionInfo, 2, 1024, handle);
EXPECT_EQ(1u, handle);
EXPECT_EQ(0u, ret);
EXPECT_EQ(1u, drm->ioctlCallsCount);
EXPECT_EQ(1024u, drm->createExt.size);
}
HWTEST2_F(MemoryInfoTest, givenMemoryInfoWithRegionsWhenCreatingGemExtWithSingleRegionThenReturnCorrectValues, NonDefaultIoctlsSupported) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
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 memoryInfo = std::make_unique<MemoryInfoImpl>(regionInfo, 2);
ASSERT_NE(nullptr, memoryInfo);
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]);
uint32_t handle = 0;
auto ret = memoryInfo->createGemExtWithSingleRegion(drm.get(), 1, 1024, handle);
EXPECT_EQ(1u, handle);
EXPECT_EQ(0u, ret);
EXPECT_EQ(1u, drm->ioctlCallsCount);
EXPECT_EQ(I915_MEMORY_CLASS_DEVICE, drm->memRegions.memory_class);
EXPECT_EQ(1024u, drm->createExt.size);
}

View File

@@ -19,8 +19,8 @@
#include "opencl/test/unit_test/mocks/mock_context.h" #include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_platform.h" #include "opencl/test/unit_test/mocks/mock_platform.h"
#include "opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests_exp.h" #include "opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests_impl.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock_exp.h" #include "opencl/test/unit_test/os_interface/linux/drm_mock_impl.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock_memory_info.h" #include "opencl/test/unit_test/os_interface/linux/drm_mock_memory_info.h"
#include "test.h" #include "test.h"
@@ -32,14 +32,14 @@ BufferObject *createBufferObjectInMemoryRegion(Drm *drm, uint64_t gpuAddress, si
class DrmMemoryManagerLocalMemoryTest : public ::testing::Test { class DrmMemoryManagerLocalMemoryTest : public ::testing::Test {
public: public:
DrmMockExp *mock; DrmTipMock *mock;
void SetUp() override { void SetUp() override {
const bool localMemoryEnabled = true; const bool localMemoryEnabled = true;
executionEnvironment = new ExecutionEnvironment; executionEnvironment = new ExecutionEnvironment;
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get()); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get());
mock = new DrmMockExp(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]); mock = new DrmTipMock(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]);
mock->memoryInfo.reset(new MockMemoryInfo()); mock->memoryInfo.reset(new MockMemoryInfo());
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
@@ -67,14 +67,14 @@ class DrmMemoryManagerLocalMemoryTest : public ::testing::Test {
class DrmMemoryManagerLocalMemoryWithCustomMockTest : public ::testing::Test { class DrmMemoryManagerLocalMemoryWithCustomMockTest : public ::testing::Test {
public: public:
DrmMockCustomExp *mock; DrmMockCustomImpl *mock;
void SetUp() override { void SetUp() override {
const bool localMemoryEnabled = true; const bool localMemoryEnabled = true;
executionEnvironment = new ExecutionEnvironment; executionEnvironment = new ExecutionEnvironment;
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
mock = new DrmMockCustomExp(*executionEnvironment->rootDeviceEnvironments[0]); mock = new DrmMockCustomImpl(*executionEnvironment->rootDeviceEnvironments[0]);
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
@@ -171,7 +171,7 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndMem
executionEnvironment->prepareRootDeviceEnvironments(rootDevicesNumber); executionEnvironment->prepareRootDeviceEnvironments(rootDevicesNumber);
for (uint32_t i = 0; i < rootDevicesNumber; i++) { for (uint32_t i = 0; i < rootDevicesNumber; i++) {
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get()); executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
auto mock = new DrmMockExp(*executionEnvironment->rootDeviceEnvironments[i]); auto mock = new DrmTipMock(*executionEnvironment->rootDeviceEnvironments[i]);
drm_i915_memory_region_info regionInfo[2] = {}; drm_i915_memory_region_info regionInfo[2] = {};
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0}; regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
@@ -190,7 +190,7 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndMem
size_t size = 4096u; size_t size = 4096u;
AllocationProperties properties(rootDeviceIndex, true, size, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, false, {}); AllocationProperties properties(rootDeviceIndex, true, size, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, false, {});
static_cast<DrmMockExp *>(executionEnvironment->rootDeviceEnvironments[0]->osInterface->getDriverModel()->as<Drm>())->outputFd = 7; static_cast<DrmTipMock *>(executionEnvironment->rootDeviceEnvironments[0]->osInterface->getDriverModel()->as<Drm>())->outputFd = 7;
auto ptr = memoryManager->createMultiGraphicsAllocationInSystemMemoryPool(rootDeviceIndices, properties, multiGraphics); auto ptr = memoryManager->createMultiGraphicsAllocationInSystemMemoryPool(rootDeviceIndices, properties, multiGraphics);
@@ -198,7 +198,7 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndMem
EXPECT_NE(static_cast<DrmAllocation *>(multiGraphics.getDefaultGraphicsAllocation())->getMmapPtr(), nullptr); EXPECT_NE(static_cast<DrmAllocation *>(multiGraphics.getDefaultGraphicsAllocation())->getMmapPtr(), nullptr);
for (uint32_t i = 0; i < rootDevicesNumber; i++) { for (uint32_t i = 0; i < rootDevicesNumber; i++) {
if (i != 0) { if (i != 0) {
EXPECT_EQ(static_cast<DrmMockExp *>(executionEnvironment->rootDeviceEnvironments[i]->osInterface->getDriverModel()->as<Drm>())->inputFd, 7); EXPECT_EQ(static_cast<DrmTipMock *>(executionEnvironment->rootDeviceEnvironments[i]->osInterface->getDriverModel()->as<Drm>())->inputFd, 7);
} }
EXPECT_NE(multiGraphics.getGraphicsAllocation(i), nullptr); EXPECT_NE(multiGraphics.getGraphicsAllocation(i), nullptr);
memoryManager->freeGraphicsMemory(multiGraphics.getGraphicsAllocation(i)); memoryManager->freeGraphicsMemory(multiGraphics.getGraphicsAllocation(i));
@@ -216,7 +216,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndMemory
executionEnvironment->prepareRootDeviceEnvironments(rootDevicesNumber); executionEnvironment->prepareRootDeviceEnvironments(rootDevicesNumber);
for (uint32_t i = 0; i < rootDevicesNumber; i++) { for (uint32_t i = 0; i < rootDevicesNumber; i++) {
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get()); executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
auto mock = new DrmMockExp(*executionEnvironment->rootDeviceEnvironments[i]); auto mock = new DrmTipMock(*executionEnvironment->rootDeviceEnvironments[i]);
drm_i915_memory_region_info regionInfo[2] = {}; drm_i915_memory_region_info regionInfo[2] = {};
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0}; regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
@@ -275,7 +275,7 @@ TEST_F(DrmMemoryManagerUsmSharedHandleTest, givenMultiRootDeviceEnvironmentAndMe
executionEnvironment->prepareRootDeviceEnvironments(rootDevicesNumber); executionEnvironment->prepareRootDeviceEnvironments(rootDevicesNumber);
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get()); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get());
auto mock = new DrmMockExp(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]); auto mock = new DrmTipMock(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]);
drm_i915_memory_region_info regionInfo[2] = {}; drm_i915_memory_region_info regionInfo[2] = {};
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0}; regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
@@ -311,7 +311,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndNoMemo
executionEnvironment->prepareRootDeviceEnvironments(rootDevicesNumber); executionEnvironment->prepareRootDeviceEnvironments(rootDevicesNumber);
for (uint32_t i = 0; i < rootDevicesNumber; i++) { for (uint32_t i = 0; i < rootDevicesNumber; i++) {
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get()); executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
auto mock = new DrmMockExp(*executionEnvironment->rootDeviceEnvironments[i]); auto mock = new DrmTipMock(*executionEnvironment->rootDeviceEnvironments[i]);
mock->memoryInfo.reset(nullptr); mock->memoryInfo.reset(nullptr);
mock->ioctlCallsCount = 0; mock->ioctlCallsCount = 0;
@@ -472,14 +472,14 @@ class DrmMemoryManagerLocalMemoryMemoryBankMock : public TestedDrmMemoryManager
class DrmMemoryManagerLocalMemoryMemoryBankTest : public ::testing::Test { class DrmMemoryManagerLocalMemoryMemoryBankTest : public ::testing::Test {
public: public:
DrmMockExp *mock; DrmTipMock *mock;
void SetUp() override { void SetUp() override {
const bool localMemoryEnabled = true; const bool localMemoryEnabled = true;
executionEnvironment = new ExecutionEnvironment; executionEnvironment = new ExecutionEnvironment;
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get()); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get());
mock = new DrmMockExp(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]); mock = new DrmTipMock(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]);
mock->memoryInfo.reset(new MockMemoryInfo()); mock->memoryInfo.reset(new MockMemoryInfo());
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
@@ -668,7 +668,7 @@ TEST_F(DrmMemoryManagerLocalMemoryWithCustomMockTest, givenDrmMemoryManagerWithL
EXPECT_EQ(nullptr, bo.peekLockedAddress()); EXPECT_EQ(nullptr, bo.peekLockedAddress());
} }
using DrmMemoryManagerFailInjectionTest = Test<DrmMemoryManagerFixtureExp>; using DrmMemoryManagerFailInjectionTest = Test<DrmMemoryManagerFixtureImpl>;
HWTEST2_F(DrmMemoryManagerFailInjectionTest, givenEnabledLocalMemoryWhenNewFailsThenAllocateInDevicePoolReturnsStatusErrorAndNullallocation, NonDefaultIoctlsSupported) { HWTEST2_F(DrmMemoryManagerFailInjectionTest, givenEnabledLocalMemoryWhenNewFailsThenAllocateInDevicePoolReturnsStatusErrorAndNullallocation, NonDefaultIoctlsSupported) {
mock->ioctl_expected.total = -1; //don't care mock->ioctl_expected.total = -1; //don't care
@@ -816,13 +816,13 @@ TEST_F(DrmMemoryManagerCopyMemoryToAllocationTest, givenDrmMemoryManagerWhenCopy
drmMemoryManger.freeGraphicsMemory(allocation); drmMemoryManger.freeGraphicsMemory(allocation);
} }
using DrmMemoryManagerTestExp = Test<DrmMemoryManagerFixtureExp>; using DrmMemoryManagerTestImpl = Test<DrmMemoryManagerFixtureImpl>;
HWTEST2_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationInLocalMemoryThenCallIoctlGemMapOffsetAndReturnLockedPtr, NonDefaultIoctlsSupported) { HWTEST2_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationInLocalMemoryThenCallIoctlGemMapOffsetAndReturnLockedPtr, NonDefaultIoctlsSupported) {
mockExp->ioctlExp_expected.gemCreateExt = 1; mockExp->ioctlImpl_expected.gemCreateExt = 1;
mockExp->ioctl_expected.gemWait = 1; mockExp->ioctl_expected.gemWait = 1;
mockExp->ioctl_expected.gemClose = 1; mockExp->ioctl_expected.gemClose = 1;
mockExp->ioctlExp_expected.gemMmapOffset = 1; mockExp->ioctlImpl_expected.gemMmapOffset = 1;
mockExp->memoryInfo.reset(new MockMemoryInfo()); mockExp->memoryInfo.reset(new MockMemoryInfo());
AllocationData allocData; AllocationData allocData;
@@ -854,8 +854,8 @@ HWTEST2_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenLockUnlockIsCalledOn
memoryManager->freeGraphicsMemory(allocation); memoryManager->freeGraphicsMemory(allocation);
} }
TEST_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationInLocalMemoryButFailsOnMmapThenReturnNullPtr) { TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationInLocalMemoryButFailsOnMmapThenReturnNullPtr) {
mockExp->ioctlExp_expected.gemMmapOffset = 2; mockExp->ioctlImpl_expected.gemMmapOffset = 2;
this->ioctlResExt = {mockExp->ioctl_cnt.total, -1}; this->ioctlResExt = {mockExp->ioctl_cnt.total, -1};
mockExp->ioctl_res_ext = &ioctlResExt; mockExp->ioctl_res_ext = &ioctlResExt;
@@ -870,8 +870,8 @@ TEST_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAll
mockExp->ioctl_res_ext = &mockExp->NONE; mockExp->ioctl_res_ext = &mockExp->NONE;
} }
TEST_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationInLocalMemoryButFailsOnIoctlMmapFunctionOffsetThenReturnNullPtr) { TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationInLocalMemoryButFailsOnIoctlMmapFunctionOffsetThenReturnNullPtr) {
mockExp->ioctlExp_expected.gemMmapOffset = 2; mockExp->ioctlImpl_expected.gemMmapOffset = 2;
mockExp->returnIoctlExtraErrorValue = true; mockExp->returnIoctlExtraErrorValue = true;
mockExp->failOnMmapOffset = true; mockExp->failOnMmapOffset = true;
@@ -886,7 +886,7 @@ TEST_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAll
mockExp->ioctl_res_ext = &mockExp->NONE; mockExp->ioctl_res_ext = &mockExp->NONE;
} }
TEST_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationInLocalMemoryButBufferObjectIsNullThenReturnNullPtr) { TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationInLocalMemoryButBufferObjectIsNullThenReturnNullPtr) {
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory); DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory);
auto ptr = memoryManager->lockResource(&drmAllocation); auto ptr = memoryManager->lockResource(&drmAllocation);
@@ -895,7 +895,7 @@ TEST_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAll
memoryManager->unlockResource(&drmAllocation); memoryManager->unlockResource(&drmAllocation);
} }
TEST_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCalledForMemoryInfoThenReturnMemoryRegionSize) { TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCalledForMemoryInfoThenReturnMemoryRegionSize) {
MockExecutionEnvironment executionEnvironment; MockExecutionEnvironment executionEnvironment;
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto drm = new DrmMock(*executionEnvironment.rootDeviceEnvironments[0]); auto drm = new DrmMock(*executionEnvironment.rootDeviceEnvironments[0]);
@@ -908,7 +908,7 @@ TEST_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCal
EXPECT_EQ(memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0)), memoryManager.getLocalMemorySize(0u, 0xF)); EXPECT_EQ(memoryInfo->getMemoryRegionSize(MemoryBanks::getBankForLocalMemory(0)), memoryManager.getLocalMemorySize(0u, 0xF));
} }
TEST_F(DrmMemoryManagerTestExp, givenLocalMemoryDisabledWhenQueryMemoryInfoThenReturnTrueAndDontCreateMemoryInfo) { TEST_F(DrmMemoryManagerTestImpl, givenLocalMemoryDisabledWhenQueryMemoryInfoThenReturnTrueAndDontCreateMemoryInfo) {
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(0); DebugManager.flags.EnableLocalMemory.set(0);
MockExecutionEnvironment executionEnvironment; MockExecutionEnvironment executionEnvironment;
@@ -919,7 +919,7 @@ TEST_F(DrmMemoryManagerTestExp, givenLocalMemoryDisabledWhenQueryMemoryInfoThenR
EXPECT_EQ(nullptr, drm->memoryInfo); EXPECT_EQ(nullptr, drm->memoryInfo);
} }
TEST_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCalledForMemoryInfoAndInvalidDeviceBitfieldThenReturnZero) { TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCalledForMemoryInfoAndInvalidDeviceBitfieldThenReturnZero) {
MockExecutionEnvironment executionEnvironment; MockExecutionEnvironment executionEnvironment;
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto drm = new DrmMock(*executionEnvironment.rootDeviceEnvironments[0]); auto drm = new DrmMock(*executionEnvironment.rootDeviceEnvironments[0]);
@@ -932,7 +932,7 @@ TEST_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCal
EXPECT_EQ(0u, memoryManager.getLocalMemorySize(0u, 0u)); EXPECT_EQ(0u, memoryManager.getLocalMemorySize(0u, 0u));
} }
TEST_F(DrmMemoryManagerTestExp, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCalledButMemoryInfoIsNotAvailableThenSizeZeroIsReturned) { TEST_F(DrmMemoryManagerTestImpl, givenDrmMemoryManagerWhenGetLocalMemorySizeIsCalledButMemoryInfoIsNotAvailableThenSizeZeroIsReturned) {
MockExecutionEnvironment executionEnvironment; MockExecutionEnvironment executionEnvironment;
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto drm = new DrmMock(*executionEnvironment.rootDeviceEnvironments[0]); auto drm = new DrmMock(*executionEnvironment.rootDeviceEnvironments[0]);

View File

@@ -10,13 +10,13 @@
#include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/os_interface/linux/drm_memory_manager_tests.h" #include "shared/test/common/os_interface/linux/drm_memory_manager_tests.h"
#include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_exp.h" #include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_impl.h"
namespace NEO { namespace NEO {
class DrmMemoryManagerFixtureExp : public DrmMemoryManagerFixture { class DrmMemoryManagerFixtureImpl : public DrmMemoryManagerFixture {
public: public:
DrmMockCustomExp *mockExp; DrmMockCustomImpl *mockExp;
void SetUp() override { void SetUp() override {
backup = std::make_unique<VariableBackup<UltHwConfig>>(&ultHwConfig); backup = std::make_unique<VariableBackup<UltHwConfig>>(&ultHwConfig);
@@ -24,12 +24,12 @@ class DrmMemoryManagerFixtureExp : public DrmMemoryManagerFixture {
MemoryManagementFixture::SetUp(); MemoryManagementFixture::SetUp();
executionEnvironment = MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), numRootDevices - 1); executionEnvironment = MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), numRootDevices - 1);
mockExp = new DrmMockCustomExp(*executionEnvironment->rootDeviceEnvironments[0]); mockExp = new DrmMockCustomImpl(*executionEnvironment->rootDeviceEnvironments[0]);
DrmMemoryManagerFixture::SetUp(mockExp, true); DrmMemoryManagerFixture::SetUp(mockExp, true);
} }
void TearDown() override { void TearDown() override {
mockExp->testIoctlsExp(); mockExp->testIoctls();
DrmMemoryManagerFixture::TearDown(); DrmMemoryManagerFixture::TearDown();
} }
std::unique_ptr<VariableBackup<UltHwConfig>> backup; std::unique_ptr<VariableBackup<UltHwConfig>> backup;

View File

@@ -15,10 +15,10 @@
using namespace NEO; using namespace NEO;
class DrmMockExp : public DrmMock { class DrmTipMock : public DrmMock {
public: public:
DrmMockExp(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockExp(rootDeviceEnvironment, defaultHwInfo.get()) {} DrmTipMock(RootDeviceEnvironment &rootDeviceEnvironment) : DrmTipMock(rootDeviceEnvironment, defaultHwInfo.get()) {}
DrmMockExp(RootDeviceEnvironment &rootDeviceEnvironment, const HardwareInfo *inputHwInfo) : DrmMock(rootDeviceEnvironment) { DrmTipMock(RootDeviceEnvironment &rootDeviceEnvironment, const HardwareInfo *inputHwInfo) : DrmMock(rootDeviceEnvironment) {
rootDeviceEnvironment.setHwInfo(inputHwInfo); rootDeviceEnvironment.setHwInfo(inputHwInfo);
} }

View File

@@ -7,7 +7,7 @@
#pragma once #pragma once
#include "opencl/test/unit_test/os_interface/linux/drm_mock_exp.h" #include "opencl/test/unit_test/os_interface/linux/drm_mock_impl.h"
namespace PROD_DG1 { namespace PROD_DG1 {
#undef DRM_IOCTL_I915_GEM_CREATE_EXT #undef DRM_IOCTL_I915_GEM_CREATE_EXT
@@ -17,10 +17,10 @@ namespace PROD_DG1 {
using namespace NEO; using namespace NEO;
class DrmMockProdDg1 : public DrmMockExp { class DrmMockProdDg1 : public DrmTipMock {
public: public:
DrmMockProdDg1(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockProdDg1(rootDeviceEnvironment, defaultHwInfo.get()) {} DrmMockProdDg1(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockProdDg1(rootDeviceEnvironment, defaultHwInfo.get()) {}
DrmMockProdDg1(RootDeviceEnvironment &rootDeviceEnvironment, const HardwareInfo *inputHwInfo) : DrmMockExp(rootDeviceEnvironment) { DrmMockProdDg1(RootDeviceEnvironment &rootDeviceEnvironment, const HardwareInfo *inputHwInfo) : DrmTipMock(rootDeviceEnvironment) {
rootDeviceEnvironment.setHwInfo(inputHwInfo); rootDeviceEnvironment.setHwInfo(inputHwInfo);
} }

View File

@@ -5,12 +5,33 @@
* *
*/ */
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/os_interface/linux/local_memory_helper.h" #include "shared/source/os_interface/linux/local_memory_helper.h"
#include "shared/source/os_interface/linux/memory_info_impl.h"
#include "shared/test/common/libult/linux/drm_mock.h"
#include "test.h" #include "test.h"
using namespace NEO; using namespace NEO;
TEST(LocalMemoryHelperTestsDefault, givenUnsupportedPlatformWhenCreateGemExtThenReturnErrorNumber) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmMock>(*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 localMemHelper = LocalMemoryHelper::get(IGFX_UNKNOWN);
uint32_t handle = 0;
auto ret = localMemHelper->createGemExt(drm.get(), &regionInfo[1], 1, 1024, handle);
EXPECT_EQ(-1u, ret);
}
TEST(LocalMemoryHelperTestsDefault, givenUnsupportedPlatformWhenTranslateIfRequiredReturnSameData) { TEST(LocalMemoryHelperTestsDefault, givenUnsupportedPlatformWhenTranslateIfRequiredReturnSameData) {
auto *data = new uint8_t{}; auto *data = new uint8_t{};
auto localMemHelper = LocalMemoryHelper::get(IGFX_UNKNOWN); auto localMemHelper = LocalMemoryHelper::get(IGFX_UNKNOWN);

View File

@@ -1,33 +0,0 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/os_interface/linux/local_memory_helper.h"
#include "shared/source/os_interface/linux/memory_info_impl.h"
#include "shared/test/common/libult/linux/drm_mock.h"
#include "test.h"
using namespace NEO;
TEST(LocalMemoryHelperTestsDefault, givenUnsupportedPlatformWhenCreateGemExtThenReturnErrorNumber) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmMock>(*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 localMemHelper = LocalMemoryHelper::get(IGFX_UNKNOWN);
uint32_t handle = 0;
auto ret = localMemHelper->createGemExt(drm.get(), &regionInfo[1], 1, 1024, handle);
EXPECT_EQ(-1u, ret);
}

View File

@@ -11,7 +11,7 @@
#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/default_hw_info.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock_exp.h" #include "opencl/test/unit_test/os_interface/linux/drm_mock_impl.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock_prod_dg1.h" #include "opencl/test/unit_test/os_interface/linux/drm_mock_prod_dg1.h"
#include "test.h" #include "test.h"
@@ -22,7 +22,7 @@ using LocalMemoryHelperTestsDg1 = ::testing::Test;
DG1TEST_F(LocalMemoryHelperTestsDg1, givenDg1WhenCreateGemExtThenReturnCorrectValue) { DG1TEST_F(LocalMemoryHelperTestsDg1, givenDg1WhenCreateGemExtThenReturnCorrectValue) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]); auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
drm_i915_memory_region_info regionInfo[2] = {}; drm_i915_memory_region_info regionInfo[2] = {};
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0}; regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
@@ -47,7 +47,7 @@ DG1TEST_F(LocalMemoryHelperTestsDg1, givenDg1WithDrmTipWhenCreateGemExtWithDebug
auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]); auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
drm_i915_memory_region_info regionInfo[2] = {}; drm_i915_memory_region_info regionInfo[2] = {};
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0}; regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0}; regionInfo[1].region = {I915_MEMORY_CLASS_DEVICE, 0};

View File

@@ -10,7 +10,7 @@
#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/default_hw_info.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock_exp.h" #include "opencl/test/unit_test/os_interface/linux/drm_mock_impl.h"
#include "test.h" #include "test.h"
using namespace NEO; using namespace NEO;
@@ -20,7 +20,7 @@ using LocalMemoryHelperTestsXeHpSdv = ::testing::Test;
XEHPTEST_F(LocalMemoryHelperTestsXeHpSdv, givenXeHpSdvWhenCreateGemExtThenReturnCorrectValue) { XEHPTEST_F(LocalMemoryHelperTestsXeHpSdv, givenXeHpSdvWhenCreateGemExtThenReturnCorrectValue) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]); auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
drm_i915_memory_region_info regionInfo[2] = {}; drm_i915_memory_region_info regionInfo[2] = {};
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0}; regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
@@ -45,7 +45,7 @@ XEHPTEST_F(LocalMemoryHelperTestsXeHpSdv, givenXeHpSdvWhenCreateGemExtWithDebugF
auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1); executionEnvironment->prepareRootDeviceEnvironments(1);
auto drm = std::make_unique<DrmMockExp>(*executionEnvironment->rootDeviceEnvironments[0]); auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
drm_i915_memory_region_info regionInfo[2] = {}; drm_i915_memory_region_info regionInfo[2] = {};
regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0}; regionInfo[0].region = {I915_MEMORY_CLASS_SYSTEM, 0};
@@ -59,4 +59,4 @@ XEHPTEST_F(LocalMemoryHelperTestsXeHpSdv, givenXeHpSdvWhenCreateGemExtWithDebugF
std::string output = testing::internal::GetCapturedStdout(); 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"); 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");
EXPECT_EQ(expectedOutput, output); EXPECT_EQ(expectedOutput, output);
} }

View File

@@ -38,8 +38,11 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_bind.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_bind.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_manager_create_multi_host_allocation.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_manager_local_memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_operations_handler_create.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_operations_handler_create.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_query_extended.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_query.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}memory_info_impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_drm.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_drm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h ${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_linux.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_linux.cpp
@@ -96,21 +99,5 @@ else()
) )
endif() endif()
if(I915_LOCAL_MEM_EXP)
list(APPEND NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_local_memory_exp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_create_multi_host_allocation_exp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_exp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_tip.h
${CMAKE_CURRENT_SOURCE_DIR}/memory_info_impl.cpp
)
else()
list(APPEND NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_manager_local_memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_manager_create_multi_host_allocation.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_query.cpp
)
endif()
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_LINUX ${NEO_CORE_OS_INTERFACE_LINUX}) set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_LINUX ${NEO_CORE_OS_INTERFACE_LINUX})
add_subdirectories() add_subdirectories()

View File

@@ -1,14 +0,0 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/drm_memory_manager.h"
namespace NEO {
DrmAllocation *DrmMemoryManager::createMultiHostAllocation(const AllocationData &allocationData) {
return allocateGraphicsMemoryWithAlignmentImpl(allocationData);
}
} // namespace NEO

View File

@@ -10,6 +10,27 @@
namespace NEO { namespace NEO {
bool retrieveMmapOffsetForBufferObject(Drm &drm, BufferObject &bo, uint64_t flags, uint64_t &offset) {
drm_i915_gem_mmap_offset mmapOffset = {};
mmapOffset.handle = bo.peekHandle();
mmapOffset.flags = I915_MMAP_OFFSET_FIXED;
auto ret = drm.ioctl(DRM_IOCTL_I915_GEM_MMAP_OFFSET, &mmapOffset);
if (ret != 0) {
mmapOffset.flags = flags;
ret = drm.ioctl(DRM_IOCTL_I915_GEM_MMAP_OFFSET, &mmapOffset);
if (ret != 0) {
int err = drm.getErrno();
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(DRM_IOCTL_I915_GEM_MMAP_OFFSET) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
DEBUG_BREAK_IF(ret != 0);
return false;
}
}
offset = mmapOffset.offset;
return true;
}
DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool hasMappedPtr) { DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool hasMappedPtr) {
drm_prime_handle openFd = {0, 0, 0}; drm_prime_handle openFd = {0, 0, 0};
openFd.fd = handle; openFd.fd = handle;
@@ -31,7 +52,56 @@ DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandl
} }
DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &allocationData, size_t size, size_t alignment, size_t alignedSize, uint64_t gpuAddress) { DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &allocationData, size_t size, size_t alignment, size_t alignedSize, uint64_t gpuAddress) {
return createAllocWithAlignmentFromUserptr(allocationData, size, alignment, alignedSize, gpuAddress); bool useBooMmap = this->getDrm(allocationData.rootDeviceIndex).getMemoryInfo() && allocationData.useMmapObject;
if (DebugManager.flags.EnableBOMmapCreate.get() != -1) {
useBooMmap = DebugManager.flags.EnableBOMmapCreate.get();
}
if (useBooMmap) {
auto totalSizeToAlloc = alignedSize + alignment;
auto cpuPointer = this->mmapFunction(0, totalSizeToAlloc, PROT_NONE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
auto cpuBasePointer = cpuPointer;
cpuPointer = alignUp(cpuPointer, alignment);
auto pointerDiff = ptrDiff(cpuPointer, cpuBasePointer);
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(this->createBufferObjectInMemoryRegion(&this->getDrm(allocationData.rootDeviceIndex), reinterpret_cast<uintptr_t>(cpuPointer), alignedSize, 0u, maxOsContextCount));
if (!bo) {
this->munmapFunction(cpuBasePointer, totalSizeToAlloc);
return nullptr;
}
uint64_t offset = 0;
if (!retrieveMmapOffsetForBufferObject(this->getDrm(allocationData.rootDeviceIndex), *bo, I915_MMAP_OFFSET_WB, offset)) {
this->munmapFunction(cpuPointer, size);
return nullptr;
}
[[maybe_unused]] auto retPtr = this->mmapFunction(cpuPointer, alignedSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, getDrm(allocationData.rootDeviceIndex).getFileDescriptor(), static_cast<off_t>(offset));
DEBUG_BREAK_IF(retPtr != cpuPointer);
obtainGpuAddress(allocationData, bo.get(), gpuAddress);
emitPinningRequest(bo.get(), allocationData);
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), cpuPointer, bo->peekAddress(), alignedSize, MemoryPool::System4KBPages);
allocation->setMmapPtr(cpuPointer);
allocation->setMmapSize(alignedSize);
if (pointerDiff != 0) {
[[maybe_unused]] auto retCode = this->munmapFunction(cpuBasePointer, pointerDiff);
DEBUG_BREAK_IF(retCode != 0);
}
[[maybe_unused]] auto retCode = this->munmapFunction(ptrOffset(cpuPointer, alignedSize), alignment - pointerDiff);
DEBUG_BREAK_IF(retCode != 0);
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuAddress), alignedSize);
bo.release();
return allocation;
} else {
return createAllocWithAlignmentFromUserptr(allocationData, size, alignment, alignedSize, gpuAddress);
}
} }
GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const AllocationData &allocationData) { GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const AllocationData &allocationData) {
@@ -39,7 +109,23 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
} }
void *DrmMemoryManager::lockResourceInLocalMemoryImpl(BufferObject *bo) { void *DrmMemoryManager::lockResourceInLocalMemoryImpl(BufferObject *bo) {
return nullptr; if (bo == nullptr) {
return nullptr;
}
auto rootDeviceIndex = this->getRootDeviceIndex(bo->peekDrm());
uint64_t offset = 0;
if (!retrieveMmapOffsetForBufferObject(this->getDrm(rootDeviceIndex), *bo, I915_MMAP_OFFSET_WC, offset)) {
return nullptr;
}
auto addr = mmapFunction(nullptr, bo->peekSize(), PROT_WRITE | PROT_READ, MAP_SHARED, getDrm(rootDeviceIndex).getFileDescriptor(), static_cast<off_t>(offset));
DEBUG_BREAK_IF(addr == MAP_FAILED);
bo->setLockedAddress(addr);
return bo->peekLockedAddress();
} }
} // namespace NEO } // namespace NEO

View File

@@ -1,140 +0,0 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/gmm_helper/resource_info.h"
#include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/heap_assigner.h"
#include "shared/source/helpers/string.h"
#include "shared/source/helpers/surface_format_info.h"
#include "shared/source/memory_manager/memory_banks.h"
#include "shared/source/os_interface/linux/drm_memory_manager.h"
#include "shared/source/os_interface/linux/memory_info_impl.h"
#include "drm_tip.h"
namespace NEO {
bool retrieveMmapOffsetForBufferObject(Drm &drm, BufferObject &bo, uint64_t flags, uint64_t &offset) {
drm_i915_gem_mmap_offset mmapOffset = {};
mmapOffset.handle = bo.peekHandle();
mmapOffset.flags = I915_MMAP_OFFSET_FIXED;
auto ret = drm.ioctl(DRM_IOCTL_I915_GEM_MMAP_OFFSET, &mmapOffset);
if (ret != 0) {
mmapOffset.flags = flags;
ret = drm.ioctl(DRM_IOCTL_I915_GEM_MMAP_OFFSET, &mmapOffset);
if (ret != 0) {
int err = drm.getErrno();
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(DRM_IOCTL_I915_GEM_MMAP_OFFSET) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
DEBUG_BREAK_IF(ret != 0);
return false;
}
}
offset = mmapOffset.offset;
return true;
}
GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const AllocationData &allocationData) {
return nullptr;
}
DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool hasMappedPtr) {
drm_prime_handle openFd = {0, 0, 0};
openFd.fd = handle;
auto ret = this->getDrm(properties.rootDeviceIndex).ioctl(DRM_IOCTL_PRIME_FD_TO_HANDLE, &openFd);
if (ret != 0) {
int err = this->getDrm(properties.rootDeviceIndex).getErrno();
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(PRIME_FD_TO_HANDLE) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
DEBUG_BREAK_IF(ret != 0);
return nullptr;
}
auto bo = new BufferObject(&getDrm(properties.rootDeviceIndex), openFd.handle, properties.size, maxOsContextCount);
bo->setAddress(properties.gpuAddress);
return new DrmAllocation(properties.rootDeviceIndex, properties.allocationType, bo, reinterpret_cast<void *>(bo->peekAddress()), bo->peekSize(),
handle, MemoryPool::SystemCpuInaccessible);
}
DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &allocationData, size_t size, size_t alignment, size_t alignedSize, uint64_t gpuAddress) {
bool useBooMmap = this->getDrm(allocationData.rootDeviceIndex).getMemoryInfo() && allocationData.useMmapObject;
if (DebugManager.flags.EnableBOMmapCreate.get() != -1) {
useBooMmap = DebugManager.flags.EnableBOMmapCreate.get();
}
if (useBooMmap) {
auto totalSizeToAlloc = alignedSize + alignment;
auto cpuPointer = this->mmapFunction(0, totalSizeToAlloc, PROT_NONE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
auto cpuBasePointer = cpuPointer;
cpuPointer = alignUp(cpuPointer, alignment);
auto pointerDiff = ptrDiff(cpuPointer, cpuBasePointer);
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(this->createBufferObjectInMemoryRegion(&this->getDrm(allocationData.rootDeviceIndex), reinterpret_cast<uintptr_t>(cpuPointer), alignedSize, 0u, maxOsContextCount));
if (!bo) {
this->munmapFunction(cpuBasePointer, totalSizeToAlloc);
return nullptr;
}
uint64_t offset = 0;
if (!retrieveMmapOffsetForBufferObject(this->getDrm(allocationData.rootDeviceIndex), *bo, I915_MMAP_OFFSET_WB, offset)) {
this->munmapFunction(cpuPointer, size);
return nullptr;
}
[[maybe_unused]] auto retPtr = this->mmapFunction(cpuPointer, alignedSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, getDrm(allocationData.rootDeviceIndex).getFileDescriptor(), static_cast<off_t>(offset));
DEBUG_BREAK_IF(retPtr != cpuPointer);
obtainGpuAddress(allocationData, bo.get(), gpuAddress);
emitPinningRequest(bo.get(), allocationData);
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), cpuPointer, bo->peekAddress(), alignedSize, MemoryPool::System4KBPages);
allocation->setMmapPtr(cpuPointer);
allocation->setMmapSize(alignedSize);
if (pointerDiff != 0) {
[[maybe_unused]] auto retCode = this->munmapFunction(cpuBasePointer, pointerDiff);
DEBUG_BREAK_IF(retCode != 0);
}
[[maybe_unused]] auto retCode = this->munmapFunction(ptrOffset(cpuPointer, alignedSize), alignment - pointerDiff);
DEBUG_BREAK_IF(retCode != 0);
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuAddress), alignedSize);
bo.release();
return allocation;
} else {
return createAllocWithAlignmentFromUserptr(allocationData, size, alignment, alignedSize, gpuAddress);
}
}
void *DrmMemoryManager::lockResourceInLocalMemoryImpl(BufferObject *bo) {
if (bo == nullptr)
return nullptr;
auto rootDeviceIndex = this->getRootDeviceIndex(bo->peekDrm());
uint64_t offset = 0;
if (!retrieveMmapOffsetForBufferObject(this->getDrm(rootDeviceIndex), *bo, I915_MMAP_OFFSET_WC, offset)) {
return nullptr;
}
auto addr = mmapFunction(nullptr, bo->peekSize(), PROT_WRITE | PROT_READ, MAP_SHARED, getDrm(rootDeviceIndex).getFileDescriptor(), static_cast<off_t>(offset));
DEBUG_BREAK_IF(addr == MAP_FAILED);
bo->setLockedAddress(addr);
return bo->peekLockedAddress();
}
} // namespace NEO

View File

@@ -5,8 +5,13 @@
* *
*/ */
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/string.h"
#include "shared/source/os_interface/linux/cache_info_impl.h"
#include "shared/source/os_interface/linux/drm_engine_mapper.h" #include "shared/source/os_interface/linux/drm_engine_mapper.h"
#include "shared/source/os_interface/linux/engine_info_impl.h" #include "shared/source/os_interface/linux/engine_info_impl.h"
#include "shared/source/os_interface/linux/local_memory_helper.h"
#include "shared/source/os_interface/linux/memory_info_impl.h"
#include "shared/source/os_interface/linux/sys_calls.h" #include "shared/source/os_interface/linux/sys_calls.h"
#include "drm_neo.h" #include "drm_neo.h"
@@ -38,7 +43,22 @@ bool Drm::queryEngineInfo(bool isSysmanEnabled) {
} }
bool Drm::queryMemoryInfo() { bool Drm::queryMemoryInfo() {
return true; auto pHwInfo = getRootDeviceEnvironment().getHardwareInfo();
auto isLocalMemSupported = HwHelper::get(pHwInfo->platform.eRenderCoreFamily).getEnableLocalMemory(*pHwInfo);
if (!isLocalMemSupported) {
return true;
}
auto length = 0;
auto dataQuery = this->query(DRM_I915_QUERY_MEMORY_REGIONS, DrmQueryItemFlags::empty, length);
if (dataQuery) {
auto localMemHelper = LocalMemoryHelper::get(pHwInfo->platform.eProductFamily);
auto data = localMemHelper->translateIfRequired(dataQuery.release(), length);
auto memRegions = reinterpret_cast<drm_i915_query_memory_regions *>(data.get());
this->memoryInfo.reset(new MemoryInfoImpl(memRegions->regions, memRegions->num_regions));
return true;
}
return false;
} }
unsigned int Drm::bindDrmContext(uint32_t drmContextId, uint32_t deviceIndex, aub_stream::EngineType engineType, bool engineInstancedDevice) { unsigned int Drm::bindDrmContext(uint32_t drmContextId, uint32_t deviceIndex, aub_stream::EngineType engineType, bool engineInstancedDevice) {
@@ -58,4 +78,70 @@ int Drm::createDrmVirtualMemory(uint32_t &drmVmId) {
return ret; return ret;
} }
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) {
return false;
}
topologyData.maxSliceCount = data->max_slices;
topologyData.maxSubSliceCount = data->max_subslices;
topologyData.maxEuCount = data->max_eus_per_subslice;
TopologyMapping mapping;
auto result = translateTopologyInfo(data, topologyData, mapping);
this->topologyMap[0] = mapping;
return result;
}
bool Drm::isDebugAttachAvailable() {
return false;
}
bool Drm::querySystemInfo() {
return false;
}
void Drm::setupSystemInfo(HardwareInfo *hwInfo, SystemInfo *sysInfo) {}
void Drm::setupCacheInfo(const HardwareInfo &hwInfo) {
this->cacheInfo.reset(new CacheInfoImpl());
}
int Drm::bindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo) {
return 0;
}
int Drm::unbindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo) {
return 0;
}
void Drm::waitForBind(uint32_t vmHandleId) {
}
int Drm::waitUserFence(uint32_t ctx, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout, uint16_t flags) {
return 0;
}
bool Drm::isVmBindAvailable() {
return this->bindAvailable;
}
uint32_t Drm::createDrmContextExt(drm_i915_gem_context_create_ext &gcc, uint32_t drmVmId, bool isSpecialContextRequested) {
return ioctl(DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT, &gcc);
}
void Drm::appendDrmContextFlags(drm_i915_gem_context_create_ext &gcc, bool isSpecialContextRequested) {
}
void Drm::queryPageFaultSupport() {
}
bool Drm::hasPageFaultSupport() const {
return pageFaultSupported;
}
} // namespace NEO } // namespace NEO

View File

@@ -1,84 +0,0 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/string.h"
#include "shared/source/os_interface/linux/drm_engine_mapper.h"
#include "shared/source/os_interface/linux/engine_info_impl.h"
#include "shared/source/os_interface/linux/local_memory_helper.h"
#include "shared/source/os_interface/linux/memory_info_impl.h"
#include "shared/source/os_interface/linux/sys_calls.h"
#include "drm_neo.h"
#include "drm_query_flags.h"
#include <fstream>
namespace NEO {
class OsContext;
namespace IoctlHelper {
std::string getIoctlStringRemaining(unsigned long request) {
return std::to_string(request);
}
std::string getIoctlParamStringRemaining(int param) {
return std::to_string(param);
}
} // namespace IoctlHelper
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;
}
return false;
}
bool Drm::queryMemoryInfo() {
auto pHwInfo = getRootDeviceEnvironment().getHardwareInfo();
auto isLocalMemSupported = HwHelper::get(pHwInfo->platform.eRenderCoreFamily).getEnableLocalMemory(*pHwInfo);
if (!isLocalMemSupported) {
return true;
}
auto length = 0;
auto dataQuery = this->query(DRM_I915_QUERY_MEMORY_REGIONS, DrmQueryItemFlags::empty, length);
if (dataQuery) {
auto pHwInfo = getRootDeviceEnvironment().getHardwareInfo();
auto localMemHelper = LocalMemoryHelper::get(pHwInfo->platform.eProductFamily);
auto data = localMemHelper->translateIfRequired(dataQuery.release(), length);
auto memRegions = reinterpret_cast<drm_i915_query_memory_regions *>(data.get());
this->memoryInfo.reset(new MemoryInfoImpl(memRegions->regions, memRegions->num_regions));
return true;
}
return false;
}
unsigned int Drm::bindDrmContext(uint32_t drmContextId, uint32_t deviceIndex, aub_stream::EngineType engineType, bool engineInstancedDevice) {
return DrmEngineMapper::engineNodeMap(engineType);
}
int Drm::createDrmVirtualMemory(uint32_t &drmVmId) {
drm_i915_gem_vm_control ctl = {};
auto ret = SysCalls::ioctl(getFileDescriptor(), DRM_IOCTL_I915_GEM_VM_CREATE, &ctl);
if (ret == 0) {
if (ctl.vm_id == 0) {
// 0 is reserved for invalid/unassigned ppgtt
return -1;
}
drmVmId = ctl.vm_id;
}
return ret;
}
} // namespace NEO

View File

@@ -1,81 +0,0 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/cache_info_impl.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "drm_query_flags.h"
namespace NEO {
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) {
return false;
}
topologyData.maxSliceCount = data->max_slices;
topologyData.maxSubSliceCount = data->max_subslices;
topologyData.maxEuCount = data->max_eus_per_subslice;
TopologyMapping mapping;
auto result = translateTopologyInfo(data, topologyData, mapping);
this->topologyMap[0] = mapping;
return result;
}
bool Drm::isDebugAttachAvailable() {
return false;
}
bool Drm::querySystemInfo() {
return false;
}
void Drm::setupSystemInfo(HardwareInfo *hwInfo, SystemInfo *sysInfo) {}
void Drm::setupCacheInfo(const HardwareInfo &hwInfo) {
this->cacheInfo.reset(new CacheInfoImpl());
}
int Drm::bindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo) {
return 0;
}
int Drm::unbindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo) {
return 0;
}
void Drm::waitForBind(uint32_t vmHandleId) {
}
int Drm::waitUserFence(uint32_t ctx, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout, uint16_t flags) {
return 0;
}
bool Drm::isVmBindAvailable() {
return this->bindAvailable;
}
uint32_t Drm::createDrmContextExt(drm_i915_gem_context_create_ext &gcc, uint32_t drmVmId, bool isSpecialContextRequested) {
return ioctl(DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT, &gcc);
}
void Drm::appendDrmContextFlags(drm_i915_gem_context_create_ext &gcc, bool isSpecialContextRequested) {
}
void Drm::queryPageFaultSupport() {
}
bool Drm::hasPageFaultSupport() const {
return pageFaultSupported;
}
} // namespace NEO

View File

@@ -1,14 +0,0 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
namespace DRM_TIP {
#undef DRM_IOCTL_I915_GEM_CREATE_EXT
#undef __I915_EXEC_UNKNOWN_FLAGS
#include "third_party/uapi/drm_tip/drm/i915_drm.h"
} // namespace DRM_TIP

View File

@@ -7,7 +7,7 @@
#include "shared/source/os_interface/linux/local_memory_helper.h" #include "shared/source/os_interface/linux/local_memory_helper.h"
#include "third_party/uapi/drm_tip/drm/i915_drm.h" #include "third_party/uapi/drm/i915_drm.h"
#include <memory> #include <memory>

View File

@@ -1,11 +1,10 @@
/** /*
* \file drm.h
* Header for the Direct Rendering Manager * Header for the Direct Rendering Manager
* *
* \author Rickard E. (Rik) Faith <faith@valinux.com> * Author: Rickard E. (Rik) Faith <faith@valinux.com>
* *
* \par Acknowledgments: * Acknowledgments:
* Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic \c cmpxchg. * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg.
*/ */
/* /*
@@ -85,7 +84,7 @@ typedef unsigned int drm_context_t;
typedef unsigned int drm_drawable_t; typedef unsigned int drm_drawable_t;
typedef unsigned int drm_magic_t; typedef unsigned int drm_magic_t;
/** /*
* Cliprect. * Cliprect.
* *
* \warning: If you change this structure, make sure you change * \warning: If you change this structure, make sure you change
@@ -101,7 +100,7 @@ struct drm_clip_rect {
unsigned short y2; unsigned short y2;
}; };
/** /*
* Drawable information. * Drawable information.
*/ */
struct drm_drawable_info { struct drm_drawable_info {
@@ -109,7 +108,7 @@ struct drm_drawable_info {
struct drm_clip_rect *rects; struct drm_clip_rect *rects;
}; };
/** /*
* Texture region, * Texture region,
*/ */
struct drm_tex_region { struct drm_tex_region {
@@ -120,7 +119,7 @@ struct drm_tex_region {
unsigned int age; unsigned int age;
}; };
/** /*
* Hardware lock. * Hardware lock.
* *
* The lock structure is a simple cache-line aligned integer. To avoid * The lock structure is a simple cache-line aligned integer. To avoid
@@ -132,7 +131,7 @@ struct drm_hw_lock {
char padding[60]; /**< Pad to cache line */ char padding[60]; /**< Pad to cache line */
}; };
/** /*
* DRM_IOCTL_VERSION ioctl argument type. * DRM_IOCTL_VERSION ioctl argument type.
* *
* \sa drmGetVersion(). * \sa drmGetVersion().
@@ -149,7 +148,7 @@ struct drm_version {
char __user *desc; /**< User-space buffer to hold desc */ char __user *desc; /**< User-space buffer to hold desc */
}; };
/** /*
* DRM_IOCTL_GET_UNIQUE ioctl argument type. * DRM_IOCTL_GET_UNIQUE ioctl argument type.
* *
* \sa drmGetBusid() and drmSetBusId(). * \sa drmGetBusid() and drmSetBusId().
@@ -168,7 +167,7 @@ struct drm_block {
int unused; int unused;
}; };
/** /*
* DRM_IOCTL_CONTROL ioctl argument type. * DRM_IOCTL_CONTROL ioctl argument type.
* *
* \sa drmCtlInstHandler() and drmCtlUninstHandler(). * \sa drmCtlInstHandler() and drmCtlUninstHandler().
@@ -183,7 +182,7 @@ struct drm_control {
int irq; int irq;
}; };
/** /*
* Type of memory to map. * Type of memory to map.
*/ */
enum drm_map_type { enum drm_map_type {
@@ -195,7 +194,7 @@ enum drm_map_type {
_DRM_CONSISTENT = 5 /**< Consistent memory for PCI DMA */ _DRM_CONSISTENT = 5 /**< Consistent memory for PCI DMA */
}; };
/** /*
* Memory mapping flags. * Memory mapping flags.
*/ */
enum drm_map_flags { enum drm_map_flags {
@@ -214,7 +213,7 @@ struct drm_ctx_priv_map {
void *handle; /**< Handle of map */ void *handle; /**< Handle of map */
}; };
/** /*
* DRM_IOCTL_GET_MAP, DRM_IOCTL_ADD_MAP and DRM_IOCTL_RM_MAP ioctls * DRM_IOCTL_GET_MAP, DRM_IOCTL_ADD_MAP and DRM_IOCTL_RM_MAP ioctls
* argument type. * argument type.
* *
@@ -231,7 +230,7 @@ struct drm_map {
/* Private data */ /* Private data */
}; };
/** /*
* DRM_IOCTL_GET_CLIENT ioctl argument type. * DRM_IOCTL_GET_CLIENT ioctl argument type.
*/ */
struct drm_client { struct drm_client {
@@ -263,7 +262,7 @@ enum drm_stat_type {
/* Add to the *END* of the list */ /* Add to the *END* of the list */
}; };
/** /*
* DRM_IOCTL_GET_STATS ioctl argument type. * DRM_IOCTL_GET_STATS ioctl argument type.
*/ */
struct drm_stats { struct drm_stats {
@@ -274,7 +273,7 @@ struct drm_stats {
} data[15]; } data[15];
}; };
/** /*
* Hardware locking flags. * Hardware locking flags.
*/ */
enum drm_lock_flags { enum drm_lock_flags {
@@ -289,7 +288,7 @@ enum drm_lock_flags {
_DRM_HALT_CUR_QUEUES = 0x20 /**< Halt all current queues */ _DRM_HALT_CUR_QUEUES = 0x20 /**< Halt all current queues */
}; };
/** /*
* DRM_IOCTL_LOCK, DRM_IOCTL_UNLOCK and DRM_IOCTL_FINISH ioctl argument type. * DRM_IOCTL_LOCK, DRM_IOCTL_UNLOCK and DRM_IOCTL_FINISH ioctl argument type.
* *
* \sa drmGetLock() and drmUnlock(). * \sa drmGetLock() and drmUnlock().
@@ -299,7 +298,7 @@ struct drm_lock {
enum drm_lock_flags flags; enum drm_lock_flags flags;
}; };
/** /*
* DMA flags * DMA flags
* *
* \warning * \warning
@@ -328,7 +327,7 @@ enum drm_dma_flags {
_DRM_DMA_LARGER_OK = 0x40 /**< Larger-than-requested buffers OK */ _DRM_DMA_LARGER_OK = 0x40 /**< Larger-than-requested buffers OK */
}; };
/** /*
* DRM_IOCTL_ADD_BUFS and DRM_IOCTL_MARK_BUFS ioctl argument type. * DRM_IOCTL_ADD_BUFS and DRM_IOCTL_MARK_BUFS ioctl argument type.
* *
* \sa drmAddBufs(). * \sa drmAddBufs().
@@ -351,7 +350,7 @@ struct drm_buf_desc {
*/ */
}; };
/** /*
* DRM_IOCTL_INFO_BUFS ioctl argument type. * DRM_IOCTL_INFO_BUFS ioctl argument type.
*/ */
struct drm_buf_info { struct drm_buf_info {
@@ -359,7 +358,7 @@ struct drm_buf_info {
struct drm_buf_desc __user *list; struct drm_buf_desc __user *list;
}; };
/** /*
* DRM_IOCTL_FREE_BUFS ioctl argument type. * DRM_IOCTL_FREE_BUFS ioctl argument type.
*/ */
struct drm_buf_free { struct drm_buf_free {
@@ -367,7 +366,7 @@ struct drm_buf_free {
int __user *list; int __user *list;
}; };
/** /*
* Buffer information * Buffer information
* *
* \sa drm_buf_map. * \sa drm_buf_map.
@@ -379,7 +378,7 @@ struct drm_buf_pub {
void __user *address; /**< Address of buffer */ void __user *address; /**< Address of buffer */
}; };
/** /*
* DRM_IOCTL_MAP_BUFS ioctl argument type. * DRM_IOCTL_MAP_BUFS ioctl argument type.
*/ */
struct drm_buf_map { struct drm_buf_map {
@@ -392,7 +391,7 @@ struct drm_buf_map {
struct drm_buf_pub __user *list; /**< Buffer information */ struct drm_buf_pub __user *list; /**< Buffer information */
}; };
/** /*
* DRM_IOCTL_DMA ioctl argument type. * DRM_IOCTL_DMA ioctl argument type.
* *
* Indices here refer to the offset into the buffer list in drm_buf_get. * Indices here refer to the offset into the buffer list in drm_buf_get.
@@ -417,7 +416,7 @@ enum drm_ctx_flags {
_DRM_CONTEXT_2DONLY = 0x02 _DRM_CONTEXT_2DONLY = 0x02
}; };
/** /*
* DRM_IOCTL_ADD_CTX ioctl argument type. * DRM_IOCTL_ADD_CTX ioctl argument type.
* *
* \sa drmCreateContext() and drmDestroyContext(). * \sa drmCreateContext() and drmDestroyContext().
@@ -427,7 +426,7 @@ struct drm_ctx {
enum drm_ctx_flags flags; enum drm_ctx_flags flags;
}; };
/** /*
* DRM_IOCTL_RES_CTX ioctl argument type. * DRM_IOCTL_RES_CTX ioctl argument type.
*/ */
struct drm_ctx_res { struct drm_ctx_res {
@@ -435,14 +434,14 @@ struct drm_ctx_res {
struct drm_ctx __user *contexts; struct drm_ctx __user *contexts;
}; };
/** /*
* DRM_IOCTL_ADD_DRAW and DRM_IOCTL_RM_DRAW ioctl argument type. * DRM_IOCTL_ADD_DRAW and DRM_IOCTL_RM_DRAW ioctl argument type.
*/ */
struct drm_draw { struct drm_draw {
drm_drawable_t handle; drm_drawable_t handle;
}; };
/** /*
* DRM_IOCTL_UPDATE_DRAW ioctl argument type. * DRM_IOCTL_UPDATE_DRAW ioctl argument type.
*/ */
typedef enum { typedef enum {
@@ -456,14 +455,14 @@ struct drm_update_draw {
unsigned long long data; unsigned long long data;
}; };
/** /*
* DRM_IOCTL_GET_MAGIC and DRM_IOCTL_AUTH_MAGIC ioctl argument type. * DRM_IOCTL_GET_MAGIC and DRM_IOCTL_AUTH_MAGIC ioctl argument type.
*/ */
struct drm_auth { struct drm_auth {
drm_magic_t magic; drm_magic_t magic;
}; };
/** /*
* DRM_IOCTL_IRQ_BUSID ioctl argument type. * DRM_IOCTL_IRQ_BUSID ioctl argument type.
* *
* \sa drmGetInterruptFromBusID(). * \sa drmGetInterruptFromBusID().
@@ -505,7 +504,7 @@ struct drm_wait_vblank_reply {
long tval_usec; long tval_usec;
}; };
/** /*
* DRM_IOCTL_WAIT_VBLANK ioctl argument type. * DRM_IOCTL_WAIT_VBLANK ioctl argument type.
* *
* \sa drmWaitVBlank(). * \sa drmWaitVBlank().
@@ -518,7 +517,7 @@ union drm_wait_vblank {
#define _DRM_PRE_MODESET 1 #define _DRM_PRE_MODESET 1
#define _DRM_POST_MODESET 2 #define _DRM_POST_MODESET 2
/** /*
* DRM_IOCTL_MODESET_CTL ioctl argument type * DRM_IOCTL_MODESET_CTL ioctl argument type
* *
* \sa drmModesetCtl(). * \sa drmModesetCtl().
@@ -528,7 +527,7 @@ struct drm_modeset_ctl {
__u32 cmd; __u32 cmd;
}; };
/** /*
* DRM_IOCTL_AGP_ENABLE ioctl argument type. * DRM_IOCTL_AGP_ENABLE ioctl argument type.
* *
* \sa drmAgpEnable(). * \sa drmAgpEnable().
@@ -537,7 +536,7 @@ struct drm_agp_mode {
unsigned long mode; /**< AGP mode */ unsigned long mode; /**< AGP mode */
}; };
/** /*
* DRM_IOCTL_AGP_ALLOC and DRM_IOCTL_AGP_FREE ioctls argument type. * DRM_IOCTL_AGP_ALLOC and DRM_IOCTL_AGP_FREE ioctls argument type.
* *
* \sa drmAgpAlloc() and drmAgpFree(). * \sa drmAgpAlloc() and drmAgpFree().
@@ -549,7 +548,7 @@ struct drm_agp_buffer {
unsigned long physical; /**< Physical used by i810 */ unsigned long physical; /**< Physical used by i810 */
}; };
/** /*
* DRM_IOCTL_AGP_BIND and DRM_IOCTL_AGP_UNBIND ioctls argument type. * DRM_IOCTL_AGP_BIND and DRM_IOCTL_AGP_UNBIND ioctls argument type.
* *
* \sa drmAgpBind() and drmAgpUnbind(). * \sa drmAgpBind() and drmAgpUnbind().
@@ -559,7 +558,7 @@ struct drm_agp_binding {
unsigned long offset; /**< In bytes -- will round to page boundary */ unsigned long offset; /**< In bytes -- will round to page boundary */
}; };
/** /*
* DRM_IOCTL_AGP_INFO ioctl argument type. * DRM_IOCTL_AGP_INFO ioctl argument type.
* *
* \sa drmAgpVersionMajor(), drmAgpVersionMinor(), drmAgpGetMode(), * \sa drmAgpVersionMajor(), drmAgpVersionMinor(), drmAgpGetMode(),
@@ -580,7 +579,7 @@ struct drm_agp_info {
unsigned short id_device; unsigned short id_device;
}; };
/** /*
* DRM_IOCTL_SG_ALLOC ioctl argument type. * DRM_IOCTL_SG_ALLOC ioctl argument type.
*/ */
struct drm_scatter_gather { struct drm_scatter_gather {
@@ -588,7 +587,7 @@ struct drm_scatter_gather {
unsigned long handle; /**< Used for mapping / unmapping */ unsigned long handle; /**< Used for mapping / unmapping */
}; };
/** /*
* DRM_IOCTL_SET_VERSION ioctl argument type. * DRM_IOCTL_SET_VERSION ioctl argument type.
*/ */
struct drm_set_version { struct drm_set_version {
@@ -598,14 +597,14 @@ struct drm_set_version {
int drm_dd_minor; int drm_dd_minor;
}; };
/** DRM_IOCTL_GEM_CLOSE ioctl argument type */ /* DRM_IOCTL_GEM_CLOSE ioctl argument type */
struct drm_gem_close { struct drm_gem_close {
/** Handle of the object to be closed. */ /** Handle of the object to be closed. */
__u32 handle; __u32 handle;
__u32 pad; __u32 pad;
}; };
/** DRM_IOCTL_GEM_FLINK ioctl argument type */ /* DRM_IOCTL_GEM_FLINK ioctl argument type */
struct drm_gem_flink { struct drm_gem_flink {
/** Handle for the object being named */ /** Handle for the object being named */
__u32 handle; __u32 handle;
@@ -614,7 +613,7 @@ struct drm_gem_flink {
__u32 name; __u32 name;
}; };
/** DRM_IOCTL_GEM_OPEN ioctl argument type */ /* DRM_IOCTL_GEM_OPEN ioctl argument type */
struct drm_gem_open { struct drm_gem_open {
/** Name of object being opened */ /** Name of object being opened */
__u32 name; __u32 name;
@@ -626,33 +625,150 @@ struct drm_gem_open {
__u64 size; __u64 size;
}; };
/**
* DRM_CAP_DUMB_BUFFER
*
* If set to 1, the driver supports creating dumb buffers via the
* &DRM_IOCTL_MODE_CREATE_DUMB ioctl.
*/
#define DRM_CAP_DUMB_BUFFER 0x1 #define DRM_CAP_DUMB_BUFFER 0x1
/**
* DRM_CAP_VBLANK_HIGH_CRTC
*
* If set to 1, the kernel supports specifying a :ref:`CRTC index<crtc_index>`
* in the high bits of &drm_wait_vblank_request.type.
*
* Starting kernel version 2.6.39, this capability is always set to 1.
*/
#define DRM_CAP_VBLANK_HIGH_CRTC 0x2 #define DRM_CAP_VBLANK_HIGH_CRTC 0x2
/**
* DRM_CAP_DUMB_PREFERRED_DEPTH
*
* The preferred bit depth for dumb buffers.
*
* The bit depth is the number of bits used to indicate the color of a single
* pixel excluding any padding. This is different from the number of bits per
* pixel. For instance, XRGB8888 has a bit depth of 24 but has 32 bits per
* pixel.
*
* Note that this preference only applies to dumb buffers, it's irrelevant for
* other types of buffers.
*/
#define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3 #define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3
/**
* DRM_CAP_DUMB_PREFER_SHADOW
*
* If set to 1, the driver prefers userspace to render to a shadow buffer
* instead of directly rendering to a dumb buffer. For best speed, userspace
* should do streaming ordered memory copies into the dumb buffer and never
* read from it.
*
* Note that this preference only applies to dumb buffers, it's irrelevant for
* other types of buffers.
*/
#define DRM_CAP_DUMB_PREFER_SHADOW 0x4 #define DRM_CAP_DUMB_PREFER_SHADOW 0x4
/**
* DRM_CAP_PRIME
*
* Bitfield of supported PRIME sharing capabilities. See &DRM_PRIME_CAP_IMPORT
* and &DRM_PRIME_CAP_EXPORT.
*
* PRIME buffers are exposed as dma-buf file descriptors. See
* Documentation/gpu/drm-mm.rst, section "PRIME Buffer Sharing".
*/
#define DRM_CAP_PRIME 0x5 #define DRM_CAP_PRIME 0x5
/**
* DRM_PRIME_CAP_IMPORT
*
* If this bit is set in &DRM_CAP_PRIME, the driver supports importing PRIME
* buffers via the &DRM_IOCTL_PRIME_FD_TO_HANDLE ioctl.
*/
#define DRM_PRIME_CAP_IMPORT 0x1 #define DRM_PRIME_CAP_IMPORT 0x1
/**
* DRM_PRIME_CAP_EXPORT
*
* If this bit is set in &DRM_CAP_PRIME, the driver supports exporting PRIME
* buffers via the &DRM_IOCTL_PRIME_HANDLE_TO_FD ioctl.
*/
#define DRM_PRIME_CAP_EXPORT 0x2 #define DRM_PRIME_CAP_EXPORT 0x2
/**
* DRM_CAP_TIMESTAMP_MONOTONIC
*
* If set to 0, the kernel will report timestamps with ``CLOCK_REALTIME`` in
* struct drm_event_vblank. If set to 1, the kernel will report timestamps with
* ``CLOCK_MONOTONIC``. See ``clock_gettime(2)`` for the definition of these
* clocks.
*
* Starting from kernel version 2.6.39, the default value for this capability
* is 1. Starting kernel version 4.15, this capability is always set to 1.
*/
#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6 #define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
/**
* DRM_CAP_ASYNC_PAGE_FLIP
*
* If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC.
*/
#define DRM_CAP_ASYNC_PAGE_FLIP 0x7 #define DRM_CAP_ASYNC_PAGE_FLIP 0x7
/* /**
* The CURSOR_WIDTH and CURSOR_HEIGHT capabilities return a valid widthxheight * DRM_CAP_CURSOR_WIDTH
* combination for the hardware cursor. The intention is that a hardware *
* agnostic userspace can query a cursor plane size to use. * The ``CURSOR_WIDTH`` and ``CURSOR_HEIGHT`` capabilities return a valid
* width x height combination for the hardware cursor. The intention is that a
* hardware agnostic userspace can query a cursor plane size to use.
* *
* Note that the cross-driver contract is to merely return a valid size; * Note that the cross-driver contract is to merely return a valid size;
* drivers are free to attach another meaning on top, eg. i915 returns the * drivers are free to attach another meaning on top, eg. i915 returns the
* maximum plane size. * maximum plane size.
*/ */
#define DRM_CAP_CURSOR_WIDTH 0x8 #define DRM_CAP_CURSOR_WIDTH 0x8
/**
* DRM_CAP_CURSOR_HEIGHT
*
* See &DRM_CAP_CURSOR_WIDTH.
*/
#define DRM_CAP_CURSOR_HEIGHT 0x9 #define DRM_CAP_CURSOR_HEIGHT 0x9
/**
* DRM_CAP_ADDFB2_MODIFIERS
*
* If set to 1, the driver supports supplying modifiers in the
* &DRM_IOCTL_MODE_ADDFB2 ioctl.
*/
#define DRM_CAP_ADDFB2_MODIFIERS 0x10 #define DRM_CAP_ADDFB2_MODIFIERS 0x10
/**
* DRM_CAP_PAGE_FLIP_TARGET
*
* If set to 1, the driver supports the &DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE and
* &DRM_MODE_PAGE_FLIP_TARGET_RELATIVE flags in
* &drm_mode_crtc_page_flip_target.flags for the &DRM_IOCTL_MODE_PAGE_FLIP
* ioctl.
*/
#define DRM_CAP_PAGE_FLIP_TARGET 0x11 #define DRM_CAP_PAGE_FLIP_TARGET 0x11
/**
* DRM_CAP_CRTC_IN_VBLANK_EVENT
*
* If set to 1, the kernel supports reporting the CRTC ID in
* &drm_event_vblank.crtc_id for the &DRM_EVENT_VBLANK and
* &DRM_EVENT_FLIP_COMPLETE events.
*
* Starting kernel version 4.12, this capability is always set to 1.
*/
#define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12 #define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12
/**
* DRM_CAP_SYNCOBJ
*
* If set to 1, the driver supports sync objects. See
* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects".
*/
#define DRM_CAP_SYNCOBJ 0x13 #define DRM_CAP_SYNCOBJ 0x13
/**
* DRM_CAP_SYNCOBJ_TIMELINE
*
* If set to 1, the driver supports timeline operations on sync objects. See
* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects".
*/
#define DRM_CAP_SYNCOBJ_TIMELINE 0x14 #define DRM_CAP_SYNCOBJ_TIMELINE 0x14
/** DRM_IOCTL_GET_CAP ioctl argument type */ /* DRM_IOCTL_GET_CAP ioctl argument type */
struct drm_get_cap { struct drm_get_cap {
__u64 capability; __u64 capability;
__u64 value; __u64 value;
@@ -661,9 +777,12 @@ struct drm_get_cap {
/** /**
* DRM_CLIENT_CAP_STEREO_3D * DRM_CLIENT_CAP_STEREO_3D
* *
* if set to 1, the DRM core will expose the stereo 3D capabilities of the * If set to 1, the DRM core will expose the stereo 3D capabilities of the
* monitor by advertising the supported 3D layouts in the flags of struct * monitor by advertising the supported 3D layouts in the flags of struct
* drm_mode_modeinfo. * drm_mode_modeinfo. See ``DRM_MODE_FLAG_3D_*``.
*
* This capability is always supported for all drivers starting from kernel
* version 3.13.
*/ */
#define DRM_CLIENT_CAP_STEREO_3D 1 #define DRM_CLIENT_CAP_STEREO_3D 1
@@ -672,13 +791,25 @@ struct drm_get_cap {
* *
* If set to 1, the DRM core will expose all planes (overlay, primary, and * If set to 1, the DRM core will expose all planes (overlay, primary, and
* cursor) to userspace. * cursor) to userspace.
*
* This capability has been introduced in kernel version 3.15. Starting from
* kernel version 3.17, this capability is always supported for all drivers.
*/ */
#define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2 #define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2
/** /**
* DRM_CLIENT_CAP_ATOMIC * DRM_CLIENT_CAP_ATOMIC
* *
* If set to 1, the DRM core will expose atomic properties to userspace * If set to 1, the DRM core will expose atomic properties to userspace. This
* implicitly enables &DRM_CLIENT_CAP_UNIVERSAL_PLANES and
* &DRM_CLIENT_CAP_ASPECT_RATIO.
*
* If the driver doesn't support atomic mode-setting, enabling this capability
* will fail with -EOPNOTSUPP.
*
* This capability has been introduced in kernel version 4.0. Starting from
* kernel version 4.2, this capability is always supported for atomic-capable
* drivers.
*/ */
#define DRM_CLIENT_CAP_ATOMIC 3 #define DRM_CLIENT_CAP_ATOMIC 3
@@ -686,6 +817,10 @@ struct drm_get_cap {
* DRM_CLIENT_CAP_ASPECT_RATIO * DRM_CLIENT_CAP_ASPECT_RATIO
* *
* If set to 1, the DRM core will provide aspect ratio information in modes. * If set to 1, the DRM core will provide aspect ratio information in modes.
* See ``DRM_MODE_FLAG_PIC_AR_*``.
*
* This capability is always supported for all drivers starting from kernel
* version 4.18.
*/ */
#define DRM_CLIENT_CAP_ASPECT_RATIO 4 #define DRM_CLIENT_CAP_ASPECT_RATIO 4
@@ -693,12 +828,15 @@ struct drm_get_cap {
* DRM_CLIENT_CAP_WRITEBACK_CONNECTORS * DRM_CLIENT_CAP_WRITEBACK_CONNECTORS
* *
* If set to 1, the DRM core will expose special connectors to be used for * If set to 1, the DRM core will expose special connectors to be used for
* writing back to memory the scene setup in the commit. Depends on client * writing back to memory the scene setup in the commit. The client must enable
* also supporting DRM_CLIENT_CAP_ATOMIC * &DRM_CLIENT_CAP_ATOMIC first.
*
* This capability is always supported for atomic-capable drivers starting from
* kernel version 4.19.
*/ */
#define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS 5 #define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS 5
/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ /* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
struct drm_set_client_cap { struct drm_set_client_cap {
__u64 capability; __u64 capability;
__u64 value; __u64 value;
@@ -778,11 +916,12 @@ struct drm_syncobj_array {
__u32 pad; __u32 pad;
}; };
#define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* last available point on timeline syncobj */
struct drm_syncobj_timeline_array { struct drm_syncobj_timeline_array {
__u64 handles; __u64 handles;
__u64 points; __u64 points;
__u32 count_handles; __u32 count_handles;
__u32 pad; __u32 flags;
}; };
@@ -911,6 +1050,16 @@ extern "C" {
#define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xAC, struct drm_mode_get_blob) #define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xAC, struct drm_mode_get_blob)
#define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xAD, struct drm_mode_fb_cmd) #define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xAD, struct drm_mode_fb_cmd)
#define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xAE, struct drm_mode_fb_cmd) #define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xAE, struct drm_mode_fb_cmd)
/**
* DRM_IOCTL_MODE_RMFB - Remove a framebuffer.
*
* This removes a framebuffer previously added via ADDFB/ADDFB2. The IOCTL
* argument is a framebuffer object ID.
*
* Warning: removing a framebuffer currently in-use on an enabled plane will
* disable that plane. The CRTC the plane is linked to may also be disabled
* (depending on driver capabilities).
*/
#define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xAF, unsigned int) #define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xAF, unsigned int)
#define DRM_IOCTL_MODE_PAGE_FLIP DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip) #define DRM_IOCTL_MODE_PAGE_FLIP DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip)
#define DRM_IOCTL_MODE_DIRTYFB DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd) #define DRM_IOCTL_MODE_DIRTYFB DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd)
@@ -947,7 +1096,9 @@ extern "C" {
#define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer) #define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer)
#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array) #define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array)
/** #define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2)
/*
* Device specific ioctls should only be in their respective headers * Device specific ioctls should only be in their respective headers
* The device specific ioctl range is from 0x40 to 0x9f. * The device specific ioctl range is from 0x40 to 0x9f.
* Generic IOCTLS restart at 0xA0. * Generic IOCTLS restart at 0xA0.
@@ -958,7 +1109,7 @@ extern "C" {
#define DRM_COMMAND_BASE 0x40 #define DRM_COMMAND_BASE 0x40
#define DRM_COMMAND_END 0xA0 #define DRM_COMMAND_END 0xA0
/** /*
* Header for events written back to userspace on the drm fd. The * Header for events written back to userspace on the drm fd. The
* type defines the type of event, the length specifies the total * type defines the type of event, the length specifies the total
* length of the event (including the header), and user_data is * length of the event (including the header), and user_data is

File diff suppressed because it is too large Load Diff

View File

@@ -218,6 +218,27 @@ extern "C" {
#define DRM_MODE_CONTENT_PROTECTION_DESIRED 1 #define DRM_MODE_CONTENT_PROTECTION_DESIRED 1
#define DRM_MODE_CONTENT_PROTECTION_ENABLED 2 #define DRM_MODE_CONTENT_PROTECTION_ENABLED 2
/**
* struct drm_mode_modeinfo - Display mode information.
* @clock: pixel clock in kHz
* @hdisplay: horizontal display size
* @hsync_start: horizontal sync start
* @hsync_end: horizontal sync end
* @htotal: horizontal total size
* @hskew: horizontal skew
* @vdisplay: vertical display size
* @vsync_start: vertical sync start
* @vsync_end: vertical sync end
* @vtotal: vertical total size
* @vscan: vertical scan
* @vrefresh: approximate vertical refresh rate in Hz
* @flags: bitmask of misc. flags, see DRM_MODE_FLAG_* defines
* @type: bitmask of type flags, see DRM_MODE_TYPE_* defines
* @name: string describing the mode resolution
*
* This is the user-space API display mode information structure. For the
* kernel version see struct drm_display_mode.
*/
struct drm_mode_modeinfo { struct drm_mode_modeinfo {
__u32 clock; __u32 clock;
__u16 hdisplay; __u16 hdisplay;
@@ -291,16 +312,48 @@ struct drm_mode_set_plane {
__u32 src_w; __u32 src_w;
}; };
/**
* struct drm_mode_get_plane - Get plane metadata.
*
* Userspace can perform a GETPLANE ioctl to retrieve information about a
* plane.
*
* To retrieve the number of formats supported, set @count_format_types to zero
* and call the ioctl. @count_format_types will be updated with the value.
*
* To retrieve these formats, allocate an array with the memory needed to store
* @count_format_types formats. Point @format_type_ptr to this array and call
* the ioctl again (with @count_format_types still set to the value returned in
* the first ioctl call).
*/
struct drm_mode_get_plane { struct drm_mode_get_plane {
/**
* @plane_id: Object ID of the plane whose information should be
* retrieved. Set by caller.
*/
__u32 plane_id; __u32 plane_id;
/** @crtc_id: Object ID of the current CRTC. */
__u32 crtc_id; __u32 crtc_id;
/** @fb_id: Object ID of the current fb. */
__u32 fb_id; __u32 fb_id;
/**
* @possible_crtcs: Bitmask of CRTC's compatible with the plane. CRTC's
* are created and they receive an index, which corresponds to their
* position in the bitmask. Bit N corresponds to
* :ref:`CRTC index<crtc_index>` N.
*/
__u32 possible_crtcs; __u32 possible_crtcs;
/** @gamma_size: Never used. */
__u32 gamma_size; __u32 gamma_size;
/** @count_format_types: Number of formats. */
__u32 count_format_types; __u32 count_format_types;
/**
* @format_type_ptr: Pointer to ``__u32`` array of formats that are
* supported by the plane. These formats do not require modifiers.
*/
__u64 format_type_ptr; __u64 format_type_ptr;
}; };
@@ -332,14 +385,19 @@ struct drm_mode_get_encoder {
/* This is for connectors with multiple signal types. */ /* This is for connectors with multiple signal types. */
/* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */ /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
enum drm_mode_subconnector { enum drm_mode_subconnector {
DRM_MODE_SUBCONNECTOR_Automatic = 0, DRM_MODE_SUBCONNECTOR_Automatic = 0, /* DVI-I, TV */
DRM_MODE_SUBCONNECTOR_Unknown = 0, DRM_MODE_SUBCONNECTOR_Unknown = 0, /* DVI-I, TV, DP */
DRM_MODE_SUBCONNECTOR_DVID = 3, DRM_MODE_SUBCONNECTOR_VGA = 1, /* DP */
DRM_MODE_SUBCONNECTOR_DVIA = 4, DRM_MODE_SUBCONNECTOR_DVID = 3, /* DVI-I DP */
DRM_MODE_SUBCONNECTOR_Composite = 5, DRM_MODE_SUBCONNECTOR_DVIA = 4, /* DVI-I */
DRM_MODE_SUBCONNECTOR_SVIDEO = 6, DRM_MODE_SUBCONNECTOR_Composite = 5, /* TV */
DRM_MODE_SUBCONNECTOR_Component = 8, DRM_MODE_SUBCONNECTOR_SVIDEO = 6, /* TV */
DRM_MODE_SUBCONNECTOR_SCART = 9, DRM_MODE_SUBCONNECTOR_Component = 8, /* TV */
DRM_MODE_SUBCONNECTOR_SCART = 9, /* TV */
DRM_MODE_SUBCONNECTOR_DisplayPort = 10, /* DP */
DRM_MODE_SUBCONNECTOR_HDMIA = 11, /* DP */
DRM_MODE_SUBCONNECTOR_Native = 15, /* DP */
DRM_MODE_SUBCONNECTOR_Wireless = 18, /* DP */
}; };
#define DRM_MODE_CONNECTOR_Unknown 0 #define DRM_MODE_CONNECTOR_Unknown 0
@@ -361,28 +419,96 @@ enum drm_mode_subconnector {
#define DRM_MODE_CONNECTOR_DSI 16 #define DRM_MODE_CONNECTOR_DSI 16
#define DRM_MODE_CONNECTOR_DPI 17 #define DRM_MODE_CONNECTOR_DPI 17
#define DRM_MODE_CONNECTOR_WRITEBACK 18 #define DRM_MODE_CONNECTOR_WRITEBACK 18
#define DRM_MODE_CONNECTOR_SPI 19
#define DRM_MODE_CONNECTOR_USB 20
/**
* struct drm_mode_get_connector - Get connector metadata.
*
* User-space can perform a GETCONNECTOR ioctl to retrieve information about a
* connector. User-space is expected to retrieve encoders, modes and properties
* by performing this ioctl at least twice: the first time to retrieve the
* number of elements, the second time to retrieve the elements themselves.
*
* To retrieve the number of elements, set @count_props and @count_encoders to
* zero, set @count_modes to 1, and set @modes_ptr to a temporary struct
* drm_mode_modeinfo element.
*
* To retrieve the elements, allocate arrays for @encoders_ptr, @modes_ptr,
* @props_ptr and @prop_values_ptr, then set @count_modes, @count_props and
* @count_encoders to their capacity.
*
* Performing the ioctl only twice may be racy: the number of elements may have
* changed with a hotplug event in-between the two ioctls. User-space is
* expected to retry the last ioctl until the number of elements stabilizes.
* The kernel won't fill any array which doesn't have the expected length.
*
* **Force-probing a connector**
*
* If the @count_modes field is set to zero and the DRM client is the current
* DRM master, the kernel will perform a forced probe on the connector to
* refresh the connector status, modes and EDID. A forced-probe can be slow,
* might cause flickering and the ioctl will block.
*
* User-space needs to force-probe connectors to ensure their metadata is
* up-to-date at startup and after receiving a hot-plug event. User-space
* may perform a forced-probe when the user explicitly requests it. User-space
* shouldn't perform a forced-probe in other situations.
*/
struct drm_mode_get_connector { struct drm_mode_get_connector {
/** @encoders_ptr: Pointer to ``__u32`` array of object IDs. */
__u64 encoders_ptr; __u64 encoders_ptr;
/** @modes_ptr: Pointer to struct drm_mode_modeinfo array. */
__u64 modes_ptr; __u64 modes_ptr;
/** @props_ptr: Pointer to ``__u32`` array of property IDs. */
__u64 props_ptr; __u64 props_ptr;
/** @prop_values_ptr: Pointer to ``__u64`` array of property values. */
__u64 prop_values_ptr; __u64 prop_values_ptr;
/** @count_modes: Number of modes. */
__u32 count_modes; __u32 count_modes;
/** @count_props: Number of properties. */
__u32 count_props; __u32 count_props;
/** @count_encoders: Number of encoders. */
__u32 count_encoders; __u32 count_encoders;
__u32 encoder_id; /**< Current Encoder */ /** @encoder_id: Object ID of the current encoder. */
__u32 connector_id; /**< Id */ __u32 encoder_id;
/** @connector_id: Object ID of the connector. */
__u32 connector_id;
/**
* @connector_type: Type of the connector.
*
* See DRM_MODE_CONNECTOR_* defines.
*/
__u32 connector_type; __u32 connector_type;
/**
* @connector_type_id: Type-specific connector number.
*
* This is not an object ID. This is a per-type connector number. Each
* (type, type_id) combination is unique across all connectors of a DRM
* device.
*/
__u32 connector_type_id; __u32 connector_type_id;
/**
* @connection: Status of the connector.
*
* See enum drm_connector_status.
*/
__u32 connection; __u32 connection;
__u32 mm_width; /**< width in millimeters */ /** @mm_width: Width of the connected sink in millimeters. */
__u32 mm_height; /**< height in millimeters */ __u32 mm_width;
/** @mm_height: Height of the connected sink in millimeters. */
__u32 mm_height;
/**
* @subpixel: Subpixel order of the connected sink.
*
* See enum subpixel_order.
*/
__u32 subpixel; __u32 subpixel;
/** @pad: Padding, must be zero. */
__u32 pad; __u32 pad;
}; };
@@ -415,22 +541,74 @@ struct drm_mode_get_connector {
*/ */
#define DRM_MODE_PROP_ATOMIC 0x80000000 #define DRM_MODE_PROP_ATOMIC 0x80000000
/**
* struct drm_mode_property_enum - Description for an enum/bitfield entry.
* @value: numeric value for this enum entry.
* @name: symbolic name for this enum entry.
*
* See struct drm_property_enum for details.
*/
struct drm_mode_property_enum { struct drm_mode_property_enum {
__u64 value; __u64 value;
char name[DRM_PROP_NAME_LEN]; char name[DRM_PROP_NAME_LEN];
}; };
/**
* struct drm_mode_get_property - Get property metadata.
*
* User-space can perform a GETPROPERTY ioctl to retrieve information about a
* property. The same property may be attached to multiple objects, see
* "Modeset Base Object Abstraction".
*
* The meaning of the @values_ptr field changes depending on the property type.
* See &drm_property.flags for more details.
*
* The @enum_blob_ptr and @count_enum_blobs fields are only meaningful when the
* property has the type &DRM_MODE_PROP_ENUM or &DRM_MODE_PROP_BITMASK. For
* backwards compatibility, the kernel will always set @count_enum_blobs to
* zero when the property has the type &DRM_MODE_PROP_BLOB. User-space must
* ignore these two fields if the property has a different type.
*
* User-space is expected to retrieve values and enums by performing this ioctl
* at least twice: the first time to retrieve the number of elements, the
* second time to retrieve the elements themselves.
*
* To retrieve the number of elements, set @count_values and @count_enum_blobs
* to zero, then call the ioctl. @count_values will be updated with the number
* of elements. If the property has the type &DRM_MODE_PROP_ENUM or
* &DRM_MODE_PROP_BITMASK, @count_enum_blobs will be updated as well.
*
* To retrieve the elements themselves, allocate an array for @values_ptr and
* set @count_values to its capacity. If the property has the type
* &DRM_MODE_PROP_ENUM or &DRM_MODE_PROP_BITMASK, allocate an array for
* @enum_blob_ptr and set @count_enum_blobs to its capacity. Calling the ioctl
* again will fill the arrays.
*/
struct drm_mode_get_property { struct drm_mode_get_property {
__u64 values_ptr; /* values and blob lengths */ /** @values_ptr: Pointer to a ``__u64`` array. */
__u64 enum_blob_ptr; /* enum and blob id ptrs */ __u64 values_ptr;
/** @enum_blob_ptr: Pointer to a struct drm_mode_property_enum array. */
__u64 enum_blob_ptr;
/**
* @prop_id: Object ID of the property which should be retrieved. Set
* by the caller.
*/
__u32 prop_id; __u32 prop_id;
/**
* @flags: ``DRM_MODE_PROP_*`` bitfield. See &drm_property.flags for
* a definition of the flags.
*/
__u32 flags; __u32 flags;
/**
* @name: Symbolic property name. User-space should use this field to
* recognize properties.
*/
char name[DRM_PROP_NAME_LEN]; char name[DRM_PROP_NAME_LEN];
/** @count_values: Number of elements in @values_ptr. */
__u32 count_values; __u32 count_values;
/* This is only used to count enum values, not blobs. The _blobs is /** @count_enum_blobs: Number of elements in @enum_blob_ptr. */
* simply because of a historical reason, i.e. backwards compat. */
__u32 count_enum_blobs; __u32 count_enum_blobs;
}; };
@@ -496,7 +674,7 @@ struct drm_mode_fb_cmd2 {
* In case of planar formats, this ioctl allows up to 4 * In case of planar formats, this ioctl allows up to 4
* buffer objects with offsets and pitches per plane. * buffer objects with offsets and pitches per plane.
* The pitch and offset order is dictated by the fourcc, * The pitch and offset order is dictated by the fourcc,
* e.g. NV12 (http://fourcc.org/yuv.php#NV12) is described as: * e.g. NV12 (https://fourcc.org/yuv.php#NV12) is described as:
* *
* YUV 4:2:0 image with a plane of 8 bit Y samples * YUV 4:2:0 image with a plane of 8 bit Y samples
* followed by an interleaved U/V plane containing * followed by an interleaved U/V plane containing
@@ -898,26 +1076,31 @@ struct drm_format_modifier {
}; };
/** /**
* struct drm_mode_create_blob - Create New block property * struct drm_mode_create_blob - Create New blob property
* @data: Pointer to data to copy. *
* @length: Length of data to copy.
* @blob_id: new property ID.
* Create a new 'blob' data property, copying length bytes from data pointer, * Create a new 'blob' data property, copying length bytes from data pointer,
* and returning new blob ID. * and returning new blob ID.
*/ */
struct drm_mode_create_blob { struct drm_mode_create_blob {
/** Pointer to data to copy. */ /** @data: Pointer to data to copy. */
__u64 data; __u64 data;
/** Length of data to copy. */ /** @length: Length of data to copy. */
__u32 length; __u32 length;
/** Return: new property ID. */ /** @blob_id: Return: new property ID. */
__u32 blob_id; __u32 blob_id;
}; };
/** /**
* struct drm_mode_destroy_blob - Destroy user blob * struct drm_mode_destroy_blob - Destroy user blob
* @blob_id: blob_id to destroy * @blob_id: blob_id to destroy
*
* Destroy a user-created blob property. * Destroy a user-created blob property.
*
* User-space can release blobs as soon as they do not need to refer to them by
* their blob object ID. For instance, if you are using a MODE_ID blob in an
* atomic commit and you will not make another commit re-using the same ID, you
* can destroy the blob as soon as the commit has been issued, without waiting
* for it to complete.
*/ */
struct drm_mode_destroy_blob { struct drm_mode_destroy_blob {
__u32 blob_id; __u32 blob_id;
@@ -925,36 +1108,35 @@ struct drm_mode_destroy_blob {
/** /**
* struct drm_mode_create_lease - Create lease * struct drm_mode_create_lease - Create lease
* @object_ids: Pointer to array of object ids. *
* @object_count: Number of object ids.
* @flags: flags for new FD.
* @lessee_id: unique identifier for lessee.
* @fd: file descriptor to new drm_master file.
* Lease mode resources, creating another drm_master. * Lease mode resources, creating another drm_master.
*
* The @object_ids array must reference at least one CRTC, one connector and
* one plane if &DRM_CLIENT_CAP_UNIVERSAL_PLANES is enabled.
*/ */
struct drm_mode_create_lease { struct drm_mode_create_lease {
/** Pointer to array of object ids (__u32) */ /** @object_ids: Pointer to array of object ids (__u32) */
__u64 object_ids; __u64 object_ids;
/** Number of object ids */ /** @object_count: Number of object ids */
__u32 object_count; __u32 object_count;
/** flags for new FD (O_CLOEXEC, etc) */ /** @flags: flags for new FD (O_CLOEXEC, etc) */
__u32 flags; __u32 flags;
/** Return: unique identifier for lessee. */ /** @lessee_id: Return: unique identifier for lessee. */
__u32 lessee_id; __u32 lessee_id;
/** Return: file descriptor to new drm_master file */ /** @fd: Return: file descriptor to new drm_master file */
__u32 fd; __u32 fd;
}; };
/** /**
* struct drm_mode_list_lessees - List lessees * struct drm_mode_list_lessees - List lessees
* @count_lessees: Number of lessees. *
* @pad: pad. * List lesses from a drm_master.
* @lessees_ptr: Pointer to lessess.
* List lesses from a drm_master
*/ */
struct drm_mode_list_lessees { struct drm_mode_list_lessees {
/** Number of lessees. /**
* @count_lessees: Number of lessees.
*
* On input, provides length of the array. * On input, provides length of the array.
* On output, provides total number. No * On output, provides total number. No
* more than the input number will be written * more than the input number will be written
@@ -962,23 +1144,26 @@ struct drm_mode_list_lessees {
* the size and then the data. * the size and then the data.
*/ */
__u32 count_lessees; __u32 count_lessees;
/** @pad: Padding. */
__u32 pad; __u32 pad;
/** Pointer to lessees. /**
* pointer to __u64 array of lessee ids * @lessees_ptr: Pointer to lessees.
*
* Pointer to __u64 array of lessee ids
*/ */
__u64 lessees_ptr; __u64 lessees_ptr;
}; };
/** /**
* struct drm_mode_get_lease - Get Lease * struct drm_mode_get_lease - Get Lease
* @count_objects: Number of leased objects. *
* @pad: pad. * Get leased objects.
* @objects_ptr: Pointer to objects.
* Get leased objects
*/ */
struct drm_mode_get_lease { struct drm_mode_get_lease {
/** Number of leased objects. /**
* @count_objects: Number of leased objects.
*
* On input, provides length of the array. * On input, provides length of the array.
* On output, provides total number. No * On output, provides total number. No
* more than the input number will be written * more than the input number will be written
@@ -986,22 +1171,22 @@ struct drm_mode_get_lease {
* the size and then the data. * the size and then the data.
*/ */
__u32 count_objects; __u32 count_objects;
/** @pad: Padding. */
__u32 pad; __u32 pad;
/** Pointer to objects. /**
* pointer to __u32 array of object ids * @objects_ptr: Pointer to objects.
*
* Pointer to __u32 array of object ids.
*/ */
__u64 objects_ptr; __u64 objects_ptr;
}; };
/** /**
* struct drm_mode_revoke_lease - Revoke lease * struct drm_mode_revoke_lease - Revoke lease
* @lessee_id: Unique ID of lessee.
* Revoke lease
*/ */
struct drm_mode_revoke_lease { struct drm_mode_revoke_lease {
/** Unique ID of lessee /** @lessee_id: Unique ID of lessee */
*/
__u32 lessee_id; __u32 lessee_id;
}; };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff