[dahdi-commits] sruffell: branch linux/sruffell/dahdi-linux-chainedvb r7307 - /linux/team/sru...

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Thu Oct 1 15:43:08 CDT 2009


Author: sruffell
Date: Thu Oct  1 15:42:58 2009
New Revision: 7307

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7307
Log:
wip: try moving the latency bump until later in the function and fix limit

Also add a temporary debug module parameter for the dahdi_voicebus module while
troubleshooting.  Interrupts aren't stopping anymore, but the 'softunderrun' is
now not properly detected.

Modified:
    linux/team/sruffell/dahdi-linux-chainedvb/drivers/dahdi/voicebus/voicebus.c

Modified: linux/team/sruffell/dahdi-linux-chainedvb/drivers/dahdi/voicebus/voicebus.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-chainedvb/drivers/dahdi/voicebus/voicebus.c?view=diff&rev=7307&r1=7306&r2=7307
==============================================================================
--- linux/team/sruffell/dahdi-linux-chainedvb/drivers/dahdi/voicebus/voicebus.c (original)
+++ linux/team/sruffell/dahdi-linux-chainedvb/drivers/dahdi/voicebus/voicebus.c Thu Oct  1 15:42:58 2009
@@ -29,6 +29,8 @@
 
 #define DEBUG
 #define HERE() printk(KERN_DEBUG "HERE: %s:%d\n", __FILE__, __LINE__)
+
+static int debug;
 
 #include <linux/version.h>
 #include <linux/slab.h>
@@ -136,6 +138,9 @@
 	dma_addr_t	dma_addr;
 	struct list_head node;
 	void 		*pending;
+#ifdef DEBUG
+	int		index;
+#endif
 };
 
 /**
@@ -415,6 +420,9 @@
 		d = kzalloc(sizeof(*d), GFP_KERNEL);
 		if (!d)
 			goto error_nomem;
+#ifdef DEBUG
+		d->index = i;
+#endif
 
 		d->desc = dma_alloc_coherent(&vb->pdev->dev, sizeof(*d->desc),
 					     &d->dma_addr, GFP_KERNEL);
@@ -462,10 +470,8 @@
 	}
 
 	list_for_each_entry(d, &vb->txd.list, node) {
-		/*
-		dev_dbg(&vb->pdev->dev, "desc: %p (next: %08x)\n",
-			(void*)d->desc, d->desc->buffer2);
-		*/
+		dev_dbg(&vb->pdev->dev, "desc: %p (next: %08x) idle: %08llx\n",
+			d->desc, d->desc->buffer2, (u64)vb->idle_vbb_dma_addr);
 		d->desc->buffer1 = vb->idle_vbb_dma_addr;
 		d->pending = vb->idle_vbb;
 		SET_OWNED(d->desc);
@@ -797,12 +803,10 @@
 
 	d = dl->tail;
 
-	/* 
-	if (printk_ratelimit())
-		dev_dbg(&vb->pdev->dev, "d->desc->buffer1 = %08x\n", d->desc->buffer1);
-	*/
 	/* Do not overwrite a buffer that is still in progress. */
 	if (unlikely(d->desc->buffer1 != vb->idle_vbb_dma_addr)) {
+		if (debug)
+			dev_dbg(&vb->pdev->dev, "overrun d->index = %d\n", d->index);
 		voicebus_free(vb, vbb);
 		return -EFAULT;
 	}
@@ -812,6 +816,9 @@
 	d->desc->buffer2 = dl->tail->dma_addr;
 	d->desc->buffer1 = dma_map_single(&vb->pdev->dev, vbb,
 					  vb->framesize, dl->direction);
+	if (debug)
+		dev_dbg(&vb->pdev->dev, "tail->index %d tail->buffer1 %08x (vbb:%p)\n", d->index, d->desc->buffer1, vbb);
+
 
 	/* That's it until the hardware is done with it. */
 	SET_OWNED(d->desc);
@@ -871,15 +878,16 @@
 	assert_in_vb_deferred(vb);
 	d = dl->head;
 
-	/*
-	if (printk_ratelimit()) {
-		dev_dbg(&vb->pdev->dev, "buffer1: %08x idle: %08x\n",
-			d->desc->buffer1, (u32)vb->idle_vbb_dma_addr);
-	}
-	*/
-
 	if (d->desc->buffer1 == vb->idle_vbb_dma_addr)
 		return NULL;
+
+	if (debug) {
+		if ((d->desc->des1 & 0x3ff) != vb->framesize) {
+			dev_dbg(&vb->pdev->dev, "*************************");
+		}
+		dev_dbg(&vb->pdev->dev, "complete %d buffer1: %08x (des1: %08x) (framesize: %d)\n",
+			d->index, d->desc->buffer1, (d->desc->des1), vb->framesize);
+	}
 
 	dma_unmap_single(&vb->pdev->dev, d->desc->buffer1,
 			 vb->framesize, dl->direction);
@@ -905,7 +913,13 @@
 static bool vb_check_softunderrun(const struct voicebus *vb)
 {
 	const struct voicebus_chained_descriptor *const d = vb->txd.head;
-	return ((d->desc->buffer1 == vb->idle_vbb_dma_addr) && !OWNED(d->desc));
+	if ((d->desc->buffer1 == vb->idle_vbb_dma_addr) && !OWNED(d->desc)) {
+		dev_dbg(&vb->pdev->dev, "UNDERRUN desc: %p buffer1: %08x idle: %08x\n",
+			d->desc, d->desc->buffer1, (u32)vb->idle_vbb_dma_addr);
+		return true;
+	} else {
+		return false;
+	}
 }
 
 /**
@@ -923,7 +937,8 @@
 	struct voicebus_chained_descriptor *next;
 	int count = 1;
 
-	next = get_next_descriptor(dl, dl->head);
+	/* next = get_next_descriptor(dl, dl->head); */
+	next = dl->head;
 
 	while (!OWNED(next->desc)) {
 		next->desc->buffer1 = vb->idle_vbb_dma_addr;
@@ -933,13 +948,13 @@
 		++count;
 	}
 
-	if (printk_ratelimit())
+	if (debug)
 		dev_info(&vb->pdev->dev, "Behind by %d descriptors.\n", count);
 
 	count = 8;
 	while (--count) {
 		next = get_next_descriptor(dl, next);
-		SET_OWNED(next->desc); /* !!! this shouldn't be necessary */
+		/* SET_OWNED(next->desc); */ /* !!! this shouldn't be necessary */
 	}
 
 	vb->txd.tail = next;
@@ -1324,28 +1339,18 @@
 	int limit = DLIST_SIZE;
 
 	start_vb_deferred(vb);
-	if (unlikely(underrun)) {
-		/* When we've underrun our FIFO, for some reason we're not
-		 * able to keep enough transmit descriptors pending.  This can
-		 * happen if either interrupts or this deferred processing
-		 * function is not run soon enough (within 1ms when using the
-		 * default 3 transmit buffers to start).  In this case, we'll
-		 * insert an additional transmit buffer onto the descriptor
-		 * list which decreases the sensitivity to latency, but also
-		 * adds more delay to the TDM and SPI data.
-		 */
-		__vb_increase_latency(vb, 1);
-	}
-
 	/* Always handle the transmit buffers first. */
-	while ((vbb = vb_get_completed_txb(vb)) && --limit) {
+	while ((vbb = vb_get_completed_txb(vb))) {
 		vb->handle_transmit(vbb, vb->context);
+		if (!(--limit))
+			break;
 	}
 
 	if (unlikely(vb_check_softunderrun(vb)))
 		vb_recover_tx_descriptor_list(vb);
 
 	if (unlikely(underrun)) {
+		__vb_increase_latency(vb, 1);
 		vb_rx_demand_poll(vb);
 		vb_tx_demand_poll(vb);
 		clear_bit(TX_UNDERRUN, &vb->flags);
@@ -1359,7 +1364,6 @@
 	stop_vb_deferred(vb);
 	/* dev_dbg(&vb->pdev->dev, "Leaving %s\n", __func__); */
 }
-
 
 /*!
  * \brief Interrupt handler for VoiceBus interface.
@@ -1796,6 +1800,8 @@
 	WARN_ON(!list_empty(&binary_loader_list));
 }
 
+module_param(debug, int, 0600);
+
 MODULE_DESCRIPTION("Voicebus Interface w/VPMADT032 support");
 MODULE_AUTHOR("Digium Incorporated <support at digium.com>");
 MODULE_LICENSE("GPL");




More information about the dahdi-commits mailing list