diff mbox series

au1000_eth: stop using virt_to_bus()

Message ID 20220607090206.19830-1-arnd@kernel.org (mailing list archive)
State Accepted
Commit a6958951ebe7db60e84b2437ee53aa4843028726
Delegated to: Netdev Maintainers
Headers show
Series au1000_eth: stop using virt_to_bus() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: jgg@ziepe.ca
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 80 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Arnd Bergmann June 7, 2022, 9:01 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

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.

Cc: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/amd/au1000_eth.c | 22 +++++++++++-----------
 drivers/net/ethernet/amd/au1000_eth.h |  4 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)

Comments

Manuel Lauss June 7, 2022, 10:35 a.m. UTC | #1
On Tue, Jun 7, 2022 at 11:02 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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.
>
> Cc: Manuel Lauss <manuel.lauss@gmail.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

lightly tested on a DB1500 board, without issues.

Tested-by: Manuel Lauss <manuel.lauss@gmail.com>

Thanks!
Jakub Kicinski June 8, 2022, 6:01 p.m. UTC | #2
On Tue,  7 Jun 2022 11:01:46 +0200 Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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.
> 
> Cc: Manuel Lauss <manuel.lauss@gmail.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Hi Arnd, this can go via net-next, right? The changes are simple
enough, we can try to slip them into -rc2 if necessary.
Arnd Bergmann June 8, 2022, 6:19 p.m. UTC | #3
On Wed, Jun 8, 2022 at 8:01 PM Jakub Kicinski <kuba@kernel.org> wrote:
> On Tue,  7 Jun 2022 11:01:46 +0200 Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > 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.
> >
> > Cc: Manuel Lauss <manuel.lauss@gmail.com>
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Hi Arnd, this can go via net-next, right? The changes are simple
> enough, we can try to slip them into -rc2 if necessary.

It's probably fine either way. I hope to get the CONFIG_VIRT_TO_BUS
removal into v5.20, and if the final patch of that series comes before
this one, there will be a trivial bisection problem on mips/au1000, so
having it merged now would help.

        Arnd
patchwork-bot+netdevbpf@kernel.org June 8, 2022, 6:40 p.m. UTC | #4
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue,  7 Jun 2022 11:01:46 +0200 you wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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.
> 
> [...]

Here is the summary with links:
  - au1000_eth: stop using virt_to_bus()
    https://git.kernel.org/netdev/net/c/a6958951ebe7

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index c6f003975621..d5f2c6989221 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -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 @@  static int au1000_probe(struct platform_device *pdev)
 	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);
diff --git a/drivers/net/ethernet/amd/au1000_eth.h b/drivers/net/ethernet/amd/au1000_eth.h
index e3a3ed29db61..2489c2f4fd8a 100644
--- a/drivers/net/ethernet/amd/au1000_eth.h
+++ b/drivers/net/ethernet/amd/au1000_eth.h
@@ -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 */