Support channel names in RTIO errors #209

Merged
sb10q merged 3 commits from esavkin/artiq-zynq:1697-rtiomap into master 2023-01-09 12:35:56 +08:00
3 changed files with 19 additions and 11 deletions
Showing only changes of commit 439653b02a - Show all commits

View File

@ -1,4 +1,4 @@
use core::fmt; use core::{fmt, slice, str};
use core::cell::RefCell; use core::cell::RefCell;
use alloc::{vec, vec::Vec, string::String, collections::BTreeMap, rc::Rc}; use alloc::{vec, vec::Vec, string::String, collections::BTreeMap, rc::Rc};
use log::{info, warn, error}; use log::{info, warn, error};
@ -31,7 +31,7 @@ use crate::rpc;
use crate::moninj; use crate::moninj;
use crate::mgmt; use crate::mgmt;
use crate::analyzer; use crate::analyzer;
use crate::rtio_mgt; use crate::rtio_mgt::{self, resolve_channel_name};
#[cfg(has_drtio)] #[cfg(has_drtio)]
use crate::pl; use crate::pl;
@ -246,7 +246,16 @@ async fn handle_run_kernel(stream: Option<&TcpStream>, control: &Rc<RefCell<kern
for exception in exceptions.iter() { for exception in exceptions.iter() {
let exception = exception.as_ref().unwrap(); let exception = exception.as_ref().unwrap();
write_i32(stream, exception.id as i32).await?; write_i32(stream, exception.id as i32).await?;
write_exception_string(stream, exception.message).await?;
if exception.message.len() == usize::MAX { // exception with host string
write_exception_string(stream, exception.message).await?;
} else {
let msg = str::from_utf8(unsafe { slice::from_raw_parts(exception.message.as_ptr(), exception.message.len()) })
.unwrap()
.replace("{rtio_channel_info:0}", &format!("{}:{}", exception.param[0], resolve_channel_name(exception.param[0] as u32)));
write_exception_string(stream, unsafe { CSlice::new(msg.as_ptr(), msg.len()) }).await?;
}
write_i64(stream, exception.param[0] as i64).await?; write_i64(stream, exception.param[0] as i64).await?;
write_i64(stream, exception.param[1] as i64).await?; write_i64(stream, exception.param[1] as i64).await?;
write_i64(stream, exception.param[2] as i64).await?; write_i64(stream, exception.param[2] as i64).await?;

View File

@ -2,7 +2,6 @@ use crate::{
pl::csr, pl::csr,
artiq_raise, artiq_raise,
rtio, rtio,
rtio_mgt::resolve_channel_name,
}; };
use alloc::{vec::Vec, string::String, boxed::Box}; use alloc::{vec::Vec, string::String, boxed::Box};
use cslice::CSlice; use cslice::CSlice;
@ -199,13 +198,13 @@ pub extern fn dma_playback(timestamp: i64, ptr: i32) {
csr::rtio_dma::error_write(1); csr::rtio_dma::error_write(1);
if error & 1 != 0 { if error & 1 != 0 {
artiq_raise!("RTIOUnderflow", artiq_raise!("RTIOUnderflow",
format!("RTIO underflow at {{0}} mu, channel {}:{}", channel, resolve_channel_name(channel as u32)), "RTIO underflow at {1} mu, channel {rtio_channel_info:0}",
timestamp as i64, channel as i64, 0); channel as i64, timestamp as i64, 0);
} }
if error & 2 != 0 { if error & 2 != 0 {
artiq_raise!("RTIODestinationUnreachable", artiq_raise!("RTIODestinationUnreachable",
format!("RTIO destination unreachable, output, at {{0}} mu, channel {}:{}", channel, resolve_channel_name(channel as u32)), "RTIO destination unreachable, output, at {1} mu, channel {rtio_channel_info:0}",
timestamp as i64, channel as i64, 0); channel as i64, timestamp as i64, 0);
} }
} }
} }

View File

@ -226,15 +226,15 @@ pub mod drtio {
destination_set_up(routing_table, up_destinations, destination, false).await, destination_set_up(routing_table, up_destinations, destination, false).await,
Ok(Packet::DestinationOkReply) => (), Ok(Packet::DestinationOkReply) => (),
Ok(Packet::DestinationSequenceErrorReply { channel }) =>{ Ok(Packet::DestinationSequenceErrorReply { channel }) =>{
error!("[DEST#{}] RTIO sequence error involving channel 0x{:04x}", destination, channel); error!("[DEST#{}] RTIO sequence error involving channel {} 0x{:04x}", destination, resolve_channel_name(channel), channel);
unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_SEQUENCE_ERROR }; unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_SEQUENCE_ERROR };
} }
Ok(Packet::DestinationCollisionReply { channel }) =>{ Ok(Packet::DestinationCollisionReply { channel }) =>{
error!("[DEST#{}] RTIO collision involving channel 0x{:04x}", destination, channel); error!("[DEST#{}] RTIO collision involving channel {} 0x{:04x}", destination, resolve_channel_name(channel), channel);
unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_COLLISION }; unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_COLLISION };
} }
Ok(Packet::DestinationBusyReply { channel }) =>{ Ok(Packet::DestinationBusyReply { channel }) =>{
error!("[DEST#{}] RTIO busy error involving channel 0x{:04x}", destination, channel); error!("[DEST#{}] RTIO busy error involving channel {} 0x{:04x}", destination, resolve_channel_name(channel), channel);
unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_BUSY }; unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_BUSY };
} }
Ok(packet) => error!("[DEST#{}] received unexpected aux packet: {:?}", destination, packet), Ok(packet) => error!("[DEST#{}] received unexpected aux packet: {:?}", destination, packet),