Skip to content

Commit

Permalink
feat: print desc if error IRQ raised
Browse files Browse the repository at this point in the history
  • Loading branch information
patrislav1 committed May 30, 2024
1 parent 8962c79 commit 030f949
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
5 changes: 3 additions & 2 deletions inc/udmaio/UioAxiDmaIf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

#pragma once

#include <tuple>

#include "RegAccessor.hpp"
#include "UioIf.hpp"
#include "udmaio/rdl/AxiDma.hpp"

namespace udmaio {

using AxiDmaBlock = axi_dma::block<RegAccessorArray>;
Expand All @@ -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<uint32_t, axi_dma::s2mm_dmasr_t> clear_interrupt();

/// @brief Check status register and log any errors
/// @return true if any error occurred
Expand Down
23 changes: 13 additions & 10 deletions src/DataHandlerAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 2 additions & 5 deletions src/UioAxiDmaIf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t, axi_dma::s2mm_dmasr_t> UioAxiDmaIf::clear_interrupt() {
uint32_t irq_count = wait_for_interrupt();

auto stat = s2mm_dmasr.rd();
Expand All @@ -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() {
Expand Down

0 comments on commit 030f949

Please sign in to comment.