From 1f75a7278184199651e5555e56d2c1d524d925e0 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Mon, 8 Aug 2016 09:59:45 -0700 Subject: [PATCH] ioat: No longer abstract away pthread calls pthreads are widely supported and are available on any platform we currently foresee porting to. Use that API instead of attempting to abstract it away to simplify the code. Change-Id: I28123d427ea8da07c6329b0233f0702f2d85c2a0 Signed-off-by: Ben Walker --- lib/ioat/ioat.c | 14 ++++++++------ lib/ioat/ioat_impl.h | 6 ------ test/lib/ioat/unit/ioat_impl.h | 6 ------ 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/lib/ioat/ioat.c b/lib/ioat/ioat.c index a4ad7e3a0..e6b7e2aed 100644 --- a/lib/ioat/ioat.c +++ b/lib/ioat/ioat.c @@ -34,13 +34,15 @@ #include "ioat_internal.h" #include "ioat_pci.h" +#include + struct ioat_driver { - ioat_mutex_t lock; + pthread_mutex_t lock; TAILQ_HEAD(, spdk_ioat_chan) attached_chans; }; static struct ioat_driver g_ioat_driver = { - .lock = IOAT_MUTEX_INITIALIZER, + .lock = PTHREAD_MUTEX_INITIALIZER, .attached_chans = TAILQ_HEAD_INITIALIZER(g_ioat_driver.attached_chans), }; @@ -532,7 +534,7 @@ spdk_ioat_probe(void *cb_ctx, spdk_ioat_probe_cb probe_cb, spdk_ioat_attach_cb a int rc; struct ioat_enum_ctx enum_ctx; - ioat_mutex_lock(&g_ioat_driver.lock); + pthread_mutex_lock(&g_ioat_driver.lock); enum_ctx.probe_cb = probe_cb; enum_ctx.attach_cb = attach_cb; @@ -540,7 +542,7 @@ spdk_ioat_probe(void *cb_ctx, spdk_ioat_probe_cb probe_cb, spdk_ioat_attach_cb a rc = ioat_pci_enumerate(ioat_enum_cb, &enum_ctx); - ioat_mutex_unlock(&g_ioat_driver.lock); + pthread_mutex_unlock(&g_ioat_driver.lock); return rc; } @@ -553,9 +555,9 @@ spdk_ioat_detach(struct spdk_ioat_chan *ioat) /* ioat should be in the free list (not registered to a thread) * when calling ioat_detach(). */ - ioat_mutex_lock(&driver->lock); + pthread_mutex_lock(&driver->lock); TAILQ_REMOVE(&driver->attached_chans, ioat, tailq); - ioat_mutex_unlock(&driver->lock); + pthread_mutex_unlock(&driver->lock); ioat_channel_destruct(ioat); free(ioat); diff --git a/lib/ioat/ioat_impl.h b/lib/ioat/ioat_impl.h index 146fce3e4..24b55d8fa 100644 --- a/lib/ioat/ioat_impl.h +++ b/lib/ioat/ioat_impl.h @@ -301,10 +301,4 @@ ioat_pci_enumerate(int (*enum_cb)(void *enum_ctx, struct spdk_pci_device *pci_de #endif /* !SPDK_CONFIG_PCIACCESS */ -typedef pthread_mutex_t ioat_mutex_t; - -#define ioat_mutex_lock pthread_mutex_lock -#define ioat_mutex_unlock pthread_mutex_unlock -#define IOAT_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER - #endif /* __IOAT_IMPL_H__ */ diff --git a/test/lib/ioat/unit/ioat_impl.h b/test/lib/ioat/unit/ioat_impl.h index 8d07f0249..a3048d1e7 100644 --- a/test/lib/ioat/unit/ioat_impl.h +++ b/test/lib/ioat/unit/ioat_impl.h @@ -50,10 +50,4 @@ ioat_pcicfg_unmap_bar(void *devhandle, uint32_t bar, void *addr) return 0; } -typedef pthread_mutex_t ioat_mutex_t; - -#define ioat_mutex_lock pthread_mutex_lock -#define ioat_mutex_unlock pthread_mutex_unlock -#define IOAT_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER - #endif /* __IOAT_IMPL_H__ */