summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-17 18:26:46 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-17 18:26:46 +0200
commit8ad813673ae155ce0e601ae864466a59ce7afa95 (patch)
treea7289e7179fed4ac939430de259cbaf1df7a71dc
parent21d12d6157061bca3926607a248ccc16d6b07bd1 (diff)
downloadipecamera-8ad813673ae155ce0e601ae864466a59ce7afa95.tar.gz
ipecamera-8ad813673ae155ce0e601ae864466a59ce7afa95.tar.bz2
ipecamera-8ad813673ae155ce0e601ae864466a59ce7afa95.tar.xz
ipecamera-8ad813673ae155ce0e601ae864466a59ce7afa95.zip
Few more fixes
-rw-r--r--dma/nwl_engine.c2
-rw-r--r--dma/nwl_engine_buffers.h11
-rw-r--r--dma/nwl_loopback.c16
3 files changed, 21 insertions, 8 deletions
diff --git a/dma/nwl_engine.c b/dma/nwl_engine.c
index 6987045..669dbbd 100644
--- a/dma/nwl_engine.c
+++ b/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);
diff --git a/dma/nwl_engine_buffers.h b/dma/nwl_engine_buffers.h
index 30385ea..6b794c6 100644
--- a/dma/nwl_engine_buffers.h
+++ b/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);
diff --git a/dma/nwl_loopback.c b/dma/nwl_loopback.c
index de17962..1904177 100644
--- a/dma/nwl_loopback.c
+++ b/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;
}