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

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Mon Oct 5 17:58:46 CDT 2009


Author: sruffell
Date: Mon Oct  5 17:58:35 2009
New Revision: 7341

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7341
Log:
wip: move the vbb_stash into 'struct voicebus' and cleanup the print messages.

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=7341&r1=7340&r2=7341
==============================================================================
--- linux/team/sruffell/dahdi-linux-chainedvb/drivers/dahdi/voicebus/voicebus.c (original)
+++ linux/team/sruffell/dahdi-linux-chainedvb/drivers/dahdi/voicebus/voicebus.c Mon Oct  5 17:58:35 2009
@@ -175,6 +175,11 @@
  *
  * @tx_idle_vbb: 		 
  * @tx_idle_vbb_dma_addr:
+ * @vbb_stash:	Temporary holding place for the vb_deferred routine.
+ *
+ * NOTE: vbb_stash is in this structure even though it is only used in the
+ * interrupt handler because I do not want to put that much data on the
+ * interrupts stack.
  *
  */
 struct voicebus {
@@ -236,6 +241,7 @@
 	u32 sdi;
 	/*! Number of tx buffers to queue up before enabling interrupts. */
 	unsigned int 	min_tx_buffer_count;
+	void *vbb_stash[DLIST_SIZE];
 };
 
 /*
@@ -1298,7 +1304,15 @@
 	voicebus_set_minlatency(vb, latency);
 }
 
-static void *vbb_stash[DLIST_SIZE];
+static void vb_set_all_owned(struct voicebus *vb)
+{
+	struct voicebus_chained_descriptor *d;
+	struct list_head *const list = &vb->txd.list;
+
+	list_for_each_entry(d, list, node)
+		SET_OWNED(d->desc);
+}
+
 /*!
  * \brief Actually process the completed transmit and receive buffers.
  *
@@ -1320,12 +1334,20 @@
 	start_vb_deferred(vb);
 
 	buffer_count = 0;
-	/* Always handle the transmit buffers first. */
+
+	/* First, grab any buffers that are completed. */
 	while ((vbb = vb_get_completed_txb(vb))) {
-		vbb_stash[buffer_count] = vbb;
+		vb->vbb_stash[buffer_count] = vbb;
 		++buffer_count;
 	}
 
+	/* Insurance in the case of an underrun condition.  We don't want the
+	 * card getting 'stuck' on a descriptor that isn't owened. */
+	if (unlikely(underrun))
+		vb_set_all_owned(vb);
+
+	/* Before adding any new buffers to the transmit descriptor ring, check
+	 * to see if we're in a softunderrun condition. */
 	/* NOTE: Do not print anything to the console from the time you've
 	 * detected a soft underrun until the transmit descriptors are fixed up
 	 * again. Otherwise the hardware could advance past where you set the
@@ -1338,19 +1360,20 @@
 		__vb_increase_latency(vb, idle_buffers + buffer_count);
 	}
 
-	for (i = 0; i < buffer_count; ++i) {
-		/* After the upper layer is done with the completed buffer, it
-		 * will call voicebus_transmit to add it back to the descriptor
-		 * ring itself. */
-		vb->handle_transmit(vbb_stash[i], vb->context);
-	}
+	/* Now that we've checked for and handled any soft underrun condition,
+	 * it's safe to give the buffers to the client for processing. */
+	for (i = 0; i < buffer_count; ++i)
+		vb->handle_transmit(vb->vbb_stash[i], vb->context);
 
 	/* This is a hard underrun.  I.e., the hardware was able to completely
 	 * drain the transmit descriptor ring which means that interrupts were
 	 * locked for DLIST_SIZE ms. */
 	if (unlikely(underrun)) {
-		if (printk_ratelimit())
-			HERE();
+		if (printk_ratelimit()) {
+			dev_info(&vb->pdev->dev, "Host failed to service "
+				 "card interrupt within %d. Recovery "
+				 "attempted.\n", DLIST_SIZE);
+		}
 		vb_rx_demand_poll(vb);
 		vb_tx_demand_poll(vb);
 		clear_bit(TX_UNDERRUN, &vb->flags);
@@ -1360,9 +1383,10 @@
 	 * transmit buffer...otherwise it's possible to take so much time
 	 * printing the dmesg output that we lost the lead that we got on the
 	 * hardware, resulting in a hard underrun condition. */
-	if (unlikely(softunderrun)) {
-		dev_info(&vb->pdev->dev, "Sent %d idle buffers. Latency set to %d ms in order to compensate.\n",
-			idle_buffers, vb->min_tx_buffer_count);
+	if (unlikely(softunderrun) && printk_ratelimit()) {
+		dev_info(&vb->pdev->dev, "Sent %d idle buffers. Latency set "
+			 "to %d ms in order to compensate.\n",
+			 idle_buffers, vb->min_tx_buffer_count);
 	}
 
 	while ((vbb = vb_get_completed_rxb(vb))) {




More information about the dahdi-commits mailing list