Skip to content

Commit d425f13

Browse files
isilenceaxboe
authored andcommitted
io_uring/zcrx: don't pass slot to io_zcrx_create_area
Don't pass a pointer to a pointer where an area should be stored to io_zcrx_create_area(), and let it handle finding the right place for a new area. It's more straightforward and will be needed to support multiple areas. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c49606f commit d425f13

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

io_uring/zcrx.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,16 @@ static void io_zcrx_free_area(struct io_zcrx_area *area)
397397

398398
#define IO_ZCRX_AREA_SUPPORTED_FLAGS (IORING_ZCRX_AREA_DMABUF)
399399

400+
static int io_zcrx_append_area(struct io_zcrx_ifq *ifq,
401+
struct io_zcrx_area *area)
402+
{
403+
if (ifq->area)
404+
return -EINVAL;
405+
ifq->area = area;
406+
return 0;
407+
}
408+
400409
static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
401-
struct io_zcrx_area **res,
402410
struct io_uring_zcrx_area_reg *area_reg)
403411
{
404412
struct io_zcrx_area *area;
@@ -455,8 +463,10 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
455463
area->area_id = 0;
456464
area_reg->rq_area_token = (u64)area->area_id << IORING_ZCRX_AREA_SHIFT;
457465
spin_lock_init(&area->freelist_lock);
458-
*res = area;
459-
return 0;
466+
467+
ret = io_zcrx_append_area(ifq, area);
468+
if (!ret)
469+
return 0;
460470
err:
461471
if (area)
462472
io_zcrx_free_area(area);
@@ -610,7 +620,7 @@ int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
610620
}
611621
get_device(ifq->dev);
612622

613-
ret = io_zcrx_create_area(ifq, &ifq->area, &area);
623+
ret = io_zcrx_create_area(ifq, &area);
614624
if (ret)
615625
goto err;
616626

0 commit comments

Comments
 (0)