From dbc3f581e5fb96e0472a58d23247d267c18a03fd Mon Sep 17 00:00:00 2001 From: Steve Fan Date: Mon, 6 Dec 2021 14:51:46 +0800 Subject: [PATCH 1/3] rtio_mgt: capture occurrences of async errors to a global variable --- src/runtime/src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/runtime/src/main.rs b/src/runtime/src/main.rs index da93f3f..1a30357 100644 --- a/src/runtime/src/main.rs +++ b/src/runtime/src/main.rs @@ -42,6 +42,13 @@ mod analyzer; mod irq; mod i2c; +static mut SEEN_ASYNC_ERRORS: u8 = 0; + +pub unsafe fn get_async_errors() -> u8 { + let errors = SEEN_ASYNC_ERRORS; + SEEN_ASYNC_ERRORS = 0; + errors +} fn wait_for_async_rtio_error() -> nb::Result<(), Void> { unsafe { @@ -70,6 +77,7 @@ async fn report_async_rtio_errors() { error!("RTIO sequence error involving channel {}", pl::csr::rtio_core::sequence_error_channel_read()); } + SEEN_ASYNC_ERRORS = errors; pl::csr::rtio_core::async_error_write(errors); } } -- 2.42.0 From 851ed095df714730d9f59845924929d9f002275e Mon Sep 17 00:00:00 2001 From: Steve Fan Date: Mon, 6 Dec 2021 15:00:59 +0800 Subject: [PATCH 2/3] session: send host any async errors detection if found --- src/runtime/src/comms.rs | 6 ++++-- src/runtime/src/kernel/core1.rs | 8 +++++--- src/runtime/src/kernel/mod.rs | 6 ++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/runtime/src/comms.rs b/src/runtime/src/comms.rs index f90b6de..00a2b6f 100644 --- a/src/runtime/src/comms.rs +++ b/src/runtime/src/comms.rs @@ -224,13 +224,14 @@ async fn handle_run_kernel(stream: Option<&TcpStream>, control: &Rc { + kernel::Message::KernelFinished { async_errors } => { if let Some(stream) = stream { write_header(stream, Reply::KernelFinished).await?; + write_i8(stream, async_errors as i8).await?; } break; }, - kernel::Message::KernelException(exception, backtrace) => { + kernel::Message::KernelException(exception, backtrace, async_errors) => { match stream { Some(stream) => { // only send the exception data to host if there is host, @@ -249,6 +250,7 @@ async fn handle_run_kernel(stream: Option<&TcpStream>, control: &Rc { error!("Uncaught kernel exception: {:?}", exception); diff --git a/src/runtime/src/kernel/core1.rs b/src/runtime/src/kernel/core1.rs index 91a8dd9..ab6a428 100644 --- a/src/runtime/src/kernel/core1.rs +++ b/src/runtime/src/kernel/core1.rs @@ -14,7 +14,7 @@ use libcortex_a9::{ use libboard_zynq::{mpcore, gic}; use libsupport_zynq::ram; use dyld::{self, Library}; -use crate::{eh_artiq, rtio}; +use crate::{eh_artiq, get_async_errors, rtio}; use super::{ api::resolve, rpc::rpc_send_async, @@ -192,7 +192,8 @@ pub extern "C" fn main_core1() { } } info!("kernel finished"); - core1_tx.send(Message::KernelFinished); + let async_errors = unsafe { get_async_errors() }; + core1_tx.send(Message::KernelFinished { async_errors }); } _ => error!("Core1 received unexpected message: {:?}", message), } @@ -216,7 +217,8 @@ pub fn terminate(exception: &'static eh_artiq::Exception<'static>, backtrace: &' { let core1_tx = unsafe { KERNEL_CHANNEL_1TO0.as_mut().unwrap() }; - core1_tx.send(Message::KernelException(exception, &backtrace[..cursor])); + let errors = unsafe { get_async_errors() }; + core1_tx.send(Message::KernelException(exception, &backtrace[..cursor], errors)); } loop {} } diff --git a/src/runtime/src/kernel/mod.rs b/src/runtime/src/kernel/mod.rs index c3bb1fb..3ca8bf6 100644 --- a/src/runtime/src/kernel/mod.rs +++ b/src/runtime/src/kernel/mod.rs @@ -30,8 +30,10 @@ pub enum Message { LoadCompleted, LoadFailed, StartRequest, - KernelFinished, - KernelException(&'static eh_artiq::Exception<'static>, &'static [usize]), + KernelFinished { + async_errors: u8 + }, + KernelException(&'static eh_artiq::Exception<'static>, &'static [usize], u8), RpcSend { is_async: bool, data: Vec }, RpcRecvRequest(*mut ()), RpcRecvReply(Result), -- 2.42.0 From 24747f09cd3de1f226f52d6d56f1c6ecca1cacba Mon Sep 17 00:00:00 2001 From: Steve Fan Date: Mon, 6 Dec 2021 15:23:34 +0800 Subject: [PATCH 3/3] fixup! session: send host any async errors detection if found --- src/runtime/src/comms.rs | 2 +- src/runtime/src/kernel/core1.rs | 2 +- src/runtime/src/kernel/mod.rs | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/runtime/src/comms.rs b/src/runtime/src/comms.rs index 00a2b6f..55cfc18 100644 --- a/src/runtime/src/comms.rs +++ b/src/runtime/src/comms.rs @@ -224,7 +224,7 @@ async fn handle_run_kernel(stream: Option<&TcpStream>, control: &Rc { + kernel::Message::KernelFinished(async_errors) => { if let Some(stream) = stream { write_header(stream, Reply::KernelFinished).await?; write_i8(stream, async_errors as i8).await?; diff --git a/src/runtime/src/kernel/core1.rs b/src/runtime/src/kernel/core1.rs index ab6a428..9084260 100644 --- a/src/runtime/src/kernel/core1.rs +++ b/src/runtime/src/kernel/core1.rs @@ -193,7 +193,7 @@ pub extern "C" fn main_core1() { } info!("kernel finished"); let async_errors = unsafe { get_async_errors() }; - core1_tx.send(Message::KernelFinished { async_errors }); + core1_tx.send(Message::KernelFinished(async_errors)); } _ => error!("Core1 received unexpected message: {:?}", message), } diff --git a/src/runtime/src/kernel/mod.rs b/src/runtime/src/kernel/mod.rs index 3ca8bf6..58bebf2 100644 --- a/src/runtime/src/kernel/mod.rs +++ b/src/runtime/src/kernel/mod.rs @@ -30,9 +30,7 @@ pub enum Message { LoadCompleted, LoadFailed, StartRequest, - KernelFinished { - async_errors: u8 - }, + KernelFinished(u8), KernelException(&'static eh_artiq::Exception<'static>, &'static [usize], u8), RpcSend { is_async: bool, data: Vec }, RpcRecvRequest(*mut ()), -- 2.42.0