Skip to content

Commit 563476a

Browse files
shayshyiSaeed Mahameed
authored andcommitted
net/mlx5: Synchronize correct IRQ when destroying CQ
The CQ destroy is performed based on the IRQ number that is stored in cq->irqn. That number wasn't set explicitly during CQ creation and as expected some of the API users of mlx5_core_create_cq() forgot to update it. This caused to wrong synchronization call of the wrong IRQ with a number 0 instead of the real one. As a fix, set the IRQ number directly in the mlx5_core_create_cq() and update all users accordingly. Fixes: 1a86b37 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices") Fixes: ef1659a ("IB/mlx5: Add DEVX support for CQ events") Signed-off-by: Shay Drory <shayd@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 88bbd7b commit 563476a

10 files changed

Lines changed: 27 additions & 30 deletions

File tree

‎drivers/infiniband/hw/mlx5/cq.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,6 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
945945
u32 *cqb = NULL;
946946
void *cqc;
947947
int cqe_size;
948-
unsigned int irqn;
949948
int eqn;
950949
int err;
951950

@@ -984,7 +983,7 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
984983
INIT_WORK(&cq->notify_work, notify_soft_wc_handler);
985984
}
986985

987-
err = mlx5_vector2eqn(dev->mdev, vector, &eqn, &irqn);
986+
err = mlx5_vector2eqn(dev->mdev, vector, &eqn);
988987
if (err)
989988
goto err_cqb;
990989

@@ -1007,7 +1006,6 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
10071006
goto err_cqb;
10081007

10091008
mlx5_ib_dbg(dev, "cqn 0x%x\n", cq->mcq.cqn);
1010-
cq->mcq.irqn = irqn;
10111009
if (udata)
10121010
cq->mcq.tasklet_ctx.comp = mlx5_ib_cq_comp;
10131011
else

‎drivers/infiniband/hw/mlx5/devx.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,6 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_QUERY_EQN)(
975975
struct mlx5_ib_dev *dev;
976976
int user_vector;
977977
int dev_eqn;
978-
unsigned int irqn;
979978
int err;
980979

981980
if (uverbs_copy_from(&user_vector, attrs,
@@ -987,7 +986,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_QUERY_EQN)(
987986
return PTR_ERR(c);
988987
dev = to_mdev(c->ibucontext.device);
989988

990-
err = mlx5_vector2eqn(dev->mdev, user_vector, &dev_eqn, &irqn);
989+
err = mlx5_vector2eqn(dev->mdev, user_vector, &dev_eqn);
991990
if (err < 0)
992991
return err;
993992

‎drivers/net/ethernet/mellanox/mlx5/core/cq.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ int mlx5_core_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
134134
cq->cqn);
135135

136136
cq->uar = dev->priv.uar;
137+
cq->irqn = eq->core.irqn;
137138

138139
return 0;
139140

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,15 +1535,9 @@ static int mlx5e_alloc_cq_common(struct mlx5e_priv *priv,
15351535
{
15361536
struct mlx5_core_dev *mdev = priv->mdev;
15371537
struct mlx5_core_cq *mcq = &cq->mcq;
1538-
int eqn_not_used;
1539-
unsigned int irqn;
15401538
int err;
15411539
u32 i;
15421540

1543-
err = mlx5_vector2eqn(mdev, param->eq_ix, &eqn_not_used, &irqn);
1544-
if (err)
1545-
return err;
1546-
15471541
err = mlx5_cqwq_create(mdev, &param->wq, param->cqc, &cq->wq,
15481542
&cq->wq_ctrl);
15491543
if (err)
@@ -1557,7 +1551,6 @@ static int mlx5e_alloc_cq_common(struct mlx5e_priv *priv,
15571551
mcq->vector = param->eq_ix;
15581552
mcq->comp = mlx5e_completion_event;
15591553
mcq->event = mlx5e_cq_error_event;
1560-
mcq->irqn = irqn;
15611554

15621555
for (i = 0; i < mlx5_cqwq_get_size(&cq->wq); i++) {
15631556
struct mlx5_cqe64 *cqe = mlx5_cqwq_get_wqe(&cq->wq, i);
@@ -1605,11 +1598,10 @@ static int mlx5e_create_cq(struct mlx5e_cq *cq, struct mlx5e_cq_param *param)
16051598
void *in;
16061599
void *cqc;
16071600
int inlen;
1608-
unsigned int irqn_not_used;
16091601
int eqn;
16101602
int err;
16111603

1612-
err = mlx5_vector2eqn(mdev, param->eq_ix, &eqn, &irqn_not_used);
1604+
err = mlx5_vector2eqn(mdev, param->eq_ix, &eqn);
16131605
if (err)
16141606
return err;
16151607

@@ -1983,9 +1975,8 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
19831975
struct mlx5e_channel *c;
19841976
unsigned int irq;
19851977
int err;
1986-
int eqn;
19871978

1988-
err = mlx5_vector2eqn(priv->mdev, ix, &eqn, &irq);
1979+
err = mlx5_vector2irqn(priv->mdev, ix, &irq);
19891980
if (err)
19901981
return err;
19911982

‎drivers/net/ethernet/mellanox/mlx5/core/eq.c‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,8 @@ static int create_comp_eqs(struct mlx5_core_dev *dev)
855855
return err;
856856
}
857857

858-
int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn,
859-
unsigned int *irqn)
858+
static int vector2eqnirqn(struct mlx5_core_dev *dev, int vector, int *eqn,
859+
unsigned int *irqn)
860860
{
861861
struct mlx5_eq_table *table = dev->priv.eq_table;
862862
struct mlx5_eq_comp *eq, *n;
@@ -865,17 +865,29 @@ int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn,
865865

866866
list_for_each_entry_safe(eq, n, &table->comp_eqs_list, list) {
867867
if (i++ == vector) {
868-
*eqn = eq->core.eqn;
869-
*irqn = eq->core.irqn;
868+
if (irqn)
869+
*irqn = eq->core.irqn;
870+
if (eqn)
871+
*eqn = eq->core.eqn;
870872
err = 0;
871873
break;
872874
}
873875
}
874876

875877
return err;
876878
}
879+
880+
int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn)
881+
{
882+
return vector2eqnirqn(dev, vector, eqn, NULL);
883+
}
877884
EXPORT_SYMBOL(mlx5_vector2eqn);
878885

886+
int mlx5_vector2irqn(struct mlx5_core_dev *dev, int vector, unsigned int *irqn)
887+
{
888+
return vector2eqnirqn(dev, vector, NULL, irqn);
889+
}
890+
879891
unsigned int mlx5_comp_vectors_count(struct mlx5_core_dev *dev)
880892
{
881893
return dev->priv.eq_table->num_comp_eqs;

‎drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ static int mlx5_fpga_conn_create_cq(struct mlx5_fpga_conn *conn, int cq_size)
417417
struct mlx5_wq_param wqp;
418418
struct mlx5_cqe64 *cqe;
419419
int inlen, err, eqn;
420-
unsigned int irqn;
421420
void *cqc, *in;
422421
__be64 *pas;
423422
u32 i;
@@ -446,7 +445,7 @@ static int mlx5_fpga_conn_create_cq(struct mlx5_fpga_conn *conn, int cq_size)
446445
goto err_cqwq;
447446
}
448447

449-
err = mlx5_vector2eqn(mdev, smp_processor_id(), &eqn, &irqn);
448+
err = mlx5_vector2eqn(mdev, smp_processor_id(), &eqn);
450449
if (err) {
451450
kvfree(in);
452451
goto err_cqwq;
@@ -476,7 +475,6 @@ static int mlx5_fpga_conn_create_cq(struct mlx5_fpga_conn *conn, int cq_size)
476475
*conn->cq.mcq.arm_db = 0;
477476
conn->cq.mcq.vector = 0;
478477
conn->cq.mcq.comp = mlx5_fpga_conn_cq_complete;
479-
conn->cq.mcq.irqn = irqn;
480478
conn->cq.mcq.uar = fdev->conn_res.uar;
481479
tasklet_setup(&conn->cq.tasklet, mlx5_fpga_conn_cq_tasklet);
482480

‎drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,6 @@ void mlx5_core_eq_free_irqs(struct mlx5_core_dev *dev);
104104
struct cpu_rmap *mlx5_eq_table_get_rmap(struct mlx5_core_dev *dev);
105105
#endif
106106

107+
int mlx5_vector2irqn(struct mlx5_core_dev *dev, int vector, unsigned int *irqn);
108+
107109
#endif

‎drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,6 @@ static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev,
749749
struct mlx5_cqe64 *cqe;
750750
struct mlx5dr_cq *cq;
751751
int inlen, err, eqn;
752-
unsigned int irqn;
753752
void *cqc, *in;
754753
__be64 *pas;
755754
int vector;
@@ -782,7 +781,7 @@ static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev,
782781
goto err_cqwq;
783782

784783
vector = raw_smp_processor_id() % mlx5_comp_vectors_count(mdev);
785-
err = mlx5_vector2eqn(mdev, vector, &eqn, &irqn);
784+
err = mlx5_vector2eqn(mdev, vector, &eqn);
786785
if (err) {
787786
kvfree(in);
788787
goto err_cqwq;
@@ -818,7 +817,6 @@ static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev,
818817
*cq->mcq.arm_db = cpu_to_be32(2 << 28);
819818

820819
cq->mcq.vector = 0;
821-
cq->mcq.irqn = irqn;
822820
cq->mcq.uar = uar;
823821

824822
return cq;

‎drivers/vdpa/mlx5/net/mlx5_vnet.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ static int cq_create(struct mlx5_vdpa_net *ndev, u16 idx, u32 num_ent)
526526
void __iomem *uar_page = ndev->mvdev.res.uar->map;
527527
u32 out[MLX5_ST_SZ_DW(create_cq_out)];
528528
struct mlx5_vdpa_cq *vcq = &mvq->cq;
529-
unsigned int irqn;
530529
__be64 *pas;
531530
int inlen;
532531
void *cqc;
@@ -566,7 +565,7 @@ static int cq_create(struct mlx5_vdpa_net *ndev, u16 idx, u32 num_ent)
566565
/* Use vector 0 by default. Consider adding code to choose least used
567566
* vector.
568567
*/
569-
err = mlx5_vector2eqn(mdev, 0, &eqn, &irqn);
568+
err = mlx5_vector2eqn(mdev, 0, &eqn);
570569
if (err)
571570
goto err_vec;
572571

‎include/linux/mlx5/driver.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,7 @@ void mlx5_unregister_debugfs(void);
10441044
void mlx5_fill_page_array(struct mlx5_frag_buf *buf, __be64 *pas);
10451045
void mlx5_fill_page_frag_array_perm(struct mlx5_frag_buf *buf, __be64 *pas, u8 perm);
10461046
void mlx5_fill_page_frag_array(struct mlx5_frag_buf *frag_buf, __be64 *pas);
1047-
int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn,
1048-
unsigned int *irqn);
1047+
int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn);
10491048
int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
10501049
int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
10511050

0 commit comments

Comments
 (0)