Use flag to opt-in for VM_BIND mode

Related-To: NEO-6640
Signed-off-by: Naklicki, Mateusz <mateusz.naklicki@intel.com>
This commit is contained in:
Naklicki, Mateusz
2022-04-21 16:59:48 +00:00
committed by Compute-Runtime-Automation
parent 944319b3d9
commit f1574bebb4
11 changed files with 49 additions and 20 deletions

View File

@@ -1514,9 +1514,10 @@ int Drm::createDrmVirtualMemory(uint32_t &drmVmId) {
}
bool disableScratch = DebugManager.flags.DisableScratchPages.get();
bool enablePageFault = hasPageFaultSupport() && isVmBindAvailable();
bool useVmBind = isVmBindAvailable();
bool enablePageFault = hasPageFaultSupport() && useVmBind;
ctl.flags = ioctlHelper->getFlagsForVmCreate(disableScratch, enablePageFault);
ctl.flags = ioctlHelper->getFlagsForVmCreate(disableScratch, enablePageFault, useVmBind);
auto ret = SysCalls::ioctl(getFileDescriptor(), DRM_IOCTL_I915_GEM_VM_CREATE, &ctl);

View File

@@ -109,7 +109,7 @@ class IoctlHelper {
virtual bool completionFenceExtensionSupported(const HardwareInfo &hwInfo, const bool isVmBindAvailable) = 0;
virtual std::optional<int> getHasPageFaultParamId() = 0;
virtual std::unique_ptr<uint8_t[]> createVmControlExtRegion(const std::optional<MemoryClassInstance> &regionInstanceClass) = 0;
virtual uint32_t getFlagsForVmCreate(bool disableScratch, bool enablePageFault) = 0;
virtual uint32_t getFlagsForVmCreate(bool disableScratch, bool enablePageFault, bool useVmBind) = 0;
virtual uint32_t createContextWithAccessCounters(Drm *drm, drm_i915_gem_context_create_ext &gcc) = 0;
virtual uint32_t createCooperativeContext(Drm *drm, drm_i915_gem_context_create_ext &gcc) = 0;
virtual void fillVmBindExtSetPat(VmBindExtSetPatT &vmBindExtSetPat, uint64_t patIndex, uint64_t nextExtension) = 0;
@@ -160,7 +160,7 @@ class IoctlHelperUpstream : public IoctlHelper {
bool completionFenceExtensionSupported(const HardwareInfo &hwInfo, const bool isVmBindAvailable) override;
std::optional<int> getHasPageFaultParamId() override;
std::unique_ptr<uint8_t[]> createVmControlExtRegion(const std::optional<MemoryClassInstance> &regionInstanceClass) override;
uint32_t getFlagsForVmCreate(bool disableScratch, bool enablePageFault) override;
uint32_t getFlagsForVmCreate(bool disableScratch, bool enablePageFault, bool useVmBind) override;
uint32_t createContextWithAccessCounters(Drm *drm, drm_i915_gem_context_create_ext &gcc) override;
uint32_t createCooperativeContext(Drm *drm, drm_i915_gem_context_create_ext &gcc) override;
void fillVmBindExtSetPat(VmBindExtSetPatT &vmBindExtSetPat, uint64_t patIndex, uint64_t nextExtension) override;
@@ -224,7 +224,7 @@ class IoctlHelperPrelim20 : public IoctlHelper {
bool completionFenceExtensionSupported(const HardwareInfo &hwInfo, const bool isVmBindAvailable) override;
std::optional<int> getHasPageFaultParamId() override;
std::unique_ptr<uint8_t[]> createVmControlExtRegion(const std::optional<MemoryClassInstance> &regionInstanceClass) override;
uint32_t getFlagsForVmCreate(bool disableScratch, bool enablePageFault) override;
uint32_t getFlagsForVmCreate(bool disableScratch, bool enablePageFault, bool useVmBind) override;
uint32_t createContextWithAccessCounters(Drm *drm, drm_i915_gem_context_create_ext &gcc) override;
uint32_t createCooperativeContext(Drm *drm, drm_i915_gem_context_create_ext &gcc) override;
void fillVmBindExtSetPat(VmBindExtSetPatT &vmBindExtSetPat, uint64_t patIndex, uint64_t nextExtension) override;

View File

@@ -374,7 +374,7 @@ std::unique_ptr<uint8_t[]> IoctlHelperPrelim20::createVmControlExtRegion(const s
return {};
}
uint32_t IoctlHelperPrelim20::getFlagsForVmCreate(bool disableScratch, bool enablePageFault) {
uint32_t IoctlHelperPrelim20::getFlagsForVmCreate(bool disableScratch, bool enablePageFault, bool useVmBind) {
uint32_t flags = 0u;
if (disableScratch) {
flags |= PRELIM_I915_VM_CREATE_FLAGS_DISABLE_SCRATCH;
@@ -384,6 +384,10 @@ uint32_t IoctlHelperPrelim20::getFlagsForVmCreate(bool disableScratch, bool enab
flags |= PRELIM_I915_VM_CREATE_FLAGS_ENABLE_PAGE_FAULT;
}
if (useVmBind) {
flags |= PRELIM_I915_VM_CREATE_FLAGS_USE_VM_BIND;
}
return flags;
}

View File

@@ -183,7 +183,7 @@ std::unique_ptr<uint8_t[]> IoctlHelperUpstream::createVmControlExtRegion(const s
return {};
}
uint32_t IoctlHelperUpstream::getFlagsForVmCreate(bool disableScratch, bool enablePageFault) {
uint32_t IoctlHelperUpstream::getFlagsForVmCreate(bool disableScratch, bool enablePageFault, bool useVmBind) {
return 0u;
}

View File

@@ -147,6 +147,13 @@ class DrmMock : public Drm {
return 0;
}
bool isVmBindAvailable() override {
if (callBaseIsVmBindAvailable) {
return Drm::isVmBindAvailable();
}
return bindAvailable;
}
static const int mockFd = 33;
bool failRetTopology = false;
@@ -182,6 +189,7 @@ class DrmMock : public Drm {
bool allowDebugAttach = false;
bool allowDebugAttachCallBase = false;
bool callBaseCreateDrmContext = true;
bool callBaseIsVmBindAvailable = false;
bool capturedCooperativeContextRequest = false;
@@ -289,6 +297,7 @@ class DrmMockResources : public DrmMock {
public:
DrmMockResources(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMock(mockFd, rootDeviceEnvironment) {
setBindAvailable();
callBaseIsVmBindAvailable = true;
}
bool registerResourceClasses() override {

View File

@@ -25,6 +25,7 @@ class DrmQueryMock : public DrmMock {
DrmQueryMock(RootDeviceEnvironment &rootDeviceEnvironment, const HardwareInfo *inputHwInfo) : DrmMock(rootDeviceEnvironment) {
rootDeviceEnvironment.setHwInfo(inputHwInfo);
context.hwInfo = rootDeviceEnvironment.getHardwareInfo();
callBaseIsVmBindAvailable = true;
setupIoctlHelper(IGFX_UNKNOWN);

View File

@@ -57,6 +57,7 @@ TEST(DrmBindTest, givenBindNotCompleteWhenWaitForBindThenWaitUserFenceIoctlIsCal
TEST(DrmBindTest, whenCheckingVmBindAvailabilityThenIoctlHelperSupportIsUsed) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
drm.callBaseIsVmBindAvailable = true;
EXPECT_EQ(drm.isVmBindAvailable(), drm.getIoctlHelper()->isVmBindAvailable(&drm));
}

View File

@@ -101,17 +101,22 @@ TEST_F(IoctlPrelimHelperTests, givenValidRegionInstanceClassWhenCreatingVmContro
TEST_F(IoctlPrelimHelperTests, whenGettingFlagsForVmCreateThenProperValueIsReturned) {
for (auto &disableScratch : ::testing::Bool()) {
for (auto &enablePageFault : ::testing::Bool()) {
auto flags = ioctlHelper.getFlagsForVmCreate(disableScratch, enablePageFault);
if (disableScratch) {
EXPECT_EQ(static_cast<uint32_t>(PRELIM_I915_VM_CREATE_FLAGS_DISABLE_SCRATCH), (flags & PRELIM_I915_VM_CREATE_FLAGS_DISABLE_SCRATCH));
}
if (enablePageFault) {
EXPECT_EQ(static_cast<uint32_t>(PRELIM_I915_VM_CREATE_FLAGS_ENABLE_PAGE_FAULT), (flags & PRELIM_I915_VM_CREATE_FLAGS_ENABLE_PAGE_FAULT));
}
if (disableScratch || enablePageFault) {
EXPECT_NE(0u, flags);
} else {
EXPECT_EQ(0u, flags);
for (auto &useVmBind : ::testing::Bool()) {
auto flags = ioctlHelper.getFlagsForVmCreate(disableScratch, enablePageFault, useVmBind);
if (disableScratch) {
EXPECT_EQ(static_cast<uint32_t>(PRELIM_I915_VM_CREATE_FLAGS_DISABLE_SCRATCH), (flags & PRELIM_I915_VM_CREATE_FLAGS_DISABLE_SCRATCH));
}
if (enablePageFault) {
EXPECT_EQ(static_cast<uint32_t>(PRELIM_I915_VM_CREATE_FLAGS_ENABLE_PAGE_FAULT), (flags & PRELIM_I915_VM_CREATE_FLAGS_ENABLE_PAGE_FAULT));
}
if (useVmBind) {
EXPECT_EQ(static_cast<uint32_t>(PRELIM_I915_VM_CREATE_FLAGS_USE_VM_BIND), (flags & PRELIM_I915_VM_CREATE_FLAGS_USE_VM_BIND));
}
if (disableScratch || enablePageFault || useVmBind) {
EXPECT_NE(0u, flags);
} else {
EXPECT_EQ(0u, flags);
}
}
}
}

View File

@@ -52,8 +52,10 @@ TEST(IoctlHelperUpstreamTest, whenGettingFlagsForVmCreateThenZeroIsReturned) {
IoctlHelperUpstream ioctlHelper{};
for (auto &disableScratch : ::testing::Bool()) {
for (auto &enablePageFault : ::testing::Bool()) {
auto flags = ioctlHelper.getFlagsForVmCreate(disableScratch, enablePageFault);
EXPECT_EQ(0u, flags);
for (auto &useVmBind : ::testing::Bool()) {
auto flags = ioctlHelper.getFlagsForVmCreate(disableScratch, enablePageFault, useVmBind);
EXPECT_EQ(0u, flags);
}
}
}
}