From 030f94975ca1654ee8590a55f6946e70376f6fda Mon Sep 17 00:00:00 2001 From: Patrick Huesmann Date: Thu, 30 May 2024 14:32:00 +0200 Subject: [PATCH] feat: print desc if error IRQ raised --- inc/udmaio/UioAxiDmaIf.hpp | 5 +++-- src/DataHandlerAbstract.cpp | 23 +++++++++++++---------- src/UioAxiDmaIf.cpp | 7 ++----- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/inc/udmaio/UioAxiDmaIf.hpp b/inc/udmaio/UioAxiDmaIf.hpp index 5ee2d217..1a232765 100644 --- a/inc/udmaio/UioAxiDmaIf.hpp +++ b/inc/udmaio/UioAxiDmaIf.hpp @@ -11,10 +11,11 @@ #pragma once +#include + #include "RegAccessor.hpp" #include "UioIf.hpp" #include "udmaio/rdl/AxiDma.hpp" - namespace udmaio { using AxiDmaBlock = axi_dma::block; @@ -31,7 +32,7 @@ class UioAxiDmaIf : public UioIf, AxiDmaBlock { using UioIf::arm_interrupt; /// Wait for interrupt and acknowledge it - uint32_t clear_interrupt(); + std::tuple clear_interrupt(); /// @brief Check status register and log any errors /// @return true if any error occurred diff --git a/src/DataHandlerAbstract.cpp b/src/DataHandlerAbstract.cpp index 575c3469..78eda398 100644 --- a/src/DataHandlerAbstract.cpp +++ b/src/DataHandlerAbstract.cpp @@ -59,18 +59,21 @@ void DataHandlerAbstract::_handle_input(const boost::system::error_code& ec) { return; } - // Check for error flags and log them - _dma.check_for_errors(); - - uint32_t irq_count = _dma.clear_interrupt(); + auto [irq_count, dma_stat] = _dma.clear_interrupt(); BOOST_LOG_SEV(_lg, bls::trace) << "irq count = " << irq_count; + if (dma_stat.err_irq && _dma.check_for_errors()) { + _desc.print_descs(); + throw std::runtime_error("DMA engine error raised"); + } - auto full_bufs = _receive_packets ? _desc.get_next_packet() : _desc.get_full_buffers(); - if (full_bufs.empty()) { - BOOST_LOG_SEV(_lg, bls::trace) << "spurious event, got no data"; - } else { - auto bytes = _desc.read_buffers(full_bufs); - process_data(std::move(bytes)); + if (dma_stat.ioc_irq) { + auto full_bufs = _receive_packets ? _desc.get_next_packet() : _desc.get_full_buffers(); + if (full_bufs.empty()) { + BOOST_LOG_SEV(_lg, bls::trace) << "spurious event, got no data"; + } else { + auto bytes = _desc.read_buffers(full_bufs); + process_data(std::move(bytes)); + } } _start_read(); diff --git a/src/UioAxiDmaIf.cpp b/src/UioAxiDmaIf.cpp index cab107a2..9042588c 100644 --- a/src/UioAxiDmaIf.cpp +++ b/src/UioAxiDmaIf.cpp @@ -51,7 +51,7 @@ void UioAxiDmaIf::start(uintptr_t start_desc) { << "DMA ctrl = 0x" << std::hex << reg_to_raw(s2mm_dmacr.rd()) << std::dec; } -uint32_t UioAxiDmaIf::clear_interrupt() { +std::tuple UioAxiDmaIf::clear_interrupt() { uint32_t irq_count = wait_for_interrupt(); auto stat = s2mm_dmasr.rd(); @@ -60,13 +60,10 @@ uint32_t UioAxiDmaIf::clear_interrupt() { } if (stat.err_irq) { BOOST_LOG_SEV(_lg, bls::warning) << "ERR IRQ"; - if (check_for_errors()) { - throw std::runtime_error("DMA engine error raised"); - } } s2mm_dmasr.wr({.ioc_irq = stat.ioc_irq, .err_irq = stat.err_irq}); - return irq_count; + return std::make_tuple(irq_count, stat); } bool UioAxiDmaIf::check_for_errors() {