diff mbox

[1/1,v2] IB/srp: fix mr allocation when the device supports sg gaps

Message ID 1482922108-3243-2-git-send-email-maxg@mellanox.com (mailing list archive)
State Accepted
Headers show

Commit Message

Max Gurtovoy Dec. 28, 2016, 10:48 a.m. UTC
From: Israel Rukshin <israelr@mellanox.com>

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")
Cc: <stable@vger.kernel.org>        [4.7+]
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>
---
 drivers/infiniband/ulp/srp/ib_srp.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Yuval Shaia Dec. 28, 2016, 11:25 a.m. UTC | #1
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>

On Wed, Dec 28, 2016 at 12:48:28PM +0200, Max Gurtovoy wrote:
> From: Israel Rukshin <israelr@mellanox.com>
> 
> 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")
> Cc: <stable@vger.kernel.org>        [4.7+]
> 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>
> ---
>  drivers/infiniband/ulp/srp/ib_srp.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
> index 8ddc071..0f67cf9 100644
> --- a/drivers/infiniband/ulp/srp/ib_srp.c
> +++ b/drivers/infiniband/ulp/srp/ib_srp.c
> @@ -371,6 +371,7 @@ static struct srp_fr_pool *srp_create_fr_pool(struct ib_device *device,
>  	struct srp_fr_desc *d;
>  	struct ib_mr *mr;
>  	int i, ret = -EINVAL;
> +	enum ib_mr_type mr_type;
>  
>  	if (pool_size <= 0)
>  		goto err;
> @@ -384,9 +385,13 @@ static struct srp_fr_pool *srp_create_fr_pool(struct ib_device *device,
>  	spin_lock_init(&pool->lock);
>  	INIT_LIST_HEAD(&pool->free_list);
>  
> +	if (device->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG)
> +		mr_type = IB_MR_TYPE_SG_GAPS;
> +	else
> +		mr_type = IB_MR_TYPE_MEM_REG;
> +
>  	for (i = 0, d = &pool->desc[0]; i < pool->size; i++, d++) {
> -		mr = ib_alloc_mr(pd, IB_MR_TYPE_MEM_REG,
> -				 max_page_list_len);
> +		mr = ib_alloc_mr(pd, mr_type, max_page_list_len);
>  		if (IS_ERR(mr)) {
>  			ret = PTR_ERR(mr);
>  			if (ret == -ENOMEM)
> -- 
> 1.8.4.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bart Van Assche Jan. 2, 2017, 8:40 a.m. UTC | #2
T24gV2VkLCAyMDE2LTEyLTI4IGF0IDEyOjQ4ICswMjAwLCBNYXggR3VydG92b3kgd3JvdGU6DQo+
IElmIHRoZSBkZXZpY2Ugc3VwcG9ydCBhcmJpdHJhcnkgc2cgbGlzdCBtYXBwaW5nIChkZXZpY2Ug
Y2FwDQo+IElCX0RFVklDRV9TR19HQVBTX1JFRyBzZXQpIHdlIGFsbG9jYXRlIHRoZSBtZW1vcnkg
cmVnaW9ucyB3aXRoDQo+IElCX01SX1RZUEVfU0dfR0FQUy4NCg0KUmV2aWV3ZWQtYnk6IEJhcnQg
VmFuIEFzc2NoZSA8YmFydC52YW5hc3NjaGVAc2FuZGlzay5jb20+
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Doug Ledford Jan. 24, 2017, 4:04 p.m. UTC | #3
On Wed, 2016-12-28 at 12:48 +0200, Max Gurtovoy wrote:
> From: Israel Rukshin <israelr@mellanox.com>
> 
> 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")
> Cc: <stable@vger.kernel.org>        [4.7+]
> 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>


The v2 version of this patch has been applied, thanks.
diff mbox

Patch

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 8ddc071..0f67cf9 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -371,6 +371,7 @@  static struct srp_fr_pool *srp_create_fr_pool(struct ib_device *device,
 	struct srp_fr_desc *d;
 	struct ib_mr *mr;
 	int i, ret = -EINVAL;
+	enum ib_mr_type mr_type;
 
 	if (pool_size <= 0)
 		goto err;
@@ -384,9 +385,13 @@  static struct srp_fr_pool *srp_create_fr_pool(struct ib_device *device,
 	spin_lock_init(&pool->lock);
 	INIT_LIST_HEAD(&pool->free_list);
 
+	if (device->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG)
+		mr_type = IB_MR_TYPE_SG_GAPS;
+	else
+		mr_type = IB_MR_TYPE_MEM_REG;
+
 	for (i = 0, d = &pool->desc[0]; i < pool->size; i++, d++) {
-		mr = ib_alloc_mr(pd, IB_MR_TYPE_MEM_REG,
-				 max_page_list_len);
+		mr = ib_alloc_mr(pd, mr_type, max_page_list_len);
 		if (IS_ERR(mr)) {
 			ret = PTR_ERR(mr);
 			if (ret == -ENOMEM)