From 8da61292f595c5e700a4fef981b0e0d07910b4b2 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 30 Apr 2015 19:51:49 +0200 Subject: Provide an interface for logging debug messages --- dma/ipe.c | 15 ++++++--------- dma/ipe_private.h | 1 - dma/nwl_engine.c | 1 + dma/nwl_engine_buffers.h | 8 ++------ dma/nwl_private.h | 3 --- 5 files changed, 9 insertions(+), 19 deletions(-) (limited to 'dma') diff --git a/dma/ipe.c b/dma/ipe.c index 439b231..855109c 100644 --- a/dma/ipe.c +++ b/dma/ipe.c @@ -12,6 +12,7 @@ #include "pcilib.h" #include "error.h" #include "tools.h" +#include "debug.h" #include "ipe.h" #include "ipe_private.h" @@ -425,9 +426,7 @@ int dma_ipe_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uin // case PCILIB_STREAMING_CHECK: wait = 0; break; } -#ifdef IPEDMA_DEBUG - printf("Waiting for data: %u (last read) 0x%x (last read addr) 0x%x (last_written)\n", ctx->last_read, ctx->last_read_addr, *last_written_addr_ptr); -#endif /* IPEDMA_DEBUG */ + pcilib_debug(DMA, "Waiting for data: %u (last read) 0x%x (last read addr) 0x%x (last_written)\n", ctx->last_read, ctx->last_read_addr, *last_written_addr_ptr); gettimeofday(&start, NULL); memcpy(&cur, &start, sizeof(struct timeval)); @@ -442,10 +441,10 @@ int dma_ipe_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uin // Failing out if we exited on timeout if ((ctx->last_read_addr == (*last_written_addr_ptr))||(*last_written_addr_ptr == 0)) { #ifdef IPEDMA_SUPPORT_EMPTY_DETECTED -# ifdef IPEDMA_DEBUG +# ifdef PCILIB_DEBUG_DMA if ((wait)&&(*last_written_addr_ptr)&&(!*empty_detected_ptr)) - pcilib_warning("The empty_detected flag is not set, but no data arrived within %lu us\n", wait); -# endif /* IPEDMA_DEBUG */ + pcilib_debug(DMA, "The empty_detected flag is not set, but no data arrived within %lu us\n", wait); +# endif /* PCILIB_DEBUG_DMA */ #endif /* IPEDMA_SUPPORT_EMPTY_DETECTED */ return (ret&PCILIB_STREAMING_FAIL)?PCILIB_ERROR_TIMEOUT:0; } @@ -454,9 +453,7 @@ int dma_ipe_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uin cur_read = ctx->last_read + 1; if (cur_read == ctx->ring_size) cur_read = 0; -#ifdef IPEDMA_DEBUG - printf("Reading: %u (last read) 0x%x (last read addr) 0x%x (last_written)\n", cur_read, ctx->last_read_addr, *last_written_addr_ptr); -#endif /* IPEDMA_DEBUG */ + pcilib_debug(DMA, "Reading: %u (last read) 0x%x (last read addr) 0x%x (last_written)\n", cur_read, ctx->last_read_addr, *last_written_addr_ptr); #ifdef IPEDMA_DETECT_PACKETS if ((*empty_detected_ptr)&&(pcilib_kmem_get_block_ba(ctx->dmactx.pcilib, ctx->pages, cur_read) == (*last_written_addr_ptr))) packet_flags = PCILIB_DMA_FLAG_EOP; diff --git a/dma/ipe_private.h b/dma/ipe_private.h index 161e609..f6aa2f7 100644 --- a/dma/ipe_private.h +++ b/dma/ipe_private.h @@ -11,7 +11,6 @@ #define IPEDMA_DESCRIPTOR_SIZE 128 #define IPEDMA_DESCRIPTOR_ALIGNMENT 64 -//#define IPEDMA_DEBUG //#define IPEDMA_BUG_DMARD /**< No register read during DMA transfer */ //#define IPEDMA_DETECT_PACKETS /**< Using empty_deceted flag */ #define IPEDMA_SUPPORT_EMPTY_DETECTED /**< Avoid waiting for data when empty_detected flag is set in hardware */ diff --git a/dma/nwl_engine.c b/dma/nwl_engine.c index 6930533..15ae27e 100644 --- a/dma/nwl_engine.c +++ b/dma/nwl_engine.c @@ -10,6 +10,7 @@ #include "pcilib.h" #include "error.h" #include "tools.h" +#include "debug.h" #include "nwl_private.h" #include "nwl_defines.h" diff --git a/dma/nwl_engine_buffers.h b/dma/nwl_engine_buffers.h index 71fb736..d3af079 100644 --- a/dma/nwl_engine_buffers.h +++ b/dma/nwl_engine_buffers.h @@ -33,9 +33,7 @@ static int dma_nwl_compute_read_s2c_pointers(nwl_dma_t *ctx, pcilib_nwl_engine_c return PCILIB_ERROR_INVALID_STATE; } -#ifdef DEBUG_NWL - printf("S2C: %lu %lu\n", ectx->tail, ectx->head); -#endif /* DEBUG_NWL */ + pcilib_debug(DMA, "S2C: %lu %lu\n", ectx->tail, ectx->head); return 0; } @@ -61,9 +59,7 @@ static int dma_nwl_compute_read_c2s_pointers(nwl_dma_t *ctx, pcilib_nwl_engine_c ectx->tail = ectx->head + 1; if (ectx->tail == PCILIB_NWL_DMA_PAGES) ectx->tail = 0; -#ifdef DEBUG_NWL - printf("C2S: %lu %lu\n", ectx->tail, ectx->head); -#endif /* DEBUG_NWL */ + pcilib_debug(DMA, "C2S: %lu %lu\n", ectx->tail, ectx->head); return 0; } diff --git a/dma/nwl_private.h b/dma/nwl_private.h index 1d60169..08f0feb 100644 --- a/dma/nwl_private.h +++ b/dma/nwl_private.h @@ -17,9 +17,6 @@ typedef struct pcilib_nwl_engine_context_s pcilib_nwl_engine_context_t; #define PCILIB_NWL_REGISTER_TIMEOUT 10000 /**< us */ -//#define DEBUG_HARDWARE -//#define DEBUG_NWL - #include "nwl.h" #include "nwl_irq.h" #include "nwl_engine.h" -- cgit v1.2.3