summaryrefslogtreecommitdiffstats
path: root/drivers/net/mlx4/mcg.c
diff options
context:
space:
mode:
authorEli Cohen2008-04-17 06:09:35 +0200
committerRoland Dreier2008-04-17 06:09:35 +0200
commit4dc51b32582d45cb7e8322d750ffe0e6d82b506d (patch)
tree0d8549a6cc82b9719086a2673c76de8cd5b161e9 /drivers/net/mlx4/mcg.c
parentIB/ehca: Support all ibv_devinfo values in query_device() and query_port() (diff)
downloadkernel-qcow2-linux-4dc51b32582d45cb7e8322d750ffe0e6d82b506d.tar.gz
kernel-qcow2-linux-4dc51b32582d45cb7e8322d750ffe0e6d82b506d.tar.xz
kernel-qcow2-linux-4dc51b32582d45cb7e8322d750ffe0e6d82b506d.zip
IB/mlx4: Fix race when detaching a QP from a multicast group
When detaching the last QP from an MCG entry, we need to make sure that at any time, there will be no entry with zero number of QPs which is linked to the list of the MCGs of the corresponding hash index. So don't write back the MCG entry if we are removing the last QP; just unlink the entry. Also, remove an unnecessary MCG read when attaching a QP requires allocation of a new entry in the AMGM. Signed-off-by: Eli Cohen <eli@mellanox.co.il> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/net/mlx4/mcg.c')
-rw-r--r--drivers/net/mlx4/mcg.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/net/mlx4/mcg.c b/drivers/net/mlx4/mcg.c
index a99e7729d333..57f7f1f0d4ec 100644
--- a/drivers/net/mlx4/mcg.c
+++ b/drivers/net/mlx4/mcg.c
@@ -190,10 +190,6 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
}
index += dev->caps.num_mgms;
- err = mlx4_READ_MCG(dev, index, mailbox);
- if (err)
- goto out;
-
memset(mgm, 0, sizeof *mgm);
memcpy(mgm->gid, gid, 16);
}
@@ -301,12 +297,10 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
mgm->qp[loc] = mgm->qp[i - 1];
mgm->qp[i - 1] = 0;
- err = mlx4_WRITE_MCG(dev, index, mailbox);
- if (err)
- goto out;
-
- if (i != 1)
+ if (i != 1) {
+ err = mlx4_WRITE_MCG(dev, index, mailbox);
goto out;
+ }
if (prev == -1) {
/* Remove entry from MGM */