From: Dekel Peled Date: Wed, 24 Jul 2019 09:05:10 +0000 (+0300) Subject: net/mlx5: fix doorbell release on Rx queue release X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a88209b04c774b2c72bfb6f288dff4bc01fc9a8b;p=dpdk.git net/mlx5: fix doorbell release on Rx queue release Function mlx5_rxq_release() calls mlx5_release_dbr() to release the doorbell allocated for this Rx queue. This call is relevant only for Rx queue objects created using DevX API. This patch adds the required check, to call mlx5_release_dbr() only when relevant. It also updates mlx5_release_dbr() to use the input offset correctly. Fixes: dc9ceff73c99 ("net/mlx5: create advanced RxQ via DevX") Signed-off-by: Dekel Peled Acked-by: Viacheslav Ovsiienko --- diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 617f5eeb7c..ad0883dee9 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1460,6 +1460,7 @@ mlx5_release_dbr(struct rte_eth_dev *dev, uint32_t umem_id, uint64_t offset) rte_free(page); } else { /* Mark in bitmap that this door-bell is not in use. */ + offset /= MLX5_DBR_SIZE; int i = offset / 64; int j = offset % 64; diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index b225055077..c9df8b01f6 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1242,6 +1242,7 @@ mlx5_rxq_obj_new(struct rte_eth_dev *dev, uint16_t idx, goto error; rxq_ctrl->dbr_offset = dbr_offset; rxq_ctrl->dbr_umem_id = dbr_page->umem->umem_id; + rxq_ctrl->dbr_umem_id_valid = 1; rxq_data->rq_db = (uint32_t *)((uintptr_t)dbr_page->dbrs + (uintptr_t)rxq_ctrl->dbr_offset); } @@ -1829,8 +1830,9 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx) if (rxq_ctrl->obj && !mlx5_rxq_obj_release(rxq_ctrl->obj)) rxq_ctrl->obj = NULL; if (rte_atomic32_dec_and_test(&rxq_ctrl->refcnt)) { - claim_zero(mlx5_release_dbr(dev, rxq_ctrl->dbr_umem_id, - rxq_ctrl->dbr_offset)); + if (rxq_ctrl->dbr_umem_id_valid) + claim_zero(mlx5_release_dbr(dev, rxq_ctrl->dbr_umem_id, + rxq_ctrl->dbr_offset)); mlx5_mr_btree_free(&rxq_ctrl->rxq.mr_ctrl.cache_bh); LIST_REMOVE(rxq_ctrl, next); rte_free(rxq_ctrl); diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 928d6c3930..60d871c39a 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -184,6 +184,7 @@ struct mlx5_rxq_ctrl { struct mlx5_priv *priv; /* Back pointer to private data. */ unsigned int socket; /* CPU socket ID for allocations. */ unsigned int irq:1; /* Whether IRQ is enabled. */ + unsigned int dbr_umem_id_valid:1; /* dbr_umem_id holds a valid value. */ uint32_t flow_mark_n; /* Number of Mark/Flag flows using this Queue. */ uint32_t flow_tunnels_n[MLX5_FLOW_TUNNEL]; /* Tunnels counters. */ uint32_t wqn; /* WQ number. */