aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJie Yang <jie.yang@atheros.com>2009-09-17 13:27:28 -0400
committerDavid S. Miller <davem@davemloft.net>2009-09-17 13:27:28 -0400
commit03f18991614cba1fa5be5dcd1a79b0e30ac44c50 (patch)
tree2b01d55c9c106d391c0ce9f01c9a6d240672ec81 /drivers
parenta19d2158439d6fba8160d7d2446f233f525f09e7 (diff)
atl1e: fix 2.6.31-git4 -- ATL1E 0000:03:00.0: DMA-API: device driver frees DMA
use the wrong API when free dma. So when map dma use a flag to demostrate whether it is 'pci_map_single' or 'pci_map_page'. When free the dma, check the flags to select the right APIs('pci_unmap_single' or 'pci_unmap_page'). set the flags type to u16 instead of unsigned long on David's comments. Signed-off-by: Jie Yang <jie.yang@atheros.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/atl1e/atl1e.h9
-rw-r--r--drivers/net/atl1e/atl1e_main.c15
2 files changed, 22 insertions, 2 deletions
diff --git a/drivers/net/atl1e/atl1e.h b/drivers/net/atl1e/atl1e.h
index ba48220df16a..490d3b38e0cb 100644
--- a/drivers/net/atl1e/atl1e.h
+++ b/drivers/net/atl1e/atl1e.h
@@ -377,10 +377,19 @@ struct atl1e_hw {
377 */ 377 */
378struct atl1e_tx_buffer { 378struct atl1e_tx_buffer {
379 struct sk_buff *skb; 379 struct sk_buff *skb;
380 u16 flags;
381#define ATL1E_TX_PCIMAP_SINGLE 0x0001
382#define ATL1E_TX_PCIMAP_PAGE 0x0002
383#define ATL1E_TX_PCIMAP_TYPE_MASK 0x0003
380 u16 length; 384 u16 length;
381 dma_addr_t dma; 385 dma_addr_t dma;
382}; 386};
383 387
388#define ATL1E_SET_PCIMAP_TYPE(tx_buff, type) do { \
389 ((tx_buff)->flags) &= ~ATL1E_TX_PCIMAP_TYPE_MASK; \
390 ((tx_buff)->flags) |= (type); \
391 } while (0)
392
384struct atl1e_rx_page { 393struct atl1e_rx_page {
385 dma_addr_t dma; /* receive rage DMA address */ 394 dma_addr_t dma; /* receive rage DMA address */
386 u8 *addr; /* receive rage virtual address */ 395 u8 *addr; /* receive rage virtual address */
diff --git a/drivers/net/atl1e/atl1e_main.c b/drivers/net/atl1e/atl1e_main.c
index 69b830f4b68f..955da733c2ad 100644
--- a/drivers/net/atl1e/atl1e_main.c
+++ b/drivers/net/atl1e/atl1e_main.c
@@ -635,7 +635,11 @@ static void atl1e_clean_tx_ring(struct atl1e_adapter *adapter)
635 for (index = 0; index < ring_count; index++) { 635 for (index = 0; index < ring_count; index++) {
636 tx_buffer = &tx_ring->tx_buffer[index]; 636 tx_buffer = &tx_ring->tx_buffer[index];
637 if (tx_buffer->dma) { 637 if (tx_buffer->dma) {
638 pci_unmap_page(pdev, tx_buffer->dma, 638 if (tx_buffer->flags & ATL1E_TX_PCIMAP_SINGLE)
639 pci_unmap_single(pdev, tx_buffer->dma,
640 tx_buffer->length, PCI_DMA_TODEVICE);
641 else if (tx_buffer->flags & ATL1E_TX_PCIMAP_PAGE)
642 pci_unmap_page(pdev, tx_buffer->dma,
639 tx_buffer->length, PCI_DMA_TODEVICE); 643 tx_buffer->length, PCI_DMA_TODEVICE);
640 tx_buffer->dma = 0; 644 tx_buffer->dma = 0;
641 } 645 }
@@ -1220,7 +1224,11 @@ static bool atl1e_clean_tx_irq(struct atl1e_adapter *adapter)
1220 while (next_to_clean != hw_next_to_clean) { 1224 while (next_to_clean != hw_next_to_clean) {
1221 tx_buffer = &tx_ring->tx_buffer[next_to_clean]; 1225 tx_buffer = &tx_ring->tx_buffer[next_to_clean];
1222 if (tx_buffer->dma) { 1226 if (tx_buffer->dma) {
1223 pci_unmap_page(adapter->pdev, tx_buffer->dma, 1227 if (tx_buffer->flags & ATL1E_TX_PCIMAP_SINGLE)
1228 pci_unmap_single(adapter->pdev, tx_buffer->dma,
1229 tx_buffer->length, PCI_DMA_TODEVICE);
1230 else if (tx_buffer->flags & ATL1E_TX_PCIMAP_PAGE)
1231 pci_unmap_page(adapter->pdev, tx_buffer->dma,
1224 tx_buffer->length, PCI_DMA_TODEVICE); 1232 tx_buffer->length, PCI_DMA_TODEVICE);
1225 tx_buffer->dma = 0; 1233 tx_buffer->dma = 0;
1226 } 1234 }
@@ -1741,6 +1749,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
1741 tx_buffer->length = map_len; 1749 tx_buffer->length = map_len;
1742 tx_buffer->dma = pci_map_single(adapter->pdev, 1750 tx_buffer->dma = pci_map_single(adapter->pdev,
1743 skb->data, hdr_len, PCI_DMA_TODEVICE); 1751 skb->data, hdr_len, PCI_DMA_TODEVICE);
1752 ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_SINGLE);
1744 mapped_len += map_len; 1753 mapped_len += map_len;
1745 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); 1754 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma);
1746 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | 1755 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) |
@@ -1766,6 +1775,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
1766 tx_buffer->dma = 1775 tx_buffer->dma =
1767 pci_map_single(adapter->pdev, skb->data + mapped_len, 1776 pci_map_single(adapter->pdev, skb->data + mapped_len,
1768 map_len, PCI_DMA_TODEVICE); 1777 map_len, PCI_DMA_TODEVICE);
1778 ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_SINGLE);
1769 mapped_len += map_len; 1779 mapped_len += map_len;
1770 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); 1780 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma);
1771 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | 1781 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) |
@@ -1801,6 +1811,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
1801 (i * MAX_TX_BUF_LEN), 1811 (i * MAX_TX_BUF_LEN),
1802 tx_buffer->length, 1812 tx_buffer->length,
1803 PCI_DMA_TODEVICE); 1813 PCI_DMA_TODEVICE);
1814 ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_PAGE);
1804 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); 1815 use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma);
1805 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | 1816 use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) |
1806 ((cpu_to_le32(tx_buffer->length) & 1817 ((cpu_to_le32(tx_buffer->length) &