summaryrefslogtreecommitdiffstats
path: root/pcilib/kmem.c
diff options
context:
space:
mode:
authorzilio nicolas <nicolas.zilio@kit.edu>2015-08-26 14:45:18 +0200
committerzilio nicolas <nicolas.zilio@kit.edu>2015-08-26 14:45:18 +0200
commit1e5f0b6d5e02c0dc11bedefa92fc3c5bb406845a (patch)
treea978bd11f64f619ee8f40e42e73a582754c122de /pcilib/kmem.c
parent0f298bd861ac8d847f33d6b8bc73b089d2749bbb (diff)
parent6bad94bb8546a3a5595d340e7a2d809635e3bd5d (diff)
downloadpcitool-1e5f0b6d5e02c0dc11bedefa92fc3c5bb406845a.tar.gz
pcitool-1e5f0b6d5e02c0dc11bedefa92fc3c5bb406845a.tar.bz2
pcitool-1e5f0b6d5e02c0dc11bedefa92fc3c5bb406845a.tar.xz
pcitool-1e5f0b6d5e02c0dc11bedefa92fc3c5bb406845a.zip
pull from server
Diffstat (limited to 'pcilib/kmem.c')
-rw-r--r--pcilib/kmem.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/pcilib/kmem.c b/pcilib/kmem.c
index 8560eae..b1d2c5c 100644
--- a/pcilib/kmem.c
+++ b/pcilib/kmem.c
@@ -79,9 +79,16 @@ pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type
}
memset(kbuf, 0, sizeof(pcilib_kmem_list_t) + nmemb * sizeof(pcilib_kmem_addr_t));
-
+
+ err = pcilib_lock_global(ctx);
+ if (err) {
+ pcilib_error("Error (%i) acquiring mmap lock", err);
+ return NULL;
+ }
+
ret = ioctl( ctx->handle, PCIDRIVER_IOC_MMAP_MODE, PCIDRIVER_MMAP_KMEM );
if (ret) {
+ pcilib_unlock_global(ctx);
pcilib_error("PCIDRIVER_IOC_MMAP_MODE ioctl have failed");
return NULL;
}
@@ -169,6 +176,9 @@ pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type
kbuf->buf.blocks[i].mmap_offset = kh.pa & ctx->page_mask;
}
+ pcilib_unlock_global(ctx);
+
+
//This is possible in the case of error (nothing is allocated yet) or if buffers are not reused
if (persistent < 0) persistent = 0;
if (hardware < 0) hardware = 0;