aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/wireless/ath9k/xmit.c
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2008-12-03 03:35:29 -0800
committerJohn W. Linville <linville@tuxdriver.com>2008-12-05 09:35:59 -0500
commitf8316df10c4e3bec5b4c3a5a8e026c577640c3a6 (patch)
treef56af9c85de35bda97a0b45275eed6b6f7362712 /drivers/net/wireless/ath9k/xmit.c
parent73a5267087b5acd4a4288e0a1b809f09ca578d49 (diff)
ath9k: Check for pci_map_single() errors
pci_map_single() can fail so detect those errors with pci_dma_mapping_error() and deal with them accordingly. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k/xmit.c')
-rw-r--r--drivers/net/wireless/ath9k/xmit.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c
index 5cf83111e1a..17fd05e2f24 100644
--- a/drivers/net/wireless/ath9k/xmit.c
+++ b/drivers/net/wireless/ath9k/xmit.c
@@ -1642,7 +1642,7 @@ static void ath_txq_drain_pending_buffers(struct ath_softc *sc,
}
}
-static void ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf,
+static int ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf,
struct sk_buff *skb,
struct ath_tx_control *txctl)
{
@@ -1701,9 +1701,18 @@ static void ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf,
/* DMA setup */
bf->bf_mpdu = skb;
+
bf->bf_dmacontext = pci_map_single(sc->pdev, skb->data,
skb->len, PCI_DMA_TODEVICE);
+ if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_dmacontext))) {
+ bf->bf_mpdu = NULL;
+ DPRINTF(sc, ATH_DBG_CONFIG,
+ "pci_dma_mapping_error() on TX\n");
+ return -ENOMEM;
+ }
+
bf->bf_buf_addr = bf->bf_dmacontext;
+ return 0;
}
/* FIXME: tx power */
@@ -1775,10 +1784,12 @@ static void ath_tx_start_dma(struct ath_softc *sc, struct ath_buf *bf,
spin_unlock_bh(&txctl->txq->axq_lock);
}
+/* Upon failure caller should free skb */
int ath_tx_start(struct ath_softc *sc, struct sk_buff *skb,
struct ath_tx_control *txctl)
{
struct ath_buf *bf;
+ int r;
/* Check if a tx buffer is available */
@@ -1788,7 +1799,15 @@ int ath_tx_start(struct ath_softc *sc, struct sk_buff *skb,
return -1;
}
- ath_tx_setup_buffer(sc, bf, skb, txctl);
+ r = ath_tx_setup_buffer(sc, bf, skb, txctl);
+ if (unlikely(r)) {
+ spin_lock_bh(&sc->sc_txbuflock);
+ DPRINTF(sc, ATH_DBG_FATAL, "TX mem alloc failure\n");
+ list_add_tail(&bf->list, &sc->sc_txbuf);
+ spin_unlock_bh(&sc->sc_txbuflock);
+ return r;
+ }
+
ath_tx_start_dma(sc, bf, txctl);
return 0;