Skip to content

Commit 303ba01

Browse files
shayshyigregkh
authored andcommitted
net/mlx5: Synchronize correct IRQ when destroying CQ
[ Upstream commit 563476a ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 00a0c11 commit 303ba01

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
@@ -930,7 +930,6 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
930930
u32 *cqb = NULL;
931931
void *cqc;
932932
int cqe_size;
933-
unsigned int irqn;
934933
int eqn;
935934
int err;
936935

@@ -969,7 +968,7 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
969968
INIT_WORK(&cq->notify_work, notify_soft_wc_handler);
970969
}
971970

972-
err = mlx5_vector2eqn(dev->mdev, vector, &eqn, &irqn);
971+
err = mlx5_vector2eqn(dev->mdev, vector, &eqn);
973972
if (err)
974973
goto err_cqb;
975974

@@ -992,7 +991,6 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
992991
goto err_cqb;
993992

994993
mlx5_ib_dbg(dev, "cqn 0x%x\n", cq->mcq.cqn);
995-
cq->mcq.irqn = irqn;
996994
if (udata)
997995
cq->mcq.tasklet_ctx.comp = mlx5_ib_cq_comp;
998996
else

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,6 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_QUERY_EQN)(
904904
struct mlx5_ib_dev *dev;
905905
int user_vector;
906906
int dev_eqn;
907-
unsigned int irqn;
908907
int err;
909908

910909
if (uverbs_copy_from(&user_vector, attrs,
@@ -916,7 +915,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_QUERY_EQN)(
916915
return PTR_ERR(c);
917916
dev = to_mdev(c->ibucontext.device);
918917

919-
err = mlx5_vector2eqn(dev->mdev, user_vector, &dev_eqn, &irqn);
918+
err = mlx5_vector2eqn(dev->mdev, user_vector, &dev_eqn);
920919
if (err < 0)
921920
return err;
922921

‎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
@@ -1547,15 +1547,9 @@ static int mlx5e_alloc_cq_common(struct mlx5_core_dev *mdev,
15471547
struct mlx5e_cq *cq)
15481548
{
15491549
struct mlx5_core_cq *mcq = &cq->mcq;
1550-
int eqn_not_used;
1551-
unsigned int irqn;
15521550
int err;
15531551
u32 i;
15541552

1555-
err = mlx5_vector2eqn(mdev, param->eq_ix, &eqn_not_used, &irqn);
1556-
if (err)
1557-
return err;
1558-
15591553
err = mlx5_cqwq_create(mdev, &param->wq, param->cqc, &cq->wq,
15601554
&cq->wq_ctrl);
15611555
if (err)
@@ -1569,7 +1563,6 @@ static int mlx5e_alloc_cq_common(struct mlx5_core_dev *mdev,
15691563
mcq->vector = param->eq_ix;
15701564
mcq->comp = mlx5e_completion_event;
15711565
mcq->event = mlx5e_cq_error_event;
1572-
mcq->irqn = irqn;
15731566

15741567
for (i = 0; i < mlx5_cqwq_get_size(&cq->wq); i++) {
15751568
struct mlx5_cqe64 *cqe = mlx5_cqwq_get_wqe(&cq->wq, i);
@@ -1615,11 +1608,10 @@ static int mlx5e_create_cq(struct mlx5e_cq *cq, struct mlx5e_cq_param *param)
16151608
void *in;
16161609
void *cqc;
16171610
int inlen;
1618-
unsigned int irqn_not_used;
16191611
int eqn;
16201612
int err;
16211613

1622-
err = mlx5_vector2eqn(mdev, param->eq_ix, &eqn, &irqn_not_used);
1614+
err = mlx5_vector2eqn(mdev, param->eq_ix, &eqn);
16231615
if (err)
16241616
return err;
16251617

@@ -1977,9 +1969,8 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
19771969
struct mlx5e_channel *c;
19781970
unsigned int irq;
19791971
int err;
1980-
int eqn;
19811972

1982-
err = mlx5_vector2eqn(priv->mdev, ix, &eqn, &irq);
1973+
err = mlx5_vector2irqn(priv->mdev, ix, &irq);
19831974
if (err)
19841975
return err;
19851976

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,8 @@ static int create_comp_eqs(struct mlx5_core_dev *dev)
859859
return err;
860860
}
861861

862-
int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn,
863-
unsigned int *irqn)
862+
static int vector2eqnirqn(struct mlx5_core_dev *dev, int vector, int *eqn,
863+
unsigned int *irqn)
864864
{
865865
struct mlx5_eq_table *table = dev->priv.eq_table;
866866
struct mlx5_eq_comp *eq, *n;
@@ -869,17 +869,29 @@ int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn,
869869

870870
list_for_each_entry_safe(eq, n, &table->comp_eqs_list, list) {
871871
if (i++ == vector) {
872-
*eqn = eq->core.eqn;
873-
*irqn = eq->core.irqn;
872+
if (irqn)
873+
*irqn = eq->core.irqn;
874+
if (eqn)
875+
*eqn = eq->core.eqn;
874876
err = 0;
875877
break;
876878
}
877879
}
878880

879881
return err;
880882
}
883+
884+
int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn)
885+
{
886+
return vector2eqnirqn(dev, vector, eqn, NULL);
887+
}
881888
EXPORT_SYMBOL(mlx5_vector2eqn);
882889

890+
int mlx5_vector2irqn(struct mlx5_core_dev *dev, int vector, unsigned int *irqn)
891+
{
892+
return vector2eqnirqn(dev, vector, NULL, irqn);
893+
}
894+
883895
unsigned int mlx5_comp_vectors_count(struct mlx5_core_dev *dev)
884896
{
885897
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
@@ -98,4 +98,6 @@ void mlx5_core_eq_free_irqs(struct mlx5_core_dev *dev);
9898
struct cpu_rmap *mlx5_eq_table_get_rmap(struct mlx5_core_dev *dev);
9999
#endif
100100

101+
int mlx5_vector2irqn(struct mlx5_core_dev *dev, int vector, unsigned int *irqn);
102+
101103
#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
@@ -711,7 +711,6 @@ static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev,
711711
struct mlx5_cqe64 *cqe;
712712
struct mlx5dr_cq *cq;
713713
int inlen, err, eqn;
714-
unsigned int irqn;
715714
void *cqc, *in;
716715
__be64 *pas;
717716
int vector;
@@ -744,7 +743,7 @@ static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev,
744743
goto err_cqwq;
745744

746745
vector = raw_smp_processor_id() % mlx5_comp_vectors_count(mdev);
747-
err = mlx5_vector2eqn(mdev, vector, &eqn, &irqn);
746+
err = mlx5_vector2eqn(mdev, vector, &eqn);
748747
if (err) {
749748
kvfree(in);
750749
goto err_cqwq;
@@ -780,7 +779,6 @@ static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev,
780779
*cq->mcq.arm_db = cpu_to_be32(2 << 28);
781780

782781
cq->mcq.vector = 0;
783-
cq->mcq.irqn = irqn;
784782
cq->mcq.uar = uar;
785783

786784
return cq;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ static int cq_create(struct mlx5_vdpa_net *ndev, u16 idx, u32 num_ent)
511511
void __iomem *uar_page = ndev->mvdev.res.uar->map;
512512
u32 out[MLX5_ST_SZ_DW(create_cq_out)];
513513
struct mlx5_vdpa_cq *vcq = &mvq->cq;
514-
unsigned int irqn;
515514
__be64 *pas;
516515
int inlen;
517516
void *cqc;
@@ -551,7 +550,7 @@ static int cq_create(struct mlx5_vdpa_net *ndev, u16 idx, u32 num_ent)
551550
/* Use vector 0 by default. Consider adding code to choose least used
552551
* vector.
553552
*/
554-
err = mlx5_vector2eqn(mdev, 0, &eqn, &irqn);
553+
err = mlx5_vector2eqn(mdev, 0, &eqn);
555554
if (err)
556555
goto err_vec;
557556

‎include/linux/mlx5/driver.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,7 @@ void mlx5_unregister_debugfs(void);
981981
void mlx5_fill_page_array(struct mlx5_frag_buf *buf, __be64 *pas);
982982
void mlx5_fill_page_frag_array_perm(struct mlx5_frag_buf *buf, __be64 *pas, u8 perm);
983983
void mlx5_fill_page_frag_array(struct mlx5_frag_buf *frag_buf, __be64 *pas);
984-
int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn,
985-
unsigned int *irqn);
984+
int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn);
986985
int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
987986
int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
988987

0 commit comments

Comments
 (0)