[zaptel-commits] sruffell: branch sruffell/voicebus r3810 - /team/sruffell/voicebus/voicebus.c
SVN commits to the Zaptel project
zaptel-commits at lists.digium.com
Wed Feb 6 15:59:36 CST 2008
Author: sruffell
Date: Wed Feb 6 15:59:35 2008
New Revision: 3810
URL: http://svn.digium.com/view/zaptel?view=rev&rev=3810
Log:
- Ensure that the cache-line size is set properly in the interface.
- Various minor cleanups.
Modified:
team/sruffell/voicebus/voicebus.c
Modified: team/sruffell/voicebus/voicebus.c
URL: http://svn.digium.com/view/zaptel/team/sruffell/voicebus/voicebus.c?view=diff&rev=3810&r1=3809&r2=3810
==============================================================================
--- team/sruffell/voicebus/voicebus.c (original)
+++ team/sruffell/voicebus/voicebus.c Wed Feb 6 15:59:35 2008
@@ -527,11 +527,6 @@
{
void *vbb;
vbb = kmem_cache_alloc(vb->buffer_cache, VOICEBUS_ALLOC_FLAGS);
- /*
- if (vbb) {
- memset(vbb, 0, vb->framesize);
- }
- */
return vbb;
}
@@ -549,12 +544,40 @@
/*! \brief Resets the voicebus hardware interface. */
static int
-voicebus_reset_interface(struct voicebus *vb)
+vb_reset_interface(struct voicebus *vb)
{
unsigned long timeout;
u32 reg;
+ u8 cache_line_size;
+ const u32 DEFAULT_PCI_ACCESS = 0xfff80002;
BUG_ON(in_interrupt());
- vb_setctl(vb, 0x0000, 0xfff88001);
+
+ if (pci_read_config_byte(vb->pdev, 0x0c, &cache_line_size)) {
+ VB_PRINTK(vb, ERR, "Failed read of cache line " \
+ "size from PCI configuration space.\n");
+ return -EIO;
+ }
+
+ switch (cache_line_size) {
+ case 0x08:
+ reg = DEFAULT_PCI_ACCESS | (0x1 << 14);
+ break;
+ case 0x10:
+ reg = DEFAULT_PCI_ACCESS | (0x2 << 14);
+ break;
+ case 0x20:
+ reg = DEFAULT_PCI_ACCESS | (0x3 << 14);
+ break;
+ default:
+ VB_PRINTK(vb, WARNING, "Host system set a cache size "\
+ "of %d which is not supported. " \
+ "Disabling memory write line and memory read line.",
+ cache_line_size);
+ reg = 0xfe584202;
+ break;
+ }
+
+ vb_setctl(vb, 0x0000, reg | 1);
timeout = jiffies + HZ/10; /* 100ms interval */
do {
reg = vb_getctl(vb, 0x0000);
@@ -569,7 +592,6 @@
vb_cleanup_descriptors(vb, &vb->txd);
vb_cleanup_descriptors(vb, &vb->rxd);
- vb_setctl(vb, 0x0000, 0xfff88000);
/* Pass bad packets, runt packets, disable SQE function,
* store-and-forward */
vb_setctl(vb, 0x0030, 0x00280048);
@@ -753,7 +775,7 @@
/*!
* \brief Instruct the hardware to check for a new tx descriptor.
*/
-static void
+inline static void
__vb_tx_demand_poll(struct voicebus *vb)
{
__vb_setctl(vb, 0x0008, 0x00000000);
@@ -764,7 +786,7 @@
* descriptor.
*/
static void
-voicebus_tx_demand_poll(struct voicebus *vb)
+vb_tx_demand_poll(struct voicebus *vb)
{
LOCKS_VOICEBUS;
VBLOCK(vb);
@@ -776,14 +798,14 @@
* \brief Command the hardware to check if it owns the next receive
* descriptor.
*/
+inline static void
+__vb_rx_demand_poll(struct voicebus *vb)
+{
+ __vb_setctl(vb, 0x0010, 0x00000000);
+}
+
static void
-__vb_rx_demand_poll(struct voicebus *vb)
-{
- __vb_setctl(vb, 0x0010, 0x00000000);
-}
-
-static void
-voicebus_rx_demand_poll(struct voicebus *vb)
+vb_rx_demand_poll(struct voicebus *vb)
{
LOCKS_VOICEBUS;
VBLOCK(vb);
@@ -818,9 +840,6 @@
* When the VoiceBus interface is started, it is actively transferring
* frames to and from the backend of the card. This means the card will
* generate interrupts.
- *
- * Before calling this function, callers should have at least two buffers
- * queued for transmit.
*
* This function should only be called from process context, with interrupts
* enabled, since it can sleep while running the self checks.
@@ -842,7 +861,7 @@
return -EBUSY;
}
- if ((ret=voicebus_reset_interface(vb))) {
+ if ((ret=vb_reset_interface(vb))) {
return ret;
}
@@ -1010,7 +1029,7 @@
#elif VOICEBUS_DEFERRED == TASKLET
tasklet_kill(&vb->tasklet);
#endif
- voicebus_reset_interface(vb);
+ vb_reset_interface(vb);
#if VOICEBUS_DEFERRED != TIMER
free_irq(vb->pdev->irq, vb);
#endif
@@ -1231,8 +1250,8 @@
}
if (unlikely(underrun)) {
- voicebus_rx_demand_poll(vb);
- voicebus_tx_demand_poll(vb);
+ vb_rx_demand_poll(vb);
+ vb_tx_demand_poll(vb);
clear_bit(TX_UNDERRUN, &vb->flags);
}
@@ -1349,7 +1368,8 @@
*vbp = NULL;
vb = kmalloc(sizeof(*vb), GFP_KERNEL);
if (NULL == vb) {
- VB_PRINTK(vb, DEBUG, "Failed to allocate memory for voicebus interface.\n");
+ VB_PRINTK(vb, DEBUG, "Failed to allocate memory for voicebus "\
+ "interface.\n");
retval = -ENOMEM;
goto cleanup;
}
More information about the zaptel-commits
mailing list