From ca51cf7729040a9c8c18546f8a521235709d9b58 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 27 Mar 2023 14:55:12 +0800 Subject: [PATCH] erase remote ID if name is overwritten --- src/runtime/src/comms.rs | 2 +- src/runtime/src/rtio_dma.rs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/runtime/src/comms.rs b/src/runtime/src/comms.rs index 814c693..bafe253 100644 --- a/src/runtime/src/comms.rs +++ b/src/runtime/src/comms.rs @@ -323,7 +323,7 @@ async fn handle_run_kernel( .await; } kernel::Message::DmaPutRequest(recorder) => { - let _id = rtio_dma::put_record(recorder); + let _id = rtio_dma::put_record(aux_mutex, routing_table, timer, recorder).await; #[cfg(has_drtio)] rtio_dma::remote_dma::upload_traces(aux_mutex, routing_table, timer, _id).await; } diff --git a/src/runtime/src/rtio_dma.rs b/src/runtime/src/rtio_dma.rs index 01f3c2d..164acc8 100644 --- a/src/runtime/src/rtio_dma.rs +++ b/src/runtime/src/rtio_dma.rs @@ -293,7 +293,11 @@ pub mod remote_dma { } -pub fn put_record(mut recorder: DmaRecorder) -> u32 { +pub async fn put_record(_aux_mutex: &Rc>, + _routing_table: &RoutingTable, + _timer: GlobalTimer, + mut recorder: DmaRecorder, +) -> u32 { #[cfg(has_drtio)] let mut remote_traces: BTreeMap> = BTreeMap::new(); @@ -338,12 +342,17 @@ pub fn put_record(mut recorder: DmaRecorder) -> u32 { let ptr = recorder.buffer[padding..].as_ptr() as u32; - DMA_RECORD_STORE + let _old_record = DMA_RECORD_STORE .lock() .insert(recorder.name, (ptr, recorder.buffer, recorder.duration)); #[cfg(has_drtio)] - remote_dma::add_traces(ptr, remote_traces); + { + if let Some((old_id, _v, _d)) = _old_record { + remote_dma::erase(_aux_mutex, _routing_table, _timer, old_id).await; + } + remote_dma::add_traces(ptr, remote_traces); + } ptr }