diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 9aa316f11c..de455b605b 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -64,7 +64,7 @@ class ProductHelper { static constexpr uint32_t uuidSize = 16u; static constexpr uint32_t luidSize = 8u; - int configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment); + MOCKABLE_VIRTUAL int configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment); int configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment); virtual int configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) const = 0; virtual void adjustPlatformForProductFamily(HardwareInfo *hwInfo) = 0; diff --git a/shared/source/os_interface/windows/init_wddm_os_interface.cpp b/shared/source/os_interface/windows/init_wddm_os_interface.cpp index 5bbeb3a922..a43ff785e9 100644 --- a/shared/source/os_interface/windows/init_wddm_os_interface.cpp +++ b/shared/source/os_interface/windows/init_wddm_os_interface.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -19,7 +19,6 @@ bool initWddmOsInterface(std::unique_ptr &&hwDeviceId, RootDeviceEnv auto hwDeviceIdWddm = std::unique_ptr(reinterpret_cast(hwDeviceId.release())); NEO::Wddm *wddm = Wddm::createWddm(std::move(hwDeviceIdWddm), *rootDeviceEnv); if (!wddm->init()) { - delete wddm; return false; } rootDeviceEnv->memoryOperationsInterface = std::make_unique(wddm); diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index 5f174ef426..f82a27ea13 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -87,6 +87,7 @@ bool Wddm::init() { rootDeviceEnvironment.osInterface = std::make_unique(); rootDeviceEnvironment.osInterface->setDriverModel(std::unique_ptr(this)); } + if (!queryAdapterInfo()) { return false; } diff --git a/shared/test/common/mocks/mock_product_helper.h b/shared/test/common/mocks/mock_product_helper.h index 630877841a..f9f89146e8 100644 --- a/shared/test/common/mocks/mock_product_helper.h +++ b/shared/test/common/mocks/mock_product_helper.h @@ -16,5 +16,6 @@ struct MockProductHelper : ProductHelperHw { MockProductHelper() = default; ADDMETHOD_CONST_NOBASE(is48bResourceNeededForRayTracing, bool, true, ()); + ADDMETHOD_NOBASE(configureHwInfoWddm, int, 0, (const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment)); }; } // namespace NEO diff --git a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp index ea24fd664e..bc2fe152fd 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp @@ -14,6 +14,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/mocks/mock_gmm_client_context_base.h" #include "shared/test/common/mocks/mock_io_functions.h" +#include "shared/test/common/mocks/mock_product_helper.h" #include "shared/test/common/os_interface/windows/wddm_fixture.h" #include "shared/test/common/test_macros/hw_test.h" @@ -650,4 +651,17 @@ TEST(WddmAllocationTest, whenAllocationIsNotShareableThenItDoesntReturnSharedHan int ret = allocation.peekInternalHandle(nullptr, handle); EXPECT_NE(ret, 0); } + +TEST_F(WddmTests, whenInitializeFailureThenInitOsInterfaceWddmFails) { + + auto hwDeviceId = std::make_unique(0, LUID{0, 0}, 1u, executionEnvironment->osEnvironment.get(), nullptr); + + rootDeviceEnvironment->osInterface.reset(); + auto productHelper = std::make_unique(); + productHelper->configureHwInfoWddmResult = 1; // failure + rootDeviceEnvironment->productHelper = std::move(productHelper); + + EXPECT_FALSE(rootDeviceEnvironment->initOsInterface(std::move(hwDeviceId), 0u)); +} + } // namespace NEO