From 21d12d6157061bca3926607a248ccc16d6b07bd1 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Sun, 17 Jul 2011 16:43:47 +0200 Subject: Correctly detect the tail pointer of C2S ring --- dma/nwl_loopback.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'dma/nwl_loopback.c') diff --git a/dma/nwl_loopback.c b/dma/nwl_loopback.c index 3c2c124..de17962 100644 --- a/dma/nwl_loopback.c +++ b/dma/nwl_loopback.c @@ -16,7 +16,8 @@ int dma_nwl_start_loopback(nwl_dma_t *ctx, pcilib_dma_direction_t direction, size_t packet_size) { uint32_t val; - // Re-initializing always + ctx->loopback_started = 1; + dma_nwl_stop_loopback(ctx); val = packet_size; nwl_write_register(val, ctx, ctx->base_addr, PKT_SIZE_ADDRESS); @@ -24,17 +25,16 @@ int dma_nwl_start_loopback(nwl_dma_t *ctx, pcilib_dma_direction_t direction, si switch (direction) { case PCILIB_DMA_BIDIRECTIONAL: val = LOOPBACK; + nwl_write_register(val, ctx, ctx->base_addr, TX_CONFIG_ADDRESS); break; case PCILIB_DMA_TO_DEVICE: return -1; case PCILIB_DMA_FROM_DEVICE: val = PKTGENR; + nwl_write_register(val, ctx, ctx->base_addr, RX_CONFIG_ADDRESS); break; } - nwl_write_register(val, ctx, ctx->base_addr, TX_CONFIG_ADDRESS); - nwl_write_register(val, ctx, ctx->base_addr, RX_CONFIG_ADDRESS); - ctx->loopback_started = 1; return 0; @@ -42,6 +42,8 @@ int dma_nwl_start_loopback(nwl_dma_t *ctx, pcilib_dma_direction_t direction, si int dma_nwl_stop_loopback(nwl_dma_t *ctx) { uint32_t val = 0; + + if (!ctx->loopback_started) return 0; /* Stop in any case, otherwise we can have problems in benchmark due to engine initialized in previous run, and benchmark is only actual usage. -- cgit v1.2.3