aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mlx5/cmd.c
diff options
context:
space:
mode:
authorAriel Levkovich <lariel@mellanox.com>2018-04-05 18:53:28 +0300
committerJason Gunthorpe <jgg@mellanox.com>2018-04-05 13:04:49 -0600
commitcdbd0d2bae14566cf875595180b91527b4431df8 (patch)
treeba0a04ffe881ff7d8acf5726ea98bcaf2232b76d /drivers/infiniband/hw/mlx5/cmd.c
parentIB/mlx5: Device memory support in mlx5_ib (diff)
downloadlinux-dev-cdbd0d2bae14566cf875595180b91527b4431df8.tar.xz
linux-dev-cdbd0d2bae14566cf875595180b91527b4431df8.zip
net/mlx5: Mkey creation command adjustments
This change updates the mlx5 interface to create mkey on the device. The updates in the command mailbox include increasing the access mode type field to 5 bits in order to support additional types such as MLX5_MKC_ACCESS_MODE_MEMIC which represents device memory access type and will be used when registering MR on allocated device memory. All the places that use the old access mode format are adjusted as well. Signed-off-by: Ariel Levkovich <lariel@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/hw/mlx5/cmd.c')
-rw-r--r--drivers/infiniband/hw/mlx5/cmd.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/infiniband/hw/mlx5/cmd.c b/drivers/infiniband/hw/mlx5/cmd.c
index 55a227cc8609..188512bf46e6 100644
--- a/drivers/infiniband/hw/mlx5/cmd.c
+++ b/drivers/infiniband/hw/mlx5/cmd.c
@@ -99,23 +99,21 @@ int mlx5_cmd_alloc_memic(struct mlx5_memic *memic, phys_addr_t *addr,
MLX5_SET(alloc_memic_in, in, log_memic_addr_alignment,
mlx5_alignment);
- do {
+ while (page_idx < num_memic_hw_pages) {
spin_lock(&memic->memic_lock);
page_idx = bitmap_find_next_zero_area(memic->memic_alloc_pages,
num_memic_hw_pages,
page_idx,
num_pages, 0);
- if (page_idx + num_pages <= num_memic_hw_pages)
+ if (page_idx < num_memic_hw_pages)
bitmap_set(memic->memic_alloc_pages,
page_idx, num_pages);
- else
- ret = -ENOMEM;
spin_unlock(&memic->memic_lock);
- if (ret)
- return ret;
+ if (page_idx >= num_memic_hw_pages)
+ break;
MLX5_SET64(alloc_memic_in, in, range_start_addr,
hw_start_addr + (page_idx * PAGE_SIZE));
@@ -138,10 +136,10 @@ int mlx5_cmd_alloc_memic(struct mlx5_memic *memic, phys_addr_t *addr,
*addr = pci_resource_start(dev->pdev, 0) +
MLX5_GET64(alloc_memic_out, out, memic_start_addr);
- return ret;
- } while (page_idx < num_memic_hw_pages);
+ return 0;
+ }
- return ret;
+ return -ENOMEM;
}
int mlx5_cmd_dealloc_memic(struct mlx5_memic *memic, u64 addr, u64 length)