summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli.c39
-rw-r--r--dma.c9
-rw-r--r--dma/nwl_buffers.h5
-rw-r--r--dma/nwl_engine.c16
-rw-r--r--driver/kmem.c6
-rw-r--r--kmem.c5
6 files changed, 53 insertions, 27 deletions
diff --git a/cli.c b/cli.c
index 924fd5b..8cdab0c 100644
--- a/cli.c
+++ b/cli.c
@@ -894,37 +894,46 @@ int StartStopDMA(pcilib_t *handle, pcilib_model_description_t *model_info, pcil
int err;
pcilib_dma_engine_t dmaid;
- if (dma_direction&PCILIB_DMA_FROM_DEVICE) {
- if (dma == PCILIB_DMA_ENGINE_ADDR_INVALID) {
- if (start) Error("DMA engine should be specified");
- dmaid = PCILIB_DMA_ENGINE_INVALID;
- } else {
- dmaid = pcilib_find_dma_by_addr(handle, PCILIB_DMA_FROM_DEVICE, dma);
- if (dmaid == PCILIB_DMA_ENGINE_INVALID) Error("Invalid DMA engine (C2S %lu) is specified", dma);
+ if (dma == PCILIB_DMA_ENGINE_ADDR_INVALID) {
+ const pcilib_dma_info_t *dma_info = pcilib_get_dma_info(handle);
+
+ if (start) Error("DMA engine should be specified");
+
+ for (dmaid = 0; dma_info->engines[dmaid]; dmaid++) {
+ err = pcilib_start_dma(handle, dmaid, 0);
+ if (err) Error("Error starting DMA Engine (%s %i)", ((dma_info->engines[dmaid]->direction == PCILIB_DMA_FROM_DEVICE)?"C2S":"S2C"), dma_info->engines[dmaid]->addr);
+ err = pcilib_stop_dma(handle, dmaid, PCILIB_DMA_FLAG_PERSISTENT);
+ if (err) Error("Error stopping DMA Engine (%s %i)", ((dma_info->engines[dmaid]->direction == PCILIB_DMA_FROM_DEVICE)?"C2S":"S2C"), dma_info->engines[dmaid]->addr);
}
+ return 0;
+ }
+
+ if (dma_direction&PCILIB_DMA_FROM_DEVICE) {
+ dmaid = pcilib_find_dma_by_addr(handle, PCILIB_DMA_FROM_DEVICE, dma);
+ if (dmaid == PCILIB_DMA_ENGINE_INVALID) Error("Invalid DMA engine (C2S %lu) is specified", dma);
+
if (start) {
err = pcilib_start_dma(handle, dmaid, PCILIB_DMA_FLAG_PERSISTENT);
if (err) Error("Error starting DMA engine (C2S %lu)", dma);
} else {
+ err = pcilib_start_dma(handle, dmaid, 0);
+ if (err) Error("Error starting DMA engine (C2S %lu)", dma);
err = pcilib_stop_dma(handle, dmaid, PCILIB_DMA_FLAG_PERSISTENT);
if (err) Error("Error stopping DMA engine (C2S %lu)", dma);
}
}
-
+
if (dma_direction&PCILIB_DMA_TO_DEVICE) {
- if (dma == PCILIB_DMA_ENGINE_ADDR_INVALID) {
- if (start) Error("DMA engine should be specified");
- dmaid = PCILIB_DMA_ENGINE_INVALID;
- } else {
- dmaid = pcilib_find_dma_by_addr(handle, PCILIB_DMA_TO_DEVICE, dma);
- if (dmaid == PCILIB_DMA_ENGINE_INVALID) Error("Invalid DMA engine (S2C %lu) is specified", dma);
- }
+ dmaid = pcilib_find_dma_by_addr(handle, PCILIB_DMA_TO_DEVICE, dma);
+ if (dmaid == PCILIB_DMA_ENGINE_INVALID) Error("Invalid DMA engine (S2C %lu) is specified", dma);
if (start) {
err = pcilib_start_dma(handle, dmaid, PCILIB_DMA_FLAG_PERSISTENT);
if (err) Error("Error starting DMA engine (S2C %lu)", dma);
} else {
+ err = pcilib_start_dma(handle, dmaid, 0);
+ if (err) Error("Error starting DMA engine (S2C %lu)", dma);
err = pcilib_stop_dma(handle, dmaid, PCILIB_DMA_FLAG_PERSISTENT);
if (err) Error("Error stopping DMA engine (S2C %lu)", dma);
}
diff --git a/dma.c b/dma.c
index 45466b7..db7625c 100644
--- a/dma.c
+++ b/dma.c
@@ -72,7 +72,6 @@ int pcilib_start_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_flags_t
}
if (!ctx->model_info.dma_api->start_dma) {
- //pcilib_error("The IRQs are not supported by configured DMA engine");
return 0;
}
@@ -94,10 +93,12 @@ int pcilib_stop_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_flags_t f
}
if (!ctx->model_info.dma_api->stop_dma) {
- //pcilib_error("The IRQs are not supported by configured DMA engine");
return 0;
}
-
+
+
+ printf("stop dma: %li\n", dma);
+
return ctx->model_info.dma_api->stop_dma(ctx->dma_ctx, dma, flags);
}
@@ -119,7 +120,7 @@ int pcilib_enable_irq(pcilib_t *ctx, pcilib_irq_type_t irq_type, pcilib_dma_flag
//pcilib_error("The IRQs are not supported by configured DMA engine");
return 0;
}
-
+
return ctx->model_info.dma_api->enable_irq(ctx->dma_ctx, irq_type, flags);
}
diff --git a/dma/nwl_buffers.h b/dma/nwl_buffers.h
index 9e60461..c298612 100644
--- a/dma/nwl_buffers.h
+++ b/dma/nwl_buffers.h
@@ -113,10 +113,11 @@ static int dma_nwl_allocate_engine_buffers(nwl_dma_t *ctx, pcilib_nwl_engine_des
char *base = info->base_addr;
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;
- flags = PCILIB_KMEM_FLAG_REUSE|PCILIB_KMEM_FLAG_EXCLUSIVE|PCILIB_KMEM_FLAG_HARDWARE|info->preserve?PCILIB_KMEM_FLAG_PERSISTENT:0;
+ 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);
pcilib_kmem_handle_t *pages = pcilib_alloc_kernel_memory(ctx->pcilib, PCILIB_KMEM_TYPE_PAGE, PCILIB_NWL_DMA_PAGES, 0, 0, PCILIB_KMEM_USE(PCILIB_KMEM_USE_DMA_PAGES, sub_use), flags);
diff --git a/dma/nwl_engine.c b/dma/nwl_engine.c
index 58d5522..68e1805 100644
--- a/dma/nwl_engine.c
+++ b/dma/nwl_engine.c
@@ -161,6 +161,8 @@ int dma_nwl_stop_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
uint32_t val;
uint32_t ring_pa;
struct timeval start, cur;
+ pcilib_kmem_flags_t flags;
+
pcilib_nwl_engine_description_t *info = ctx->engines + dma;
char *base = ctx->engines[dma].base_addr;
@@ -194,19 +196,25 @@ int dma_nwl_stop_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) {
nwl_write_register(val, ctx, base, REG_DMA_ENG_CTRL_STATUS);
}
+ if (info->preserve) {
+ flags = PCILIB_KMEM_FLAG_REUSE;
+ } else {
+ 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, info->preserve?PCILIB_KMEM_FLAG_REUSE:0);
+ pcilib_free_kernel_memory(ctx->pcilib, info->ring, flags);
info->ring = NULL;
}
if (info->pages) {
- pcilib_free_kernel_memory(ctx->pcilib, info->pages, info->preserve?PCILIB_KMEM_FLAG_REUSE:0);
+ pcilib_free_kernel_memory(ctx->pcilib, info->pages, flags);
info->pages = NULL;
}
- nwl_read_register(val, ctx, info->base_addr, REG_DMA_ENG_CTRL_STATUS);
-
return 0;
}
diff --git a/driver/kmem.c b/driver/kmem.c
index a720095..a7180f8 100644
--- a/driver/kmem.c
+++ b/driver/kmem.c
@@ -165,6 +165,7 @@ int pcidriver_kmem_free( pcidriver_privdata_t *privdata, kmem_handle_t *kmem_han
if ((kmem_entry = pcidriver_kmem_find_entry(privdata, kmem_handle)) == NULL)
return -EINVAL; /* kmem_handle is not valid */
+ mod_info("1: %x %lx %lx\n", kmem_handle->flags, kmem_entry->refs, kmem_entry->mode);
if (kmem_entry->mode&KMEM_MODE_COUNT)
kmem_entry->mode -= 1;
@@ -174,6 +175,8 @@ int pcidriver_kmem_free( pcidriver_privdata_t *privdata, kmem_handle_t *kmem_han
if (kmem_handle->flags&KMEM_FLAG_PERSISTENT)
kmem_entry->mode &= ~KMEM_MODE_PERSISTENT;
+
+ mod_info("2: %x %lx %lx\n", kmem_handle->flags, kmem_entry->refs, kmem_entry->mode);
if (kmem_handle->flags&KMEM_FLAG_REUSE)
return 0;
@@ -192,6 +195,9 @@ int pcidriver_kmem_free( pcidriver_privdata_t *privdata, kmem_handle_t *kmem_han
if (((kmem_entry->mode&KMEM_MODE_EXCLUSIVE)==0)&&(kmem_entry->mode&KMEM_MODE_COUNT))
return 0;
+
+ mod_info("cleaned %i\n", kmem_entry->id);
+
return pcidriver_kmem_free_entry(privdata, kmem_entry);
}
diff --git a/kmem.c b/kmem.c
index d7f2833..5511b7a 100644
--- a/kmem.c
+++ b/kmem.c
@@ -24,7 +24,7 @@ static int pcilib_free_kernel_buffer(pcilib_t *ctx, pcilib_kmem_list_t *kbuf, si
kh.handle_id = kbuf->buf.blocks[i].handle_id;
kh.pa = kbuf->buf.blocks[i].pa;
kh.flags = flags;
-
+
return ioctl(ctx->handle, PCIDRIVER_IOC_KMEM_FREE, &kh);
}
@@ -87,6 +87,7 @@ pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type
kh.size += alignment;
}
+ printf("KMEM Flags: %lx\n", flags);
for ( i = 0; i < nmemb; i++) {
kh.item = i;
kh.flags = flags;
@@ -202,7 +203,7 @@ void pcilib_free_kernel_memory(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_km
else if (ctx->kmem_list == kbuf) ctx->kmem_list = kbuf->next;
for (i = 0; i < kbuf->buf.n_blocks; i++) {
- ret = pcilib_free_kernel_buffer(ctx, kbuf, --kbuf->buf.n_blocks, flags);
+ ret = pcilib_free_kernel_buffer(ctx, kbuf, i, flags);
if ((ret)&&(!err)) err = ret;
}