From 9a7ec0c7c063c86e0c2775bbf7fb485c691d9bb9 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Tue, 12 Jul 2011 19:51:27 +0200 Subject: Few fixes --- dma/nwl.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'dma/nwl.c') diff --git a/dma/nwl.c b/dma/nwl.c index c5240f0..b48e0a4 100644 --- a/dma/nwl.c +++ b/dma/nwl.c @@ -128,11 +128,13 @@ void dma_nwl_free(pcilib_dma_context_t *vctx) { pcilib_dma_engine_t i; nwl_dma_t *ctx = (nwl_dma_t*)vctx; - dma_nwl_stop_loopback(ctx); - dma_nwl_free_irq(ctx); - dma_nwl_stop(ctx, PCILIB_DMA_ENGINE_ALL, PCILIB_DMA_FLAGS_DEFAULT); - - free(ctx); + if (ctx) { + dma_nwl_stop_loopback(ctx); + dma_nwl_free_irq(ctx); + dma_nwl_stop(ctx, PCILIB_DMA_ENGINE_ALL, PCILIB_DMA_FLAGS_DEFAULT); + + free(ctx); + } } @@ -144,7 +146,7 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm uint32_t val; uint32_t *buf, *cmp; const char *error = NULL; -// pcilib_register_value_t regval; + pcilib_register_value_t regval; size_t us = 0; struct timeval start, cur; @@ -208,6 +210,11 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm // Benchmark for (i = 0; i < iterations; i++) { +// puts("===================================="); + pcilib_write_register(ctx->pcilib, NULL, "control", 0x1e1); +// pcilib_read_register(ctx->pcilib, NULL, "control", ®val); +// printf("Control: %lx\n", regval); + gettimeofday(&start, NULL); if (direction&PCILIB_DMA_TO_DEVICE) { memcpy(buf, cmp, size * sizeof(uint32_t)); @@ -241,6 +248,10 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm nwl_read_register(val, ctx, write_base, REG_DMA_ENG_CTRL_STATUS); printf("Write DMA control (after write): %lx\n", val); */ + pcilib_write_register(ctx->pcilib, NULL, "control", 0x3e1); +// pcilib_read_register(ctx->pcilib, NULL, "control", ®val); +// printf("Control: %lx\n", regval); + memset(buf, 0, size * sizeof(uint32_t)); err = pcilib_read_dma(ctx->pcilib, readid, addr, size * sizeof(uint32_t), buf, &bytes); -- cgit v1.2.3