mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 07:14:10 +08:00
Add mechanism to avoid calling gdi calls while process exit
Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
673a6244ee
commit
ddd8a08fac
@@ -643,14 +643,19 @@ TEST_F(WddmLinuxTest, givenRequestFor32bitAllocationWithoutPreexistingHostPtrWhe
|
||||
TEST_F(WddmLinuxTest, whenCheckedIfResourcesCleanupCanBeSkippedAndDeviceIsAliveThenReturnsFalse) {
|
||||
osEnvironment->gdi->getDeviceState = getDeviceStateMock;
|
||||
gdiMockConfig.getDeviceStateClb.returnValue = STATUS_SUCCESS;
|
||||
EXPECT_FALSE(this->wddm->skipResourceCleanup());
|
||||
EXPECT_TRUE(this->wddm->isDriverAvaliable());
|
||||
EXPECT_EQ(1, gdiMockConfig.getDeviceStateClb.callCount);
|
||||
}
|
||||
|
||||
TEST_F(WddmLinuxTest, whenCheckedIfResourcesCleanupCanBeSkippedAndDeviceIsLostThenReturnsTrue) {
|
||||
osEnvironment->gdi->getDeviceState = getDeviceStateMock;
|
||||
gdiMockConfig.getDeviceStateClb.returnValue = -1;
|
||||
EXPECT_TRUE(this->wddm->skipResourceCleanup());
|
||||
EXPECT_FALSE(this->wddm->isDriverAvaliable());
|
||||
EXPECT_EQ(0, this->wddm->getGdi()->destroyAllocation2(nullptr));
|
||||
EXPECT_EQ(0, this->wddm->getGdi()->waitForSynchronizationObjectFromCpu(nullptr));
|
||||
EXPECT_EQ(0, this->wddm->getGdi()->destroyPagingQueue(nullptr));
|
||||
EXPECT_EQ(0, this->wddm->getGdi()->destroyDevice(nullptr));
|
||||
EXPECT_EQ(0, this->wddm->getGdi()->closeAdapter(nullptr));
|
||||
EXPECT_EQ(1, gdiMockConfig.getDeviceStateClb.callCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ TEST_F(WddmTests, givenWddmWhenPassesIncorrectHandleToVerifyNTHandleThenReturnFa
|
||||
TEST_F(WddmTests, whenCheckedIfResourcesCleanupCanBeSkippedThenReturnsFalse) {
|
||||
init();
|
||||
EXPECT_FALSE(wddm->skipResourceCleanup());
|
||||
EXPECT_TRUE(wddm->isDriverAvaliable());
|
||||
}
|
||||
|
||||
TEST_F(WddmTests, whenCreatingContextWithPowerHintSuccessIsReturned) {
|
||||
@@ -100,4 +101,98 @@ TEST(WddmPciSpeedInfoTest, WhenGetPciSpeedInfoIsCalledThenUnknownIsReturned) {
|
||||
EXPECT_EQ(-1, speedInfo.maxBandwidth);
|
||||
}
|
||||
|
||||
uint64_t waitForSynchronizationObjectFromCpuCounter = 0u;
|
||||
|
||||
NTSTATUS __stdcall waitForSynchronizationObjectFromCpuNoOp(const D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU *waitStruct) {
|
||||
waitForSynchronizationObjectFromCpuCounter++;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
class WddmSkipResourceCleanupMock : public WddmMock {
|
||||
public:
|
||||
using NEO::DriverModel::skipResourceCleanupVar;
|
||||
};
|
||||
|
||||
struct WddmSkipResourceCleanupFixtureWithMockGdiDll : public GdiDllFixture, public MockExecutionEnvironmentGmmFixture {
|
||||
void SetUp() override {
|
||||
MockExecutionEnvironmentGmmFixture::SetUp();
|
||||
GdiDllFixture::SetUp();
|
||||
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
||||
wddm = static_cast<WddmSkipResourceCleanupMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
|
||||
wddmMockInterface = new WddmMockInterface20(*wddm);
|
||||
wddm->wddmInterface.reset(wddmMockInterface);
|
||||
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
|
||||
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
|
||||
rootDeviceEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
|
||||
osInterface = rootDeviceEnvironment->osInterface.get();
|
||||
}
|
||||
|
||||
void init() {
|
||||
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
|
||||
wddmMockInterface = static_cast<WddmMockInterface20 *>(wddm->wddmInterface.release());
|
||||
wddm->init();
|
||||
wddm->wddmInterface.reset(wddmMockInterface);
|
||||
|
||||
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
|
||||
auto engine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
|
||||
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engine, preemptionMode));
|
||||
osContext->ensureContextInitialized();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
osContext.reset(nullptr);
|
||||
GdiDllFixture::TearDown();
|
||||
MockExecutionEnvironmentGmmFixture::TearDown();
|
||||
}
|
||||
|
||||
WddmSkipResourceCleanupMock *wddm = nullptr;
|
||||
OSInterface *osInterface;
|
||||
std::unique_ptr<OsContextWin> osContext;
|
||||
WddmMockInterface20 *wddmMockInterface = nullptr;
|
||||
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
|
||||
};
|
||||
|
||||
using WddmSkipResourceCleanupFixtureTests = Test<WddmSkipResourceCleanupFixtureWithMockGdiDll>;
|
||||
|
||||
TEST_F(WddmSkipResourceCleanupFixtureTests, givenWaitForSynchronizationObjectFromCpuWhenSkipResourceCleanupIsTrueThenSuccessIsReturnedAndGdiFunctionIsNotCalled) {
|
||||
VariableBackup<uint64_t> varBackup(&waitForSynchronizationObjectFromCpuCounter);
|
||||
init();
|
||||
wddm->skipResourceCleanupVar = true;
|
||||
EXPECT_TRUE(wddm->skipResourceCleanup());
|
||||
wddm->getGdi()->waitForSynchronizationObjectFromCpu = &waitForSynchronizationObjectFromCpuNoOp;
|
||||
MonitoredFence monitoredFence = {};
|
||||
EXPECT_TRUE(wddm->waitFromCpu(0, monitoredFence));
|
||||
EXPECT_EQ(0u, waitForSynchronizationObjectFromCpuCounter);
|
||||
}
|
||||
|
||||
TEST_F(WddmSkipResourceCleanupFixtureTests, givenWaitForSynchronizationObjectFromCpuWhenSkipResourceCleanupIsFalseThenSuccessIsReturnedAndGdiFunctionIsCalled) {
|
||||
VariableBackup<uint64_t> varBackup(&waitForSynchronizationObjectFromCpuCounter);
|
||||
init();
|
||||
wddm->skipResourceCleanupVar = false;
|
||||
EXPECT_FALSE(wddm->skipResourceCleanup());
|
||||
wddm->getGdi()->waitForSynchronizationObjectFromCpu = &waitForSynchronizationObjectFromCpuNoOp;
|
||||
uint64_t fenceValue = 0u;
|
||||
D3DKMT_HANDLE fenceHandle = 1u;
|
||||
MonitoredFence monitoredFence = {};
|
||||
monitoredFence.lastSubmittedFence = 1u;
|
||||
monitoredFence.cpuAddress = &fenceValue;
|
||||
monitoredFence.fenceHandle = fenceHandle;
|
||||
EXPECT_TRUE(wddm->waitFromCpu(1u, monitoredFence));
|
||||
EXPECT_EQ(1u, waitForSynchronizationObjectFromCpuCounter);
|
||||
}
|
||||
|
||||
TEST_F(WddmSkipResourceCleanupFixtureTests, givenWaitForSynchronizationObjectFromCpuWhenSkipResourceCleanupIsFalseAndFenceWasNotUpdatedThenSuccessIsReturnedAndGdiFunctionIsNotCalled) {
|
||||
VariableBackup<uint64_t> varBackup(&waitForSynchronizationObjectFromCpuCounter);
|
||||
init();
|
||||
wddm->skipResourceCleanupVar = false;
|
||||
EXPECT_FALSE(wddm->skipResourceCleanup());
|
||||
wddm->getGdi()->waitForSynchronizationObjectFromCpu = &waitForSynchronizationObjectFromCpuNoOp;
|
||||
uint64_t fenceValue = 1u;
|
||||
MonitoredFence monitoredFence = {};
|
||||
monitoredFence.lastSubmittedFence = 0u;
|
||||
monitoredFence.cpuAddress = &fenceValue;
|
||||
EXPECT_TRUE(wddm->waitFromCpu(1u, monitoredFence));
|
||||
EXPECT_EQ(0u, waitForSynchronizationObjectFromCpuCounter);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user