From 280aa6da910eddab4f4b0410d611ec53c61cd3ee Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi Date: Sun, 12 Jun 2022 12:34:29 +0300 Subject: [PATCH] rsx: Fix NV406E semaphore_acquire timeout detection (#12205) --- rpcs3/Emu/RSX/rsx_methods.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 3f3a44c714..84d8818248 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -121,6 +121,8 @@ namespace rsx } u64 start = rsx::uclock(); + u64 last_check_val = start; + while (sema != arg) { if (rsx->test_stopped()) @@ -130,26 +132,23 @@ namespace rsx if (const auto tdr = static_cast(g_cfg.video.driver_recovery_timeout)) { - if (rsx->is_paused()) + const u64 current = rsx::uclock(); + + if (current - last_check_val > 20'000) { - const u64 start0 = rsx::uclock(); - - while (rsx->is_paused()) - { - rsx->check_state(); - } - - // Reset - start += rsx::uclock() - start0; + // Suspicious amnount of time has passed + // External pause such as debuggers' pause or operating system sleep may have taken place + // Ignore it + start += current - last_check_val; } - else + + last_check_val = current; + + if ((current - start) > tdr) { - if ((rsx::uclock() - start) > tdr) - { - // If longer than driver timeout force exit - rsx_log.error("nv406e::semaphore_acquire has timed out. semaphore_address=0x%X", addr); - break; - } + // If longer than driver timeout force exit + rsx_log.error("nv406e::semaphore_acquire has timed out. semaphore_address=0x%X", addr); + break; } }