diff options
author | Nick Nunley <nicholasx.d.nunley@intel.com> | 2010-04-27 09:08:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-27 19:29:49 -0400 |
commit | b16f53bef9be0a756a0672e27d0a526686040e02 (patch) | |
tree | ef44806ac770a2af3cc34501ee138ef00ed55a1f /drivers/net/e1000/e1000_main.c | |
parent | ff65e8275f6c96a5eda57493bd84c4555decf7b3 (diff) |
e1000: use DMA API instead of PCI DMA functions
Signed-off-by: Nicholas Nunley <nicholasx.d.nunley@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/e1000/e1000_main.c')
-rw-r--r-- | drivers/net/e1000/e1000_main.c | 110 |
1 files changed, 62 insertions, 48 deletions
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index 974a02d81823..0a56e7d1f33b 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c | |||
@@ -823,13 +823,14 @@ static int __devinit e1000_probe(struct pci_dev *pdev, | |||
823 | if (err) | 823 | if (err) |
824 | return err; | 824 | return err; |
825 | 825 | ||
826 | if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && | 826 | if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) && |
827 | !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) { | 827 | !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) { |
828 | pci_using_dac = 1; | 828 | pci_using_dac = 1; |
829 | } else { | 829 | } else { |
830 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); | 830 | err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); |
831 | if (err) { | 831 | if (err) { |
832 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); | 832 | err = dma_set_coherent_mask(&pdev->dev, |
833 | DMA_BIT_MASK(32)); | ||
833 | if (err) { | 834 | if (err) { |
834 | E1000_ERR("No usable DMA configuration, " | 835 | E1000_ERR("No usable DMA configuration, " |
835 | "aborting\n"); | 836 | "aborting\n"); |
@@ -1395,7 +1396,8 @@ static int e1000_setup_tx_resources(struct e1000_adapter *adapter, | |||
1395 | txdr->size = txdr->count * sizeof(struct e1000_tx_desc); | 1396 | txdr->size = txdr->count * sizeof(struct e1000_tx_desc); |
1396 | txdr->size = ALIGN(txdr->size, 4096); | 1397 | txdr->size = ALIGN(txdr->size, 4096); |
1397 | 1398 | ||
1398 | txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma); | 1399 | txdr->desc = dma_alloc_coherent(&pdev->dev, txdr->size, &txdr->dma, |
1400 | GFP_KERNEL); | ||
1399 | if (!txdr->desc) { | 1401 | if (!txdr->desc) { |
1400 | setup_tx_desc_die: | 1402 | setup_tx_desc_die: |
1401 | vfree(txdr->buffer_info); | 1403 | vfree(txdr->buffer_info); |
@@ -1411,18 +1413,21 @@ setup_tx_desc_die: | |||
1411 | DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes " | 1413 | DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes " |
1412 | "at %p\n", txdr->size, txdr->desc); | 1414 | "at %p\n", txdr->size, txdr->desc); |
1413 | /* Try again, without freeing the previous */ | 1415 | /* Try again, without freeing the previous */ |
1414 | txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma); | 1416 | txdr->desc = dma_alloc_coherent(&pdev->dev, txdr->size, |
1417 | &txdr->dma, GFP_KERNEL); | ||
1415 | /* Failed allocation, critical failure */ | 1418 | /* Failed allocation, critical failure */ |
1416 | if (!txdr->desc) { | 1419 | if (!txdr->desc) { |
1417 | pci_free_consistent(pdev, txdr->size, olddesc, olddma); | 1420 | dma_free_coherent(&pdev->dev, txdr->size, olddesc, |
1421 | olddma); | ||
1418 | goto setup_tx_desc_die; | 1422 | goto setup_tx_desc_die; |
1419 | } | 1423 | } |
1420 | 1424 | ||
1421 | if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) { | 1425 | if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) { |
1422 | /* give up */ | 1426 | /* give up */ |
1423 | pci_free_consistent(pdev, txdr->size, txdr->desc, | 1427 | dma_free_coherent(&pdev->dev, txdr->size, txdr->desc, |
1424 | txdr->dma); | 1428 | txdr->dma); |
1425 | pci_free_consistent(pdev, txdr->size, olddesc, olddma); | 1429 | dma_free_coherent(&pdev->dev, txdr->size, olddesc, |
1430 | olddma); | ||
1426 | DPRINTK(PROBE, ERR, | 1431 | DPRINTK(PROBE, ERR, |
1427 | "Unable to allocate aligned memory " | 1432 | "Unable to allocate aligned memory " |
1428 | "for the transmit descriptor ring\n"); | 1433 | "for the transmit descriptor ring\n"); |
@@ -1430,7 +1435,8 @@ setup_tx_desc_die: | |||
1430 | return -ENOMEM; | 1435 | return -ENOMEM; |
1431 | } else { | 1436 | } else { |
1432 | /* Free old allocation, new allocation was successful */ | 1437 | /* Free old allocation, new allocation was successful */ |
1433 | pci_free_consistent(pdev, txdr->size, olddesc, olddma); | 1438 | dma_free_coherent(&pdev->dev, txdr->size, olddesc, |
1439 | olddma); | ||
1434 | } | 1440 | } |
1435 | } | 1441 | } |
1436 | memset(txdr->desc, 0, txdr->size); | 1442 | memset(txdr->desc, 0, txdr->size); |
@@ -1590,7 +1596,8 @@ static int e1000_setup_rx_resources(struct e1000_adapter *adapter, | |||
1590 | rxdr->size = rxdr->count * desc_len; | 1596 | rxdr->size = rxdr->count * desc_len; |
1591 | rxdr->size = ALIGN(rxdr->size, 4096); | 1597 | rxdr->size = ALIGN(rxdr->size, 4096); |
1592 | 1598 | ||
1593 | rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma); | 1599 | rxdr->desc = dma_alloc_coherent(&pdev->dev, rxdr->size, &rxdr->dma, |
1600 | GFP_KERNEL); | ||
1594 | 1601 | ||
1595 | if (!rxdr->desc) { | 1602 | if (!rxdr->desc) { |
1596 | DPRINTK(PROBE, ERR, | 1603 | DPRINTK(PROBE, ERR, |
@@ -1607,10 +1614,12 @@ setup_rx_desc_die: | |||
1607 | DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes " | 1614 | DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes " |
1608 | "at %p\n", rxdr->size, rxdr->desc); | 1615 | "at %p\n", rxdr->size, rxdr->desc); |
1609 | /* Try again, without freeing the previous */ | 1616 | /* Try again, without freeing the previous */ |
1610 | rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma); | 1617 | rxdr->desc = dma_alloc_coherent(&pdev->dev, rxdr->size, |
1618 | &rxdr->dma, GFP_KERNEL); | ||
1611 | /* Failed allocation, critical failure */ | 1619 | /* Failed allocation, critical failure */ |
1612 | if (!rxdr->desc) { | 1620 | if (!rxdr->desc) { |
1613 | pci_free_consistent(pdev, rxdr->size, olddesc, olddma); | 1621 | dma_free_coherent(&pdev->dev, rxdr->size, olddesc, |
1622 | olddma); | ||
1614 | DPRINTK(PROBE, ERR, | 1623 | DPRINTK(PROBE, ERR, |
1615 | "Unable to allocate memory " | 1624 | "Unable to allocate memory " |
1616 | "for the receive descriptor ring\n"); | 1625 | "for the receive descriptor ring\n"); |
@@ -1619,16 +1628,18 @@ setup_rx_desc_die: | |||
1619 | 1628 | ||
1620 | if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) { | 1629 | if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) { |
1621 | /* give up */ | 1630 | /* give up */ |
1622 | pci_free_consistent(pdev, rxdr->size, rxdr->desc, | 1631 | dma_free_coherent(&pdev->dev, rxdr->size, rxdr->desc, |
1623 | rxdr->dma); | 1632 | rxdr->dma); |
1624 | pci_free_consistent(pdev, rxdr->size, olddesc, olddma); | 1633 | dma_free_coherent(&pdev->dev, rxdr->size, olddesc, |
1634 | olddma); | ||
1625 | DPRINTK(PROBE, ERR, | 1635 | DPRINTK(PROBE, ERR, |
1626 | "Unable to allocate aligned memory " | 1636 | "Unable to allocate aligned memory " |
1627 | "for the receive descriptor ring\n"); | 1637 | "for the receive descriptor ring\n"); |
1628 | goto setup_rx_desc_die; | 1638 | goto setup_rx_desc_die; |
1629 | } else { | 1639 | } else { |
1630 | /* Free old allocation, new allocation was successful */ | 1640 | /* Free old allocation, new allocation was successful */ |
1631 | pci_free_consistent(pdev, rxdr->size, olddesc, olddma); | 1641 | dma_free_coherent(&pdev->dev, rxdr->size, olddesc, |
1642 | olddma); | ||
1632 | } | 1643 | } |
1633 | } | 1644 | } |
1634 | memset(rxdr->desc, 0, rxdr->size); | 1645 | memset(rxdr->desc, 0, rxdr->size); |
@@ -1804,7 +1815,8 @@ static void e1000_free_tx_resources(struct e1000_adapter *adapter, | |||
1804 | vfree(tx_ring->buffer_info); | 1815 | vfree(tx_ring->buffer_info); |
1805 | tx_ring->buffer_info = NULL; | 1816 | tx_ring->buffer_info = NULL; |
1806 | 1817 | ||
1807 | pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma); | 1818 | dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc, |
1819 | tx_ring->dma); | ||
1808 | 1820 | ||
1809 | tx_ring->desc = NULL; | 1821 | tx_ring->desc = NULL; |
1810 | } | 1822 | } |
@@ -1829,12 +1841,12 @@ static void e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter, | |||
1829 | { | 1841 | { |
1830 | if (buffer_info->dma) { | 1842 | if (buffer_info->dma) { |
1831 | if (buffer_info->mapped_as_page) | 1843 | if (buffer_info->mapped_as_page) |
1832 | pci_unmap_page(adapter->pdev, buffer_info->dma, | 1844 | dma_unmap_page(&adapter->pdev->dev, buffer_info->dma, |
1833 | buffer_info->length, PCI_DMA_TODEVICE); | 1845 | buffer_info->length, DMA_TO_DEVICE); |
1834 | else | 1846 | else |
1835 | pci_unmap_single(adapter->pdev, buffer_info->dma, | 1847 | dma_unmap_single(&adapter->pdev->dev, buffer_info->dma, |
1836 | buffer_info->length, | 1848 | buffer_info->length, |
1837 | PCI_DMA_TODEVICE); | 1849 | DMA_TO_DEVICE); |
1838 | buffer_info->dma = 0; | 1850 | buffer_info->dma = 0; |
1839 | } | 1851 | } |
1840 | if (buffer_info->skb) { | 1852 | if (buffer_info->skb) { |
@@ -1912,7 +1924,8 @@ static void e1000_free_rx_resources(struct e1000_adapter *adapter, | |||
1912 | vfree(rx_ring->buffer_info); | 1924 | vfree(rx_ring->buffer_info); |
1913 | rx_ring->buffer_info = NULL; | 1925 | rx_ring->buffer_info = NULL; |
1914 | 1926 | ||
1915 | pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma); | 1927 | dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc, |
1928 | rx_ring->dma); | ||
1916 | 1929 | ||
1917 | rx_ring->desc = NULL; | 1930 | rx_ring->desc = NULL; |
1918 | } | 1931 | } |
@@ -1952,14 +1965,14 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter, | |||
1952 | buffer_info = &rx_ring->buffer_info[i]; | 1965 | buffer_info = &rx_ring->buffer_info[i]; |
1953 | if (buffer_info->dma && | 1966 | if (buffer_info->dma && |
1954 | adapter->clean_rx == e1000_clean_rx_irq) { | 1967 | adapter->clean_rx == e1000_clean_rx_irq) { |
1955 | pci_unmap_single(pdev, buffer_info->dma, | 1968 | dma_unmap_single(&pdev->dev, buffer_info->dma, |
1956 | buffer_info->length, | 1969 | buffer_info->length, |
1957 | PCI_DMA_FROMDEVICE); | 1970 | DMA_FROM_DEVICE); |
1958 | } else if (buffer_info->dma && | 1971 | } else if (buffer_info->dma && |
1959 | adapter->clean_rx == e1000_clean_jumbo_rx_irq) { | 1972 | adapter->clean_rx == e1000_clean_jumbo_rx_irq) { |
1960 | pci_unmap_page(pdev, buffer_info->dma, | 1973 | dma_unmap_page(&pdev->dev, buffer_info->dma, |
1961 | buffer_info->length, | 1974 | buffer_info->length, |
1962 | PCI_DMA_FROMDEVICE); | 1975 | DMA_FROM_DEVICE); |
1963 | } | 1976 | } |
1964 | 1977 | ||
1965 | buffer_info->dma = 0; | 1978 | buffer_info->dma = 0; |
@@ -2714,9 +2727,10 @@ static int e1000_tx_map(struct e1000_adapter *adapter, | |||
2714 | /* set time_stamp *before* dma to help avoid a possible race */ | 2727 | /* set time_stamp *before* dma to help avoid a possible race */ |
2715 | buffer_info->time_stamp = jiffies; | 2728 | buffer_info->time_stamp = jiffies; |
2716 | buffer_info->mapped_as_page = false; | 2729 | buffer_info->mapped_as_page = false; |
2717 | buffer_info->dma = pci_map_single(pdev, skb->data + offset, | 2730 | buffer_info->dma = dma_map_single(&pdev->dev, |
2718 | size, PCI_DMA_TODEVICE); | 2731 | skb->data + offset, |
2719 | if (pci_dma_mapping_error(pdev, buffer_info->dma)) | 2732 | size, DMA_TO_DEVICE); |
2733 | if (dma_mapping_error(&pdev->dev, buffer_info->dma)) | ||
2720 | goto dma_error; | 2734 | goto dma_error; |
2721 | buffer_info->next_to_watch = i; | 2735 | buffer_info->next_to_watch = i; |
2722 | 2736 | ||
@@ -2760,10 +2774,10 @@ static int e1000_tx_map(struct e1000_adapter *adapter, | |||
2760 | buffer_info->length = size; | 2774 | buffer_info->length = size; |
2761 | buffer_info->time_stamp = jiffies; | 2775 | buffer_info->time_stamp = jiffies; |
2762 | buffer_info->mapped_as_page = true; | 2776 | buffer_info->mapped_as_page = true; |
2763 | buffer_info->dma = pci_map_page(pdev, frag->page, | 2777 | buffer_info->dma = dma_map_page(&pdev->dev, frag->page, |
2764 | offset, size, | 2778 | offset, size, |
2765 | PCI_DMA_TODEVICE); | 2779 | DMA_TO_DEVICE); |
2766 | if (pci_dma_mapping_error(pdev, buffer_info->dma)) | 2780 | if (dma_mapping_error(&pdev->dev, buffer_info->dma)) |
2767 | goto dma_error; | 2781 | goto dma_error; |
2768 | buffer_info->next_to_watch = i; | 2782 | buffer_info->next_to_watch = i; |
2769 | 2783 | ||
@@ -3634,8 +3648,8 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, | |||
3634 | 3648 | ||
3635 | cleaned = true; | 3649 | cleaned = true; |
3636 | cleaned_count++; | 3650 | cleaned_count++; |
3637 | pci_unmap_page(pdev, buffer_info->dma, buffer_info->length, | 3651 | dma_unmap_page(&pdev->dev, buffer_info->dma, |
3638 | PCI_DMA_FROMDEVICE); | 3652 | buffer_info->length, DMA_FROM_DEVICE); |
3639 | buffer_info->dma = 0; | 3653 | buffer_info->dma = 0; |
3640 | 3654 | ||
3641 | length = le16_to_cpu(rx_desc->length); | 3655 | length = le16_to_cpu(rx_desc->length); |
@@ -3817,8 +3831,8 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | |||
3817 | 3831 | ||
3818 | cleaned = true; | 3832 | cleaned = true; |
3819 | cleaned_count++; | 3833 | cleaned_count++; |
3820 | pci_unmap_single(pdev, buffer_info->dma, buffer_info->length, | 3834 | dma_unmap_single(&pdev->dev, buffer_info->dma, |
3821 | PCI_DMA_FROMDEVICE); | 3835 | buffer_info->length, DMA_FROM_DEVICE); |
3822 | buffer_info->dma = 0; | 3836 | buffer_info->dma = 0; |
3823 | 3837 | ||
3824 | length = le16_to_cpu(rx_desc->length); | 3838 | length = le16_to_cpu(rx_desc->length); |
@@ -3998,11 +4012,11 @@ check_page: | |||
3998 | } | 4012 | } |
3999 | 4013 | ||
4000 | if (!buffer_info->dma) { | 4014 | if (!buffer_info->dma) { |
4001 | buffer_info->dma = pci_map_page(pdev, | 4015 | buffer_info->dma = dma_map_page(&pdev->dev, |
4002 | buffer_info->page, 0, | 4016 | buffer_info->page, 0, |
4003 | buffer_info->length, | 4017 | buffer_info->length, |
4004 | PCI_DMA_FROMDEVICE); | 4018 | DMA_FROM_DEVICE); |
4005 | if (pci_dma_mapping_error(pdev, buffer_info->dma)) { | 4019 | if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { |
4006 | put_page(buffer_info->page); | 4020 | put_page(buffer_info->page); |
4007 | dev_kfree_skb(skb); | 4021 | dev_kfree_skb(skb); |
4008 | buffer_info->page = NULL; | 4022 | buffer_info->page = NULL; |
@@ -4098,11 +4112,11 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, | |||
4098 | buffer_info->skb = skb; | 4112 | buffer_info->skb = skb; |
4099 | buffer_info->length = adapter->rx_buffer_len; | 4113 | buffer_info->length = adapter->rx_buffer_len; |
4100 | map_skb: | 4114 | map_skb: |
4101 | buffer_info->dma = pci_map_single(pdev, | 4115 | buffer_info->dma = dma_map_single(&pdev->dev, |
4102 | skb->data, | 4116 | skb->data, |
4103 | buffer_info->length, | 4117 | buffer_info->length, |
4104 | PCI_DMA_FROMDEVICE); | 4118 | DMA_FROM_DEVICE); |
4105 | if (pci_dma_mapping_error(pdev, buffer_info->dma)) { | 4119 | if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { |
4106 | dev_kfree_skb(skb); | 4120 | dev_kfree_skb(skb); |
4107 | buffer_info->skb = NULL; | 4121 | buffer_info->skb = NULL; |
4108 | buffer_info->dma = 0; | 4122 | buffer_info->dma = 0; |
@@ -4126,9 +4140,9 @@ map_skb: | |||
4126 | dev_kfree_skb(skb); | 4140 | dev_kfree_skb(skb); |
4127 | buffer_info->skb = NULL; | 4141 | buffer_info->skb = NULL; |
4128 | 4142 | ||
4129 | pci_unmap_single(pdev, buffer_info->dma, | 4143 | dma_unmap_single(&pdev->dev, buffer_info->dma, |
4130 | adapter->rx_buffer_len, | 4144 | adapter->rx_buffer_len, |
4131 | PCI_DMA_FROMDEVICE); | 4145 | DMA_FROM_DEVICE); |
4132 | buffer_info->dma = 0; | 4146 | buffer_info->dma = 0; |
4133 | 4147 | ||
4134 | adapter->alloc_rx_buff_failed++; | 4148 | adapter->alloc_rx_buff_failed++; |