Commit e2dbb33a authored by Kazuya Mizuguchi's avatar Kazuya Mizuguchi Committed by David S. Miller

ravb: Provide dev parameter to DMA API

This patch is in preparation for using this driver on arm64 where the
implementation of __dma_alloc_coherent fails if a device parameter is not
provided.
Signed-off-by: default avatarKazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: default avatarMasaru Nagai <masaru.nagai.vx@renesas.com>
[horms: squashed into a single patch]
Signed-off-by: default avatarSimon Horman <horms+renesas@verge.net.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f3a6bd39
...@@ -201,7 +201,7 @@ static void ravb_ring_free(struct net_device *ndev, int q) ...@@ -201,7 +201,7 @@ static void ravb_ring_free(struct net_device *ndev, int q)
if (priv->rx_ring[q]) { if (priv->rx_ring[q]) {
ring_size = sizeof(struct ravb_ex_rx_desc) * ring_size = sizeof(struct ravb_ex_rx_desc) *
(priv->num_rx_ring[q] + 1); (priv->num_rx_ring[q] + 1);
dma_free_coherent(NULL, ring_size, priv->rx_ring[q], dma_free_coherent(ndev->dev.parent, ring_size, priv->rx_ring[q],
priv->rx_desc_dma[q]); priv->rx_desc_dma[q]);
priv->rx_ring[q] = NULL; priv->rx_ring[q] = NULL;
} }
...@@ -209,7 +209,7 @@ static void ravb_ring_free(struct net_device *ndev, int q) ...@@ -209,7 +209,7 @@ static void ravb_ring_free(struct net_device *ndev, int q)
if (priv->tx_ring[q]) { if (priv->tx_ring[q]) {
ring_size = sizeof(struct ravb_tx_desc) * ring_size = sizeof(struct ravb_tx_desc) *
(priv->num_tx_ring[q] * NUM_TX_DESC + 1); (priv->num_tx_ring[q] * NUM_TX_DESC + 1);
dma_free_coherent(NULL, ring_size, priv->tx_ring[q], dma_free_coherent(ndev->dev.parent, ring_size, priv->tx_ring[q],
priv->tx_desc_dma[q]); priv->tx_desc_dma[q]);
priv->tx_ring[q] = NULL; priv->tx_ring[q] = NULL;
} }
...@@ -240,13 +240,13 @@ static void ravb_ring_format(struct net_device *ndev, int q) ...@@ -240,13 +240,13 @@ static void ravb_ring_format(struct net_device *ndev, int q)
rx_desc = &priv->rx_ring[q][i]; rx_desc = &priv->rx_ring[q][i];
/* The size of the buffer should be on 16-byte boundary. */ /* The size of the buffer should be on 16-byte boundary. */
rx_desc->ds_cc = cpu_to_le16(ALIGN(PKT_BUF_SZ, 16)); rx_desc->ds_cc = cpu_to_le16(ALIGN(PKT_BUF_SZ, 16));
dma_addr = dma_map_single(&ndev->dev, priv->rx_skb[q][i]->data, dma_addr = dma_map_single(ndev->dev.parent, priv->rx_skb[q][i]->data,
ALIGN(PKT_BUF_SZ, 16), ALIGN(PKT_BUF_SZ, 16),
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
/* We just set the data size to 0 for a failed mapping which /* We just set the data size to 0 for a failed mapping which
* should prevent DMA from happening... * should prevent DMA from happening...
*/ */
if (dma_mapping_error(&ndev->dev, dma_addr)) if (dma_mapping_error(ndev->dev.parent, dma_addr))
rx_desc->ds_cc = cpu_to_le16(0); rx_desc->ds_cc = cpu_to_le16(0);
rx_desc->dptr = cpu_to_le32(dma_addr); rx_desc->dptr = cpu_to_le32(dma_addr);
rx_desc->die_dt = DT_FEMPTY; rx_desc->die_dt = DT_FEMPTY;
...@@ -309,7 +309,7 @@ static int ravb_ring_init(struct net_device *ndev, int q) ...@@ -309,7 +309,7 @@ static int ravb_ring_init(struct net_device *ndev, int q)
/* Allocate all RX descriptors. */ /* Allocate all RX descriptors. */
ring_size = sizeof(struct ravb_ex_rx_desc) * (priv->num_rx_ring[q] + 1); ring_size = sizeof(struct ravb_ex_rx_desc) * (priv->num_rx_ring[q] + 1);
priv->rx_ring[q] = dma_alloc_coherent(NULL, ring_size, priv->rx_ring[q] = dma_alloc_coherent(ndev->dev.parent, ring_size,
&priv->rx_desc_dma[q], &priv->rx_desc_dma[q],
GFP_KERNEL); GFP_KERNEL);
if (!priv->rx_ring[q]) if (!priv->rx_ring[q])
...@@ -320,7 +320,7 @@ static int ravb_ring_init(struct net_device *ndev, int q) ...@@ -320,7 +320,7 @@ static int ravb_ring_init(struct net_device *ndev, int q)
/* Allocate all TX descriptors. */ /* Allocate all TX descriptors. */
ring_size = sizeof(struct ravb_tx_desc) * ring_size = sizeof(struct ravb_tx_desc) *
(priv->num_tx_ring[q] * NUM_TX_DESC + 1); (priv->num_tx_ring[q] * NUM_TX_DESC + 1);
priv->tx_ring[q] = dma_alloc_coherent(NULL, ring_size, priv->tx_ring[q] = dma_alloc_coherent(ndev->dev.parent, ring_size,
&priv->tx_desc_dma[q], &priv->tx_desc_dma[q],
GFP_KERNEL); GFP_KERNEL);
if (!priv->tx_ring[q]) if (!priv->tx_ring[q])
...@@ -443,7 +443,7 @@ static int ravb_tx_free(struct net_device *ndev, int q) ...@@ -443,7 +443,7 @@ static int ravb_tx_free(struct net_device *ndev, int q)
size = le16_to_cpu(desc->ds_tagl) & TX_DS; size = le16_to_cpu(desc->ds_tagl) & TX_DS;
/* Free the original skb. */ /* Free the original skb. */
if (priv->tx_skb[q][entry / NUM_TX_DESC]) { if (priv->tx_skb[q][entry / NUM_TX_DESC]) {
dma_unmap_single(&ndev->dev, le32_to_cpu(desc->dptr), dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr),
size, DMA_TO_DEVICE); size, DMA_TO_DEVICE);
/* Last packet descriptor? */ /* Last packet descriptor? */
if (entry % NUM_TX_DESC == NUM_TX_DESC - 1) { if (entry % NUM_TX_DESC == NUM_TX_DESC - 1) {
...@@ -546,7 +546,7 @@ static bool ravb_rx(struct net_device *ndev, int *quota, int q) ...@@ -546,7 +546,7 @@ static bool ravb_rx(struct net_device *ndev, int *quota, int q)
skb = priv->rx_skb[q][entry]; skb = priv->rx_skb[q][entry];
priv->rx_skb[q][entry] = NULL; priv->rx_skb[q][entry] = NULL;
dma_unmap_single(&ndev->dev, le32_to_cpu(desc->dptr), dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr),
ALIGN(PKT_BUF_SZ, 16), ALIGN(PKT_BUF_SZ, 16),
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
get_ts &= (q == RAVB_NC) ? get_ts &= (q == RAVB_NC) ?
...@@ -586,14 +586,14 @@ static bool ravb_rx(struct net_device *ndev, int *quota, int q) ...@@ -586,14 +586,14 @@ static bool ravb_rx(struct net_device *ndev, int *quota, int q)
if (!skb) if (!skb)
break; /* Better luck next round. */ break; /* Better luck next round. */
ravb_set_buffer_align(skb); ravb_set_buffer_align(skb);
dma_addr = dma_map_single(&ndev->dev, skb->data, dma_addr = dma_map_single(ndev->dev.parent, skb->data,
le16_to_cpu(desc->ds_cc), le16_to_cpu(desc->ds_cc),
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
skb_checksum_none_assert(skb); skb_checksum_none_assert(skb);
/* We just set the data size to 0 for a failed mapping /* We just set the data size to 0 for a failed mapping
* which should prevent DMA from happening... * which should prevent DMA from happening...
*/ */
if (dma_mapping_error(&ndev->dev, dma_addr)) if (dma_mapping_error(ndev->dev.parent, dma_addr))
desc->ds_cc = cpu_to_le16(0); desc->ds_cc = cpu_to_le16(0);
desc->dptr = cpu_to_le32(dma_addr); desc->dptr = cpu_to_le32(dma_addr);
priv->rx_skb[q][entry] = skb; priv->rx_skb[q][entry] = skb;
...@@ -1300,8 +1300,8 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev) ...@@ -1300,8 +1300,8 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
entry / NUM_TX_DESC * DPTR_ALIGN; entry / NUM_TX_DESC * DPTR_ALIGN;
len = PTR_ALIGN(skb->data, DPTR_ALIGN) - skb->data; len = PTR_ALIGN(skb->data, DPTR_ALIGN) - skb->data;
memcpy(buffer, skb->data, len); memcpy(buffer, skb->data, len);
dma_addr = dma_map_single(&ndev->dev, buffer, len, DMA_TO_DEVICE); dma_addr = dma_map_single(ndev->dev.parent, buffer, len, DMA_TO_DEVICE);
if (dma_mapping_error(&ndev->dev, dma_addr)) if (dma_mapping_error(ndev->dev.parent, dma_addr))
goto drop; goto drop;
desc = &priv->tx_ring[q][entry]; desc = &priv->tx_ring[q][entry];
...@@ -1310,8 +1310,8 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev) ...@@ -1310,8 +1310,8 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
buffer = skb->data + len; buffer = skb->data + len;
len = skb->len - len; len = skb->len - len;
dma_addr = dma_map_single(&ndev->dev, buffer, len, DMA_TO_DEVICE); dma_addr = dma_map_single(ndev->dev.parent, buffer, len, DMA_TO_DEVICE);
if (dma_mapping_error(&ndev->dev, dma_addr)) if (dma_mapping_error(ndev->dev.parent, dma_addr))
goto unmap; goto unmap;
desc++; desc++;
...@@ -1323,7 +1323,7 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev) ...@@ -1323,7 +1323,7 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
ts_skb = kmalloc(sizeof(*ts_skb), GFP_ATOMIC); ts_skb = kmalloc(sizeof(*ts_skb), GFP_ATOMIC);
if (!ts_skb) { if (!ts_skb) {
desc--; desc--;
dma_unmap_single(&ndev->dev, dma_addr, len, dma_unmap_single(ndev->dev.parent, dma_addr, len,
DMA_TO_DEVICE); DMA_TO_DEVICE);
goto unmap; goto unmap;
} }
...@@ -1358,7 +1358,7 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev) ...@@ -1358,7 +1358,7 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
return NETDEV_TX_OK; return NETDEV_TX_OK;
unmap: unmap:
dma_unmap_single(&ndev->dev, le32_to_cpu(desc->dptr), dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr),
le16_to_cpu(desc->ds_tagl), DMA_TO_DEVICE); le16_to_cpu(desc->ds_tagl), DMA_TO_DEVICE);
drop: drop:
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
...@@ -1708,7 +1708,7 @@ static int ravb_probe(struct platform_device *pdev) ...@@ -1708,7 +1708,7 @@ static int ravb_probe(struct platform_device *pdev)
/* Allocate descriptor base address table */ /* Allocate descriptor base address table */
priv->desc_bat_size = sizeof(struct ravb_desc) * DBAT_ENTRY_NUM; priv->desc_bat_size = sizeof(struct ravb_desc) * DBAT_ENTRY_NUM;
priv->desc_bat = dma_alloc_coherent(NULL, priv->desc_bat_size, priv->desc_bat = dma_alloc_coherent(ndev->dev.parent, priv->desc_bat_size,
&priv->desc_bat_dma, GFP_KERNEL); &priv->desc_bat_dma, GFP_KERNEL);
if (!priv->desc_bat) { if (!priv->desc_bat) {
dev_err(&ndev->dev, dev_err(&ndev->dev,
...@@ -1763,7 +1763,7 @@ static int ravb_probe(struct platform_device *pdev) ...@@ -1763,7 +1763,7 @@ static int ravb_probe(struct platform_device *pdev)
netif_napi_del(&priv->napi[RAVB_BE]); netif_napi_del(&priv->napi[RAVB_BE]);
ravb_mdio_release(priv); ravb_mdio_release(priv);
out_dma_free: out_dma_free:
dma_free_coherent(NULL, priv->desc_bat_size, priv->desc_bat, dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
priv->desc_bat_dma); priv->desc_bat_dma);
out_release: out_release:
if (ndev) if (ndev)
...@@ -1779,7 +1779,7 @@ static int ravb_remove(struct platform_device *pdev) ...@@ -1779,7 +1779,7 @@ static int ravb_remove(struct platform_device *pdev)
struct net_device *ndev = platform_get_drvdata(pdev); struct net_device *ndev = platform_get_drvdata(pdev);
struct ravb_private *priv = netdev_priv(ndev); struct ravb_private *priv = netdev_priv(ndev);
dma_free_coherent(NULL, priv->desc_bat_size, priv->desc_bat, dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
priv->desc_bat_dma); priv->desc_bat_dma);
/* Set reset mode */ /* Set reset mode */
ravb_write(ndev, CCC_OPC_RESET, CCC); ravb_write(ndev, CCC_OPC_RESET, CCC);
......
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