Add ioctl helper function to check vm bind availability

Related-To: NEO-6591
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2022-02-15 09:33:27 +00:00
committed by Compute-Runtime-Automation
parent 964596e514
commit 12e2670b9a
14 changed files with 75 additions and 7 deletions

View File

@ -669,6 +669,7 @@ TEST(DrmMemoryManagerCreate, whenCallCreateMemoryManagerThenDrmMemoryManagerIsCr
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
auto drm = new DrmMockSuccess(fakeFd, *executionEnvironment.rootDeviceEnvironments[0]);
drm->setupIoctlHelper(defaultHwInfo->platform.eProductFamily);
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
auto drmMemoryManager = MemoryManager::createMemoryManager(executionEnvironment);
@ -687,6 +688,7 @@ TEST(DrmMemoryManagerCreate, givenEnableHostPtrValidationSetToZeroWhenCreateDrmM
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
auto drm = new DrmMockSuccess(fakeFd, *executionEnvironment.rootDeviceEnvironments[0]);
drm->setupIoctlHelper(defaultHwInfo->platform.eProductFamily);
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
auto drmMemoryManager = MemoryManager::createMemoryManager(executionEnvironment);

View File

@ -24,6 +24,7 @@ using namespace NEO;
TEST(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSharedAllocationIsCreatedFromMultipleThreadsThenSingleBoIsReused) {
class MockDrm : public Drm {
public:
using Drm::setupIoctlHelper;
MockDrm(int fd, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(fd, ""), rootDeviceEnvironment) {}
int ioctl(unsigned long request, void *arg) override {
@ -37,6 +38,7 @@ TEST(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSharedAllocationIsCreatedFro
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto mock = new MockDrm(0, *executionEnvironment.rootDeviceEnvironments[0]);
mock->setupIoctlHelper(defaultHwInfo->platform.eProductFamily);
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u);
@ -76,6 +78,7 @@ TEST(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSharedAllocationIsCreatedFro
TEST(DrmMemoryManagerTest, givenMultipleThreadsWhenSharedAllocationIsCreatedThenPrimeFdToHandleDoesNotRaceWithClose) {
class MockDrm : public Drm {
public:
using Drm::setupIoctlHelper;
MockDrm(int fd, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(fd, ""), rootDeviceEnvironment) {
primeFdHandle = 1;
closeHandle = 1;
@ -107,6 +110,7 @@ TEST(DrmMemoryManagerTest, givenMultipleThreadsWhenSharedAllocationIsCreatedThen
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto mock = new MockDrm(0, *executionEnvironment.rootDeviceEnvironments[0]);
mock->setupIoctlHelper(defaultHwInfo->platform.eProductFamily);
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u);

View File

@ -33,14 +33,14 @@ class DrmCommandStreamTest : public ::testing::Test {
DebugManager.flags.EnableForcePin.set(false);
mock = new ::testing::NiceMock<DrmMockImpl>(mockFd, *executionEnvironment.rootDeviceEnvironments[0]);
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
mock->setupIoctlHelper(hwInfo->platform.eProductFamily);
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u);
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
mock->createVirtualMemoryAddressSpace(HwHelper::getSubDevicesCount(hwInfo));
mock->setupIoctlHelper(hwInfo->platform.eProductFamily);
osContext = std::make_unique<OsContextLinux>(*mock, 0u,
EngineDescriptorHelper::getDefaultDescriptor(HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0],
PreemptionHelper::getDefaultPreemptionMode(*hwInfo)));

View File

@ -34,6 +34,7 @@ using namespace NEO;
class DrmMockForWorker : public Drm {
public:
using Drm::setupIoctlHelper;
std::mutex mutex;
std::atomic<int> gem_close_cnt;
std::atomic<int> gem_close_expected;
@ -68,6 +69,9 @@ class DrmGemCloseWorkerFixture {
void SetUp() {
this->drmMock = new DrmMockForWorker(*executionEnvironment.rootDeviceEnvironments[0]);
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
drmMock->setupIoctlHelper(hwInfo->platform.eProductFamily);
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drmMock));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drmMock, 0u);