facetimehd: add channel waitqueue

add a per channel waitqueue to be able to have more than one ringbuffer
entry in flight.

Signed-off-by: Sven Schnelle <svens@stackframe.org>
This commit is contained in:
Sven Schnelle
2015-11-28 22:59:44 +01:00
parent 3574901c31
commit ca8c5584e0
6 changed files with 35 additions and 63 deletions

View File

@@ -86,12 +86,7 @@ int fthd_channel_ringbuf_send(struct fthd_private *dev_priv, struct fw_channel *
spin_lock_irq(&chan->lock);
entry = get_entry_addr(dev_priv, chan, chan->ringbuf.idx);
if (chan->tx_lock) {
spin_unlock_irq(&chan->lock);
return -EBUSY;
}
if (chan->type != FW_CHAN_TYPE_OUT && ++chan->ringbuf.idx >= chan->size)
if (++chan->ringbuf.idx >= chan->size)
chan->ringbuf.idx = 0;
if (!(FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_ADDRESS_FLAGS) & 1) ^ (chan->type != 0)) {
@@ -99,9 +94,6 @@ int fthd_channel_ringbuf_send(struct fthd_private *dev_priv, struct fw_channel *
return -EAGAIN;
}
chan->tx_lock = 1;
chan->rx_lock = 0;
FTHD_S2_MEM_WRITE(request_size, entry + FTHD_RINGBUF_REQUEST_SIZE);
FTHD_S2_MEM_WRITE(response_size, entry + FTHD_RINGBUF_RESPONSE_SIZE);
wmb();
@@ -123,8 +115,6 @@ u32 fthd_channel_ringbuf_receive(struct fthd_private *dev_priv,
u32 entry, ret = (u32)-1;
spin_lock_irq(&chan->lock);
if (chan->rx_lock)
goto out;
entry = get_entry_addr(dev_priv, chan, chan->ringbuf.idx);
@@ -137,9 +127,19 @@ u32 fthd_channel_ringbuf_receive(struct fthd_private *dev_priv,
if (chan->type == FW_CHAN_TYPE_OUT && ++chan->ringbuf.idx >= chan->size)
chan->ringbuf.idx = 0;
chan->rx_lock = 1;
chan->tx_lock = 0;
out:
spin_unlock_irq(&chan->lock);
return ret;
}
int fthd_channel_wait_ready(struct fthd_private *dev_priv, struct fw_channel *chan, u32 entry, int timeout)
{
if (wait_event_interruptible_timeout(chan->wq,
(FTHD_S2_MEM_READ(entry + FTHD_RINGBUF_ADDRESS_FLAGS) & 1) ^ (chan->type != 0),
msecs_to_jiffies(timeout)) <= 0) {
dev_err(&dev_priv->pdev->dev, "%s: timeout\n", chan->name);
fthd_channel_ringbuf_dump(dev_priv, chan);
return -ETIMEDOUT;
}
return 0;
}