From 6df36e566723f497bf7774705f660d23e7b84e4e Mon Sep 17 00:00:00 2001 From: "Jablonski, Mateusz" Date: Mon, 2 Mar 2020 14:11:08 +0100 Subject: [PATCH] Linux: setup correct FileDescriptor when initializing GmmClientContext. Related-To: NEO-3691 Change-Id: I192e53ba97b36decb197fa3aaa009b1c60787db5 Signed-off-by: Jablonski, Mateusz --- .../linux/os_interface_linux_tests.cpp | 18 ++++++++++++++++++ .../source/os_interface/linux/os_interface.cpp | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/opencl/test/unit_test/os_interface/linux/os_interface_linux_tests.cpp b/opencl/test/unit_test/os_interface/linux/os_interface_linux_tests.cpp index a253632658..1eabf56b81 100644 --- a/opencl/test/unit_test/os_interface/linux/os_interface_linux_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/os_interface_linux_tests.cpp @@ -6,10 +6,12 @@ */ #include "shared/source/command_stream/preemption.h" +#include "shared/source/gmm_helper/gmm_lib.h" #include "shared/source/helpers/hw_helper.h" #include "shared/source/os_interface/linux/os_context_linux.h" #include "shared/source/os_interface/linux/os_interface.h" +#include "opencl/test/unit_test/mocks/mock_execution_environment.h" #include "opencl/test/unit_test/os_interface/linux/drm_mock.h" #include "gtest/gtest.h" @@ -24,4 +26,20 @@ TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenDeviceHandleQueriedthenZeroIsRetu OSInterface osInterface; EXPECT_EQ(0u, osInterface.getDeviceHandle()); } + +TEST(OsInterfaceTest, whenOsInterfaceSetupsGmmInputArgsThenProperFileDescriptorIsSet) { + MockExecutionEnvironment executionEnvironment; + auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get(); + auto osInterface = new OSInterface(); + rootDeviceEnvironment->osInterface.reset(osInterface); + + auto drm = Drm::create(nullptr, *rootDeviceEnvironment); + osInterface->get()->setDrm(drm); + GMM_INIT_IN_ARGS gmmInputArgs = {}; + EXPECT_EQ(0u, gmmInputArgs.FileDescriptor); + osInterface->setGmmInputArgs(&gmmInputArgs); + EXPECT_NE(0u, gmmInputArgs.FileDescriptor); + uint32_t expectedFileDescriptor = drm->getFileDescriptor(); + EXPECT_EQ(expectedFileDescriptor, gmmInputArgs.FileDescriptor); +} } // namespace NEO diff --git a/shared/source/os_interface/linux/os_interface.cpp b/shared/source/os_interface/linux/os_interface.cpp index ecb6174d32..cc79482a16 100644 --- a/shared/source/os_interface/linux/os_interface.cpp +++ b/shared/source/os_interface/linux/os_interface.cpp @@ -9,6 +9,7 @@ #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/gmm_helper/gmm_lib.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/os_interface/linux/drm_memory_operations_handler.h" #include "shared/source/os_interface/linux/drm_neo.h" @@ -39,7 +40,9 @@ uint32_t OSInterface::getDeviceHandle() const { return 0; } -void OSInterface::setGmmInputArgs(void *args) {} +void OSInterface::setGmmInputArgs(void *args) { + reinterpret_cast(args)->FileDescriptor = this->get()->getDrm()->getFileDescriptor(); +} bool RootDeviceEnvironment::initOsInterface(std::unique_ptr &&hwDeviceId) { Drm *drm = Drm::create(std::move(hwDeviceId), *this);