File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212#pragma once
1313
14+ #include < tuple>
15+
1416#include " RegAccessor.hpp"
1517#include " UioIf.hpp"
1618#include " udmaio/rdl/AxiDma.hpp"
17-
1819namespace udmaio {
1920
2021using AxiDmaBlock = axi_dma::block<RegAccessorArray>;
@@ -31,7 +32,7 @@ class UioAxiDmaIf : public UioIf, AxiDmaBlock {
3132 using UioIf::arm_interrupt;
3233
3334 // / Wait for interrupt and acknowledge it
34- uint32_t clear_interrupt ();
35+ std::tuple< uint32_t , axi_dma:: s2mm_dmasr_t > clear_interrupt ();
3536
3637 // / @brief Check status register and log any errors
3738 // / @return true if any error occurred
Original file line number Diff line number Diff line change @@ -59,18 +59,21 @@ void DataHandlerAbstract::_handle_input(const boost::system::error_code& ec) {
5959 return ;
6060 }
6161
62- // Check for error flags and log them
63- _dma.check_for_errors ();
64-
65- uint32_t irq_count = _dma.clear_interrupt ();
62+ auto [irq_count, dma_stat] = _dma.clear_interrupt ();
6663 BOOST_LOG_SEV (_lg, bls::trace) << " irq count = " << irq_count;
64+ if (dma_stat.err_irq && _dma.check_for_errors ()) {
65+ _desc.print_descs ();
66+ throw std::runtime_error (" DMA engine error raised" );
67+ }
6768
68- auto full_bufs = _receive_packets ? _desc.get_next_packet () : _desc.get_full_buffers ();
69- if (full_bufs.empty ()) {
70- BOOST_LOG_SEV (_lg, bls::trace) << " spurious event, got no data" ;
71- } else {
72- auto bytes = _desc.read_buffers (full_bufs);
73- process_data (std::move (bytes));
69+ if (dma_stat.ioc_irq ) {
70+ auto full_bufs = _receive_packets ? _desc.get_next_packet () : _desc.get_full_buffers ();
71+ if (full_bufs.empty ()) {
72+ BOOST_LOG_SEV (_lg, bls::trace) << " spurious event, got no data" ;
73+ } else {
74+ auto bytes = _desc.read_buffers (full_bufs);
75+ process_data (std::move (bytes));
76+ }
7477 }
7578
7679 _start_read ();
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ void UioAxiDmaIf::start(uintptr_t start_desc) {
5151 << " DMA ctrl = 0x" << std::hex << reg_to_raw (s2mm_dmacr.rd ()) << std::dec;
5252}
5353
54- uint32_t UioAxiDmaIf::clear_interrupt () {
54+ std::tuple< uint32_t , axi_dma:: s2mm_dmasr_t > UioAxiDmaIf::clear_interrupt () {
5555 uint32_t irq_count = wait_for_interrupt ();
5656
5757 auto stat = s2mm_dmasr.rd ();
@@ -60,13 +60,10 @@ uint32_t UioAxiDmaIf::clear_interrupt() {
6060 }
6161 if (stat.err_irq ) {
6262 BOOST_LOG_SEV (_lg, bls::warning) << " ERR IRQ" ;
63- if (check_for_errors ()) {
64- throw std::runtime_error (" DMA engine error raised" );
65- }
6663 }
6764 s2mm_dmasr.wr ({.ioc_irq = stat.ioc_irq , .err_irq = stat.err_irq });
6865
69- return irq_count;
66+ return std::make_tuple ( irq_count, stat) ;
7067}
7168
7269bool UioAxiDmaIf::check_for_errors () {
You can’t perform that action at this time.
0 commit comments