From 905d28d1e4dd15fb9c97ac61523e1e251a1bcc5c Mon Sep 17 00:00:00 2001 From: Niklas Eiling Date: Thu, 1 Dec 2022 15:06:05 +0100 Subject: [PATCH] ips/dma: use destructor to reset DMA controller Signed-off-by: Niklas Eiling --- fpga/include/villas/fpga/ips/dma.hpp | 1 + fpga/lib/ips/dma.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fpga/include/villas/fpga/ips/dma.hpp b/fpga/include/villas/fpga/ips/dma.hpp index 52acf4cbd..83f25166f 100644 --- a/fpga/include/villas/fpga/ips/dma.hpp +++ b/fpga/include/villas/fpga/ips/dma.hpp @@ -39,6 +39,7 @@ class Dma : public Node public: friend class DmaFactory; + ~Dma(); bool init(); bool reset(); diff --git a/fpga/lib/ips/dma.cpp b/fpga/lib/ips/dma.cpp index 70e793189..62fe6c994 100644 --- a/fpga/lib/ips/dma.cpp +++ b/fpga/lib/ips/dma.cpp @@ -178,6 +178,8 @@ void Dma::setupScatterGatherRingTx() bool Dma::reset() { + XAxiDma_IntrDisable(&xDma, XAXIDMA_IRQ_ALL_MASK, XAXIDMA_DMA_TO_DEVICE); + XAxiDma_IntrDisable(&xDma, XAXIDMA_IRQ_ALL_MASK, XAXIDMA_DEVICE_TO_DMA); XAxiDma_Reset(&xDma); // Value taken from libxil implementation @@ -189,12 +191,20 @@ bool Dma::reset() timeout--; } - - logger->info("DMA has been resetted"); + if (timeout == 0) { + logger->error("DMA reset timed out"); + } else { + logger->info("DMA has been reset."); + } return false; } +Dma::~Dma() +{ + reset(); +} + bool Dma::memcpy(const MemoryBlock &src, const MemoryBlock &dst, size_t len) { if (len == 0)