Suren A. Chilingaryan 13 anni fa
parent
commit
8ad813673a
3 ha cambiato i file con 21 aggiunte e 8 eliminazioni
  1. 2 0
      dma/nwl_engine.c
  2. 6 5
      dma/nwl_engine_buffers.h
  3. 13 3
      dma/nwl_loopback.c

+ 2 - 0
dma/nwl_engine.c

@@ -65,6 +65,7 @@ int dma_nwl_start_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
     
     if (info->started) return 0;
 
+
 	// This will only successed if there are no parallel access to DMA engine
     err = dma_nwl_allocate_engine_buffers(ctx, info);
     if (err) {
@@ -77,6 +78,7 @@ int dma_nwl_start_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
     	info->preserve = 1;
 
 	    // Acknowledge asserted engine interrupts    
+        nwl_read_register(val, ctx, info->base_addr, REG_DMA_ENG_CTRL_STATUS);
 	if (val & DMA_ENG_INT_ACTIVE_MASK) {
 	    val |= DMA_ENG_ALLINT_MASK;
 	    nwl_write_register(val, ctx, base, REG_DMA_ENG_CTRL_STATUS);

+ 6 - 5
dma/nwl_engine_buffers.h

@@ -128,6 +128,7 @@ static int dma_nwl_allocate_engine_buffers(nwl_dma_t *ctx, pcilib_nwl_engine_des
 		else if (reuse_ring & PCILIB_KMEM_REUSE_HARDWARE == 0) pcilib_warning("Lost DMA buffers are found (missing HW reference), reinitializing...");
 		else {
 		    nwl_read_register(val, ctx, info->base_addr, REG_DMA_ENG_CTRL_STATUS);
+
 		    if (val&DMA_ENG_RUNNING == 0) pcilib_warning("Lost DMA buffers are found (DMA engine is stopped), reinitializing...");
 		    else preserve = 1;
 		}
@@ -146,9 +147,10 @@ static int dma_nwl_allocate_engine_buffers(nwl_dma_t *ctx, pcilib_nwl_engine_des
 	if (err) preserve = 0;
     }
     
-    if (preserve)
+    if (preserve) {
 	info->reused = 1;
-    else {
+        buf_sz = pcilib_kmem_get_block_size(ctx->pcilib, pages, 0);
+    } else {
 	memset(data, 0, PCILIB_NWL_DMA_PAGES * PCILIB_NWL_DMA_DESCRIPTOR_SIZE);
 
 	for (i = 0; i < PCILIB_NWL_DMA_PAGES; i++, data += PCILIB_NWL_DMA_DESCRIPTOR_SIZE) {
@@ -178,7 +180,6 @@ static int dma_nwl_allocate_engine_buffers(nwl_dma_t *ctx, pcilib_nwl_engine_des
     info->page_size = buf_sz;
     info->ring_size = PCILIB_NWL_DMA_PAGES;
     
-    
     return 0;
 }
 
@@ -254,7 +255,7 @@ static size_t dma_nwl_get_next_buffer(nwl_dma_t * ctx, pcilib_nwl_engine_descrip
 	    n += res;
 	}
     }
-    
+
     if (n < n_buffers) return PCILIB_DMA_BUFFER_INVALID;
     
     return info->head;
@@ -278,7 +279,7 @@ static int dma_nwl_push_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *
 	flags |= DMA_BD_EOP_MASK;
 	info->writting = 0;
     }
-
+    
     NWL_RING_SET(ring, DMA_BD_BUFL_CTRL_OFFSET, size|flags);
     NWL_RING_SET(ring, DMA_BD_BUFL_STATUS_OFFSET, size);
 

+ 13 - 3
dma/nwl_loopback.c

@@ -114,9 +114,6 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
 	return -1;
     }
 
-    memset(cmp, 0x13, size * sizeof(uint32_t));
-
-
 #ifdef DEBUG_HARDWARE	     
     if (ctx->type == PCILIB_NWL_MODIFICATION_IPECAMERA) {
 	pcilib_write_register(ctx->pcilib, NULL, "control", 0x1e5);
@@ -127,6 +124,8 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
 
 	// Benchmark
     for (i = 0; i < iterations; i++) {
+        memset(cmp, 0x13 + i, size * sizeof(uint32_t));
+
 #ifdef DEBUG_HARDWARE	     
 	if (ctx->type == PCILIB_NWL_MODIFICATION_IPECAMERA) {
 	    pcilib_write_register(ctx->pcilib, NULL, "control", 0x1e1);
@@ -165,6 +164,17 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm
 	if (direction == PCILIB_DMA_BIDIRECTIONAL) {
 	    res = memcmp(buf, cmp, size * sizeof(uint32_t));
 	    if (res) {
+		for (i = 0; i < size; i++)
+		    if (buf[i] != cmp[i]) break;
+		
+		bytes = i;
+		printf("Expected: *%lx, Written:", 0x13 + i);
+		for (; (i < size)&&(i < (bytes + 16)); i++) {
+		    if (((i - bytes)%8)==0) printf("\n");
+		    printf("% 10lx", buf[i]);
+		}
+		printf("\n\n");
+		
 		error = "Written and read values does not match";
 		break;
 	    }