diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-08-05 18:11:59 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-08-05 18:11:59 +0200 |
commit | 7c5897933f4f64594602b2e38264af705c061754 (patch) | |
tree | b6051387f6e2ff6c995141ba9bcb6960ecdd0b6a /pcilib/bar.c | |
parent | f2e47ba725cc7ba477d3a788addc974f2b18d36f (diff) | |
download | pcitool-7c5897933f4f64594602b2e38264af705c061754.tar.gz pcitool-7c5897933f4f64594602b2e38264af705c061754.tar.bz2 pcitool-7c5897933f4f64594602b2e38264af705c061754.tar.xz pcitool-7c5897933f4f64594602b2e38264af705c061754.zip |
Use global locks to protect kmem allocation to prevent race while allocating simmultaneously locking kmem pages and any other type of kmem
Diffstat (limited to 'pcilib/bar.c')
-rw-r--r-- | pcilib/bar.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pcilib/bar.c b/pcilib/bar.c index 17828a8..418f864 100644 --- a/pcilib/bar.c +++ b/pcilib/bar.c @@ -80,7 +80,7 @@ void *pcilib_map_bar(pcilib_t *ctx, pcilib_bar_t bar) { if (ctx->bar_space[bar]) return ctx->bar_space[bar]; - err = pcilib_lock(ctx->locks.mmap); + err = pcilib_lock_global(ctx); if (err) { pcilib_error("Error (%i) acquiring mmap lock", err); return NULL; @@ -88,14 +88,14 @@ void *pcilib_map_bar(pcilib_t *ctx, pcilib_bar_t bar) { ret = ioctl( ctx->handle, PCIDRIVER_IOC_MMAP_MODE, PCIDRIVER_MMAP_PCI ); if (ret) { - pcilib_unlock(ctx->locks.mmap); + pcilib_unlock_global(ctx); pcilib_error("PCIDRIVER_IOC_MMAP_MODE ioctl have failed", bar); return NULL; } ret = ioctl( ctx->handle, PCIDRIVER_IOC_MMAP_AREA, PCIDRIVER_BAR0 + bar ); if (ret) { - pcilib_unlock(ctx->locks.mmap); + pcilib_unlock_global(ctx); pcilib_error("PCIDRIVER_IOC_MMAP_AREA ioctl have failed for bank %i", bar); return NULL; } @@ -106,7 +106,8 @@ void *pcilib_map_bar(pcilib_t *ctx, pcilib_bar_t bar) { #else res = mmap( 0, board_info->bar_length[bar], PROT_WRITE | PROT_READ, MAP_SHARED, ctx->handle, 0 ); #endif - pcilib_unlock(ctx->locks.mmap); + + pcilib_unlock_global(ctx); if ((!res)||(res == MAP_FAILED)) { pcilib_error("Failed to mmap data bank %i", bar); |