net: devmem: fix DMA direction on unmapping
Subsystems (2)
Jakub Kicinski
maintainerPATCH 1/1 net: devmem: fix DMA direction on unmapping
Looks like we always unmap the DMA_BUF with DMA_FROM_DEVICE direction. While at it unexport __net_devmem_dmabuf_binding_free(), it's internal.
Found by code inspection.
---
Compile tested only. I could be missing something here.
--- net/core/devmem.h | 7 +++---- net/core/devmem.c | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-)
net/core/devmem.h +3 -4
@@ -56,6 +56,9 @@ struct net_devmem_dmabuf_binding {*/ u32 id; +/* DMA direction, FROM_DEVICE for Rx binding, TO_DEVICE for Tx. */ +enum dma_data_direction direction; +/* Array of net_iov pointers for this binding, sorted by virtual * address. This array is convenient to map the virtual addresses to * net_iovs in the TX path.
@@ -165,10 +168,6 @@ static inline void net_devmem_put_net_iov(struct net_iov *niov) { } -static inline void __net_devmem_dmabuf_binding_free (struct work_struct *wq) -{ -} -static inline struct net_devmem_dmabuf_binding * net_devmem_bind_dmabuf(struct net_device *dev, enum dma_data_direction direction,
net/core/devmem.c +3 -3
@@ -70,14 +70,13 @@ void __net_devmem_dmabuf_binding_free(struct work_struct *wq)gen_pool_destroy (binding->chunk_pool);dma_buf_unmap_attachment_unlocked (binding->attachment, binding->sgt, -DMA_FROM_DEVICE ); + binding->direction);dma_buf_detach (binding->dmabuf, binding->attachment);dma_buf_put (binding->dmabuf);xa_destroy (&binding->bound_rxqs);kvfree (binding->tx_vec);kfree (binding); } -EXPORT_SYMBOL (__net_devmem_dmabuf_binding_free);struct net_iov *net_devmem_alloc_dmabuf (struct net_devmem_dmabuf_binding *binding)
@@ -208,6 +207,7 @@ net_devmem_bind_dmabuf(struct net_device *dev,mutex_init (&binding->lock); binding->dmabuf = dmabuf; + binding->direction = direction; binding->attachment =dma_buf_attach (binding->dmabuf, dev->dev.parent);if (IS_ERR (binding->attachment)) {
@@ -312,7 +312,7 @@ net_devmem_bind_dmabuf(struct net_device *dev,kvfree (binding->tx_vec); err_unmap:dma_buf_unmap_attachment_unlocked (binding->attachment, binding->sgt, -DMA_FROM_DEVICE ); + direction); err_detach:dma_buf_detach (dmabuf, binding->attachment); err_free_binding:
Signature · 1 line
2.50.1
Quoted 9 lines · Jakub Kicinski
Looks like we always unmap the
DMA_BUFwithDMA_FROM_DEVICEdirection. While at it unexport__net_devmem_dmabuf_binding_free(), it's internal.Found by code inspection.
Fixes bd61848900bf ("net: devmem: Implement TX path")Signed-off-by Jakub Kicinski <[email protected]>---
Compile tested only. I could be missing something here.
Quoted 8 lines · Jakub Kicinski
Looks like we always unmap the
DMA_BUFwithDMA_FROM_DEVICEdirection. While at it unexport__net_devmem_dmabuf_binding_free(), it's internal.Found by code inspection.
Fixes bd61848900bf ("net: devmem: Implement TX path")Signed-off-by Jakub Kicinski <[email protected]>
Thanks!
Signature · 2 lines
Thanks, Mina
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Thu, 31 Jul 2025 18:13:35 -0700 you wrote:
Looks like we always unmap the
DMA_BUFwithDMA_FROM_DEVICEdirection. While at it unexport__net_devmem_dmabuf_binding_free(), it's internal.Found by code inspection.
Fixes bd61848900bf ("net: devmem: Implement TX path")Signed-off-by Jakub Kicinski <[email protected]>[...]
Here is the summary with links:
- [net] net: devmem: fix DMA direction on unmapping
https://git.kernel.org/netdev/net/c/fa516c0d8bf9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html