From 9150230ea79d223b9e82d3f7aa74cb2fdc65d9a1 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 27 Mar 2023 17:06:20 +0800 Subject: [PATCH] dma: gate ddma features behind cfg(has_drtio) --- artiq/firmware/ksupport/lib.rs | 41 +++++++++++++++++------------- artiq/firmware/runtime/rtio_dma.rs | 13 +++++----- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/artiq/firmware/ksupport/lib.rs b/artiq/firmware/ksupport/lib.rs index 1af9f7b46..6693b7196 100644 --- a/artiq/firmware/ksupport/lib.rs +++ b/artiq/firmware/ksupport/lib.rs @@ -405,6 +405,7 @@ extern fn dma_playback(timestamp: i64, ptr: i32) { csr::cri_con::selected_write(1); csr::rtio_dma::enable_write(1); + #[cfg(has_drtio)] send(&DmaStartRemoteRequest { id: ptr as i32, timestamp: timestamp }); while csr::rtio_dma::enable_read() != 0 {} csr::cri_con::selected_write(0); @@ -427,23 +428,29 @@ extern fn dma_playback(timestamp: i64, ptr: i32) { } } - send(&DmaAwaitRemoteRequest { id: ptr as i32 }); - recv!(&DmaAwaitRemoteReply { timeout, error, channel, timestamp } => { - if timeout { - raise!("DMAError", - "Error running DMA on satellite device, timed out waiting for results"); - } - if error & 1 != 0 { - raise!("RTIOUnderflow", - "RTIO underflow at channel {rtio_channel_info:0}, {1} mu", - channel as i64, timestamp as i64, 0); - } - if error & 2 != 0 { - raise!("RTIODestinationUnreachable", - "RTIO destination unreachable, output, at channel {rtio_channel_info:0}, {1} mu", - channel as i64, timestamp as i64, 0); - } - }); + #[cfg(has_drtio)] + { + send(&DmaAwaitRemoteRequest { id: ptr as i32 }); + recv!(&DmaAwaitRemoteReply { timeout, error, channel, timestamp } => { + if timeout { + println!("timeout\n"); + raise!("DMAError", + "Error running DMA on satellite device, timed out waiting for results"); + } + if error & 1 != 0 { + println!("rtio underflow from ddma\n"); + raise!("RTIOUnderflow", + "RTIO underflow at channel {rtio_channel_info:0}, {1} mu", + channel as i64, timestamp as i64, 0); + } + if error & 2 != 0 { + println!("rtio destun from ddma\n"); + raise!("RTIODestinationUnreachable", + "RTIO destination unreachable, output, at channel {rtio_channel_info:0}, {1} mu", + channel as i64, timestamp as i64, 0); + } + }); + } } #[cfg(not(has_rtio_dma))] diff --git a/artiq/firmware/runtime/rtio_dma.rs b/artiq/firmware/runtime/rtio_dma.rs index 1ec15384e..d388d9bfc 100644 --- a/artiq/firmware/runtime/rtio_dma.rs +++ b/artiq/firmware/runtime/rtio_dma.rs @@ -218,12 +218,13 @@ impl Manager { self.recording_trace.extend_from_slice(data) } - pub fn record_stop(&mut self, duration: u64, enable_ddma: bool, + pub fn record_stop(&mut self, duration: u64, _enable_ddma: bool, _io: &Io, _ddma_mutex: &Mutex) -> u32 { let mut local_trace = Vec::new(); - let mut remote_traces: BTreeMap> = BTreeMap::new(); + let mut _remote_traces: BTreeMap> = BTreeMap::new(); - if enable_ddma { + #[cfg(has_drtio)] + if _enable_ddma { let mut trace = Vec::new(); mem::swap(&mut self.recording_trace, &mut trace); trace.push(0); @@ -239,10 +240,10 @@ impl Manager { local_trace.extend(&trace[ptr..ptr+len]); } else { - if let Some(remote_trace) = remote_traces.get_mut(&destination) { + if let Some(remote_trace) = _remote_traces.get_mut(&destination) { remote_trace.extend(&trace[ptr..ptr+len]); } else { - remote_traces.insert(destination, trace[ptr..ptr+len].to_vec()); + _remote_traces.insert(destination, trace[ptr..ptr+len].to_vec()); } } // and jump to the next event @@ -278,7 +279,7 @@ impl Manager { self.name_map.insert(name, id); #[cfg(has_drtio)] - remote_dma::add_traces(_io, _ddma_mutex, id, remote_traces); + remote_dma::add_traces(_io, _ddma_mutex, id, _remote_traces); id }