Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/zcrx: introduce io_populate_area_dma

Add a helper that initialises page-pool dma addresses from a sg table.
It'll be reused in following patches.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: David Wei <dw@davidwei.uk>
Link: https://lore.kernel.org/r/a8972a77be9b5675abc585d6e2e6e30f9c7dbd85.1751466461.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
54e89a93 06897ddf

+31 -25
+31 -25
io_uring/zcrx.c
··· 47 47 return area->mem.pages[net_iov_idx(niov)]; 48 48 } 49 49 50 + static int io_populate_area_dma(struct io_zcrx_ifq *ifq, 51 + struct io_zcrx_area *area, 52 + struct sg_table *sgt, unsigned long off) 53 + { 54 + struct scatterlist *sg; 55 + unsigned i, niov_idx = 0; 56 + 57 + for_each_sgtable_dma_sg(sgt, sg, i) { 58 + dma_addr_t dma = sg_dma_address(sg); 59 + unsigned long sg_len = sg_dma_len(sg); 60 + unsigned long sg_off = min(sg_len, off); 61 + 62 + off -= sg_off; 63 + sg_len -= sg_off; 64 + dma += sg_off; 65 + 66 + while (sg_len && niov_idx < area->nia.num_niovs) { 67 + struct net_iov *niov = &area->nia.niovs[niov_idx]; 68 + 69 + if (net_mp_niov_set_dma_addr(niov, dma)) 70 + return -EFAULT; 71 + sg_len -= PAGE_SIZE; 72 + dma += PAGE_SIZE; 73 + niov_idx++; 74 + } 75 + } 76 + return 0; 77 + } 78 + 50 79 static void io_release_dmabuf(struct io_zcrx_mem *mem) 51 80 { 52 81 if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER)) ··· 150 121 151 122 static int io_zcrx_map_area_dmabuf(struct io_zcrx_ifq *ifq, struct io_zcrx_area *area) 152 123 { 153 - unsigned long off = area->mem.dmabuf_offset; 154 - struct scatterlist *sg; 155 - unsigned i, niov_idx = 0; 156 - 157 124 if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER)) 158 125 return -EINVAL; 159 - 160 - for_each_sgtable_dma_sg(area->mem.sgt, sg, i) { 161 - dma_addr_t dma = sg_dma_address(sg); 162 - unsigned long sg_len = sg_dma_len(sg); 163 - unsigned long sg_off = min(sg_len, off); 164 - 165 - off -= sg_off; 166 - sg_len -= sg_off; 167 - dma += sg_off; 168 - 169 - while (sg_len && niov_idx < area->nia.num_niovs) { 170 - struct net_iov *niov = &area->nia.niovs[niov_idx]; 171 - 172 - if (net_mp_niov_set_dma_addr(niov, dma)) 173 - return -EFAULT; 174 - sg_len -= PAGE_SIZE; 175 - dma += PAGE_SIZE; 176 - niov_idx++; 177 - } 178 - } 179 - return 0; 126 + return io_populate_area_dma(ifq, area, area->mem.sgt, 127 + area->mem.dmabuf_offset); 180 128 } 181 129 182 130 static int io_import_umem(struct io_zcrx_ifq *ifq,