From 6cf3db3485f8241c2cefa7744c9944b59b407573 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 12 Sep 2018 23:02:54 +0800 Subject: [PATCH] satman: forward RTIO resets --- artiq/firmware/satman/main.rs | 6 ++++++ artiq/firmware/satman/repeater.rs | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index 56345ae7a..e8c0b60f4 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -55,6 +55,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater], drtioaux::Packet::EchoRequest => drtioaux::send_link(0, &drtioaux::Packet::EchoReply), drtioaux::Packet::ResetRequest { phy } => { + info!("resetting RTIO"); if phy { drtiosat_reset_phy(true); drtiosat_reset_phy(false); @@ -62,6 +63,11 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater], drtiosat_reset(true); drtiosat_reset(false); } + for rep in _repeaters.iter() { + if let Err(e) = rep.rtio_reset(phy) { + error!("failed to issue RTIO reset ({})", e); + } + } drtioaux::send_link(0, &drtioaux::Packet::ResetAck) }, diff --git a/artiq/firmware/satman/repeater.rs b/artiq/firmware/satman/repeater.rs index 9b1f39849..bd2fe8999 100644 --- a/artiq/firmware/satman/repeater.rs +++ b/artiq/firmware/satman/repeater.rs @@ -227,6 +227,20 @@ impl Repeater { } Ok(()) } + + pub fn rtio_reset(&self, phy: bool) -> Result<(), &'static str> { + if self.state != RepeaterState::Up { + return Ok(()); + } + drtioaux::send_link(self.auxno, &drtioaux::Packet::ResetRequest { + phy: phy + }).unwrap(); + let reply = self.recv_aux_timeout(200)?; + if reply != drtioaux::Packet::ResetAck { + return Err("unexpected reply"); + } + Ok(()) + } } #[cfg(not(has_drtio_routing))]