diff options
| author | Israel Rukshin <israelr@mellanox.com> | 2016-12-28 05:48:28 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-02-01 02:33:07 -0500 |
| commit | c2293e76babeebea894f584c11a07290b4f701da (patch) | |
| tree | b43e8c3a4188cef7218611d3118b4e959b0e365e /drivers/infiniband | |
| parent | 24be606cd3b433412488ce962842489fe6e34a7a (diff) | |
IB/srp: fix mr allocation when the device supports sg gaps
commit ad8e66b4a80182174f73487ed25fd2140cf43361 upstream.
If the device support arbitrary sg list mapping (device cap
IB_DEVICE_SG_GAPS_REG set) we allocate the memory regions with
IB_MR_TYPE_SG_GAPS.
Fixes: 509c5f33f4f6 ("IB/srp: Prevent mapping failures")
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/infiniband')
| -rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index d980fb458ad4..69d2d6fb73c1 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
| @@ -366,6 +366,7 @@ static struct srp_fr_pool *srp_create_fr_pool(struct ib_device *device, | |||
| 366 | struct srp_fr_desc *d; | 366 | struct srp_fr_desc *d; |
| 367 | struct ib_mr *mr; | 367 | struct ib_mr *mr; |
| 368 | int i, ret = -EINVAL; | 368 | int i, ret = -EINVAL; |
| 369 | enum ib_mr_type mr_type; | ||
| 369 | 370 | ||
| 370 | if (pool_size <= 0) | 371 | if (pool_size <= 0) |
| 371 | goto err; | 372 | goto err; |
| @@ -379,9 +380,13 @@ static struct srp_fr_pool *srp_create_fr_pool(struct ib_device *device, | |||
| 379 | spin_lock_init(&pool->lock); | 380 | spin_lock_init(&pool->lock); |
| 380 | INIT_LIST_HEAD(&pool->free_list); | 381 | INIT_LIST_HEAD(&pool->free_list); |
| 381 | 382 | ||
| 383 | if (device->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG) | ||
| 384 | mr_type = IB_MR_TYPE_SG_GAPS; | ||
| 385 | else | ||
| 386 | mr_type = IB_MR_TYPE_MEM_REG; | ||
| 387 | |||
| 382 | for (i = 0, d = &pool->desc[0]; i < pool->size; i++, d++) { | 388 | for (i = 0, d = &pool->desc[0]; i < pool->size; i++, d++) { |
| 383 | mr = ib_alloc_mr(pd, IB_MR_TYPE_MEM_REG, | 389 | mr = ib_alloc_mr(pd, mr_type, max_page_list_len); |
| 384 | max_page_list_len); | ||
| 385 | if (IS_ERR(mr)) { | 390 | if (IS_ERR(mr)) { |
| 386 | ret = PTR_ERR(mr); | 391 | ret = PTR_ERR(mr); |
| 387 | goto destroy_pool; | 392 | goto destroy_pool; |
