mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 21:27:04 +08:00
fix: set ReadOnly flag when creating allocation with existing system memory
setting ReadOnly flag makes there is no ProbeForWrite call within CreateAllocation2 function call it doesn't make read-only access from GPU perspective, that access it defined in MapGpuVa function Related-To: NEO-12986, HSD-15016952776 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
ef896cc799
commit
bddb24124d
@@ -97,7 +97,6 @@ set(NEO_CORE_OS_INTERFACE_WDDM
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/set_gmm_input_args_${DRIVER_MODEL}.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/wddm/set_gmm_input_args_${DRIVER_MODEL}.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/max_mem_alloc_size_${DRIVER_MODEL}.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/wddm/max_mem_alloc_size_${DRIVER_MODEL}.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/helper_${DRIVER_MODEL}.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/wddm/helper_${DRIVER_MODEL}.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/is_readonly_memory_${DRIVER_MODEL}.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/skip_resource_cleanup_${DRIVER_MODEL}.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/wddm/skip_resource_cleanup_${DRIVER_MODEL}.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}map_tile_instanced_allocation_${DRIVER_MODEL}.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}map_tile_instanced_allocation_${DRIVER_MODEL}.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm.cpp
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2024 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
|
||||||
|
|
||||||
namespace NEO {
|
|
||||||
bool Wddm::isReadOnlyMemory(const void *ptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} // namespace NEO
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2024 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "shared/source/os_interface/windows/sys_calls.h"
|
|
||||||
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
|
||||||
|
|
||||||
namespace NEO {
|
|
||||||
|
|
||||||
bool Wddm::isReadOnlyMemory(const void *ptr) {
|
|
||||||
if (ptr) {
|
|
||||||
MEMORY_BASIC_INFORMATION info;
|
|
||||||
SysCalls::virtualQuery(ptr, &info, sizeof(info));
|
|
||||||
return info.Protect & PAGE_READONLY;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} // namespace NEO
|
|
||||||
@@ -665,6 +665,7 @@ NTSTATUS Wddm::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKM
|
|||||||
createAllocation.Flags.CreateShared = outSharedHandle ? TRUE : FALSE;
|
createAllocation.Flags.CreateShared = outSharedHandle ? TRUE : FALSE;
|
||||||
createAllocation.Flags.NtSecuritySharing = outSharedHandle ? TRUE : FALSE;
|
createAllocation.Flags.NtSecuritySharing = outSharedHandle ? TRUE : FALSE;
|
||||||
createAllocation.Flags.CreateResource = outSharedHandle ? TRUE : FALSE;
|
createAllocation.Flags.CreateResource = outSharedHandle ? TRUE : FALSE;
|
||||||
|
createAllocation.Flags.ReadOnly = alignedCpuPtr != nullptr ? TRUE : FALSE;
|
||||||
createAllocation.pAllocationInfo2 = &allocationInfo;
|
createAllocation.pAllocationInfo2 = &allocationInfo;
|
||||||
createAllocation.hDevice = device;
|
createAllocation.hDevice = device;
|
||||||
|
|
||||||
@@ -677,12 +678,6 @@ NTSTATUS Wddm::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKM
|
|||||||
}
|
}
|
||||||
|
|
||||||
status = getGdi()->createAllocation2(&createAllocation);
|
status = getGdi()->createAllocation2(&createAllocation);
|
||||||
if (status != STATUS_SUCCESS) {
|
|
||||||
if (isReadOnlyMemory(alignedCpuPtr)) {
|
|
||||||
createAllocation.Flags.ReadOnly = true;
|
|
||||||
status = getGdi()->createAllocation2(&createAllocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (status != STATUS_SUCCESS) {
|
if (status != STATUS_SUCCESS) {
|
||||||
DEBUG_BREAK_IF(true);
|
DEBUG_BREAK_IF(true);
|
||||||
return status;
|
return status;
|
||||||
@@ -777,19 +772,13 @@ NTSTATUS Wddm::createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) {
|
|||||||
createAllocation.Flags.CreateShared = FALSE;
|
createAllocation.Flags.CreateShared = FALSE;
|
||||||
createAllocation.Flags.RestrictSharedAccess = FALSE;
|
createAllocation.Flags.RestrictSharedAccess = FALSE;
|
||||||
createAllocation.Flags.CreateResource = FALSE;
|
createAllocation.Flags.CreateResource = FALSE;
|
||||||
|
createAllocation.Flags.ReadOnly = allocationInfo[0].pSystemMem != nullptr ? TRUE : FALSE;
|
||||||
createAllocation.pAllocationInfo2 = allocationInfo;
|
createAllocation.pAllocationInfo2 = allocationInfo;
|
||||||
createAllocation.hDevice = device;
|
createAllocation.hDevice = device;
|
||||||
|
|
||||||
while (status == STATUS_UNSUCCESSFUL) {
|
while (status == STATUS_UNSUCCESSFUL) {
|
||||||
status = getGdi()->createAllocation2(&createAllocation);
|
status = getGdi()->createAllocation2(&createAllocation);
|
||||||
|
|
||||||
if (status != STATUS_SUCCESS) {
|
|
||||||
if (isReadOnlyMemory(allocationInfo[0].pSystemMem)) {
|
|
||||||
createAllocation.Flags.ReadOnly = true;
|
|
||||||
status = getGdi()->createAllocation2(&createAllocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status != STATUS_SUCCESS) {
|
if (status != STATUS_SUCCESS) {
|
||||||
PRINT_DEBUG_STRING(debugManager.flags.PrintDebugMessages.get(), stderr, "%s status: %d", __FUNCTION__, status);
|
PRINT_DEBUG_STRING(debugManager.flags.PrintDebugMessages.get(), stderr, "%s status: %d", __FUNCTION__, status);
|
||||||
DEBUG_BREAK_IF(status != STATUS_GRAPHICS_NO_VIDEO_MEMORY);
|
DEBUG_BREAK_IF(status != STATUS_GRAPHICS_NO_VIDEO_MEMORY);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2018-2024 Intel Corporation
|
* Copyright (C) 2018-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -257,7 +257,6 @@ class Wddm : public DriverModel {
|
|||||||
void setNewResourceBoundToPageTable();
|
void setNewResourceBoundToPageTable();
|
||||||
void setProcessPowerThrottling();
|
void setProcessPowerThrottling();
|
||||||
void setThreadPriority();
|
void setThreadPriority();
|
||||||
bool isReadOnlyMemory(const void *ptr);
|
|
||||||
|
|
||||||
GMM_GFX_PARTITIONING gfxPartition{};
|
GMM_GFX_PARTITIONING gfxPartition{};
|
||||||
ADAPTER_BDF adapterBDF{};
|
ADAPTER_BDF adapterBDF{};
|
||||||
|
|||||||
@@ -156,20 +156,19 @@ inline void *getStaticStorage(uint32_t slot) {
|
|||||||
return ptrOffset(baseAddress, slot * singleStorageSize);
|
return ptrOffset(baseAddress, slot * singleStorageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool createAllocation2FailOnReadOnlyAllocation = false;
|
static D3DKMT_CREATEALLOCATIONFLAGS createAllocationFlags{};
|
||||||
static bool createAllocation2ReadOnlyFlagWasPassed = false;
|
static bool captureCreateAllocationFlags = false;
|
||||||
static uint32_t createAllocation2NumCalled = 0;
|
static uint32_t createAllocation2NumCalled = 0;
|
||||||
|
|
||||||
void setCreateAllocation2ReadOnlyFailConfig(bool fail) {
|
void setCapturingCreateAllocationFlags() {
|
||||||
createAllocation2FailOnReadOnlyAllocation = fail;
|
captureCreateAllocationFlags = true;
|
||||||
createAllocation2ReadOnlyFlagWasPassed = false;
|
|
||||||
createAllocation2NumCalled = 0;
|
createAllocation2NumCalled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getCreateAllocation2ReadOnlyFailConfig(bool &readOnlyFlagWasPassed, uint32_t &numCalled) {
|
void getCapturedCreateAllocationFlags(D3DKMT_CREATEALLOCATIONFLAGS &capturedCreateAllocationFlags, uint32_t &numCalled) {
|
||||||
readOnlyFlagWasPassed = createAllocation2ReadOnlyFlagWasPassed;
|
capturedCreateAllocationFlags = createAllocationFlags;
|
||||||
numCalled = createAllocation2NumCalled;
|
numCalled = createAllocation2NumCalled;
|
||||||
setCreateAllocation2ReadOnlyFailConfig(false);
|
captureCreateAllocationFlags = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS __stdcall mockD3DKMTCreateAllocation2(IN OUT D3DKMT_CREATEALLOCATION *allocation) {
|
NTSTATUS __stdcall mockD3DKMTCreateAllocation2(IN OUT D3DKMT_CREATEALLOCATION *allocation) {
|
||||||
@@ -187,14 +186,10 @@ NTSTATUS __stdcall mockD3DKMTCreateAllocation2(IN OUT D3DKMT_CREATEALLOCATION *a
|
|||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createAllocation2FailOnReadOnlyAllocation) {
|
if (captureCreateAllocationFlags) {
|
||||||
|
createAllocationFlags = pallocation.Flags;
|
||||||
createAllocation2NumCalled++;
|
createAllocation2NumCalled++;
|
||||||
if (pallocation.Flags.ReadOnly) {
|
return STATUS_SUCCESS;
|
||||||
createAllocation2ReadOnlyFlagWasPassed = true;
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
} else {
|
|
||||||
return STATUS_GRAPHICS_NO_VIDEO_MEMORY;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfAllocations = allocation->NumAllocations;
|
numOfAllocations = allocation->NumAllocations;
|
||||||
|
|||||||
@@ -109,5 +109,5 @@ void setAdapterBDF(ADAPTER_BDF &adapterBDF);
|
|||||||
void setMockDeviceExecutionState(D3DKMT_DEVICEEXECUTION_STATE newState);
|
void setMockDeviceExecutionState(D3DKMT_DEVICEEXECUTION_STATE newState);
|
||||||
void setMockGetDeviceStateReturnValue(NTSTATUS newReturnValue, bool execution);
|
void setMockGetDeviceStateReturnValue(NTSTATUS newReturnValue, bool execution);
|
||||||
void initGfxPartition();
|
void initGfxPartition();
|
||||||
void setCreateAllocation2ReadOnlyFailConfig(bool fail);
|
void setCapturingCreateAllocationFlags();
|
||||||
void getCreateAllocation2ReadOnlyFailConfig(bool &readOnlyFlagWasPassed, uint32_t &numCalled);
|
void getCapturedCreateAllocationFlags(D3DKMT_CREATEALLOCATIONFLAGS &capturedCreateAllocationFlags, uint32_t &numCalled);
|
||||||
|
|||||||
@@ -253,11 +253,11 @@ void *MockOsLibrary::getProcAddress(const std::string &procName) {
|
|||||||
if (procName == "D3DKMTUnregisterTrimNotification") {
|
if (procName == "D3DKMTUnregisterTrimNotification") {
|
||||||
return reinterpret_cast<void *>(mockD3DKMTUnregisterTrimNotification);
|
return reinterpret_cast<void *>(mockD3DKMTUnregisterTrimNotification);
|
||||||
}
|
}
|
||||||
if (procName == "getCreateAllocation2ReadOnlyFailConfig") {
|
if (procName == "setCapturingCreateAllocationFlags") {
|
||||||
return reinterpret_cast<void *>(getCreateAllocation2ReadOnlyFailConfig);
|
return reinterpret_cast<void *>(setCapturingCreateAllocationFlags);
|
||||||
}
|
}
|
||||||
if (procName == "setCreateAllocation2ReadOnlyFailConfig") {
|
if (procName == "getCapturedCreateAllocationFlags") {
|
||||||
return reinterpret_cast<void *>(setCreateAllocation2ReadOnlyFailConfig);
|
return reinterpret_cast<void *>(getCapturedCreateAllocationFlags);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2018-2024 Intel Corporation
|
* Copyright (C) 2018-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -53,7 +53,6 @@ class WddmMock : public Wddm {
|
|||||||
using Wddm::gfxWorkaroundTable;
|
using Wddm::gfxWorkaroundTable;
|
||||||
using Wddm::gmmMemory;
|
using Wddm::gmmMemory;
|
||||||
using Wddm::hwDeviceId;
|
using Wddm::hwDeviceId;
|
||||||
using Wddm::isReadOnlyMemory;
|
|
||||||
using Wddm::mapGpuVirtualAddress;
|
using Wddm::mapGpuVirtualAddress;
|
||||||
using Wddm::minAddress;
|
using Wddm::minAddress;
|
||||||
using Wddm::pagingFenceAddress;
|
using Wddm::pagingFenceAddress;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2018-2024 Intel Corporation
|
* Copyright (C) 2018-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -61,8 +61,8 @@ struct GdiDllFixture {
|
|||||||
reinterpret_cast<decltype(&setAdapterBDF)>(mockGdiDll->getProcAddress("setAdapterBDF"));
|
reinterpret_cast<decltype(&setAdapterBDF)>(mockGdiDll->getProcAddress("setAdapterBDF"));
|
||||||
setMockDeviceExecutionStateFcn = reinterpret_cast<decltype(&setMockDeviceExecutionState)>(mockGdiDll->getProcAddress("setMockDeviceExecutionState"));
|
setMockDeviceExecutionStateFcn = reinterpret_cast<decltype(&setMockDeviceExecutionState)>(mockGdiDll->getProcAddress("setMockDeviceExecutionState"));
|
||||||
setMockGetDeviceStateReturnValueFcn = reinterpret_cast<decltype(&setMockGetDeviceStateReturnValue)>(mockGdiDll->getProcAddress("setMockGetDeviceStateReturnValue"));
|
setMockGetDeviceStateReturnValueFcn = reinterpret_cast<decltype(&setMockGetDeviceStateReturnValue)>(mockGdiDll->getProcAddress("setMockGetDeviceStateReturnValue"));
|
||||||
getCreateAllocation2ReadOnlyFailConfigFcn = reinterpret_cast<decltype(&getCreateAllocation2ReadOnlyFailConfig)>(mockGdiDll->getProcAddress("getCreateAllocation2ReadOnlyFailConfig"));
|
getCapturedCreateAllocationFlagsFcn = reinterpret_cast<decltype(&getCapturedCreateAllocationFlags)>(mockGdiDll->getProcAddress("getCapturedCreateAllocationFlags"));
|
||||||
setCreateAllocation2ReadOnlyFailConfigFcn = reinterpret_cast<decltype(&setCreateAllocation2ReadOnlyFailConfig)>(mockGdiDll->getProcAddress("setCreateAllocation2ReadOnlyFailConfig"));
|
setCapturingCreateAllocationFlagsFcn = reinterpret_cast<decltype(&setCapturingCreateAllocationFlags)>(mockGdiDll->getProcAddress("setCapturingCreateAllocationFlags"));
|
||||||
setMockLastDestroyedResHandleFcn((D3DKMT_HANDLE)0);
|
setMockLastDestroyedResHandleFcn((D3DKMT_HANDLE)0);
|
||||||
*getDestroySynchronizationObjectDataFcn() = {};
|
*getDestroySynchronizationObjectDataFcn() = {};
|
||||||
*getCreateSynchronizationObject2FailCallFcn() = false;
|
*getCreateSynchronizationObject2FailCallFcn() = false;
|
||||||
@@ -111,6 +111,6 @@ struct GdiDllFixture {
|
|||||||
decltype(&setAdapterBDF) setAdapterBDFFcn = nullptr;
|
decltype(&setAdapterBDF) setAdapterBDFFcn = nullptr;
|
||||||
decltype(&setMockDeviceExecutionState) setMockDeviceExecutionStateFcn = nullptr;
|
decltype(&setMockDeviceExecutionState) setMockDeviceExecutionStateFcn = nullptr;
|
||||||
decltype(&setMockGetDeviceStateReturnValue) setMockGetDeviceStateReturnValueFcn = nullptr;
|
decltype(&setMockGetDeviceStateReturnValue) setMockGetDeviceStateReturnValueFcn = nullptr;
|
||||||
decltype(&getCreateAllocation2ReadOnlyFailConfig) getCreateAllocation2ReadOnlyFailConfigFcn = nullptr;
|
decltype(&setCapturingCreateAllocationFlags) setCapturingCreateAllocationFlagsFcn = nullptr;
|
||||||
decltype(&setCreateAllocation2ReadOnlyFailConfig) setCreateAllocation2ReadOnlyFailConfigFcn = nullptr;
|
decltype(&getCapturedCreateAllocationFlags) getCapturedCreateAllocationFlagsFcn = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021-2024 Intel Corporation
|
* Copyright (C) 2021-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -65,7 +65,6 @@ struct MockWddmLinux : NEO::Wddm {
|
|||||||
using Wddm::gfxPartition;
|
using Wddm::gfxPartition;
|
||||||
using Wddm::gfxPlatform;
|
using Wddm::gfxPlatform;
|
||||||
using Wddm::gmmMemory;
|
using Wddm::gmmMemory;
|
||||||
using Wddm::isReadOnlyMemory;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MockGmmMemoryWddmLinux : NEO::GmmMemory {
|
struct MockGmmMemoryWddmLinux : NEO::GmmMemory {
|
||||||
@@ -796,16 +795,6 @@ TEST_F(WddmLinuxTest, whenCheckedIfResourcesCleanupCanBeSkippedAndDeviceIsLostTh
|
|||||||
EXPECT_EQ(1, gdiMockConfig.getDeviceStateClb.callCount);
|
EXPECT_EQ(1, gdiMockConfig.getDeviceStateClb.callCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WddmLinuxTest, whenIsReadOnlyMemoryCalledThenCorrectValueReturned) {
|
|
||||||
EXPECT_FALSE(wddm->isReadOnlyMemory(nullptr));
|
|
||||||
|
|
||||||
static int mem[10];
|
|
||||||
EXPECT_FALSE(wddm->isReadOnlyMemory(mem));
|
|
||||||
|
|
||||||
static const int constMem[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
|
||||||
EXPECT_FALSE(wddm->isReadOnlyMemory(constMem));
|
|
||||||
}
|
|
||||||
|
|
||||||
class MockOsTimeLinux : public NEO::OSTimeLinux {
|
class MockOsTimeLinux : public NEO::OSTimeLinux {
|
||||||
public:
|
public:
|
||||||
MockOsTimeLinux(NEO::OSInterface &osInterface, std::unique_ptr<NEO::DeviceTime> deviceTime) : NEO::OSTimeLinux(osInterface, std::move(deviceTime)) {}
|
MockOsTimeLinux(NEO::OSInterface &osInterface, std::unique_ptr<NEO::DeviceTime> deviceTime) : NEO::OSTimeLinux(osInterface, std::move(deviceTime)) {}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2024 Intel Corporation
|
* Copyright (C) 2020-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -1000,4 +1000,53 @@ TEST_F(WddmTests, whenInitializeFailureThenInitOsInterfaceWddmFails) {
|
|||||||
|
|
||||||
EXPECT_FALSE(rootDeviceEnvironment->initOsInterface(std::move(hwDeviceId), 0u));
|
EXPECT_FALSE(rootDeviceEnvironment->initOsInterface(std::move(hwDeviceId), 0u));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WddmTests, givenHostMemoryPassedToCreateAllocationThenAllocationCreatedWithReadOnlyFlagPassed) {
|
||||||
|
wddm->init();
|
||||||
|
setCapturingCreateAllocationFlagsFcn();
|
||||||
|
|
||||||
|
static const int constMem[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||||
|
|
||||||
|
D3DKMT_HANDLE handle, resHandle;
|
||||||
|
GmmRequirements gmmRequirements{};
|
||||||
|
Gmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmHelper(), constMem, 10, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements);
|
||||||
|
|
||||||
|
EXPECT_EQ(STATUS_SUCCESS, wddm->createAllocation(constMem, &gmm, handle, resHandle, nullptr));
|
||||||
|
D3DKMT_CREATEALLOCATIONFLAGS createAllocationFlags{};
|
||||||
|
uint32_t createAllocation2NumCalled = 0;
|
||||||
|
getCapturedCreateAllocationFlagsFcn(createAllocationFlags, createAllocation2NumCalled);
|
||||||
|
EXPECT_TRUE(createAllocationFlags.ReadOnly);
|
||||||
|
EXPECT_EQ(1u, createAllocation2NumCalled);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(WddmTests, givenHostMemoryPassedToCreateAllocationsAndMapGpuVaThenAllocationCreatedWithReadOnlyFlagPassed) {
|
||||||
|
wddm->init();
|
||||||
|
wddm->callBaseMapGpuVa = false;
|
||||||
|
setCapturingCreateAllocationFlagsFcn();
|
||||||
|
|
||||||
|
static const int constMem[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||||
|
|
||||||
|
GmmRequirements gmmRequirements{};
|
||||||
|
Gmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmHelper(), constMem, 10, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements);
|
||||||
|
|
||||||
|
OsHandleStorage handleStorage;
|
||||||
|
OsHandleWin osHandle;
|
||||||
|
auto maxOsContextCount = 1u;
|
||||||
|
ResidencyData residency(maxOsContextCount);
|
||||||
|
|
||||||
|
handleStorage.fragmentCount = 1;
|
||||||
|
handleStorage.fragmentStorageData[0].cpuPtr = constMem;
|
||||||
|
handleStorage.fragmentStorageData[0].fragmentSize = 10;
|
||||||
|
handleStorage.fragmentStorageData[0].freeTheFragment = false;
|
||||||
|
handleStorage.fragmentStorageData[0].osHandleStorage = &osHandle;
|
||||||
|
handleStorage.fragmentStorageData[0].residency = &residency;
|
||||||
|
osHandle.gmm = &gmm;
|
||||||
|
|
||||||
|
EXPECT_EQ(STATUS_SUCCESS, wddm->createAllocationsAndMapGpuVa(handleStorage));
|
||||||
|
D3DKMT_CREATEALLOCATIONFLAGS createAllocationFlags{};
|
||||||
|
uint32_t createAllocation2NumCalled = 0;
|
||||||
|
getCapturedCreateAllocationFlagsFcn(createAllocationFlags, createAllocation2NumCalled);
|
||||||
|
EXPECT_TRUE(createAllocationFlags.ReadOnly);
|
||||||
|
EXPECT_EQ(1u, createAllocation2NumCalled);
|
||||||
|
}
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2023-2024 Intel Corporation
|
* Copyright (C) 2023-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -405,66 +405,3 @@ TEST_F(WddmTestWithMockGdiDll, givenSetThreadPriorityStateEnabledWhenInitWddmThe
|
|||||||
EXPECT_EQ(1u, SysCalls::setThreadPriorityCalled);
|
EXPECT_EQ(1u, SysCalls::setThreadPriorityCalled);
|
||||||
EXPECT_EQ(SysCalls::ThreadPriority::AboveNormal, SysCalls::setThreadPriorityLastValue);
|
EXPECT_EQ(SysCalls::ThreadPriority::AboveNormal, SysCalls::setThreadPriorityLastValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WddmTestWithMockGdiDll, whenIsReadOnlyMemoryCalledThenCorrectValueReturned) {
|
|
||||||
EXPECT_FALSE(wddm->isReadOnlyMemory(nullptr));
|
|
||||||
|
|
||||||
static int mem[10];
|
|
||||||
SysCalls::virtualQueryMemoryBasicInformation.Protect = PAGE_READWRITE;
|
|
||||||
EXPECT_FALSE(wddm->isReadOnlyMemory(mem));
|
|
||||||
|
|
||||||
static const int constMem[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
|
||||||
SysCalls::virtualQueryMemoryBasicInformation.Protect = PAGE_READONLY;
|
|
||||||
EXPECT_TRUE(wddm->isReadOnlyMemory(constMem));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(WddmTestWithMockGdiDll, givenReadOnlyHostMemoryPassedToCreateAllocationThenAllocationCreatedWithRetryAndReadOnlyFlagPassed) {
|
|
||||||
wddm->init();
|
|
||||||
setCreateAllocation2ReadOnlyFailConfigFcn(true);
|
|
||||||
|
|
||||||
static const int constMem[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
|
||||||
SysCalls::virtualQueryMemoryBasicInformation.Protect = PAGE_READONLY;
|
|
||||||
|
|
||||||
D3DKMT_HANDLE handle, resHandle;
|
|
||||||
GmmRequirements gmmRequirements{};
|
|
||||||
Gmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmHelper(), constMem, 10, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements);
|
|
||||||
|
|
||||||
EXPECT_EQ(STATUS_SUCCESS, wddm->createAllocation(constMem, &gmm, handle, resHandle, nullptr));
|
|
||||||
bool readOnlyFlagWasPassed = false;
|
|
||||||
uint32_t createAllocation2NumCalled = 0;
|
|
||||||
getCreateAllocation2ReadOnlyFailConfigFcn(readOnlyFlagWasPassed, createAllocation2NumCalled);
|
|
||||||
EXPECT_TRUE(readOnlyFlagWasPassed);
|
|
||||||
EXPECT_EQ(2u, createAllocation2NumCalled);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(WddmTestWithMockGdiDll, givenReadOnlyHostMemoryPassedToCreateAllocationsAndMapGpuVaThenAllocationCreatedWithRetryAndReadOnlyFlagPassed) {
|
|
||||||
wddm->init();
|
|
||||||
wddm->callBaseMapGpuVa = false;
|
|
||||||
setCreateAllocation2ReadOnlyFailConfigFcn(true);
|
|
||||||
|
|
||||||
static const int constMem[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
|
||||||
SysCalls::virtualQueryMemoryBasicInformation.Protect = PAGE_READONLY;
|
|
||||||
|
|
||||||
GmmRequirements gmmRequirements{};
|
|
||||||
Gmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmHelper(), constMem, 10, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements);
|
|
||||||
|
|
||||||
OsHandleStorage handleStorage;
|
|
||||||
OsHandleWin osHandle;
|
|
||||||
auto maxOsContextCount = 1u;
|
|
||||||
ResidencyData residency(maxOsContextCount);
|
|
||||||
|
|
||||||
handleStorage.fragmentCount = 1;
|
|
||||||
handleStorage.fragmentStorageData[0].cpuPtr = constMem;
|
|
||||||
handleStorage.fragmentStorageData[0].fragmentSize = 10;
|
|
||||||
handleStorage.fragmentStorageData[0].freeTheFragment = false;
|
|
||||||
handleStorage.fragmentStorageData[0].osHandleStorage = &osHandle;
|
|
||||||
handleStorage.fragmentStorageData[0].residency = &residency;
|
|
||||||
osHandle.gmm = &gmm;
|
|
||||||
|
|
||||||
EXPECT_EQ(STATUS_SUCCESS, wddm->createAllocationsAndMapGpuVa(handleStorage));
|
|
||||||
bool readOnlyFlagWasPassed = false;
|
|
||||||
uint32_t createAllocation2NumCalled = 0;
|
|
||||||
getCreateAllocation2ReadOnlyFailConfigFcn(readOnlyFlagWasPassed, createAllocation2NumCalled);
|
|
||||||
EXPECT_TRUE(readOnlyFlagWasPassed);
|
|
||||||
EXPECT_EQ(2u, createAllocation2NumCalled);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user