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 <arnd@arndb.de> Tested-by: Manuel Lauss <manuel.lauss@gmail.com> Link: https://lore.kernel.org/r/20220607090206.19830-1-arnd@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Родитель
f638a84afe
Коммит
a6958951eb
|
@ -820,7 +820,7 @@ static int au1000_rx(struct net_device *dev)
|
|||
pr_cont("\n");
|
||||
}
|
||||
}
|
||||
prxd->buff_stat = (u32)(pDB->dma_addr | RX_DMA_ENABLE);
|
||||
prxd->buff_stat = lower_32_bits(pDB->dma_addr) | RX_DMA_ENABLE;
|
||||
aup->rx_head = (aup->rx_head + 1) & (NUM_RX_DMA - 1);
|
||||
wmb(); /* drain writebuffer */
|
||||
|
||||
|
@ -996,7 +996,7 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev)
|
|||
ps->tx_packets++;
|
||||
ps->tx_bytes += ptxd->len;
|
||||
|
||||
ptxd->buff_stat = pDB->dma_addr | TX_DMA_ENABLE;
|
||||
ptxd->buff_stat = lower_32_bits(pDB->dma_addr) | TX_DMA_ENABLE;
|
||||
wmb(); /* drain writebuffer */
|
||||
dev_kfree_skb(skb);
|
||||
aup->tx_head = (aup->tx_head + 1) & (NUM_TX_DMA - 1);
|
||||
|
@ -1131,9 +1131,9 @@ static int au1000_probe(struct platform_device *pdev)
|
|||
/* Allocate the data buffers
|
||||
* Snooping works fine with eth on all au1xxx
|
||||
*/
|
||||
aup->vaddr = (u32)dma_alloc_coherent(&pdev->dev, MAX_BUF_SIZE *
|
||||
(NUM_TX_BUFFS + NUM_RX_BUFFS),
|
||||
&aup->dma_addr, 0);
|
||||
aup->vaddr = dma_alloc_coherent(&pdev->dev, MAX_BUF_SIZE *
|
||||
(NUM_TX_BUFFS + NUM_RX_BUFFS),
|
||||
&aup->dma_addr, 0);
|
||||
if (!aup->vaddr) {
|
||||
dev_err(&pdev->dev, "failed to allocate data buffers\n");
|
||||
err = -ENOMEM;
|
||||
|
@ -1234,8 +1234,8 @@ static int au1000_probe(struct platform_device *pdev)
|
|||
for (i = 0; i < (NUM_TX_BUFFS+NUM_RX_BUFFS); i++) {
|
||||
pDB->pnext = pDBfree;
|
||||
pDBfree = pDB;
|
||||
pDB->vaddr = (u32 *)((unsigned)aup->vaddr + MAX_BUF_SIZE*i);
|
||||
pDB->dma_addr = (dma_addr_t)virt_to_bus(pDB->vaddr);
|
||||
pDB->vaddr = aup->vaddr + MAX_BUF_SIZE * i;
|
||||
pDB->dma_addr = aup->dma_addr + MAX_BUF_SIZE * i;
|
||||
pDB++;
|
||||
}
|
||||
aup->pDBfree = pDBfree;
|
||||
|
@ -1246,7 +1246,7 @@ static int au1000_probe(struct platform_device *pdev)
|
|||
if (!pDB)
|
||||
goto err_out;
|
||||
|
||||
aup->rx_dma_ring[i]->buff_stat = (unsigned)pDB->dma_addr;
|
||||
aup->rx_dma_ring[i]->buff_stat = lower_32_bits(pDB->dma_addr);
|
||||
aup->rx_db_inuse[i] = pDB;
|
||||
}
|
||||
|
||||
|
@ -1255,7 +1255,7 @@ static int au1000_probe(struct platform_device *pdev)
|
|||
if (!pDB)
|
||||
goto err_out;
|
||||
|
||||
aup->tx_dma_ring[i]->buff_stat = (unsigned)pDB->dma_addr;
|
||||
aup->tx_dma_ring[i]->buff_stat = lower_32_bits(pDB->dma_addr);
|
||||
aup->tx_dma_ring[i]->len = 0;
|
||||
aup->tx_db_inuse[i] = pDB;
|
||||
}
|
||||
|
@ -1310,7 +1310,7 @@ err_remap2:
|
|||
iounmap(aup->mac);
|
||||
err_remap1:
|
||||
dma_free_coherent(&pdev->dev, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
|
||||
(void *)aup->vaddr, aup->dma_addr);
|
||||
aup->vaddr, aup->dma_addr);
|
||||
err_vaddr:
|
||||
free_netdev(dev);
|
||||
err_alloc:
|
||||
|
@ -1343,7 +1343,7 @@ static int au1000_remove(struct platform_device *pdev)
|
|||
au1000_ReleaseDB(aup, aup->tx_db_inuse[i]);
|
||||
|
||||
dma_free_coherent(&pdev->dev, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
|
||||
(void *)aup->vaddr, aup->dma_addr);
|
||||
aup->vaddr, aup->dma_addr);
|
||||
|
||||
iounmap(aup->macdma);
|
||||
iounmap(aup->mac);
|
||||
|
|
|
@ -106,8 +106,8 @@ struct au1000_private {
|
|||
struct mac_reg *mac; /* mac registers */
|
||||
u32 *enable; /* address of MAC Enable Register */
|
||||
void __iomem *macdma; /* base of MAC DMA port */
|
||||
u32 vaddr; /* virtual address of rx/tx buffers */
|
||||
dma_addr_t dma_addr; /* dma address of rx/tx buffers */
|
||||
void *vaddr; /* virtual address of rx/tx buffers */
|
||||
dma_addr_t dma_addr; /* dma address of rx/tx buffers */
|
||||
|
||||
spinlock_t lock; /* Serialise access to device */
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче