Skip to content

Commit 08a762c

Browse files
ayalevin123Saeed Mahameed
authored andcommitted
net/mlx5e: Fix error path for RQ alloc
Increase granularity of the error path to avoid unneeded free/release. Fix the cleanup to be symmetric to the order of creation. Fixes: 0ddf543 ("xdp/mlx5: setup xdp_rxq_info") Fixes: 422d4c4 ("net/mlx5e: RX, Split WQ objects for different RQ types") Signed-off-by: Aya Levin <ayal@mellanox.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 732ebfa commit 08a762c

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

  • drivers/net/ethernet/mellanox/mlx5/core

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
396396
rq_xdp_ix += params->num_channels * MLX5E_RQ_GROUP_XSK;
397397
err = xdp_rxq_info_reg(&rq->xdp_rxq, rq->netdev, rq_xdp_ix);
398398
if (err < 0)
399-
goto err_rq_wq_destroy;
399+
goto err_rq_xdp_prog;
400400

401401
rq->buff.map_dir = params->xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE;
402402
rq->buff.headroom = mlx5e_get_rq_headroom(mdev, params, xsk);
@@ -407,7 +407,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
407407
err = mlx5_wq_ll_create(mdev, &rqp->wq, rqc_wq, &rq->mpwqe.wq,
408408
&rq->wq_ctrl);
409409
if (err)
410-
goto err_rq_wq_destroy;
410+
goto err_rq_xdp;
411411

412412
rq->mpwqe.wq.db = &rq->mpwqe.wq.db[MLX5_RCV_DBR];
413413

@@ -429,13 +429,13 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
429429

430430
err = mlx5e_rq_alloc_mpwqe_info(rq, c);
431431
if (err)
432-
goto err_free;
432+
goto err_rq_mkey;
433433
break;
434434
default: /* MLX5_WQ_TYPE_CYCLIC */
435435
err = mlx5_wq_cyc_create(mdev, &rqp->wq, rqc_wq, &rq->wqe.wq,
436436
&rq->wq_ctrl);
437437
if (err)
438-
goto err_rq_wq_destroy;
438+
goto err_rq_xdp;
439439

440440
rq->wqe.wq.db = &rq->wqe.wq.db[MLX5_RCV_DBR];
441441

@@ -450,19 +450,19 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
450450
GFP_KERNEL, cpu_to_node(c->cpu));
451451
if (!rq->wqe.frags) {
452452
err = -ENOMEM;
453-
goto err_free;
453+
goto err_rq_wq_destroy;
454454
}
455455

456456
err = mlx5e_init_di_list(rq, wq_sz, c->cpu);
457457
if (err)
458-
goto err_free;
458+
goto err_rq_frags;
459459

460460
rq->mkey_be = c->mkey_be;
461461
}
462462

463463
err = mlx5e_rq_set_handlers(rq, params, xsk);
464464
if (err)
465-
goto err_free;
465+
goto err_free_by_rq_type;
466466

467467
if (xsk) {
468468
err = xdp_rxq_info_reg_mem_model(&rq->xdp_rxq,
@@ -486,13 +486,13 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
486486
if (IS_ERR(rq->page_pool)) {
487487
err = PTR_ERR(rq->page_pool);
488488
rq->page_pool = NULL;
489-
goto err_free;
489+
goto err_free_by_rq_type;
490490
}
491491
err = xdp_rxq_info_reg_mem_model(&rq->xdp_rxq,
492492
MEM_TYPE_PAGE_POOL, rq->page_pool);
493493
}
494494
if (err)
495-
goto err_free;
495+
goto err_free_by_rq_type;
496496

497497
for (i = 0; i < wq_sz; i++) {
498498
if (rq->wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ) {
@@ -542,23 +542,25 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
542542

543543
return 0;
544544

545-
err_free:
545+
err_free_by_rq_type:
546546
switch (rq->wq_type) {
547547
case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
548548
kvfree(rq->mpwqe.info);
549+
err_rq_mkey:
549550
mlx5_core_destroy_mkey(mdev, &rq->umr_mkey);
550551
break;
551552
default: /* MLX5_WQ_TYPE_CYCLIC */
552-
kvfree(rq->wqe.frags);
553553
mlx5e_free_di_list(rq);
554+
err_rq_frags:
555+
kvfree(rq->wqe.frags);
554556
}
555-
556557
err_rq_wq_destroy:
558+
mlx5_wq_destroy(&rq->wq_ctrl);
559+
err_rq_xdp:
560+
xdp_rxq_info_unreg(&rq->xdp_rxq);
561+
err_rq_xdp_prog:
557562
if (params->xdp_prog)
558563
bpf_prog_put(params->xdp_prog);
559-
xdp_rxq_info_unreg(&rq->xdp_rxq);
560-
page_pool_destroy(rq->page_pool);
561-
mlx5_wq_destroy(&rq->wq_ctrl);
562564

563565
return err;
564566
}

0 commit comments

Comments
 (0)