Commit 23413296 authored by Bruno Randolf's avatar Bruno Randolf Committed by John W. Linville

ath5k: Keep last descriptor in queue

If we return a TX descriptor to the pool of available descriptors, while a
queues TXDP still points to it we could potentially run into all sorts of
troube.

It has been suggested that there is hardware which can set the descriptors
done bit before it reads ds_link and moves on to the next descriptor. While the
documentation says this is not true for newer chipsets (the descriptor contents
are copied to some internal memory), we don't know about older hardware.

To be safe, we always keep the last descriptor in the queue, and avoid dangling
TXDP pointers. Unfortunately this does not fully resolve the problem - queues
still get stuck!

This is similar to what ath9k does.
Signed-off-by: default avatarBruno Randolf <br1@einfach.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 923e5b3d
...@@ -1586,44 +1586,44 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq) ...@@ -1586,44 +1586,44 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
spin_lock(&txq->lock); spin_lock(&txq->lock);
list_for_each_entry_safe(bf, bf0, &txq->q, list) { list_for_each_entry_safe(bf, bf0, &txq->q, list) {
ds = bf->desc;
txq->txq_poll_mark = false;
/* skb might already have been processed last time. */
if (bf->skb != NULL) {
ds = bf->desc;
ret = sc->ah->ah_proc_tx_desc(sc->ah, ds, &ts);
if (unlikely(ret == -EINPROGRESS))
break;
else if (unlikely(ret)) {
ATH5K_ERR(sc,
"error %d while processing "
"queue %u\n", ret, txq->qnum);
break;
}
skb = bf->skb;
bf->skb = NULL;
pci_unmap_single(sc->pdev, bf->skbaddr, skb->len,
PCI_DMA_TODEVICE);
ath5k_tx_frame_completed(sc, skb, &ts);
}
/* /*
* It's possible that the hardware can say the buffer is * It's possible that the hardware can say the buffer is
* completed when it hasn't yet loaded the ds_link from * completed when it hasn't yet loaded the ds_link from
* host memory and moved on. If there are more TX * host memory and moved on.
* descriptors in the queue, wait for TXDP to change * Always keep the last descriptor to avoid HW races...
* before processing this one.
*/ */
if (ath5k_hw_get_txdp(sc->ah, txq->qnum) == bf->daddr && if (ath5k_hw_get_txdp(sc->ah, txq->qnum) != bf->daddr) {
!list_is_last(&bf->list, &txq->q)) spin_lock(&sc->txbuflock);
break; list_move_tail(&bf->list, &sc->txbuf);
ret = sc->ah->ah_proc_tx_desc(sc->ah, ds, &ts); sc->txbuf_len++;
if (unlikely(ret == -EINPROGRESS)) txq->txq_len--;
break; spin_unlock(&sc->txbuflock);
else if (unlikely(ret)) {
ATH5K_ERR(sc, "error %d while processing queue %u\n",
ret, txq->qnum);
break;
} }
skb = bf->skb;
bf->skb = NULL;
pci_unmap_single(sc->pdev, bf->skbaddr, skb->len,
PCI_DMA_TODEVICE);
ath5k_tx_frame_completed(sc, skb, &ts);
spin_lock(&sc->txbuflock);
list_move_tail(&bf->list, &sc->txbuf);
sc->txbuf_len++;
txq->txq_len--;
spin_unlock(&sc->txbuflock);
txq->txq_poll_mark = false;
} }
if (likely(list_empty(&txq->q)))
txq->link = NULL;
spin_unlock(&txq->lock); spin_unlock(&txq->lock);
if (txq->txq_len < ATH5K_TXQ_LEN_LOW) if (txq->txq_len < ATH5K_TXQ_LEN_LOW)
ieee80211_wake_queue(sc->hw, txq->qnum); ieee80211_wake_queue(sc->hw, txq->qnum);
...@@ -2188,7 +2188,7 @@ ath5k_tx_complete_poll_work(struct work_struct *work) ...@@ -2188,7 +2188,7 @@ ath5k_tx_complete_poll_work(struct work_struct *work)
if (sc->txqs[i].setup) { if (sc->txqs[i].setup) {
txq = &sc->txqs[i]; txq = &sc->txqs[i];
spin_lock_bh(&txq->lock); spin_lock_bh(&txq->lock);
if (txq->txq_len > 0) { if (txq->txq_len > 1) {
if (txq->txq_poll_mark) { if (txq->txq_poll_mark) {
ATH5K_DBG(sc, ATH5K_DEBUG_XMIT, ATH5K_DBG(sc, ATH5K_DEBUG_XMIT,
"TX queue stuck %d\n", "TX queue stuck %d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment