[dahdi-commits] dahdi/linux.git branch "master" updated.
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Mon Sep 30 08:31:20 CDT 2013
branch "master" has been updated
via 745118acb9205e502c145963f7c7afb7f4da10b3 (commit)
from ce3f1f26506c27e01aa0e83f93d3c6dd73631025 (commit)
Summary of changes:
drivers/dahdi/xpp/xbus-core.c | 22 ++++++++++++++++++++--
drivers/dahdi/xpp/xbus-sysfs.c | 9 +++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit 745118acb9205e502c145963f7c7afb7f4da10b3
Author: Oron Peled <oron.peled at xorcom.com>
Date: Sun Sep 29 13:20:38 2013 +0200
xpp: Serialize dahdi registration
xpp: Serialize dahdi registration: Cause races under highly-parallel
workloads (with dahdi_autoreg=0).
Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c
index c2fb00f..7a7c368 100644
--- a/drivers/dahdi/xpp/xbus-core.c
+++ b/drivers/dahdi/xpp/xbus-core.c
@@ -24,6 +24,7 @@
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/sched.h>
+#include <linux/mutex.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#ifdef PROTOCOL_DEBUG
@@ -937,6 +938,8 @@ static void xbus_free_ddev(xbus_t *xbus)
xbus->ddev = NULL;
}
+static DEFINE_MUTEX(dahdi_registration_mutex);
+
int xbus_register_dahdi_device(xbus_t *xbus)
{
int i;
@@ -944,6 +947,11 @@ int xbus_register_dahdi_device(xbus_t *xbus)
int ret;
XBUS_DBG(DEVICES, xbus, "Entering %s\n", __func__);
+ ret = mutex_lock_interruptible(&dahdi_registration_mutex);
+ if (ret < 0) {
+ XBUS_ERR(xbus, "dahdi_registration_mutex already taken\n");
+ goto err;
+ }
if (xbus_is_registered(xbus)) {
XBUS_ERR(xbus, "Already registered to DAHDI\n");
WARN_ON(1);
@@ -1008,17 +1016,26 @@ int xbus_register_dahdi_device(xbus_t *xbus)
xpd_dahdi_postregister(xpd);
}
}
- return 0;
+ ret = 0;
+out:
+ mutex_unlock(&dahdi_registration_mutex);
+ return ret;
err:
xbus_free_ddev(xbus);
- return ret;
+ goto out;
}
void xbus_unregister_dahdi_device(xbus_t *xbus)
{
int i;
+ int ret;
XBUS_NOTICE(xbus, "%s\n", __func__);
+ ret = mutex_lock_interruptible(&dahdi_registration_mutex);
+ if (ret < 0) {
+ XBUS_ERR(xbus, "dahdi_registration_mutex already taken\n");
+ return;
+ }
for (i = 0; i < MAX_XPDS; i++) {
xpd_t *xpd = xpd_of(xbus, i);
xpd_dahdi_preunregister(xpd);
@@ -1033,6 +1050,7 @@ void xbus_unregister_dahdi_device(xbus_t *xbus)
xpd_t *xpd = xpd_of(xbus, i);
xpd_dahdi_postunregister(xpd);
}
+ mutex_unlock(&dahdi_registration_mutex);
}
/*
diff --git a/drivers/dahdi/xpp/xbus-sysfs.c b/drivers/dahdi/xpp/xbus-sysfs.c
index ad58e15..956e765 100644
--- a/drivers/dahdi/xpp/xbus-sysfs.c
+++ b/drivers/dahdi/xpp/xbus-sysfs.c
@@ -23,6 +23,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/errno.h>
+#include <linux/mutex.h>
#include <linux/proc_fs.h>
#ifdef PROTOCOL_DEBUG
#include <linux/ctype.h>
@@ -582,6 +583,8 @@ static DEVICE_ATTR_READER(span_show, dev, buf)
return len;
}
+static DEFINE_MUTEX(span_store_mutex);
+
/*
* For backward compatibility with old dahdi-tools
* Remove after dahdi_registration is upgraded
@@ -603,6 +606,11 @@ static DEVICE_ATTR_WRITER(span_store, dev, buf, count)
return -ENODEV;
XPD_DBG(DEVICES, xpd, "%s -- deprecated (should use pinned-spans)\n",
(dahdi_reg) ? "register" : "unregister");
+ ret = mutex_lock_interruptible(&span_store_mutex);
+ if (ret < 0) {
+ XBUS_ERR(xpd->xbus, "span_store_mutex already taken\n");
+ return ret;
+ }
if (xbus_is_registered(xpd->xbus)) {
if (dahdi_reg) {
XPD_DBG(DEVICES, xpd,
@@ -620,6 +628,7 @@ static DEVICE_ATTR_WRITER(span_store, dev, buf, count)
xbus_register_dahdi_device(xpd->xbus);
}
}
+ mutex_unlock(&span_store_mutex);
return count;
}
-----------------------------------------------------------------------
--
dahdi/linux.git
More information about the dahdi-commits
mailing list