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
This commit is contained in:
Harald Welte 2022-04-24 12:45:14 +02:00 committed by laforge
parent 588281bff0
commit c4cfb4a722
3 changed files with 14 additions and 0 deletions

View File

@ -53,6 +53,15 @@ void frame_fifo_init(struct frame_fifo *fifo, unsigned int threshold,
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.

View File

@ -20,6 +20,8 @@ void frame_fifo_init(struct frame_fifo *fifo, unsigned int threshold,
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)
{

View File

@ -456,6 +456,9 @@ static long dahdi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned l
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)))