Skip to content

Commit 7103418

Browse files
ffainelliLuis Henriques
authored andcommitted
net: bcmgenet: Utilize correct struct device for all DMA operations
BugLink: http://bugs.launchpad.net/bugs/1650607 [ Upstream commit 8c4799a ] __bcmgenet_tx_reclaim() and bcmgenet_free_rx_buffers() are not using the same struct device during unmap that was used for the map operation, which makes DMA-API debugging warn about it. Fix this by always using &priv->pdev->dev throughout the driver, using an identical device reference for all map/unmap calls. Fixes: 1c1008c ("net: bcmgenet: add main driver file") Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Tim Gardner <[email protected]> Signed-off-by: Luis Henriques <[email protected]>
1 parent 1d0e4bb commit 7103418

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,7 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,
11681168
struct bcmgenet_tx_ring *ring)
11691169
{
11701170
struct bcmgenet_priv *priv = netdev_priv(dev);
1171+
struct device *kdev = &priv->pdev->dev;
11711172
struct enet_cb *tx_cb_ptr;
11721173
struct netdev_queue *txq;
11731174
unsigned int pkts_compl = 0;
@@ -1195,15 +1196,15 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,
11951196
pkts_compl++;
11961197
dev->stats.tx_packets++;
11971198
dev->stats.tx_bytes += tx_cb_ptr->skb->len;
1198-
dma_unmap_single(&dev->dev,
1199+
dma_unmap_single(kdev,
11991200
dma_unmap_addr(tx_cb_ptr, dma_addr),
12001201
dma_unmap_len(tx_cb_ptr, dma_len),
12011202
DMA_TO_DEVICE);
12021203
bcmgenet_free_cb(tx_cb_ptr);
12031204
} else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) {
12041205
dev->stats.tx_bytes +=
12051206
dma_unmap_len(tx_cb_ptr, dma_len);
1206-
dma_unmap_page(&dev->dev,
1207+
dma_unmap_page(kdev,
12071208
dma_unmap_addr(tx_cb_ptr, dma_addr),
12081209
dma_unmap_len(tx_cb_ptr, dma_len),
12091210
DMA_TO_DEVICE);
@@ -1754,14 +1755,15 @@ static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv,
17541755

17551756
static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv)
17561757
{
1758+
struct device *kdev = &priv->pdev->dev;
17571759
struct enet_cb *cb;
17581760
int i;
17591761

17601762
for (i = 0; i < priv->num_rx_bds; i++) {
17611763
cb = &priv->rx_cbs[i];
17621764

17631765
if (dma_unmap_addr(cb, dma_addr)) {
1764-
dma_unmap_single(&priv->dev->dev,
1766+
dma_unmap_single(kdev,
17651767
dma_unmap_addr(cb, dma_addr),
17661768
priv->rx_buf_len, DMA_FROM_DEVICE);
17671769
dma_unmap_addr_set(cb, dma_addr, 0);

0 commit comments

Comments
 (0)