Skip to content

Commit a695895

Browse files
arndbkuba-moo
authored andcommitted
au1000_eth: stop using virt_to_bus()
The conversion to the dma-mapping API in linux-2.6.11 was incomplete and left a virt_to_bus() call around. There have been a number of fixes for DMA mapping API abuse in this driver, but this one always slipped through. Change it to just use the existing dma_addr_t pointer, and make it use the correct types throughout the driver to make it easier to understand the virtual vs dma address spaces. Signed-off-by: Arnd Bergmann <[email protected]> Tested-by: Manuel Lauss <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f638a84 commit a695895

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

drivers/net/ethernet/amd/au1000_eth.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ static int au1000_rx(struct net_device *dev)
820820
pr_cont("\n");
821821
}
822822
}
823-
prxd->buff_stat = (u32)(pDB->dma_addr | RX_DMA_ENABLE);
823+
prxd->buff_stat = lower_32_bits(pDB->dma_addr) | RX_DMA_ENABLE;
824824
aup->rx_head = (aup->rx_head + 1) & (NUM_RX_DMA - 1);
825825
wmb(); /* drain writebuffer */
826826

@@ -996,7 +996,7 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev)
996996
ps->tx_packets++;
997997
ps->tx_bytes += ptxd->len;
998998

999-
ptxd->buff_stat = pDB->dma_addr | TX_DMA_ENABLE;
999+
ptxd->buff_stat = lower_32_bits(pDB->dma_addr) | TX_DMA_ENABLE;
10001000
wmb(); /* drain writebuffer */
10011001
dev_kfree_skb(skb);
10021002
aup->tx_head = (aup->tx_head + 1) & (NUM_TX_DMA - 1);
@@ -1131,9 +1131,9 @@ static int au1000_probe(struct platform_device *pdev)
11311131
/* Allocate the data buffers
11321132
* Snooping works fine with eth on all au1xxx
11331133
*/
1134-
aup->vaddr = (u32)dma_alloc_coherent(&pdev->dev, MAX_BUF_SIZE *
1135-
(NUM_TX_BUFFS + NUM_RX_BUFFS),
1136-
&aup->dma_addr, 0);
1134+
aup->vaddr = dma_alloc_coherent(&pdev->dev, MAX_BUF_SIZE *
1135+
(NUM_TX_BUFFS + NUM_RX_BUFFS),
1136+
&aup->dma_addr, 0);
11371137
if (!aup->vaddr) {
11381138
dev_err(&pdev->dev, "failed to allocate data buffers\n");
11391139
err = -ENOMEM;
@@ -1234,8 +1234,8 @@ static int au1000_probe(struct platform_device *pdev)
12341234
for (i = 0; i < (NUM_TX_BUFFS+NUM_RX_BUFFS); i++) {
12351235
pDB->pnext = pDBfree;
12361236
pDBfree = pDB;
1237-
pDB->vaddr = (u32 *)((unsigned)aup->vaddr + MAX_BUF_SIZE*i);
1238-
pDB->dma_addr = (dma_addr_t)virt_to_bus(pDB->vaddr);
1237+
pDB->vaddr = aup->vaddr + MAX_BUF_SIZE * i;
1238+
pDB->dma_addr = aup->dma_addr + MAX_BUF_SIZE * i;
12391239
pDB++;
12401240
}
12411241
aup->pDBfree = pDBfree;
@@ -1246,7 +1246,7 @@ static int au1000_probe(struct platform_device *pdev)
12461246
if (!pDB)
12471247
goto err_out;
12481248

1249-
aup->rx_dma_ring[i]->buff_stat = (unsigned)pDB->dma_addr;
1249+
aup->rx_dma_ring[i]->buff_stat = lower_32_bits(pDB->dma_addr);
12501250
aup->rx_db_inuse[i] = pDB;
12511251
}
12521252

@@ -1255,7 +1255,7 @@ static int au1000_probe(struct platform_device *pdev)
12551255
if (!pDB)
12561256
goto err_out;
12571257

1258-
aup->tx_dma_ring[i]->buff_stat = (unsigned)pDB->dma_addr;
1258+
aup->tx_dma_ring[i]->buff_stat = lower_32_bits(pDB->dma_addr);
12591259
aup->tx_dma_ring[i]->len = 0;
12601260
aup->tx_db_inuse[i] = pDB;
12611261
}
@@ -1310,7 +1310,7 @@ static int au1000_probe(struct platform_device *pdev)
13101310
iounmap(aup->mac);
13111311
err_remap1:
13121312
dma_free_coherent(&pdev->dev, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
1313-
(void *)aup->vaddr, aup->dma_addr);
1313+
aup->vaddr, aup->dma_addr);
13141314
err_vaddr:
13151315
free_netdev(dev);
13161316
err_alloc:
@@ -1343,7 +1343,7 @@ static int au1000_remove(struct platform_device *pdev)
13431343
au1000_ReleaseDB(aup, aup->tx_db_inuse[i]);
13441344

13451345
dma_free_coherent(&pdev->dev, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
1346-
(void *)aup->vaddr, aup->dma_addr);
1346+
aup->vaddr, aup->dma_addr);
13471347

13481348
iounmap(aup->macdma);
13491349
iounmap(aup->mac);

drivers/net/ethernet/amd/au1000_eth.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ struct au1000_private {
106106
struct mac_reg *mac; /* mac registers */
107107
u32 *enable; /* address of MAC Enable Register */
108108
void __iomem *macdma; /* base of MAC DMA port */
109-
u32 vaddr; /* virtual address of rx/tx buffers */
110-
dma_addr_t dma_addr; /* dma address of rx/tx buffers */
109+
void *vaddr; /* virtual address of rx/tx buffers */
110+
dma_addr_t dma_addr; /* dma address of rx/tx buffers */
111111

112112
spinlock_t lock; /* Serialise access to device */
113113

0 commit comments

Comments
 (0)