From 058e3480dfa081160c3bb777079ff601b4a4632a Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 23 May 2022 13:47:57 +0800 Subject: [PATCH] add facility to help debug stalled suspend/resume --- services/susres/src/lib.rs | 7 ++++++- services/susres/src/main.rs | 14 +++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/services/susres/src/lib.rs b/services/susres/src/lib.rs index 2c9423bee..f525a8935 100644 --- a/services/susres/src/lib.rs +++ b/services/susres/src/lib.rs @@ -154,12 +154,17 @@ impl Drop for Susres { fn suspend_cb_server(sid0: usize, sid1: usize, sid2: usize, sid3: usize) { let sid = xous::SID::from_u32(sid0 as u32, sid1 as u32, sid2 as u32, sid3 as u32); + let mut print_once = false; loop { let msg = xous::receive_message(sid).unwrap(); match FromPrimitive::from_usize(msg.body.id()) { Some(SuspendEventCallback::Event) => msg_scalar_unpack!(msg, cid, id, token, _, { // directly pass the scalar message onto the CID with the ID memorized in the original hook - log::debug!("PID {} has s/r token {}", xous::current_pid().unwrap().get(), token); // <-- use this to debug s/r + if !print_once { + // dump this only once so we have a PID->token map in the debug logs, but don't dump it every time as it slows down the suspend + log::info!("PID {} has s/r token {}", xous::current_pid().unwrap().get(), token); // <-- use this to debug s/r + print_once = true; + } send_message(cid as u32, Message::new_scalar(id, token, 0, 0, 0) ).unwrap(); diff --git a/services/susres/src/main.rs b/services/susres/src/main.rs index 10a0074e7..e8922f06c 100644 --- a/services/susres/src/main.rs +++ b/services/susres/src/main.rs @@ -738,7 +738,19 @@ fn xmain() -> ! { } timeout_pending = false; log::warn!("Suspend timed out, forcing an unclean suspend"); - // susres_hw.debug_delay(500); // let the messages print + for sub in suspend_subscribers.iter() { + if sub.order == current_op_order { + if !sub.ready_to_suspend { + // note to debugger: you will get a token number, which is in itself not useful. + // There should be, at least once in the debug log, printed on the very first suspend cycle, + // a list of PID->tokens. Tokens are assigned in the order that the registration happens + // to the susres server. Empirically, this list is generally stable for every build, + // and is guaranteed to be stable across a single cold boot. + log::warn!(" -> NOT READY: {}", sub.token); + } + } + } + susres_hw.debug_delay(500); // let the messages print // force a suspend susres_hw.do_suspend(true);