Skip to content

Commit d07f215

Browse files
fix: read scratch page options during init
Previous logic to initialize scratch page options during Drm::create causes issues when PerContextVm is used, so moved the location of logic to be configured before creating VM. Related-To: GSD-7611 Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com> Source: 9322495
1 parent 11547d3 commit d07f215

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

opencl/test/unit_test/linux/main_linux_dll.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "shared/source/os_interface/driver_info.h"
1515
#include "shared/source/os_interface/linux/allocator_helper.h"
1616
#include "shared/source/os_interface/linux/i915.h"
17+
#include "shared/source/os_interface/linux/ioctl_helper.h"
1718
#include "shared/source/os_interface/linux/sys_calls.h"
1819
#include "shared/source/os_interface/os_interface.h"
1920
#include "shared/test/common/helpers/custom_event_listener.h"
@@ -766,6 +767,28 @@ TEST_F(DrmTests, givenDrmIsCreatedWhenCreateVirtualMemoryFailsThenReturnVirtualM
766767
::testing::internal::GetCapturedStdout();
767768
}
768769

770+
TEST_F(DrmTests, givenDrmIsCreatedWithPerContextVmRequiredWhenCreateVirtualMemoryThenCapturedVirtualMemoryIsSettingScratchPageOptionCorrectly) {
771+
DebugManagerStateRestore dbgRestorer;
772+
debugManager.flags.PrintDebugMessages.set(true);
773+
debugManager.flags.DisableScratchPages.set(true);
774+
debugManager.flags.GpuFaultCheckThreshold.set(10);
775+
776+
VariableBackup<decltype(captureVirtualMemoryCreate)> backupCaptureVirtualMemoryCreate(&captureVirtualMemoryCreate);
777+
VariableBackup<decltype(capturedVmCreate)> backupCapturedVmCreate(&capturedVmCreate);
778+
779+
captureVirtualMemoryCreate = 1;
780+
capturedVmCreate = {};
781+
782+
auto drm = DrmWrap::createDrm(*mockRootDeviceEnvironment);
783+
EXPECT_NE(drm, nullptr);
784+
785+
auto disableScratch = drm.get()->checkToDisableScratchPage();
786+
auto ioctlHelper = drm.get()->getIoctlHelper();
787+
for (auto ctl : capturedVmCreate) {
788+
EXPECT_NE(0u, (ctl.flags & ioctlHelper->getFlagsForVmCreate(disableScratch, false, false)));
789+
}
790+
}
791+
769792
TEST(SysCalls, WhenSysCallsPollCalledThenCallIsRedirectedToOs) {
770793
struct pollfd pollFd;
771794
pollFd.fd = 0;

opencl/test/unit_test/linux/mock_os_layer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ int failOnVirtualMemoryCreate = 0;
4141
int failOnSetPriority = 0;
4242
int failOnPreemption = 0;
4343
int failOnDrmVersion = 0;
44+
int captureVirtualMemoryCreate = 0;
4445
int accessCalledTimes = 0;
4546
int readLinkCalledTimes = 0;
4647
int fstatCalledTimes = 0;
@@ -49,6 +50,7 @@ char providedDrmVersion[5] = {'i', '9', '1', '5', '\0'};
4950
uint64_t gpuTimestamp = 0;
5051
int ioctlSeq[8] = {0, 0, 0, 0, 0, 0, 0, 0};
5152
size_t ioctlCnt = 0;
53+
std::vector<NEO::GemVmControl> capturedVmCreate{};
5254

5355
int fstat(int fd, struct stat *buf) {
5456
++fstatCalledTimes;
@@ -234,6 +236,9 @@ int drmVirtualMemoryCreate(NEO::GemVmControl *control) {
234236
if (!failOnVirtualMemoryCreate) {
235237
control->vmId = ++vmId;
236238
}
239+
if (captureVirtualMemoryCreate) {
240+
capturedVmCreate.push_back(*control);
241+
}
237242
return failOnVirtualMemoryCreate;
238243
}
239244

opencl/test/unit_test/linux/mock_os_layer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include "shared/source/os_interface/linux/drm_wrappers.h"
11+
1012
#include <array>
1113
#include <cstdint>
1214
#include <cstdlib>
@@ -16,6 +18,7 @@
1618
#include <stdarg.h>
1719
#include <sys/types.h>
1820
#include <unistd.h>
21+
#include <vector>
1922

2023
extern int (*openFunc)(const char *pathname, int flags, ...);
2124
extern int (*openFull)(const char *pathname, int flags, ...);
@@ -38,6 +41,7 @@ extern int failOnSetPriority;
3841
extern int failOnPreemption;
3942
extern int havePreemption;
4043
extern int failOnDrmVersion;
44+
extern int captureVirtualMemoryCreate;
4145
extern char providedDrmVersion[5];
4246
extern int ioctlSeq[8];
4347
extern size_t ioctlCnt;
@@ -47,3 +51,4 @@ extern int accessCalledTimes;
4751
extern int readLinkCalledTimes;
4852
extern int fstatCalledTimes;
4953
extern bool forceExtraIoctlDuration;
54+
extern std::vector<NEO::GemVmControl> capturedVmCreate;

shared/source/dll/linux/drm_neo_create.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironm
9898
drm->isSetPairAvailable();
9999
drm->isChunkingAvailable();
100100

101+
drm->configureScratchPagePolicy();
102+
drm->configureGpuFaultCheckThreshold();
103+
101104
if (!drm->isPerContextVMRequired()) {
102105
if (!drm->createVirtualMemoryAddressSpace(GfxCoreHelper::getSubDevicesCount(rootDeviceEnvironment.getHardwareInfo()))) {
103106
printDebugString(debugManager.flags.PrintDebugMessages.get(), stderr, "%s", "INFO: Device doesn't support GEM Virtual Memory\n");
@@ -106,9 +109,6 @@ Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironm
106109

107110
drm->queryAdapterBDF();
108111

109-
drm->configureScratchPagePolicy();
110-
drm->configureGpuFaultCheckThreshold();
111-
112112
return drm.release();
113113
}
114114

0 commit comments

Comments
 (0)