Skip to content

Commit fa516c0

Browse files
committed
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. Fixes: bd61848 ("net: devmem: Implement TX path") Acked-by: Stanislav Fomichev <[email protected]> Reviewed-by: Mina Almasry <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2df1580 commit fa516c0

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

net/core/devmem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,13 @@ void __net_devmem_dmabuf_binding_free(struct work_struct *wq)
7070
gen_pool_destroy(binding->chunk_pool);
7171

7272
dma_buf_unmap_attachment_unlocked(binding->attachment, binding->sgt,
73-
DMA_FROM_DEVICE);
73+
binding->direction);
7474
dma_buf_detach(binding->dmabuf, binding->attachment);
7575
dma_buf_put(binding->dmabuf);
7676
xa_destroy(&binding->bound_rxqs);
7777
kvfree(binding->tx_vec);
7878
kfree(binding);
7979
}
80-
EXPORT_SYMBOL(__net_devmem_dmabuf_binding_free);
8180

8281
struct net_iov *
8382
net_devmem_alloc_dmabuf(struct net_devmem_dmabuf_binding *binding)
@@ -208,6 +207,7 @@ net_devmem_bind_dmabuf(struct net_device *dev,
208207
mutex_init(&binding->lock);
209208

210209
binding->dmabuf = dmabuf;
210+
binding->direction = direction;
211211

212212
binding->attachment = dma_buf_attach(binding->dmabuf, dev->dev.parent);
213213
if (IS_ERR(binding->attachment)) {
@@ -312,7 +312,7 @@ net_devmem_bind_dmabuf(struct net_device *dev,
312312
kvfree(binding->tx_vec);
313313
err_unmap:
314314
dma_buf_unmap_attachment_unlocked(binding->attachment, binding->sgt,
315-
DMA_FROM_DEVICE);
315+
direction);
316316
err_detach:
317317
dma_buf_detach(dmabuf, binding->attachment);
318318
err_free_binding:

net/core/devmem.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ struct net_devmem_dmabuf_binding {
5656
*/
5757
u32 id;
5858

59+
/* DMA direction, FROM_DEVICE for Rx binding, TO_DEVICE for Tx. */
60+
enum dma_data_direction direction;
61+
5962
/* Array of net_iov pointers for this binding, sorted by virtual
6063
* address. This array is convenient to map the virtual addresses to
6164
* net_iovs in the TX path.
@@ -165,10 +168,6 @@ static inline void net_devmem_put_net_iov(struct net_iov *niov)
165168
{
166169
}
167170

168-
static inline void __net_devmem_dmabuf_binding_free(struct work_struct *wq)
169-
{
170-
}
171-
172171
static inline struct net_devmem_dmabuf_binding *
173172
net_devmem_bind_dmabuf(struct net_device *dev,
174173
enum dma_data_direction direction,

0 commit comments

Comments
 (0)