[svn-commits] sruffell: linux/trunk r7779 - in /linux/trunk/drivers/dahdi: voicebus/ wctdm2...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Jan 8 14:48:09 CST 2010
Author: sruffell
Date: Fri Jan 8 14:48:03 2010
New Revision: 7779
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7779
Log:
voicebus: Remove framesize, buffer_cache, and cache_line members from struct.
Framesize is the same on all the clients, so it can be removed from the 'struct
voicebus' (and changed back again if needed). Since the framesize is the same,
each board doesn't need it's own buffer_cache, and cache_line is only used
during startup and can be read directly from pci configuration space, so we
don't need to keep it around in our context.
Modified:
linux/trunk/drivers/dahdi/voicebus/voicebus.c
linux/trunk/drivers/dahdi/voicebus/voicebus.h
linux/trunk/drivers/dahdi/wctdm24xxp/base.c
linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
linux/trunk/drivers/dahdi/wcte12xp/base.c
Modified: linux/trunk/drivers/dahdi/voicebus/voicebus.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/voicebus/voicebus.c?view=diff&rev=7779&r1=7778&r2=7779
==============================================================================
--- linux/trunk/drivers/dahdi/voicebus/voicebus.c (original)
+++ linux/trunk/drivers/dahdi/voicebus/voicebus.c Fri Jan 8 14:48:03 2010
@@ -95,6 +95,12 @@
#define OWN_BIT (1 << 31)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+static kmem_cache_t *buffer_cache;
+#else
+static struct kmem_cache *buffer_cache;
+#endif
+
/* In memory structure shared by the host and the adapter. */
struct voicebus_descriptor {
volatile __le32 des0;
@@ -188,6 +194,7 @@
int i;
struct voicebus_descriptor *d;
const u32 END_OF_RING = 0x02000000;
+ u8 cache_line_size;
BUG_ON(!dl);
@@ -197,9 +204,15 @@
* cache-line sizes that we support.
*
*/
- if ((0x08 == vb->cache_line_size) || (0x10 == vb->cache_line_size) ||
- (0x20 == vb->cache_line_size)) {
- dl->padding = (vb->cache_line_size*sizeof(u32)) - sizeof(*d);
+ if (pci_read_config_byte(vb->pdev, 0x0c, &cache_line_size)) {
+ dev_err(&vb->pdev->dev, "Failed read of cache line "
+ "size from PCI configuration space.\n");
+ return -EIO;
+ }
+
+ if ((0x08 == cache_line_size) || (0x10 == cache_line_size) ||
+ (0x20 == cache_line_size)) {
+ dl->padding = (cache_line_size*sizeof(u32)) - sizeof(*d);
} else {
dl->padding = 0;
}
@@ -226,10 +239,11 @@
vb_initialize_tx_descriptors(struct voicebus *vb)
{
int i;
- int des1 = 0xe4800000 | vb->framesize;
+ int des1 = 0xe4800000 | VOICEBUS_SFRAME_SIZE;
struct voicebus_descriptor *d;
struct voicebus_descriptor_list *dl = &vb->txd;
const u32 END_OF_RING = 0x02000000;
+ u8 cache_line_size;
WARN_ON(!dl);
WARN_ON((NULL == vb->idle_vbb) || (0 == vb->idle_vbb_dma_addr));
@@ -240,9 +254,15 @@
* cache-line sizes that we support.
*
*/
- if ((0x08 == vb->cache_line_size) || (0x10 == vb->cache_line_size) ||
- (0x20 == vb->cache_line_size)) {
- dl->padding = (vb->cache_line_size*sizeof(u32)) - sizeof(*d);
+ if (pci_read_config_byte(vb->pdev, 0x0c, &cache_line_size)) {
+ dev_err(&vb->pdev->dev, "Failed read of cache line "
+ "size from PCI configuration space.\n");
+ return -EIO;
+ }
+
+ if ((0x08 == cache_line_size) || (0x10 == cache_line_size) ||
+ (0x20 == cache_line_size)) {
+ dl->padding = (cache_line_size*sizeof(u32)) - sizeof(*d);
} else {
dl->padding = 0;
}
@@ -270,7 +290,7 @@
vb_initialize_rx_descriptors(struct voicebus *vb)
{
return vb_initialize_descriptors(
- vb, &vb->rxd, vb->framesize, DMA_FROM_DEVICE);
+ vb, &vb->rxd, VOICEBUS_SFRAME_SIZE, DMA_FROM_DEVICE);
}
/*! \brief Use to set the minimum number of buffers queued to the hardware
@@ -398,7 +418,7 @@
if (d->buffer1 && (d->buffer1 != vb->idle_vbb_dma_addr)) {
WARN_ON(!dl->pending[i]);
dma_unmap_single(&vb->pdev->dev, d->buffer1,
- vb->framesize, DMA_TO_DEVICE);
+ VOICEBUS_SFRAME_SIZE, DMA_TO_DEVICE);
voicebus_free(vb, dl->pending[i]);
}
d->buffer1 = vb->idle_vbb_dma_addr;
@@ -424,7 +444,7 @@
d = vb_descriptor(dl, i);
if (d->buffer1) {
dma_unmap_single(&vb->pdev->dev, d->buffer1,
- vb->framesize, DMA_FROM_DEVICE);
+ VOICEBUS_SFRAME_SIZE, DMA_FROM_DEVICE);
d->buffer1 = 0;
BUG_ON(!dl->pending[i]);
voicebus_free(vb, dl->pending[i]);
@@ -546,7 +566,7 @@
voicebus_alloc(struct voicebus *vb)
{
void *vbb;
- vbb = kmem_cache_alloc(vb->buffer_cache, VOICEBUS_ALLOC_FLAGS);
+ vbb = kmem_cache_alloc(buffer_cache, VOICEBUS_ALLOC_FLAGS);
return vbb;
}
@@ -558,9 +578,16 @@
u32 reg;
u32 pci_access;
const u32 DEFAULT_PCI_ACCESS = 0xfff80002;
+ u8 cache_line_size;
BUG_ON(in_interrupt());
- switch (vb->cache_line_size) {
+ if (pci_read_config_byte(vb->pdev, 0x0c, &cache_line_size)) {
+ dev_err(&vb->pdev->dev, "Failed read of cache line "
+ "size from PCI configuration space.\n");
+ return -EIO;
+ }
+
+ switch (cache_line_size) {
case 0x08:
pci_access = DEFAULT_PCI_ACCESS | (0x1 << 14);
break;
@@ -575,7 +602,7 @@
dev_warn(&vb->pdev->dev, "Host system set a cache "
"size of %d which is not supported. "
"Disabling memory write line and memory "
- "read line.\n", vb->cache_line_size);
+ "read line.\n", cache_line_size);
}
pci_access = 0xfe584202;
break;
@@ -660,7 +687,7 @@
c = vbb;
printk(KERN_DEBUG "Packet %d\n", count);
printk(KERN_DEBUG "");
- for (x = 1; x <= vb->framesize; ++x) {
+ for (x = 1; x <= VOICEBUS_SFRAME_SIZE; ++x) {
printk("%02x ", c[x]);
if (x % 16 == 0)
printk("\n");
@@ -690,7 +717,7 @@
dl->pending[dl->tail] = vbb;
dl->tail = (++(dl->tail)) & DRING_MASK;
d->buffer1 = dma_map_single(&vb->pdev->dev, vbb,
- vb->framesize, DMA_TO_DEVICE);
+ VOICEBUS_SFRAME_SIZE, DMA_TO_DEVICE);
SET_OWNED(d); /* That's it until the hardware is done with it. */
atomic_inc(&dl->count);
return 0;
@@ -720,7 +747,7 @@
dl->pending[tail] = vbb;
dl->tail = (++tail) & DRING_MASK;
d->buffer1 = dma_map_single(&vb->pdev->dev, vbb,
- vb->framesize, DMA_FROM_DEVICE);
+ VOICEBUS_SFRAME_SIZE, DMA_FROM_DEVICE);
SET_OWNED(d); /* That's it until the hardware is done with it. */
atomic_inc(&dl->count);
return 0;
@@ -753,7 +780,7 @@
return NULL;
dma_unmap_single(&vb->pdev->dev, d->buffer1,
- vb->framesize, DMA_TO_DEVICE);
+ VOICEBUS_SFRAME_SIZE, DMA_TO_DEVICE);
vbb = dl->pending[head];
dl->head = (++head) & DRING_MASK;
@@ -777,7 +804,7 @@
return NULL;
dma_unmap_single(&vb->pdev->dev, d->buffer1,
- vb->framesize, DMA_FROM_DEVICE);
+ VOICEBUS_SFRAME_SIZE, DMA_FROM_DEVICE);
vbb = dl->pending[head];
dl->head = (++head) & DRING_MASK;
d->buffer1 = 0;
@@ -792,7 +819,7 @@
void
voicebus_free(struct voicebus *vb, void *vbb)
{
- kmem_cache_free(vb->buffer_cache, vbb);
+ kmem_cache_free(buffer_cache, vbb);
}
/*!
@@ -1079,10 +1106,9 @@
vb_free_descriptors(vb, &vb->txd);
vb_free_descriptors(vb, &vb->rxd);
if (vb->idle_vbb_dma_addr) {
- dma_free_coherent(&vb->pdev->dev, vb->framesize,
+ dma_free_coherent(&vb->pdev->dev, VOICEBUS_SFRAME_SIZE,
vb->idle_vbb, vb->idle_vbb_dma_addr);
}
- kmem_cache_destroy(vb->buffer_cache);
release_region(vb->iobase, 0xff);
pci_disable_device(vb->pdev);
}
@@ -1220,7 +1246,7 @@
WARN_ON(d->buffer1 == vb->idle_vbb_dma_addr);
WARN_ON(!dl->pending[dl->head]);
dma_unmap_single(&vb->pdev->dev, d->buffer1,
- vb->framesize, DMA_TO_DEVICE);
+ VOICEBUS_SFRAME_SIZE, DMA_TO_DEVICE);
vbb = dl->pending[dl->head];
atomic_dec(&dl->count);
--behind;
@@ -1519,7 +1545,6 @@
BUG_ON(NULL == board_name);
BUG_ON(NULL == vb->ops);
BUG_ON(NULL == vb->pdev);
- BUG_ON(0 == vb->framesize);
BUG_ON(NULL == vb->debug);
/* ----------------------------------------------------------------
@@ -1555,30 +1580,6 @@
vb->timer.data = (unsigned long)vb;
#endif
- /* \todo This cache should be shared by all instances supported by
- * this driver. */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
- vb->buffer_cache = kmem_cache_create(board_name, vb->framesize, 0,
-#if defined(CONFIG_SLUB) && (LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 22))
- SLAB_HWCACHE_ALIGN | SLAB_STORE_USER, NULL, NULL);
-#else
- SLAB_HWCACHE_ALIGN, NULL, NULL);
-#endif
-#else
-#ifdef DEBUG
- vb->buffer_cache = kmem_cache_create(board_name, vb->framesize, 0,
- SLAB_HWCACHE_ALIGN | SLAB_STORE_USER |
- SLAB_POISON | SLAB_DEBUG_FREE, NULL);
-#else
- vb->buffer_cache = kmem_cache_create(board_name, vb->framesize, 0,
- SLAB_HWCACHE_ALIGN, NULL);
-#endif
-#endif
- if (NULL == vb->buffer_cache) {
- dev_err(&vb->pdev->dev, "Failed to allocate buffer cache.\n");
- goto cleanup;
- }
-
#ifdef CONFIG_VOICEBUS_SYSFS
dev_dbg(&vb->pdev->dev, "Creating sysfs attributes.\n");
retval = device_create_file(&vb->pdev->dev,
@@ -1597,12 +1598,6 @@
goto cleanup;
}
- if (pci_read_config_byte(vb->pdev, 0x0c, &vb->cache_line_size)) {
- dev_err(&vb->pdev->dev, "Failed read of cache line "
- "size from PCI configuration space.\n");
- goto cleanup;
- }
-
if (pci_enable_device(vb->pdev)) {
dev_err(&vb->pdev->dev, "Failed call to pci_enable_device.\n");
retval = -EIO;
@@ -1624,7 +1619,7 @@
goto cleanup;
}
- vb->idle_vbb = dma_alloc_coherent(&vb->pdev->dev, vb->framesize,
+ vb->idle_vbb = dma_alloc_coherent(&vb->pdev->dev, VOICEBUS_SFRAME_SIZE,
&vb->idle_vbb_dma_addr, GFP_KERNEL);
retval = vb_initialize_tx_descriptors(vb);
@@ -1673,11 +1668,8 @@
if (vb->rxd.desc)
vb_free_descriptors(vb, &vb->rxd);
- dma_free_coherent(&vb->pdev->dev, vb->framesize,
+ dma_free_coherent(&vb->pdev->dev, VOICEBUS_SFRAME_SIZE,
vb->idle_vbb, vb->idle_vbb_dma_addr);
-
- if (vb->buffer_cache)
- kmem_cache_destroy(vb->buffer_cache);
if (vb->iobase)
release_region(vb->iobase, 0xff);
@@ -1777,11 +1769,41 @@
int __init voicebus_module_init(void)
{
int res;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
+ buffer_cache = kmem_cache_create(THIS_MODULE->name,
+ VOICEBUS_SFRAME_SIZE, 0,
+#if defined(CONFIG_SLUB) && (LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 22))
+ SLAB_HWCACHE_ALIGN |
+ SLAB_STORE_USER, NULL,
+ NULL);
+#else
+ SLAB_HWCACHE_ALIGN, NULL,
+ NULL);
+#endif
+#else
+#ifdef DEBUG
+ buffer_cache = kmem_cache_create(THIS_MODULE->name,
+ VOICEBUS_SFRAME_SIZE, 0,
+ SLAB_HWCACHE_ALIGN | SLAB_STORE_USER |
+ SLAB_POISON | SLAB_DEBUG_FREE, NULL);
+#else
+ buffer_cache = kmem_cache_create(THIS_MODULE->name,
+ VOICEBUS_SFRAME_SIZE, 0,
+ SLAB_HWCACHE_ALIGN, NULL);
+#endif
+#endif
+
+ if (NULL == buffer_cache) {
+ printk(KERN_ERR "%s: Failed to allocate buffer cache.\n",
+ THIS_MODULE->name);
+ return -ENOMEM;
+ }
+
/* 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.
- */
+ * unloaded as well. */
dahdi_register(0, 0);
INIT_LIST_HEAD(&binary_loader_list);
spin_lock_init(&loader_list_lock);
@@ -1793,6 +1815,7 @@
void __exit voicebus_module_cleanup(void)
{
+ kmem_cache_destroy(buffer_cache);
WARN_ON(!list_empty(&binary_loader_list));
}
Modified: linux/trunk/drivers/dahdi/voicebus/voicebus.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/voicebus/voicebus.h?view=diff&rev=7779&r1=7778&r2=7779
==============================================================================
--- linux/trunk/drivers/dahdi/voicebus/voicebus.h (original)
+++ linux/trunk/drivers/dahdi/voicebus/voicebus.h Fri Jan 8 14:48:03 2010
@@ -32,6 +32,8 @@
#define VOICEBUS_DEFAULT_LATENCY 3
#define VOICEBUS_DEFAULT_MAXLATENCY 25
#define VOICEBUS_MAXLATENCY_BUMP 6
+
+#define VOICEBUS_SFRAME_SIZE 1004
/*! The number of descriptors in both the tx and rx descriptor ring. */
#define DRING_SIZE (1 << 7) /* Must be a power of 2 */
@@ -78,18 +80,11 @@
struct voicebus {
struct pci_dev *pdev;
spinlock_t lock;
- u32 framesize;
- u8 cache_line_size;
struct voicebus_descriptor_list rxd;
struct voicebus_descriptor_list txd;
void *idle_vbb;
dma_addr_t idle_vbb_dma_addr;
const int *debug;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
- kmem_cache_t *buffer_cache;
-#else
- struct kmem_cache *buffer_cache;
-#endif
u32 iobase;
#if VOICEBUS_DEFERRED == WORKQUEUE
struct workqueue_struct *workqueue;
Modified: linux/trunk/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=7779&r1=7778&r2=7779
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/base.c Fri Jan 8 14:48:03 2010
@@ -63,6 +63,10 @@
#include "voicebus/GpakCust.h"
#include "voicebus/GpakApi.h"
+
+#if VOICEBUS_SFRAME_SIZE != SFRAME_SIZE
+#error SFRAME_SIZE must match the VOICEBUS_SFRAME_SIZE
+#endif
/*
Experimental max loop current limit for the proslic
@@ -3738,7 +3742,6 @@
pci_set_drvdata(pdev, wc);
wc->vb.ops = &voicebus_operations;
- wc->vb.framesize = SFRAME_SIZE;
wc->vb.pdev = pdev;
wc->vb.debug = &debug;
ret = voicebus_init(&wc->vb, wc->board_name);
Modified: linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h?view=diff&rev=7779&r1=7778&r2=7779
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h Fri Jan 8 14:48:03 2010
@@ -53,9 +53,9 @@
#define FLAG_3215 (1 << 0)
#define FLAG_EXPRESS (1 << 1)
-#define EFRAME_SIZE 108
-#define ERING_SIZE 16 /* Maximum ring size */
-#define EFRAME_GAP 20
+#define EFRAME_SIZE 108L
+#define ERING_SIZE 16L /* Maximum ring size */
+#define EFRAME_GAP 20L
#define SFRAME_SIZE ((EFRAME_SIZE * DAHDI_CHUNKSIZE) + (EFRAME_GAP * (DAHDI_CHUNKSIZE - 1)))
#define MAX_ALARMS 10
Modified: linux/trunk/drivers/dahdi/wcte12xp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wcte12xp/base.c?view=diff&rev=7779&r1=7778&r2=7779
==============================================================================
--- linux/trunk/drivers/dahdi/wcte12xp/base.c (original)
+++ linux/trunk/drivers/dahdi/wcte12xp/base.c Fri Jan 8 14:48:03 2010
@@ -48,6 +48,10 @@
#include "voicebus/GpakCust.h"
#include "voicebus/GpakApi.h"
+
+#if VOICEBUS_SFRAME_SIZE != SFRAME_SIZE
+#error VOICEBUS_SFRAME_SIZE != SFRAME_SIZE
+#endif
struct pci_driver te12xp_driver;
@@ -1791,7 +1795,6 @@
pci_set_drvdata(pdev, wc);
wc->vb.ops = &voicebus_operations;
wc->vb.pdev = pdev;
- wc->vb.framesize = SFRAME_SIZE;
wc->vb.debug = &debug;
res = voicebus_init(&wc->vb, wc->name);
if (res) {
More information about the svn-commits
mailing list