summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dma/nwl_engine.c4
-rw-r--r--dma/nwl_engine_buffers.h14
-rw-r--r--kmem.c26
-rw-r--r--kmem.h3
4 files changed, 24 insertions, 23 deletions
diff --git a/dma/nwl_engine.c b/dma/nwl_engine.c
index 0b5924d..d90dbef 100644
--- a/dma/nwl_engine.c
+++ b/dma/nwl_engine.c
@@ -289,10 +289,10 @@ int dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uin
}
#endif /* NWL_FIX_EOP_FOR_BIG_PACKETS */
- pcilib_sync_kernel_memory(ctx->pcilib, info->pages, PCILIB_KMEM_SYNC_FROMDEVICE);
+ pcilib_kmem_sync_block(ctx->pcilib, info->pages, PCILIB_KMEM_SYNC_FROMDEVICE, bufnum);
void *buf = pcilib_kmem_get_block_ua(ctx->pcilib, info->pages, bufnum);
ret = cb(cbattr, eop?PCILIB_DMA_FLAG_EOP:0, bufsize, buf);
- pcilib_sync_kernel_memory(ctx->pcilib, info->pages, PCILIB_KMEM_SYNC_TODEVICE);
+ pcilib_kmem_sync_block(ctx->pcilib, info->pages, PCILIB_KMEM_SYNC_TODEVICE, bufnum);
dma_nwl_return_buffer(ctx, info);
diff --git a/dma/nwl_engine_buffers.h b/dma/nwl_engine_buffers.h
index 517e690..8f31bb6 100644
--- a/dma/nwl_engine_buffers.h
+++ b/dma/nwl_engine_buffers.h
@@ -2,17 +2,6 @@
#define NWL_RING_SET(data, offset, val) *(uint32_t*)(((char*)(data)) + (offset)) = (val)
#define NWL_RING_UPDATE(data, offset, mask, val) *(uint32_t*)(((char*)(data)) + (offset)) = ((*(uint32_t*)(((char*)(data)) + (offset)))&(mask))|(val)
-int dma_nwl_sync_buffers(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info, pcilib_kmem_handle_t *kmem) {
- switch (info->desc.direction) {
- case PCILIB_DMA_FROM_DEVICE:
- return pcilib_sync_kernel_memory(ctx->pcilib, kmem, PCILIB_KMEM_SYNC_FROMDEVICE);
- case PCILIB_DMA_TO_DEVICE:
- return pcilib_sync_kernel_memory(ctx->pcilib, kmem, PCILIB_KMEM_SYNC_TODEVICE);
- }
-
- return 0;
-}
-
static int dma_nwl_compute_read_s2c_pointers(nwl_dma_t *ctx, pcilib_nwl_engine_description_t *info, unsigned char *ring, uint32_t ring_pa) {
size_t pos;
uint32_t val;
@@ -109,9 +98,6 @@ static int dma_nwl_allocate_engine_buffers(nwl_dma_t *ctx, pcilib_nwl_engine_des
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, type, PCILIB_NWL_DMA_PAGES, 0, 0, PCILIB_KMEM_USE(PCILIB_KMEM_USE_DMA_PAGES, sub_use), flags);
-// if ((ring)&&(pages)) err = dma_nwl_sync_buffers(ctx, info, pages);
-// else err = PCILIB_ERROR_FAILED;
-
if (err) {
if (pages) pcilib_free_kernel_memory(ctx->pcilib, pages, 0);
if (ring) pcilib_free_kernel_memory(ctx->pcilib, ring, 0);
diff --git a/kmem.c b/kmem.c
index b94b628..aecccde 100644
--- a/kmem.c
+++ b/kmem.c
@@ -225,6 +225,7 @@ void pcilib_free_kernel_memory(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_km
}
}
+/*
int pcilib_sync_kernel_memory(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kmem_sync_direction_t dir) {
int i;
int ret;
@@ -232,7 +233,7 @@ int pcilib_sync_kernel_memory(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kme
pcilib_kmem_list_t *kbuf = (pcilib_kmem_list_t*)k;
ks.dir = dir;
-
+
for (i = 0; i < kbuf->buf.n_blocks; i++) {
ks.handle.handle_id = kbuf->buf.blocks[i].handle_id;
ks.handle.pa = kbuf->buf.blocks[i].pa;
@@ -241,15 +242,29 @@ int pcilib_sync_kernel_memory(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kme
pcilib_error("PCIDRIVER_IOC_KMEM_SYNC ioctl have failed");
return PCILIB_ERROR_FAILED;
}
-
- if (!kbuf->buf.blocks[i].pa) {
- kbuf->buf.blocks[i].pa = ks.handle.pa;
- }
}
return 0;
}
+*/
+
+int pcilib_kmem_sync_block(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kmem_sync_direction_t dir, size_t block) {
+ int ret;
+ kmem_sync_t ks;
+ pcilib_kmem_list_t *kbuf = (pcilib_kmem_list_t*)k;
+
+ ks.dir = dir;
+ ks.handle.handle_id = kbuf->buf.blocks[block].handle_id;
+ ks.handle.pa = kbuf->buf.blocks[block].pa;
+ ret = ioctl(ctx->handle, PCIDRIVER_IOC_KMEM_SYNC, &ks);
+ if (ret) {
+ pcilib_error("PCIDRIVER_IOC_KMEM_SYNC ioctl have failed");
+ return PCILIB_ERROR_FAILED;
+ }
+
+ return 0;
+}
void *pcilib_kmem_get_ua(pcilib_t *ctx, pcilib_kmem_handle_t *k) {
pcilib_kmem_list_t *kbuf = (pcilib_kmem_list_t*)k;
@@ -280,4 +295,3 @@ pcilib_kmem_reuse_state_t pcilib_kmem_is_reused(pcilib_t *ctx, pcilib_kmem_hand
pcilib_kmem_list_t *kbuf = (pcilib_kmem_list_t*)k;
return kbuf->buf.reused;
}
-
diff --git a/kmem.h b/kmem.h
index ea806a1..b9b561f 100644
--- a/kmem.h
+++ b/kmem.h
@@ -62,7 +62,8 @@ struct pcilib_kmem_list_s {
pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type_t type, size_t nmemb, size_t size, size_t alignment, pcilib_kmem_use_t use, pcilib_kmem_flags_t flags);
void pcilib_free_kernel_memory(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kmem_flags_t flags);
-int pcilib_sync_kernel_memory(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kmem_sync_direction_t dir);
+//int pcilib_sync_kernel_memory(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kmem_sync_direction_t dir);
+int pcilib_kmem_sync_block(pcilib_t *ctx, pcilib_kmem_handle_t *k, pcilib_kmem_sync_direction_t dir, size_t block);
void *pcilib_kmem_get_ua(pcilib_t *ctx, pcilib_kmem_handle_t *k);
uintptr_t pcilib_kmem_get_pa(pcilib_t *ctx, pcilib_kmem_handle_t *k);
void *pcilib_kmem_get_block_ua(pcilib_t *ctx, pcilib_kmem_handle_t *k, size_t block);