laforge has uploaded this change for review. (
https://gerrit.osmocom.org/c/dahdi-linux/+/34011 )
Change subject: Flush DAHDI->trunkdev FIFO at open time
......................................................................
Flush DAHDI->trunkdev FIFO at open time
If we don't do this, we always have a full FIFO at the time userspace
opens the trunkdev, adding latency for no good reason.
Change-Id: Ifbda3766309cc7d6be485073e36607bdd6742f3a
---
M drivers/dahdi/trunkdev/frame_fifo.c
M drivers/dahdi/trunkdev/frame_fifo.h
M drivers/dahdi/trunkdev/trunkdev.c
3 files changed, 26 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/dahdi-linux refs/changes/11/34011/1
diff --git a/drivers/dahdi/trunkdev/frame_fifo.c b/drivers/dahdi/trunkdev/frame_fifo.c
index 19b6dba..3b7732f 100644
--- a/drivers/dahdi/trunkdev/frame_fifo.c
+++ b/drivers/dahdi/trunkdev/frame_fifo.c
@@ -53,6 +53,15 @@
spin_lock_init(&fifo->lock);
}
+/*! Flush (drop) the entire content of the FIFO */
+void frame_fifo_flush(struct frame_fifo *fifo)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&fifo->lock, flags);
+ fifo->next_out = fifo->next_in;
+ spin_unlock_irqrestore(&fifo->lock, flags);
+}
+
#define FIFO_BUF_END(f) ((f)->buf + sizeof((f)->buf))
/*! put one received frames into the FIFO.
diff --git a/drivers/dahdi/trunkdev/frame_fifo.h b/drivers/dahdi/trunkdev/frame_fifo.h
index af02811..b07cddc 100644
--- a/drivers/dahdi/trunkdev/frame_fifo.h
+++ b/drivers/dahdi/trunkdev/frame_fifo.h
@@ -20,6 +20,8 @@
void (*threshold_cb)(struct frame_fifo *fifo, unsigned int frames, void *priv),
void *priv);
+void frame_fifo_flush(struct frame_fifo *fifo);
+
/* number of frames currently available in FIFO */
static inline unsigned int __frame_fifo_frames(struct frame_fifo *fifo)
{
diff --git a/drivers/dahdi/trunkdev/trunkdev.c b/drivers/dahdi/trunkdev/trunkdev.c
index 8375c86..339b9d0 100644
--- a/drivers/dahdi/trunkdev/trunkdev.c
+++ b/drivers/dahdi/trunkdev/trunkdev.c
@@ -456,6 +456,9 @@
span->alarms &= ~(ALL_RY_ALARMS|DAHDI_ALARM_LOS);
dahdi_alarm_notify(span);
spin_unlock_irqrestore(&span->lock, flags);
+ /* FIFO should be full at this point, let's flush it as now we actually
+ * have a receiver */
+ frame_fifo_flush(&td->to_trunk);
open.spanno = span->spanno;
if (copy_to_user((__user void *) data, &open, sizeof(open)))
--
To view, visit
https://gerrit.osmocom.org/c/dahdi-linux/+/34011
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: dahdi-linux
Gerrit-Branch: master
Gerrit-Change-Id: Ifbda3766309cc7d6be485073e36607bdd6742f3a
Gerrit-Change-Number: 34011
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange