Don't unregister trim callback during process shutdown.

Resolves: NEO-4668

Signed-off-by: Piotr Zdunowski <piotr.zdunowski@intel.com>
This commit is contained in:
Piotr Zdunowski
2021-02-16 14:30:07 +00:00
committed by Compute-Runtime-Automation
parent d80afd6d0c
commit a555f28bf8
4 changed files with 29 additions and 2 deletions

View File

@@ -959,10 +959,20 @@ VOID *Wddm::registerTrimCallback(PFND3DKMT_TRIMNOTIFICATIONCALLBACK callback, Wd
}
return nullptr;
}
bool Wddm::isShutdownInProgress() {
auto handle = GetModuleHandleA("ntdll.dll");
if (!handle) {
return true;
}
auto RtlDllShutdownInProgress = reinterpret_cast<BOOLEAN(WINAPI *)()>(GetProcAddress(handle, "RtlDllShutdownInProgress"));
return RtlDllShutdownInProgress();
}
void Wddm::unregisterTrimCallback(PFND3DKMT_TRIMNOTIFICATIONCALLBACK callback, VOID *trimCallbackHandle) {
DEBUG_BREAK_IF(callback == nullptr);
if (trimCallbackHandle == nullptr) {
if (trimCallbackHandle == nullptr || isShutdownInProgress()) {
return;
}
D3DKMT_UNREGISTERTRIMNOTIFICATION unregisterTrimNotification;