Commit 7a1fe380 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by David S. Miller

tulip: de2104x: switch from 'pci_' to 'dma_' API

The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.

When memory is allocated in 'de_alloc_rings()' GFP_KERNEL can be used
because it is only called from 'de_open()' which is a '.ndo_open'
function. Such functions are synchronized using the rtnl_lock() semaphore
and no lock is taken in the between.

@@
@@
-    PCI_DMA_BIDIRECTIONAL
+    DMA_BIDIRECTIONAL

@@
@@
-    PCI_DMA_TODEVICE
+    DMA_TO_DEVICE

@@
@@
-    PCI_DMA_FROMDEVICE
+    DMA_FROM_DEVICE

@@
@@
-    PCI_DMA_NONE
+    DMA_NONE

@@
expression e1, e2, e3;
@@
-    pci_alloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3;
@@
-    pci_zalloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3, e4;
@@
-    pci_free_consistent(e1, e2, e3, e4)
+    dma_free_coherent(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_single(e1, e2, e3, e4)
+    dma_map_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_single(e1, e2, e3, e4)
+    dma_unmap_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4, e5;
@@
-    pci_map_page(e1, e2, e3, e4, e5)
+    dma_map_page(&e1->dev, e2, e3, e4, e5)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_page(e1, e2, e3, e4)
+    dma_unmap_page(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_sg(e1, e2, e3, e4)
+    dma_map_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_sg(e1, e2, e3, e4)
+    dma_unmap_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_device(e1, e2, e3, e4)
+    dma_sync_single_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2;
@@
-    pci_dma_mapping_error(e1, e2)
+    dma_mapping_error(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_dma_mask(e1, e2)
+    dma_set_mask(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_consistent_dma_mask(e1, e2)
+    dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: default avatarMoritz Fischer <mdf@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent af114c42
...@@ -443,21 +443,23 @@ static void de_rx (struct de_private *de) ...@@ -443,21 +443,23 @@ static void de_rx (struct de_private *de)
} }
if (!copying_skb) { if (!copying_skb) {
pci_unmap_single(de->pdev, mapping, dma_unmap_single(&de->pdev->dev, mapping, buflen,
buflen, PCI_DMA_FROMDEVICE); DMA_FROM_DEVICE);
skb_put(skb, len); skb_put(skb, len);
mapping = mapping =
de->rx_skb[rx_tail].mapping = de->rx_skb[rx_tail].mapping =
pci_map_single(de->pdev, copy_skb->data, dma_map_single(&de->pdev->dev, copy_skb->data,
buflen, PCI_DMA_FROMDEVICE); buflen, DMA_FROM_DEVICE);
de->rx_skb[rx_tail].skb = copy_skb; de->rx_skb[rx_tail].skb = copy_skb;
} else { } else {
pci_dma_sync_single_for_cpu(de->pdev, mapping, len, PCI_DMA_FROMDEVICE); dma_sync_single_for_cpu(&de->pdev->dev, mapping, len,
DMA_FROM_DEVICE);
skb_reserve(copy_skb, RX_OFFSET); skb_reserve(copy_skb, RX_OFFSET);
skb_copy_from_linear_data(skb, skb_put(copy_skb, len), skb_copy_from_linear_data(skb, skb_put(copy_skb, len),
len); len);
pci_dma_sync_single_for_device(de->pdev, mapping, len, PCI_DMA_FROMDEVICE); dma_sync_single_for_device(&de->pdev->dev, mapping,
len, DMA_FROM_DEVICE);
/* We'll reuse the original ring buffer. */ /* We'll reuse the original ring buffer. */
skb = copy_skb; skb = copy_skb;
...@@ -554,13 +556,15 @@ static void de_tx (struct de_private *de) ...@@ -554,13 +556,15 @@ static void de_tx (struct de_private *de)
goto next; goto next;
if (unlikely(skb == DE_SETUP_SKB)) { if (unlikely(skb == DE_SETUP_SKB)) {
pci_unmap_single(de->pdev, de->tx_skb[tx_tail].mapping, dma_unmap_single(&de->pdev->dev,
sizeof(de->setup_frame), PCI_DMA_TODEVICE); de->tx_skb[tx_tail].mapping,
sizeof(de->setup_frame),
DMA_TO_DEVICE);
goto next; goto next;
} }
pci_unmap_single(de->pdev, de->tx_skb[tx_tail].mapping, dma_unmap_single(&de->pdev->dev, de->tx_skb[tx_tail].mapping,
skb->len, PCI_DMA_TODEVICE); skb->len, DMA_TO_DEVICE);
if (status & LastFrag) { if (status & LastFrag) {
if (status & TxError) { if (status & TxError) {
...@@ -620,7 +624,8 @@ static netdev_tx_t de_start_xmit (struct sk_buff *skb, ...@@ -620,7 +624,8 @@ static netdev_tx_t de_start_xmit (struct sk_buff *skb,
txd = &de->tx_ring[entry]; txd = &de->tx_ring[entry];
len = skb->len; len = skb->len;
mapping = pci_map_single(de->pdev, skb->data, len, PCI_DMA_TODEVICE); mapping = dma_map_single(&de->pdev->dev, skb->data, len,
DMA_TO_DEVICE);
if (entry == (DE_TX_RING_SIZE - 1)) if (entry == (DE_TX_RING_SIZE - 1))
flags |= RingEnd; flags |= RingEnd;
if (!tx_free || (tx_free == (DE_TX_RING_SIZE / 2))) if (!tx_free || (tx_free == (DE_TX_RING_SIZE / 2)))
...@@ -763,8 +768,8 @@ static void __de_set_rx_mode (struct net_device *dev) ...@@ -763,8 +768,8 @@ static void __de_set_rx_mode (struct net_device *dev)
de->tx_skb[entry].skb = DE_SETUP_SKB; de->tx_skb[entry].skb = DE_SETUP_SKB;
de->tx_skb[entry].mapping = mapping = de->tx_skb[entry].mapping = mapping =
pci_map_single (de->pdev, de->setup_frame, dma_map_single(&de->pdev->dev, de->setup_frame,
sizeof (de->setup_frame), PCI_DMA_TODEVICE); sizeof(de->setup_frame), DMA_TO_DEVICE);
/* Put the setup frame on the Tx list. */ /* Put the setup frame on the Tx list. */
txd = &de->tx_ring[entry]; txd = &de->tx_ring[entry];
...@@ -1279,8 +1284,10 @@ static int de_refill_rx (struct de_private *de) ...@@ -1279,8 +1284,10 @@ static int de_refill_rx (struct de_private *de)
if (!skb) if (!skb)
goto err_out; goto err_out;
de->rx_skb[i].mapping = pci_map_single(de->pdev, de->rx_skb[i].mapping = dma_map_single(&de->pdev->dev,
skb->data, de->rx_buf_sz, PCI_DMA_FROMDEVICE); skb->data,
de->rx_buf_sz,
DMA_FROM_DEVICE);
de->rx_skb[i].skb = skb; de->rx_skb[i].skb = skb;
de->rx_ring[i].opts1 = cpu_to_le32(DescOwn); de->rx_ring[i].opts1 = cpu_to_le32(DescOwn);
...@@ -1313,7 +1320,8 @@ static int de_init_rings (struct de_private *de) ...@@ -1313,7 +1320,8 @@ static int de_init_rings (struct de_private *de)
static int de_alloc_rings (struct de_private *de) static int de_alloc_rings (struct de_private *de)
{ {
de->rx_ring = pci_alloc_consistent(de->pdev, DE_RING_BYTES, &de->ring_dma); de->rx_ring = dma_alloc_coherent(&de->pdev->dev, DE_RING_BYTES,
&de->ring_dma, GFP_KERNEL);
if (!de->rx_ring) if (!de->rx_ring)
return -ENOMEM; return -ENOMEM;
de->tx_ring = &de->rx_ring[DE_RX_RING_SIZE]; de->tx_ring = &de->rx_ring[DE_RX_RING_SIZE];
...@@ -1333,8 +1341,9 @@ static void de_clean_rings (struct de_private *de) ...@@ -1333,8 +1341,9 @@ static void de_clean_rings (struct de_private *de)
for (i = 0; i < DE_RX_RING_SIZE; i++) { for (i = 0; i < DE_RX_RING_SIZE; i++) {
if (de->rx_skb[i].skb) { if (de->rx_skb[i].skb) {
pci_unmap_single(de->pdev, de->rx_skb[i].mapping, dma_unmap_single(&de->pdev->dev,
de->rx_buf_sz, PCI_DMA_FROMDEVICE); de->rx_skb[i].mapping, de->rx_buf_sz,
DMA_FROM_DEVICE);
dev_kfree_skb(de->rx_skb[i].skb); dev_kfree_skb(de->rx_skb[i].skb);
} }
} }
...@@ -1344,15 +1353,15 @@ static void de_clean_rings (struct de_private *de) ...@@ -1344,15 +1353,15 @@ static void de_clean_rings (struct de_private *de)
if ((skb) && (skb != DE_DUMMY_SKB)) { if ((skb) && (skb != DE_DUMMY_SKB)) {
if (skb != DE_SETUP_SKB) { if (skb != DE_SETUP_SKB) {
de->dev->stats.tx_dropped++; de->dev->stats.tx_dropped++;
pci_unmap_single(de->pdev, dma_unmap_single(&de->pdev->dev,
de->tx_skb[i].mapping, de->tx_skb[i].mapping,
skb->len, PCI_DMA_TODEVICE); skb->len, DMA_TO_DEVICE);
dev_kfree_skb(skb); dev_kfree_skb(skb);
} else { } else {
pci_unmap_single(de->pdev, dma_unmap_single(&de->pdev->dev,
de->tx_skb[i].mapping, de->tx_skb[i].mapping,
sizeof(de->setup_frame), sizeof(de->setup_frame),
PCI_DMA_TODEVICE); DMA_TO_DEVICE);
} }
} }
} }
...@@ -1364,7 +1373,8 @@ static void de_clean_rings (struct de_private *de) ...@@ -1364,7 +1373,8 @@ static void de_clean_rings (struct de_private *de)
static void de_free_rings (struct de_private *de) static void de_free_rings (struct de_private *de)
{ {
de_clean_rings(de); de_clean_rings(de);
pci_free_consistent(de->pdev, DE_RING_BYTES, de->rx_ring, de->ring_dma); dma_free_coherent(&de->pdev->dev, DE_RING_BYTES, de->rx_ring,
de->ring_dma);
de->rx_ring = NULL; de->rx_ring = NULL;
de->tx_ring = NULL; de->tx_ring = NULL;
} }
......
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