diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index 0d49c9f3b4..292f4c89bb 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -385,8 +385,11 @@ bool CommandStreamReceiver::isGpuHangDetected() const { if (debugManager.flags.DisableGpuHangDetection.get()) { return false; } - - return this->osContext && this->getOSInterface() && this->getOSInterface()->getDriverModel() && this->getOSInterface()->getDriverModel()->isGpuHangDetected(*osContext); + auto isGpuHang = this->osContext && this->getOSInterface() && this->getOSInterface()->getDriverModel() && this->getOSInterface()->getDriverModel()->isGpuHangDetected(*osContext); + if (isGpuHang) { + this->getOSInterface()->getDriverModel()->getDeviceState(); + } + return isGpuHang; } void CommandStreamReceiver::cleanupResources() { diff --git a/shared/source/os_interface/os_interface.h b/shared/source/os_interface/os_interface.h index 1da07eac90..004077b9ec 100644 --- a/shared/source/os_interface/os_interface.h +++ b/shared/source/os_interface/os_interface.h @@ -97,6 +97,9 @@ class DriverModel : public NonCopyableClass { virtual bool isGpuHangDetected(OsContext &osContext) = 0; virtual const HardwareInfo *getHardwareInfo() const = 0; + virtual bool getDeviceState() { + return false; + } const TopologyMap &getTopologyMap() { return topologyMap; diff --git a/shared/source/os_interface/windows/wddm/wddm.h b/shared/source/os_interface/windows/wddm/wddm.h index 9ebeaf238a..7fa7b5ae91 100644 --- a/shared/source/os_interface/windows/wddm/wddm.h +++ b/shared/source/os_interface/windows/wddm/wddm.h @@ -230,7 +230,7 @@ class Wddm : public DriverModel { } bool getDeviceExecutionState(D3DKMT_DEVICESTATE_TYPE stateType, void *privateData); - MOCKABLE_VIRTUAL bool getDeviceState(); + bool getDeviceState() override; bool needsNotifyAubCaptureCallback() const; protected: diff --git a/shared/test/common/mocks/mock_driver_model.h b/shared/test/common/mocks/mock_driver_model.h index cc55b9c734..d3512d4c83 100644 --- a/shared/test/common/mocks/mock_driver_model.h +++ b/shared/test/common/mocks/mock_driver_model.h @@ -42,6 +42,11 @@ class MockDriverModel : public NEO::DriverModel { return isGpuHangDetectedToReturn; } + bool getDeviceState() override { + getDeviceStateCalledCount++; + return false; + } + PhysicalDevicePciSpeedInfo getPciSpeedInfo() const override { return pciSpeedInfo; } const HardwareInfo *getHardwareInfo() const override { return nullptr; } @@ -51,6 +56,7 @@ class MockDriverModel : public NEO::DriverModel { bool isGpuHangDetectedToReturn{}; std::function isGpuHangDetectedSideEffect{}; size_t maxAllocSize = 0; + uint32_t getDeviceStateCalledCount = 0; }; class MockDriverModelWDDM : public MockDriverModel { diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp index e381ddd163..20e7da23c0 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -445,6 +445,20 @@ HWTEST_F(CommandStreamReceiverTest, givenDisableGpuHangDetectionFlagWhenChecking EXPECT_FALSE(csr.isGpuHangDetected()); } +HWTEST_F(CommandStreamReceiverTest, givenCheckingGpuHangWhenGpuHangDetectedThenGetDeviceStateIsCalled) { + auto driverModelMock = std::make_unique(); + driverModelMock->isGpuHangDetectedToReturn = true; + auto driverModel = driverModelMock.get(); + auto osInterface = std::make_unique(); + osInterface->setDriverModel(std::move(driverModelMock)); + + auto &csr = pDevice->getUltCommandStreamReceiver(); + csr.executionEnvironment.rootDeviceEnvironments[csr.rootDeviceIndex]->osInterface = std::move(osInterface); + + EXPECT_TRUE(csr.isGpuHangDetected()); + EXPECT_EQ(1u, driverModel->getDeviceStateCalledCount); +} + HWTEST_F(CommandStreamReceiverTest, givenGpuHangWhenWaititingForCompletionWithTimeoutThenGpuHangIsReturned) { auto driverModelMock = std::make_unique(); driverModelMock->isGpuHangDetectedToReturn = true;