fix: correct order of wddm initialization

init gmm after getting device and paging queue handles

Related-To: NEO-11080
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2025-09-11 10:09:55 +00:00
committed by Compute-Runtime-Automation
parent 0c2a8ef30b
commit ed15408592
4 changed files with 31 additions and 7 deletions

View File

@@ -136,6 +136,13 @@ bool Wddm::init() {
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*hardwareInfo);
if (!createDevice(preemptionMode)) {
return false;
}
if (!createPagingQueue()) {
return false;
}
rootDeviceEnvironment.initGmm();
this->rootDeviceEnvironment.getGmmClientContext()->setHandleAllocator(this->hwDeviceId->getUmKmDataTranslator()->createGmmHandleAllocator());
@@ -147,13 +154,6 @@ bool Wddm::init() {
} else {
wddmInterface = std::make_unique<WddmInterface20>(*this);
}
if (!createDevice(preemptionMode)) {
return false;
}
if (!createPagingQueue()) {
return false;
}
if (!gmmMemory) {
gmmMemory.reset(GmmMemory::create(rootDeviceEnvironment.getGmmClientContext()));
}

View File

@@ -28,6 +28,8 @@ ADAPTER_BDF gAdapterBDF{};
D3DKMT_DEVICEEXECUTION_STATE gExecutionState = D3DKMT_DEVICEEXECUTION_ACTIVE;
NTSTATUS gGetDeviceStateExecutionReturnValue = STATUS_SUCCESS;
NTSTATUS gGetDeviceStatePageFaultReturnValue = STATUS_SUCCESS;
bool failCreateDevice = false;
bool failCreatePagingQueue = false;
NTSTATUS __stdcall mockD3DKMTEscape(IN CONST D3DKMT_ESCAPE *pData) {
static int perfTicks = 0;
@@ -69,6 +71,9 @@ NTSTATUS __stdcall mockD3DKMTOpenAdapterFromLuid(IN OUT CONST D3DKMT_OPENADAPTER
}
NTSTATUS __stdcall mockD3DKMTCreateDevice(IN OUT D3DKMT_CREATEDEVICE *createDevice) {
if (failCreateDevice) {
return STATUS_UNSUCCESSFUL;
}
if (createDevice == nullptr || createDevice->hAdapter != ADAPTER_HANDLE) {
return STATUS_INVALID_PARAMETER;
}
@@ -85,6 +90,9 @@ NTSTATUS __stdcall mockD3DKMTDestroyDevice(IN CONST D3DKMT_DESTROYDEVICE *destor
}
NTSTATUS __stdcall mockD3DKMTCreatePagingQueue(IN OUT D3DKMT_CREATEPAGINGQUEUE *createQueue) {
if (failCreatePagingQueue) {
return STATUS_UNSUCCESSFUL;
}
if (createQueue == nullptr || (createQueue->hDevice != DEVICE_HANDLE)) {
return STATUS_INVALID_PARAMETER;
}

View File

@@ -115,3 +115,5 @@ void initGfxPartition();
void setCapturingCreateAllocationFlags();
void getCapturedCreateAllocationFlags(D3DKMT_CREATEALLOCATIONFLAGS &capturedCreateAllocationFlags, uint32_t &numCalled);
void setSupportCreateAllocationWithReadWriteExisitingSysMemory(bool supportValue, bool &previousValue);
extern bool failCreateDevice;
extern bool failCreatePagingQueue;

View File

@@ -536,6 +536,20 @@ TEST_F(WddmTestWithMockGdiDll, givenShareableAllocationWhenCreateThenSharedHandl
EXPECT_NE(0u, handle);
}
TEST_F(WddmTestWithMockGdiDll, whenCreateDeviceFailsThenGmmIsNotIntialized) {
VariableBackup backupFailDevice(&failCreateDevice, true);
wddm->rootDeviceEnvironment.gmmHelper.reset();
EXPECT_FALSE(wddm->init());
EXPECT_EQ(nullptr, wddm->rootDeviceEnvironment.gmmHelper.get());
}
TEST_F(WddmTestWithMockGdiDll, whenCreatePagingQueueFailsThenGmmIsNotIntialized) {
VariableBackup backupFailDevice(&failCreatePagingQueue, true);
wddm->rootDeviceEnvironment.gmmHelper.reset();
EXPECT_FALSE(wddm->init());
EXPECT_EQ(nullptr, wddm->rootDeviceEnvironment.gmmHelper.get());
}
TEST_F(Wddm20Tests, WhenMakingResidentAndEvictingThenReturnIsCorrect) {
OsAgnosticMemoryManager mm(*executionEnvironment);
auto gmmHelper = getGmmHelper();