vpmadt032: Convert ifacelock from rwlock to plain spinlock.

rwlock is slower than normal spinlocks and this lock is rarely contended
for.  Also noticed that the vpmadt032_module_init function is now (was
already) redundant since all the elements initialized in it were already
initialized.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Kinsey Moore <kmoore@digium.com>
Acked-By: Russ Meyerriecks <rmeyerriecks@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9538 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
Shaun Ruffell
2010-12-15 17:53:25 +00:00
parent 9292e6f0ad
commit b7cf1d9c02
3 changed files with 7 additions and 21 deletions

View File

@@ -49,7 +49,7 @@
#include "voicebus.h"
#include "vpmadtreg.h"
static rwlock_t ifacelock;
static DEFINE_SPINLOCK(ifacelock);
static struct vpmadt032 *ifaces[MAX_DSP_CORES];
#define vpm_info(vpm, format, arg...) \
@@ -59,13 +59,13 @@ static inline struct vpmadt032 *find_iface(const unsigned short dspid)
{
struct vpmadt032 *ret;
read_lock(&ifacelock);
spin_lock(&ifacelock);
if (ifaces[dspid]) {
ret = ifaces[dspid];
} else {
ret = NULL;
}
read_unlock(&ifacelock);
spin_unlock(&ifacelock);
return ret;
}
@@ -539,7 +539,7 @@ vpmadt032_alloc(struct vpmadt032_options *options, const char *board_name)
/* Place this structure in the ifaces array so that the DspId from the
* Gpak Library can be used to locate it. */
write_lock(&ifacelock);
spin_lock(&ifacelock);
for (i=0; i<MAX_DSP_CORES; ++i) {
if (NULL == ifaces[i]) {
ifaces[i] = vpm;
@@ -547,7 +547,7 @@ vpmadt032_alloc(struct vpmadt032_options *options, const char *board_name)
break;
}
}
write_unlock(&ifacelock);
spin_unlock(&ifacelock);
if (-1 == vpm->dspid) {
kfree(vpm);
@@ -822,20 +822,13 @@ void vpmadt032_free(struct vpmadt032 *vpm)
}
BUG_ON(ifaces[vpm->dspid] != vpm);
write_lock(&ifacelock);
spin_lock(&ifacelock);
ifaces[vpm->dspid] = NULL;
write_unlock(&ifacelock);
spin_unlock(&ifacelock);
kfree(vpm);
}
EXPORT_SYMBOL(vpmadt032_free);
int vpmadt032_module_init(void)
{
rwlock_init(&ifacelock);
memset(ifaces, 0, sizeof(ifaces));
return 0;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* gpakReadDspMemory - Read DSP memory.
*

View File

@@ -191,8 +191,6 @@ static inline void vpmadt032_resend(struct vpmadt032 *vpm)
}
int vpmadt032_module_init(void);
typedef __u16 DSP_WORD; /* 16 bit DSP word */
typedef __u32 DSP_ADDRESS; /* 32 bit DSP address */
typedef __u32 GPAK_FILE_ID; /* G.PAK Download file identifier */

View File

@@ -1979,17 +1979,12 @@ EXPORT_SYMBOL(vpmadtreg_unregister);
static int __init voicebus_module_init(void)
{
int res;
/* This registration with dahdi.ko will fail since the span is not
* defined, but it will make sure that this module is a dependency of
* dahdi.ko, so that when it is being unloded, this module will be
* unloaded as well. */
dahdi_register(NULL, 0);
spin_lock_init(&loader_list_lock);
res = vpmadt032_module_init();
if (res)
return res;
return 0;
}