diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2009-11-02 09:25:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-03 02:39:02 -0500 |
commit | a21771dd189b340328c573da9e005068e8a74c53 (patch) | |
tree | 84181a65a4e13edd6b14898e1747d8c84240c6c8 /drivers/net/tg3.c | |
parent | 52cdf8526fe24f11d300b75458ddee017f3f4c88 (diff) |
tg3: Add more PCI DMA map error checking
This patch adds code to check the status of pci_map_single() before
allowing rx buffers to be used. It also converts the pci_map_single()
call in tg3_run_loopback() to use skb_dma_map() instead.
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Benjamin Li <benli@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 53a193e0d45c..54dbe988f5f1 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -4426,6 +4426,10 @@ static int tg3_alloc_rx_skb(struct tg3_napi *tnapi, u32 opaque_key, | |||
4426 | 4426 | ||
4427 | mapping = pci_map_single(tp->pdev, skb->data, skb_size, | 4427 | mapping = pci_map_single(tp->pdev, skb->data, skb_size, |
4428 | PCI_DMA_FROMDEVICE); | 4428 | PCI_DMA_FROMDEVICE); |
4429 | if (pci_dma_mapping_error(tp->pdev, mapping)) { | ||
4430 | dev_kfree_skb(skb); | ||
4431 | return -EIO; | ||
4432 | } | ||
4429 | 4433 | ||
4430 | map->skb = skb; | 4434 | map->skb = skb; |
4431 | pci_unmap_addr_set(map, mapping, mapping); | 4435 | pci_unmap_addr_set(map, mapping, mapping); |
@@ -10369,7 +10373,10 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode) | |||
10369 | for (i = 14; i < tx_len; i++) | 10373 | for (i = 14; i < tx_len; i++) |
10370 | tx_data[i] = (u8) (i & 0xff); | 10374 | tx_data[i] = (u8) (i & 0xff); |
10371 | 10375 | ||
10372 | map = pci_map_single(tp->pdev, skb->data, tx_len, PCI_DMA_TODEVICE); | 10376 | if (skb_dma_map(&tp->pdev->dev, skb, DMA_TO_DEVICE)) { |
10377 | dev_kfree_skb(skb); | ||
10378 | return -EIO; | ||
10379 | } | ||
10373 | 10380 | ||
10374 | tw32_f(HOSTCC_MODE, tp->coalesce_mode | HOSTCC_MODE_ENABLE | | 10381 | tw32_f(HOSTCC_MODE, tp->coalesce_mode | HOSTCC_MODE_ENABLE | |
10375 | rnapi->coal_now); | 10382 | rnapi->coal_now); |
@@ -10380,7 +10387,8 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode) | |||
10380 | 10387 | ||
10381 | num_pkts = 0; | 10388 | num_pkts = 0; |
10382 | 10389 | ||
10383 | tg3_set_txd(tnapi, tnapi->tx_prod, map, tx_len, 0, 1); | 10390 | tg3_set_txd(tnapi, tnapi->tx_prod, |
10391 | skb_shinfo(skb)->dma_head, tx_len, 0, 1); | ||
10384 | 10392 | ||
10385 | tnapi->tx_prod++; | 10393 | tnapi->tx_prod++; |
10386 | num_pkts++; | 10394 | num_pkts++; |
@@ -10404,7 +10412,7 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode) | |||
10404 | break; | 10412 | break; |
10405 | } | 10413 | } |
10406 | 10414 | ||
10407 | pci_unmap_single(tp->pdev, map, tx_len, PCI_DMA_TODEVICE); | 10415 | skb_dma_unmap(&tp->pdev->dev, skb, DMA_TO_DEVICE); |
10408 | dev_kfree_skb(skb); | 10416 | dev_kfree_skb(skb); |
10409 | 10417 | ||
10410 | if (tx_idx != tnapi->tx_prod) | 10418 | if (tx_idx != tnapi->tx_prod) |