From 0d23fa1a980ca392af614d6e303cbb3ca77aa249 Mon Sep 17 00:00:00 2001 From: "Vilvaraj, T J Vivek" Date: Mon, 26 Sep 2022 14:35:19 +0000 Subject: [PATCH] Sysman: increase sleep duration in warm reset warm reset needs to have a longer sleep duaration after remove to ensure that the PCIe state is save and restored safely. Signed-off-by: Vilvaraj, T J Vivek --- .../tools/source/sysman/linux/os_sysman_imp.cpp | 13 ++++++++++--- .../linux/test_zes_sysman_diagnostics.cpp | 12 ++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp b/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp index 9dfbaa3184..579e8dfc9d 100644 --- a/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp +++ b/level_zero/tools/source/sysman/linux/os_sysman_imp.cpp @@ -327,8 +327,11 @@ ze_result_t LinuxSysmanImp::osWarmReset() { if (ZE_RESULT_SUCCESS != result) { return result; } - - this->pSleepFunctionSecs(10); // Sleep for 10seconds to make sure that the config spaces of all devices are saved correctly + if (diagnosticsReset) { + this->pSleepFunctionSecs(30); // Sleep for 30seconds to make sure that the config spaces of all devices are saved correctly after IFR + } else { + this->pSleepFunctionSecs(10); // Sleep for 10seconds to make sure that the config spaces of all devices are saved correctly + } rootPortPath = getPciRootPortDirectoryPath(gtDevicePath); int fd, ret = 0; @@ -355,7 +358,11 @@ ze_result_t LinuxSysmanImp::osWarmReset() { if (ZE_RESULT_SUCCESS != result) { return result; } - this->pSleepFunctionSecs(10); // Sleep for 10seconds, allows the rescan to complete on all devices attached to the root port. + if (diagnosticsReset) { + this->pSleepFunctionSecs(30); // Sleep for 30seconds to make sure that the config spaces of all devices are saved correctly after IFR + } else { + this->pSleepFunctionSecs(10); // Sleep for 10seconds, allows the rescan to complete on all devices attached to the root port. + } return result; } diff --git a/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/test_zes_sysman_diagnostics.cpp b/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/test_zes_sysman_diagnostics.cpp index 3b9ba80156..a421820143 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/test_zes_sysman_diagnostics.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/diagnostics/linux/test_zes_sysman_diagnostics.cpp @@ -537,6 +537,18 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetThen EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxSysmanImp->osWarmReset()); } +TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetfromDiagnosticsThenCallSucceeds) { + pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; + pLinuxSysmanImp->openFunction = openMockDiag; + pLinuxSysmanImp->closeFunction = closeMockDiag; + pLinuxSysmanImp->preadFunction = preadMockDiag; + pLinuxSysmanImp->pwriteFunction = pwriteMockDiag; + pLinuxSysmanImp->pSleepFunctionSecs = mockSleepFunctionSecs; + pLinuxSysmanImp->diagnosticsReset = true; + + EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxSysmanImp->osWarmReset()); +} + TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndRootPortConfigFileFailsToOpenThenCallFails) { pLinuxSysmanImp->gtDevicePath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0"; pLinuxSysmanImp->openFunction = openMockDiagFail;