From 9b94033a4a0c7560ada330bbe73847052f114e32 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 1 Feb 2023 15:02:40 +0800 Subject: [PATCH] change suspend timeout behavior When suspend fails to happen within the designated time, instead of forcing it, return a failure code so we can retry it again later. In testing, this seems to be a very reasonable approach, because sometimes servers are just too busy to do a suspend, and just waiting a couple seconds until eg some file commits are done makes everything work much better. --- services/xous-susres/Cargo.toml | 2 +- services/xous-susres/src/main.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/services/xous-susres/Cargo.toml b/services/xous-susres/Cargo.toml index e7303a42c..df5215e60 100644 --- a/services/xous-susres/Cargo.toml +++ b/services/xous-susres/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xous-susres" -version = "0.1.32" +version = "0.1.33" authors = ["bunnie "] edition = "2018" description = "Manager of suspend/resume operations implementation" diff --git a/services/xous-susres/src/main.rs b/services/xous-susres/src/main.rs index 56b456277..1c03a79b7 100644 --- a/services/xous-susres/src/main.rs +++ b/services/xous-susres/src/main.rs @@ -772,6 +772,8 @@ fn main() -> ! { } } } + // In case of timeout, skip the suspend cycle and return a failure, instead of forcing the suspend. + /* susres_hw.debug_delay(500); // let the messages print // force a suspend susres_hw.do_suspend(true); @@ -780,22 +782,21 @@ fn main() -> ! { // ---- time passes while we are asleep ---- // ---- omg power came back! --- - // when do_suspend() returns, it means we've resumed - let sender = suspend_requested.take().expect("suspend was requested, but no requestor is on record!"); - log_server::resume(); // log server is a special case, in order to avoid circular dependencies if susres_hw.do_resume() { log::error!("We forced a suspend, some peripherals may be in an unclean state!"); } else { log::error!("We forced a suspend, but the bootloader is claiming we did a clean suspend. Internal state may be inconsistent."); } + */ + let sender = suspend_requested.take().expect("suspend was requested, but no requestor is on record!"); for pid in gated_pids.drain(..) { xous::return_scalar(pid, 0).expect("couldn't return dummy message to unblock execution"); } susres_hw.restore_wfi(); // this unblocks the requestor of the suspend - xous::return_scalar(sender, 1).ok(); + xous::return_scalar(sender, 0).ok(); } else { log::trace!("clean suspend timeout received, ignoring"); // this means we did a clean suspend, we've resumed, and the timeout came back after the resume