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>
This commit is contained in:
Young Jin Yoon 2024-06-06 16:26:42 +00:00 committed by Compute-Runtime-Automation
parent 0f0e7403bd
commit 1fc2a936fc
4 changed files with 36 additions and 3 deletions

View File

@ -14,6 +14,7 @@
#include "shared/source/os_interface/driver_info.h"
#include "shared/source/os_interface/linux/allocator_helper.h"
#include "shared/source/os_interface/linux/i915.h"
#include "shared/source/os_interface/linux/ioctl_helper.h"
#include "shared/source/os_interface/linux/sys_calls.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/test/common/helpers/custom_event_listener.h"
@ -766,6 +767,28 @@ TEST_F(DrmTests, givenDrmIsCreatedWhenCreateVirtualMemoryFailsThenReturnVirtualM
::testing::internal::GetCapturedStdout();
}
TEST_F(DrmTests, givenDrmIsCreatedWithPerContextVmRequiredWhenCreateVirtualMemoryThenCapturedVirtualMemoryIsSettingScratchPageOptionCorrectly) {
DebugManagerStateRestore dbgRestorer;
debugManager.flags.PrintDebugMessages.set(true);
debugManager.flags.DisableScratchPages.set(true);
debugManager.flags.GpuFaultCheckThreshold.set(10);
VariableBackup<decltype(captureVirtualMemoryCreate)> backupCaptureVirtualMemoryCreate(&captureVirtualMemoryCreate);
VariableBackup<decltype(capturedVmCreate)> backupCapturedVmCreate(&capturedVmCreate);
captureVirtualMemoryCreate = 1;
capturedVmCreate = {};
auto drm = DrmWrap::createDrm(*mockRootDeviceEnvironment);
EXPECT_NE(drm, nullptr);
auto disableScratch = drm.get()->checkToDisableScratchPage();
auto ioctlHelper = drm.get()->getIoctlHelper();
for (auto ctl : capturedVmCreate) {
EXPECT_NE(0u, (ctl.flags & ioctlHelper->getFlagsForVmCreate(disableScratch, false, false)));
}
}
TEST(SysCalls, WhenSysCallsPollCalledThenCallIsRedirectedToOs) {
struct pollfd pollFd;
pollFd.fd = 0;

View File

@ -41,6 +41,7 @@ int failOnVirtualMemoryCreate = 0;
int failOnSetPriority = 0;
int failOnPreemption = 0;
int failOnDrmVersion = 0;
int captureVirtualMemoryCreate = 0;
int accessCalledTimes = 0;
int readLinkCalledTimes = 0;
int fstatCalledTimes = 0;
@ -49,6 +50,7 @@ char providedDrmVersion[5] = {'i', '9', '1', '5', '\0'};
uint64_t gpuTimestamp = 0;
int ioctlSeq[8] = {0, 0, 0, 0, 0, 0, 0, 0};
size_t ioctlCnt = 0;
std::vector<NEO::GemVmControl> capturedVmCreate{};
int fstat(int fd, struct stat *buf) {
++fstatCalledTimes;
@ -234,6 +236,9 @@ int drmVirtualMemoryCreate(NEO::GemVmControl *control) {
if (!failOnVirtualMemoryCreate) {
control->vmId = ++vmId;
}
if (captureVirtualMemoryCreate) {
capturedVmCreate.push_back(*control);
}
return failOnVirtualMemoryCreate;
}

View File

@ -7,6 +7,8 @@
#pragma once
#include "shared/source/os_interface/linux/drm_wrappers.h"
#include <array>
#include <cstdint>
#include <cstdlib>
@ -16,6 +18,7 @@
#include <stdarg.h>
#include <sys/types.h>
#include <unistd.h>
#include <vector>
extern int (*openFunc)(const char *pathname, int flags, ...);
extern int (*openFull)(const char *pathname, int flags, ...);
@ -38,6 +41,7 @@ extern int failOnSetPriority;
extern int failOnPreemption;
extern int havePreemption;
extern int failOnDrmVersion;
extern int captureVirtualMemoryCreate;
extern char providedDrmVersion[5];
extern int ioctlSeq[8];
extern size_t ioctlCnt;
@ -47,3 +51,4 @@ extern int accessCalledTimes;
extern int readLinkCalledTimes;
extern int fstatCalledTimes;
extern bool forceExtraIoctlDuration;
extern std::vector<NEO::GemVmControl> capturedVmCreate;

View File

@ -98,6 +98,9 @@ Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironm
drm->isSetPairAvailable();
drm->isChunkingAvailable();
drm->configureScratchPagePolicy();
drm->configureGpuFaultCheckThreshold();
if (!drm->isPerContextVMRequired()) {
if (!drm->createVirtualMemoryAddressSpace(GfxCoreHelper::getSubDevicesCount(rootDeviceEnvironment.getHardwareInfo()))) {
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
drm->queryAdapterBDF();
drm->configureScratchPagePolicy();
drm->configureGpuFaultCheckThreshold();
return drm.release();
}