summaryrefslogtreecommitdiffstats
path: root/dma
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-17 14:22:32 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-17 14:22:32 +0200
commit06b3e35cc964d4735bd62d293b9d51f689545f97 (patch)
tree6011078f428ec1b3c2506643529c3d00cfd29c28 /dma
parentec5fd54c7559392139fa704a57185f4d4244dfde (diff)
downloadpcitool-06b3e35cc964d4735bd62d293b9d51f689545f97.tar.gz
pcitool-06b3e35cc964d4735bd62d293b9d51f689545f97.tar.bz2
pcitool-06b3e35cc964d4735bd62d293b9d51f689545f97.tar.xz
pcitool-06b3e35cc964d4735bd62d293b9d51f689545f97.zip
Handle correctly reference counting in the driver
Diffstat (limited to 'dma')
-rw-r--r--dma/nwl_buffers.h22
-rw-r--r--dma/nwl_engine.c2
2 files changed, 13 insertions, 11 deletions
diff --git a/dma/nwl_buffers.h b/dma/nwl_buffers.h
index c298612..130c189 100644
--- a/dma/nwl_buffers.h
+++ b/dma/nwl_buffers.h
@@ -21,25 +21,27 @@ static int dma_nwl_compute_read_s2c_pointers(nwl_dma_t *ctx, pcilib_nwl_engine_d
nwl_read_register(val, ctx, base, REG_SW_NEXT_BD);
if ((val < ring_pa)||((val - ring_pa) % PCILIB_NWL_DMA_DESCRIPTOR_SIZE)) {
- pcilib_warning("Inconsistent DMA Ring buffer is found (REG_SW_NEXT_BD register out of range)");
+ if (val < ring_pa) pcilib_warning("Inconsistent S2C DMA Ring buffer is found (REG_SW_NEXT_BD register value (%lx) is below start of ring [%lx,%lx])", val, ring_pa, PCILIB_NWL_DMA_DESCRIPTOR_SIZE);
+ else pcilib_warning("Inconsistent S2C DMA Ring buffer is found (REG_SW_NEXT_BD register value (%zu / %u) is fractal)", val - ring_pa, PCILIB_NWL_DMA_DESCRIPTOR_SIZE);
return PCILIB_ERROR_INVALID_STATE;
}
info->head = (val - ring_pa) / PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
if (info->head >= PCILIB_NWL_DMA_PAGES) {
- pcilib_warning("Inconsistent DMA Ring buffer is found (REG_SW_NEXT_BD register out of range)");
+ pcilib_warning("Inconsistent S2C DMA Ring buffer is found (REG_SW_NEXT_BD register value (%zu) out of range)", info->head);
return PCILIB_ERROR_INVALID_STATE;
}
nwl_read_register(val, ctx, base, REG_DMA_ENG_NEXT_BD);
if ((val < ring_pa)||((val - ring_pa) % PCILIB_NWL_DMA_DESCRIPTOR_SIZE)) {
- pcilib_warning("Inconsistent DMA Ring buffer is found (REG_DMA_ENG_NEXT_BD register out of range)");
+ if (val < ring_pa) pcilib_warning("Inconsistent S2C DMA Ring buffer is found (REG_DMA_ENG_NEXT_BD register value (%lx) is below start of ring [%lx,%lx])", val, ring_pa, PCILIB_NWL_DMA_DESCRIPTOR_SIZE);
+ else pcilib_warning("Inconsistent S2C DMA Ring buffer is found (REG_DMA_ENG_NEXT_BD register value (%zu / %u) is fractal)", val - ring_pa, PCILIB_NWL_DMA_DESCRIPTOR_SIZE);
return PCILIB_ERROR_INVALID_STATE;
}
info->tail = (val - ring_pa) / PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
if (info->tail >= PCILIB_NWL_DMA_PAGES) {
- pcilib_warning("Inconsistent DMA Ring buffer is found (REG_DMA_ENG_NEXT_BD register out of range)");
+ pcilib_warning("Inconsistent S2C DMA Ring buffer is found (REG_DMA_ENG_NEXT_BD register value (%zu) out of range)", info->tail);
return PCILIB_ERROR_INVALID_STATE;
}
@@ -56,13 +58,14 @@ static int dma_nwl_compute_read_c2s_pointers(nwl_dma_t *ctx, pcilib_nwl_engine_d
nwl_read_register(val, ctx, base, REG_SW_NEXT_BD);
if ((val < ring_pa)||((val - ring_pa) % PCILIB_NWL_DMA_DESCRIPTOR_SIZE)) {
- pcilib_warning("Inconsistent DMA Ring buffer is found (REG_SW_NEXT_BD register out of range)");
+ if (val < ring_pa) pcilib_warning("Inconsistent C2S DMA Ring buffer is found (REG_SW_NEXT_BD register value (%lx) is below start of the ring [%lx,%lx])", val, ring_pa, PCILIB_NWL_DMA_DESCRIPTOR_SIZE);
+ else pcilib_warning("Inconsistent C2S DMA Ring buffer is found (REG_SW_NEXT_BD register value (%zu / %u) is fractal)", val - ring_pa, PCILIB_NWL_DMA_DESCRIPTOR_SIZE);
return PCILIB_ERROR_INVALID_STATE;
}
info->head = (val - ring_pa) / PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
if (info->head >= PCILIB_NWL_DMA_PAGES) {
- pcilib_warning("Inconsistent DMA Ring buffer is found (REG_SW_NEXT_BD register out of range)");
+ pcilib_warning("Inconsistent C2S DMA Ring buffer is found (REG_SW_NEXT_BD register value (%zu) out of range)", info->head);
return PCILIB_ERROR_INVALID_STATE;
}
@@ -72,13 +75,14 @@ static int dma_nwl_compute_read_c2s_pointers(nwl_dma_t *ctx, pcilib_nwl_engine_d
// Last read BD
nwl_read_register(val, ctx, base, REG_DMA_ENG_LAST_BD);
if ((val < ring_pa)||((val - ring_pa) % PCILIB_NWL_DMA_DESCRIPTOR_SIZE)) {
- pcilib_warning("Inconsistent DMA Ring buffer is found (REG_DMA_ENG_LAST_BD register out of range)");
+ if (val < ring_pa) pcilib_warning("Inconsistent C2S DMA Ring buffer is found (REG_DMA_ENG_LAST_BD register value (%lx) is below start of ring [%lx,%lx])", val, ring_pa, PCILIB_NWL_DMA_DESCRIPTOR_SIZE);
+ else pcilib_warning("Inconsistent C2S DMA Ring buffer is found (REG_DMA_ENG_LAST_BD register value (%zu / %u) is fractal)", val - ring_pa, PCILIB_NWL_DMA_DESCRIPTOR_SIZE);
return PCILIB_ERROR_INVALID_STATE;
}
prev = (val - ring_pa) / PCILIB_NWL_DMA_DESCRIPTOR_SIZE;
if (prev >= PCILIB_NWL_DMA_PAGES) {
- pcilib_warning("Inconsistent DMA Ring buffer is found (REG_DMA_ENG_LAST_BD register out of range)");
+ pcilib_warning("Inconsistent C2S DMA Ring buffer is found (REG_DMA_ENG_LAST_BD register value (%zu) out of range)", prev);
return PCILIB_ERROR_INVALID_STATE;
}
@@ -115,7 +119,7 @@ static int dma_nwl_allocate_engine_buffers(nwl_dma_t *ctx, pcilib_nwl_engine_des
if (info->pages) return 0;
// Or bidirectional specified by 0x0|addr, or read 0x0|addr and write 0x80|addr
- sub_use = info->desc.addr|(info->desc.direction == PCILIB_DMA_TO_DEVICE)?0x80:0x00;
+ sub_use = info->desc.addr|((info->desc.direction == PCILIB_DMA_TO_DEVICE)?0x80:0x00);
flags = PCILIB_KMEM_FLAG_REUSE|PCILIB_KMEM_FLAG_EXCLUSIVE|PCILIB_KMEM_FLAG_HARDWARE|(info->preserve?PCILIB_KMEM_FLAG_PERSISTENT:0);
pcilib_kmem_handle_t *ring = pcilib_alloc_kernel_memory(ctx->pcilib, PCILIB_KMEM_TYPE_CONSISTENT, 1, PCILIB_NWL_DMA_PAGES * PCILIB_NWL_DMA_DESCRIPTOR_SIZE, PCILIB_NWL_ALIGNMENT, PCILIB_KMEM_USE(PCILIB_KMEM_USE_DMA_RING, sub_use), flags);
diff --git a/dma/nwl_engine.c b/dma/nwl_engine.c
index 68e1805..f5ca30e 100644
--- a/dma/nwl_engine.c
+++ b/dma/nwl_engine.c
@@ -202,8 +202,6 @@ int dma_nwl_stop_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
flags = PCILIB_KMEM_FLAG_HARDWARE|PCILIB_KMEM_FLAG_PERSISTENT;
}
-
- printf("%lx %i\n", flags, info->preserve);
// Clean buffers
if (info->ring) {
pcilib_free_kernel_memory(ctx->pcilib, info->ring, flags);