Commit fd4a3e28 authored by Tariq Toukan's avatar Tariq Toukan Committed by David S. Miller

net/mlx4_core: Cleanup FMR unmapping flow

Remove redundant and not essential operations in fmr unmap/free.
According to device spec, in FMR unmap it is sufficient to set
ownership bit to SW. This allows remapping afterwards.

Fixes: 8ad11fb6 ("IB/mlx4: Implement FMRs")
Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
Signed-off-by: default avatarMoshe Shemesh <moshe@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dc484851
...@@ -1103,30 +1103,16 @@ EXPORT_SYMBOL_GPL(mlx4_fmr_enable); ...@@ -1103,30 +1103,16 @@ EXPORT_SYMBOL_GPL(mlx4_fmr_enable);
void mlx4_fmr_unmap(struct mlx4_dev *dev, struct mlx4_fmr *fmr, void mlx4_fmr_unmap(struct mlx4_dev *dev, struct mlx4_fmr *fmr,
u32 *lkey, u32 *rkey) u32 *lkey, u32 *rkey)
{ {
struct mlx4_cmd_mailbox *mailbox;
int err;
if (!fmr->maps) if (!fmr->maps)
return; return;
fmr->maps = 0; /* To unmap: it is sufficient to take back ownership from HW */
*(u8 *)fmr->mpt = MLX4_MPT_STATUS_SW;
mailbox = mlx4_alloc_cmd_mailbox(dev); /* Make sure MPT status is visible */
if (IS_ERR(mailbox)) { wmb();
err = PTR_ERR(mailbox);
pr_warn("mlx4_ib: mlx4_alloc_cmd_mailbox failed (%d)\n", err);
return;
}
err = mlx4_HW2SW_MPT(dev, NULL, fmr->maps = 0;
key_to_hw_index(fmr->mr.key) &
(dev->caps.num_mpts - 1));
mlx4_free_cmd_mailbox(dev, mailbox);
if (err) {
pr_warn("mlx4_ib: mlx4_HW2SW_MPT failed (%d)\n", err);
return;
}
fmr->mr.enabled = MLX4_MPT_EN_SW;
} }
EXPORT_SYMBOL_GPL(mlx4_fmr_unmap); EXPORT_SYMBOL_GPL(mlx4_fmr_unmap);
...@@ -1136,6 +1122,22 @@ int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr) ...@@ -1136,6 +1122,22 @@ int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr)
if (fmr->maps) if (fmr->maps)
return -EBUSY; return -EBUSY;
if (fmr->mr.enabled == MLX4_MPT_EN_HW) {
/* In case of FMR was enabled and unmapped
* make sure to give ownership of MPT back to HW
* so HW2SW_MPT command will success.
*/
*(u8 *)fmr->mpt = MLX4_MPT_STATUS_SW;
/* Make sure MPT status is visible before changing MPT fields */
wmb();
fmr->mpt->length = 0;
fmr->mpt->start = 0;
/* Make sure MPT data is visible after changing MPT status */
wmb();
*(u8 *)fmr->mpt = MLX4_MPT_STATUS_HW;
/* make sure MPT status is visible */
wmb();
}
ret = mlx4_mr_free(dev, &fmr->mr); ret = mlx4_mr_free(dev, &fmr->mr);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment