Re: [PATCH net-next 2/3] net: devmem: use memory provider helpers for net_iovs

From
Pavel Begunkov <asml.silence@gmail.com>
Date
2026-09-27 18:13:52
Also in
io-uring, lkml
Reply to
Stanislav Fomichev, 2026-09-22
On 9/22/26 21:43, Stanislav Fomichev wrote:
Use public memory-provider helpers for DMA address storage and page-pool
association instead of open-coding page_pool state and accounting.

Zero the net_iov array because net_mp_niov_set_page_pool() ORs
PP_SIGNATURE into pp_magic. Reject DMA addresses that cannot be
represented in net_iov metadata.
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
quoted hunk ↗ jump to hunk
@@ -247,7 +245,7 @@ net_devmem_bind_dmabuf(struct net_device *dev, void *vdev,
  			goto err_unmap;
  		}
  	}
-	binding->area.niovs = kvmalloc_objs(*binding->area.niovs,
+	binding->area.niovs = kvzalloc_objs(*binding->area.niovs,
  					    binding->area.num_niovs);
  	if (!binding->area.niovs) {
  		err = -ENOMEM;
@@ -274,8 +272,12 @@ net_devmem_bind_dmabuf(struct net_device *dev, void *vdev,
  		for (i = 0; i < nr_niovs; i++, niov_idx++) {
  			niov = &binding->area.niovs[niov_idx];
  			net_iov_init(niov, &binding->area, NET_IOV_DMABUF);
-			page_pool_set_dma_addr_netmem(net_iov_to_netmem(niov),
-						      dma_addr);
+			if (net_mp_niov_set_dma_addr(niov, dma_addr)) {
I'd do this chunk as a separate patch with stable+fix tags to
keep it minimal and help backporting, e.g.

if (page_pool_set_dma_addr_netmem())
	// fail;

Looks like the bot was saying the same (with an extra wall of text),
but I guess it depends on whether you need it backported.
quoted hunk ↗ jump to hunk
+				err = -EFAULT;
+				NL_SET_ERR_MSG(extack,
+					       "dmabuf DMA address cannot be represented");
+				goto err_free_niovs;
+			}
  			if (direction == DMA_TO_DEVICE)
  				binding->tx_vec[niov_idx] = niov;
-- 
Pavel Begunkov
Thread (20 messages) 20 messages, 4 authors, last reply 2026-09-27
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help