net/mlx5: fix doorbell release on Rx queue release
authorDekel Peled <dekelp@mellanox.com>
Wed, 24 Jul 2019 09:05:10 +0000 (12:05 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 24 Jul 2019 16:05:07 +0000 (18:05 +0200)
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 <dekelp@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5_rxq.c
drivers/net/mlx5/mlx5_rxtx.h

index 617f5ee..ad0883d 100644 (file)
@@ -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;
 
index b225055..c9df8b0 100644 (file)
@@ -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);
index 928d6c3..60d871c 100644 (file)
@@ -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. */