]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring/zcrx: set sgt for umem area
authorPavel Begunkov <asml.silence@gmail.com>
Tue, 16 Sep 2025 14:27:54 +0000 (15:27 +0100)
committerJens Axboe <axboe@kernel.dk>
Tue, 16 Sep 2025 18:37:20 +0000 (12:37 -0600)
Set struct io_zcrx_mem::sgt for umem areas as well to simplify looking
up the current sg table.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/zcrx.c
io_uring/zcrx.h

index bcefb302aadf2ba96893d767a9f4d851a7019996..764723bf04d61fdfee24e931a50217c6cea924d0 100644 (file)
@@ -52,9 +52,9 @@ static inline struct page *io_zcrx_iov_page(const struct net_iov *niov)
 }
 
 static int io_populate_area_dma(struct io_zcrx_ifq *ifq,
-                               struct io_zcrx_area *area,
-                               struct sg_table *sgt)
+                               struct io_zcrx_area *area)
 {
+       struct sg_table *sgt = area->mem.sgt;
        struct scatterlist *sg;
        unsigned i, niov_idx = 0;
 
@@ -197,6 +197,7 @@ static int io_import_umem(struct io_zcrx_ifq *ifq,
        if (ret < 0)
                mem->account_pages = 0;
 
+       mem->sgt = &mem->page_sg_table;
        mem->pages = pages;
        mem->nr_folios = nr_pages;
        mem->size = area_reg->len;
@@ -211,7 +212,8 @@ static void io_release_area_mem(struct io_zcrx_mem *mem)
        }
        if (mem->pages) {
                unpin_user_pages(mem->pages, mem->nr_folios);
-               sg_free_table(&mem->page_sg_table);
+               sg_free_table(mem->sgt);
+               mem->sgt = NULL;
                kvfree(mem->pages);
        }
 }
@@ -263,7 +265,6 @@ static void io_zcrx_unmap_area(struct io_zcrx_ifq *ifq,
 
 static int io_zcrx_map_area(struct io_zcrx_ifq *ifq, struct io_zcrx_area *area)
 {
-       struct sg_table *sgt;
        int ret;
 
        guard(mutex)(&ifq->dma_lock);
@@ -275,12 +276,9 @@ static int io_zcrx_map_area(struct io_zcrx_ifq *ifq, struct io_zcrx_area *area)
                                      DMA_FROM_DEVICE, IO_DMA_ATTR);
                if (ret < 0)
                        return ret;
-               sgt = &area->mem.page_sg_table;
-       } else {
-               sgt = area->mem.sgt;
        }
 
-       ret = io_populate_area_dma(ifq, area, sgt);
+       ret = io_populate_area_dma(ifq, area);
        if (ret == 0)
                area->is_mapped = true;
        return ret;
index 24ed473632c616a2e0084dfcc63e12ec3af04087..27d7cf28a04e9717ef9d4bf5c81029d624e61f6d 100644 (file)
@@ -16,10 +16,10 @@ struct io_zcrx_mem {
        unsigned long                   nr_folios;
        struct sg_table                 page_sg_table;
        unsigned long                   account_pages;
+       struct sg_table                 *sgt;
 
        struct dma_buf_attachment       *attach;
        struct dma_buf                  *dmabuf;
-       struct sg_table                 *sgt;
 };
 
 struct io_zcrx_area {