summaryrefslogtreecommitdiffstats
path: root/pcilib/pci.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-08-06 04:24:58 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-08-06 04:24:58 +0200
commitd60dd48eec0ef5d7bf2feca9b3f06374a2f444aa (patch)
tree5dac744f57edafe76e73648509a19bfa275097f5 /pcilib/pci.c
parent8b8a2bee0bce0bc9cc78d43f236c6a3d8a0bd2e4 (diff)
downloadpcitool-d60dd48eec0ef5d7bf2feca9b3f06374a2f444aa.tar.gz
pcitool-d60dd48eec0ef5d7bf2feca9b3f06374a2f444aa.tar.bz2
pcitool-d60dd48eec0ef5d7bf2feca9b3f06374a2f444aa.tar.xz
pcitool-d60dd48eec0ef5d7bf2feca9b3f06374a2f444aa.zip
Protect access to the DMA engine with locks
Diffstat (limited to 'pcilib/pci.c')
-rw-r--r--pcilib/pci.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/pcilib/pci.c b/pcilib/pci.c
index 6078a6e..4351c1e 100644
--- a/pcilib/pci.c
+++ b/pcilib/pci.c
@@ -337,6 +337,7 @@ void pcilib_close(pcilib_t *ctx) {
pcilib_bar_t i;
if (ctx) {
+ pcilib_dma_engine_t dma;
const pcilib_model_description_t *model_info = pcilib_get_model_description(ctx);
const pcilib_event_api_description_t *eapi = model_info->api;
const pcilib_dma_api_description_t *dapi = ctx->dma.api;
@@ -344,6 +345,13 @@ void pcilib_close(pcilib_t *ctx) {
if ((eapi)&&(eapi->free)) eapi->free(ctx->event_ctx);
if ((dapi)&&(dapi->free)) dapi->free(ctx->dma_ctx);
+ for (dma = 0; dma < PCILIB_MAX_DMA_ENGINES; dma++) {
+ if (ctx->dma_rlock[dma])
+ pcilib_return_lock(ctx, PCILIB_LOCK_FLAGS_DEFAULT, ctx->dma_rlock[dma]);
+ if (ctx->dma_wlock[dma])
+ pcilib_return_lock(ctx, PCILIB_LOCK_FLAGS_DEFAULT, ctx->dma_wlock[dma]);
+ }
+
pcilib_free_register_banks(ctx);
if (ctx->register_ctx)