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
Showing only changes of commit e7752a3d6d - Show all commits

View File

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

10
src/Cargo.lock generated
View File

@ -201,7 +201,7 @@ dependencies = [
[[package]] [[package]]
name = "libasync" name = "libasync"
version = "0.0.0" 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 = [ dependencies = [
"embedded-hal", "embedded-hal",
"libcortex_a9", "libcortex_a9",
@ -213,7 +213,7 @@ dependencies = [
[[package]] [[package]]
name = "libboard_zynq" name = "libboard_zynq"
version = "0.0.0" 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 = [ dependencies = [
"bit_field", "bit_field",
"embedded-hal", "embedded-hal",
@ -237,7 +237,7 @@ dependencies = [
[[package]] [[package]]
name = "libcortex_a9" name = "libcortex_a9"
version = "0.0.0" 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 = [ dependencies = [
"bit_field", "bit_field",
"libregister", "libregister",
@ -252,7 +252,7 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
[[package]] [[package]]
name = "libregister" name = "libregister"
version = "0.0.0" 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 = [ dependencies = [
"bit_field", "bit_field",
"vcell", "vcell",
@ -262,7 +262,7 @@ dependencies = [
[[package]] [[package]]
name = "libsupport_zynq" name = "libsupport_zynq"
version = "0.0.0" 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 = [ dependencies = [
"compiler_builtins", "compiler_builtins",
"libboard_zynq", "libboard_zynq",

View File

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

View File

@ -18,6 +18,7 @@ use crate::eh_artiq;
use super::{ use super::{
api::resolve, api::resolve,
rpc::rpc_send_async, rpc::rpc_send_async,
INIT_LOCK,
CHANNEL_0TO1, CHANNEL_1TO0, CHANNEL_0TO1, CHANNEL_1TO0,
KERNEL_CHANNEL_0TO1, KERNEL_CHANNEL_1TO0, KERNEL_CHANNEL_0TO1, KERNEL_CHANNEL_1TO0,
KERNEL_IMAGE, KERNEL_IMAGE,
@ -147,6 +148,7 @@ pub fn main_core1() {
let (mut core0_tx, mut core1_rx) = sync_channel!(Message, 4); let (mut core0_tx, mut core1_rx) = sync_channel!(Message, 4);
let (mut core1_tx, core0_rx) = sync_channel!(Message, 4); let (mut core1_tx, core0_rx) = sync_channel!(Message, 4);
unsafe { unsafe {
INIT_LOCK.lock();
core0_tx.reset(); core0_tx.reset();
core1_tx.reset(); core1_tx.reset();
dma::init_dma_recorder(); 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 mut KERNEL_IMAGE: *const core1::KernelImage = ptr::null();
static INIT_LOCK: Mutex<()> = Mutex::new(());