runtime/kernel: fixes core0 memory leak. #87

Merged
sb10q merged 1 commits from pca006132/artiq-zynq:core1-restart into master 2020-08-06 10:05:45 +08:00
5 changed files with 18 additions and 8 deletions

View File

@ -14,7 +14,7 @@ let
version = "0.1.0";
src = ./src;
cargoSha256 = "0da6smxhlq1z739g8pdhmkfiq7b8vjqapvskz58rzklh9scf2i99";
cargoSha256 = "1lxjb37vl7s359r4801n7b73wnm3p28qlafl04vs9pznadcf6ar0";
nativeBuildInputs = [
pkgs.gnumake

10
src/Cargo.lock generated
View File

@ -201,7 +201,7 @@ dependencies = [
[[package]]
name = "libasync"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#25c6d5eeaa6243724700e975e3935a5965c09a27"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#3958953ceb56aa81e33fb4f3d19ab7ee4c06d1ba"
dependencies = [
"embedded-hal",
"libcortex_a9",
@ -213,7 +213,7 @@ dependencies = [
[[package]]
name = "libboard_zynq"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#25c6d5eeaa6243724700e975e3935a5965c09a27"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#3958953ceb56aa81e33fb4f3d19ab7ee4c06d1ba"
dependencies = [
"bit_field",
"embedded-hal",
@ -237,7 +237,7 @@ dependencies = [
[[package]]
name = "libcortex_a9"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#25c6d5eeaa6243724700e975e3935a5965c09a27"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#3958953ceb56aa81e33fb4f3d19ab7ee4c06d1ba"
dependencies = [
"bit_field",
"libregister",
@ -252,7 +252,7 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
[[package]]
name = "libregister"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#25c6d5eeaa6243724700e975e3935a5965c09a27"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#3958953ceb56aa81e33fb4f3d19ab7ee4c06d1ba"
dependencies = [
"bit_field",
"vcell",
@ -262,7 +262,7 @@ dependencies = [
[[package]]
name = "libsupport_zynq"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#25c6d5eeaa6243724700e975e3935a5965c09a27"
source = "git+https://git.m-labs.hk/M-Labs/zc706.git#3958953ceb56aa81e33fb4f3d19ab7ee4c06d1ba"
dependencies = [
"compiler_builtins",
"libboard_zynq",

View File

@ -1,7 +1,7 @@
use libcortex_a9::sync_channel::{Sender, Receiver};
use libsupport_zynq::boot::Core1;
use super::{CHANNEL_0TO1, CHANNEL_1TO0, Message};
use super::{CHANNEL_0TO1, CHANNEL_1TO0, INIT_LOCK, Message};
use crate::irq::restart_core1;
use core::mem::{forget, replace};
@ -39,7 +39,13 @@ impl Control {
}
pub fn restart(&mut self) {
restart_core1();
{
INIT_LOCK.lock();
restart_core1();
unsafe {
self.tx.drop_elements();
}
}
let (core0_tx, core0_rx) = get_channels();
// dangling pointer here, so we forget it
forget(replace(&mut self.tx, core0_tx));

View File

@ -18,6 +18,7 @@ use crate::eh_artiq;
use super::{
api::resolve,
rpc::rpc_send_async,
INIT_LOCK,
CHANNEL_0TO1, CHANNEL_1TO0,
KERNEL_CHANNEL_0TO1, KERNEL_CHANNEL_1TO0,
KERNEL_IMAGE,
@ -147,6 +148,7 @@ pub fn main_core1() {
let (mut core0_tx, mut core1_rx) = sync_channel!(Message, 4);
let (mut core1_tx, core0_rx) = sync_channel!(Message, 4);
unsafe {
INIT_LOCK.lock();
core0_tx.reset();
core1_tx.reset();
dma::init_dma_recorder();

View File

@ -54,3 +54,5 @@ static KERNEL_CHANNEL_1TO0: Mutex<Option<sync_channel::Sender<'static, Message>>
static mut KERNEL_IMAGE: *const core1::KernelImage = ptr::null();
static INIT_LOCK: Mutex<()> = Mutex::new(());