[dahdi-commits] fjoe: freebsd/trunk r8500 - /freebsd/trunk/drivers/dahdi/dahdi_dynamic.c
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Mon Apr 12 09:49:30 CDT 2010
Author: fjoe
Date: Mon Apr 12 09:49:28 2010
New Revision: 8500
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8500
Log:
- Fix locking: return back rwlocks
- Use safe list iteration macro in dahdi_dynamic_unregister()
Modified:
freebsd/trunk/drivers/dahdi/dahdi_dynamic.c
Modified: freebsd/trunk/drivers/dahdi/dahdi_dynamic.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_dynamic.c?view=diff&rev=8500&r1=8499&r2=8500
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_dynamic.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_dynamic.c Mon Apr 12 09:49:28 2010
@@ -47,28 +47,6 @@
#include <dahdi/kernel.h>
-#if defined(__FreeBSD__)
-static DEFINE_SPINLOCK(dlock);
-
-static inline void
-rcu_read_lock(void)
-{
- spin_lock(&dlock);
-}
-
-static inline void
-rcu_read_unlock(void)
-{
- spin_unlock(&dlock);
-}
-
-#define synchronize_rcu()
-
-#define list_add_rcu(e, l) list_add(e, l)
-#define list_del_rcu(e) list_del(e)
-#define list_for_each_entry_rcu(e, l, elem) list_for_each_entry(e, l, elem)
-#endif
-
/*
* Tasklets provide better system interactive response at the cost of the
* possibility of losing a frame of data at very infrequent intervals. If
@@ -148,7 +126,11 @@
};
#ifdef DEFINE_SPINLOCK
+#if defined(__FreeBSD__)
+static DEFINE_RWLOCK(dspan_lock);
+#else
static DEFINE_SPINLOCK(dspan_lock);
+#endif
static DEFINE_SPINLOCK(driver_lock);
#else
static spinlock_t dspan_lock = SPIN_LOCK_UNLOCKED;
@@ -157,6 +139,25 @@
static _LIST_HEAD(dspan_list);
static _LIST_HEAD(driver_list);
+
+#if defined(__FreeBSD__)
+static inline void
+rcu_read_lock(void)
+{
+ read_lock(&dspan_lock);
+}
+
+static inline void
+rcu_read_unlock(void)
+{
+ read_unlock(&dspan_lock);
+}
+
+#define list_add_rcu(e, l) list_add(e, l)
+#define list_del_rcu(e) list_del(e)
+#define _list_temp(e) __CONCAT(e##_tmp_, __LINE__)
+#define list_for_each_entry_rcu(e, l, elem) __typeof__(e) _list_temp(e); list_for_each_entry_safe(e, _list_temp(e), l, elem)
+#endif
static int debug = 0;
@@ -512,10 +513,9 @@
return -EBUSY;
}
- spin_lock_irqsave(&dspan_lock, flags);
+ write_lock_irqsave(&dspan_lock, flags);
list_del_rcu(&z->list);
- spin_unlock_irqrestore(&dspan_lock, flags);
- synchronize_rcu();
+ write_unlock_irqrestore(&dspan_lock, flags);
/* Destroy it */
dynamic_destroy(z);
@@ -678,9 +678,9 @@
return -EINVAL;
}
- spin_lock_irqsave(&dspan_lock, flags);
+ write_lock_irqsave(&dspan_lock, flags);
list_add_rcu(&z->list, &dspan_list);
- spin_unlock_irqrestore(&dspan_lock, flags);
+ write_unlock_irqrestore(&dspan_lock, flags);
checkmaster();
@@ -760,20 +760,16 @@
spin_lock_irqsave(&driver_lock, flags);
list_del_rcu(&dri->list);
spin_unlock_irqrestore(&driver_lock, flags);
- synchronize_rcu();
-
- list_for_each_entry(z, &dspan_list, list) {
+
+ list_for_each_entry_rcu(z, &dspan_list, list) {
if (z->driver == dri) {
- spin_lock_irqsave(&dspan_lock, flags);
+ write_lock_irqsave(&dspan_lock, flags);
list_del_rcu(&z->list);
- spin_unlock_irqrestore(&dspan_lock, flags);
- synchronize_rcu();
-
- if (!z->usecount) {
- spin_unlock_irqrestore(&dlock, flags);
+ write_unlock_irqrestore(&dspan_lock, flags);
+
+ if (!z->usecount)
dynamic_destroy(z);
- spin_lock_irqsave(&dlock, flags);
- } else
+ else
z->dead = 1;
}
}
More information about the dahdi-commits
mailing list